assign option
This commit is contained in:
@@ -176,18 +176,15 @@ export function stampNow(now = new Date()): string {
|
||||
);
|
||||
}
|
||||
|
||||
/** Just the date half, for `deliverydate`. */
|
||||
export function dateOf(now = new Date()): string {
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* One row of the `createdeliveries` array.
|
||||
*
|
||||
* `Pickupaddress` is capitalised. That is not a typo here — it is the JSON tag
|
||||
* on `models.Deliveries`, alone among fifty lowercase ones, and sending
|
||||
* `pickupaddress` instead means the address is simply dropped.
|
||||
* `Pickupaddress` is capitalised because that is the JSON tag on
|
||||
* `models.Deliveries`, alone among fifty lowercase ones. Matching it exactly is
|
||||
* a courtesy rather than a requirement: Go's decoder matches field names
|
||||
* case-insensitively, so the old console's lowercase `pickupaddress` landed
|
||||
* fine — verified. Spelled as the model spells it so a reader grepping the Go
|
||||
* struct finds this.
|
||||
*/
|
||||
export interface DeliveryDraft {
|
||||
orderheaderid: number;
|
||||
@@ -261,9 +258,18 @@ export function buildDelivery(
|
||||
|
||||
userid: rider.userid,
|
||||
orderstatus: DELIVERY_CREATED_STATUS,
|
||||
// The date the job is for, and the moment it was handed out. Both are
|
||||
// written by us: the backend stamps neither on create.
|
||||
deliverydate: dateOf(now),
|
||||
/*
|
||||
* The date the job is FOR, not today.
|
||||
*
|
||||
* An order row carries its scheduled slot as `deliverytime` — there is no
|
||||
* `deliverydate` on an order — so it is copied through, with the order date
|
||||
* and finally the assign stamp behind it. The fallback chain is the old
|
||||
* console's and the reason is its reason: `getdeliveries` filters on
|
||||
* `deliverydate`, so a delivery written without one is excluded from every
|
||||
* dated view, and a job stamped today when it is scheduled for tomorrow
|
||||
* shows up in the wrong day's window.
|
||||
*/
|
||||
deliverydate: row.deliverydate || row.deliverytime || row.orderdate || at,
|
||||
assigntime: at,
|
||||
|
||||
// What the rider is carrying, so the deliveries page can say so.
|
||||
|
||||
Reference in New Issue
Block a user