delivery slot updated in orders and deliveries
This commit is contained in:
@@ -120,13 +120,26 @@ const (
|
||||
a.riderslat,a.riderslon,a.deliveryamt,a.kms,a.actualkms,a.riderkms,a.deliverycharges,a.deliverytype,a.paymenttype,a.smsdelivery,
|
||||
a.expecteddeliverytime,a.profit,a.transitminutes,a.calculationdistancekm,
|
||||
a.notes,a.ordernotes,b.tenantname,b.primarycontact as tenantcontactno,b.tenanttoken,b.suburb as tenantsuburb,b.city as tenantcity,
|
||||
c.firstname AS ridername,c.userfcmtoken,e.locationname,e.suburb AS locationsuburb,e.contactno AS locationcontactno
|
||||
c.firstname AS ridername,c.userfcmtoken,e.locationname,e.suburb AS locationsuburb,e.contactno AS locationcontactno,
|
||||
-- The delivery window, read from the ORDER.
|
||||
--
|
||||
-- The deliveries table has no window column and deliberately gets none:
|
||||
-- the window is a fact about what the customer asked for, and copying it
|
||||
-- here would be a second truth that can drift from the first. The
|
||||
-- dispatch board is exactly where drift would be noticed and exactly where
|
||||
-- it would cost the most, so it is joined.
|
||||
o.deliveryslotid, o.deliveryslotdate, s.slotkey, s.name AS deliveryslotname,
|
||||
s.starttime AS deliveryslotstart, s.endtime AS deliveryslotend
|
||||
FROM deliveries a
|
||||
INNER JOIN tenants b ON a.tenantid=b.tenantid
|
||||
INNER JOIN app_users c ON a.userid=c.userid
|
||||
INNER JOIN tenantlocations e ON a.locationid=e.locationid
|
||||
INNER JOIN app_location f ON a.applocationid = f.applocationid
|
||||
INNER JOIN app_locationconfig g ON f.applocationid = g.applocationid`
|
||||
INNER JOIN app_locationconfig g ON f.applocationid = g.applocationid
|
||||
-- Both LEFT. Most deliveries have no window, and every one of them must
|
||||
-- still appear on the board — an INNER JOIN here would empty dispatch.
|
||||
LEFT JOIN orders o ON a.orderheaderid = o.orderheaderid
|
||||
LEFT JOIN deliveryslots s ON o.deliveryslotid = s.slotid`
|
||||
)
|
||||
|
||||
func (r *deliveriesRepository) CreateDeliveries(data []models.Deliveries) error {
|
||||
|
||||
Reference in New Issue
Block a user