lookup endpoint updated

This commit is contained in:
2026-09-30 16:13:25 +05:30
parent d0804ae84f
commit ea90b95cdc
4 changed files with 193 additions and 11 deletions

View File

@@ -72,7 +72,12 @@ type StoreOptionRow struct {
Productunit string
Unitvalue string
Price float64
Stock int
// The shop's own cost, distinct from Price. Selected because the product
// screens already return it and the app asked for it by name.
Productcost float64
Categoryid int
Subcategoryid int
Stock int
// For a size row: the product it hangs under and the label given to it.
Parentid int
Variantname string
@@ -246,6 +251,9 @@ const storeOptionSelect = `
COALESCE(a.productunit, '') AS productunit,
COALESCE(a.unitvalue, '') AS unitvalue,
CASE WHEN COALESCE(b.price, 0) > 0 THEN b.price ELSE COALESCE(a.retailprice, 0) END AS price,
COALESCE(a.productcost, 0) AS productcost,
COALESCE(a.categoryid, 0) AS categoryid,
COALESCE(a.subcategoryid, 0) AS subcategoryid,
COALESCE((
SELECT SUM(CASE WHEN LOWER(c.stocktype) = 'in' THEN c.quantity
WHEN LOWER(c.stocktype) = 'out' THEN -c.quantity