delivery slot updated in orders and deliveries

This commit is contained in:
2026-10-06 19:37:08 +05:30
parent 03ae7d310b
commit a30763d323
5 changed files with 274 additions and 6 deletions

View File

@@ -102,14 +102,30 @@ const (
a.deliveryid AS deliverycustomerid, a.deliveryid, a.deliveryaddress, a.deliverylat, a.deliverylong, a.deliverytype,
a.deliverycustomer,a.deliverycontactno,a.deliverylocation as deliverysuburb, a.deliverycity, a.paymenttype, a.smsdelivery, b.customertoken,
c.tenantname, c.tenanttoken, c.primarycontact AS tenantcontactno, c.postcode AS tenantpostcode, c.suburb AS tenantsuburb, c.city AS tenantcity,
d.locationname, d.contactno AS locationcontactno, d.postcode AS locationpostcode, d.suburb AS locationsuburb, d.city AS locationcity
d.locationname, d.contactno AS locationcontactno, d.postcode AS locationpostcode, d.suburb AS locationsuburb, d.city AS locationcity,
-- The delivery window the customer asked for.
--
-- Selected EXPLICITLY, like everything else here: this select names its
-- columns, so a field added to the Go struct and not added to this line
-- is simply absent from every row, with nothing anywhere saying so. That
-- exact gap shipped once on products.showhealthscore and made every
-- reading taken from the list meaningless.
--
-- The NAME is joined rather than stored on the order, so a shop that
-- renames "Evening" to "After work" sees the new name on old orders --
-- the window they chose has not changed, only what it is called.
a.deliveryslotid, a.deliveryslotdate, s.slotkey, s.name AS deliveryslotname,
s.starttime AS deliveryslotstart, s.endtime AS deliveryslotend
FROM orders a
LEFT JOIN customers b ON a.customerid = b.customerid
LEFT JOIN tenants c ON a.tenantid = c.tenantid
LEFT JOIN tenantlocations d ON a.locationid = d.locationid
LEFT JOIN app_location h ON a.applocationid = h.applocationid
LEFT JOIN app_locationconfig i ON a.applocationid = i.applocationid`
LEFT JOIN app_locationconfig i ON a.applocationid = i.applocationid
-- LEFT, because the overwhelming majority of orders have no window and
-- must still appear. An INNER JOIN here would silently empty the list.
LEFT JOIN deliveryslots s ON a.deliveryslotid = s.slotid`
orderdetails = `SELECT DISTINCT a.orderheaderid, a.applocationid,
a.tenantid, a.locationid, a.partnerid, a.configid, a.categoryid, a.subcategoryid, a.moduleid,