Fix empty categories disappearing in unified schema menu builder

The unified schema query used INNER JOIN to children, which excluded
categories with no items. Changed to direct query with NOT EXISTS
template filter so empty categories persist after save+reload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-03-14 20:47:19 -07:00
parent 6d157b44f7
commit 6a73752136

View file

@ -205,16 +205,16 @@ try {
", { businessID: businessID }, { datasource: "payfrit" });
} else {
// NEW UNIFIED SCHEMA: Categories are Items at ParentID=0 with children
// NEW UNIFIED SCHEMA: Categories are Items at ParentID=0, CategoryID=0, not templates
qCategories = queryTimed("
SELECT DISTINCT
p.ID as CategoryID,
p.Name as Name,
SELECT
p.ID,
p.Name,
p.SortOrder
FROM Items p
INNER JOIN Items c ON c.ParentItemID = p.ID
WHERE p.BusinessID = :businessID
AND p.ParentItemID = 0
AND (p.CategoryID = 0 OR p.CategoryID IS NULL)
AND p.IsActive = 1
AND NOT EXISTS (
SELECT 1 FROM lt_ItemID_TemplateItemID tl WHERE tl.TemplateItemID = p.ID