This commit is contained in:
2026-09-25 15:21:02 +05:30
parent 72f3bb0961
commit d169d24934
12 changed files with 516 additions and 28 deletions

View File

@@ -319,6 +319,7 @@ export interface RiderShift {
*/
export interface NewRiderShift {
applocationid: number;
shiftname?: string;
starttime: string;
endtime: string;
basefare?: number;

View File

@@ -12,6 +12,7 @@ import type {
DeliveryRow,
DeliverySummary,
LocationOrderSummary,
OrderItem,
OrderRow,
OrderSummary,
PosLocationHealth,
@@ -163,6 +164,32 @@ export const insightsApi = {
...range,
}),
/**
* What is actually IN an order.
*
* The only read that carries line items. Every list endpoint returns an
* order's totals and never its contents, which is why the detail sheet could
* say an order was worth ₹840 and not what the ₹840 bought.
*
* The envelope rather than `api.list`, because the authoritative total lives
* outside `details`: `OrderDetail.Orderamount` is `json:"-"` on the server, so
* `pricedetails.orderamount` is the only place it appears. Summing the lines
* would be recomputing a figure Fiesta has already worked out, and the two
* would disagree the first time a discount rounded differently.
*/
orderItems: async (orderheaderid: number) => {
const envelope = await api.envelope<OrderItem[]>(`${WEB}/orders/getorderdetails`, {
params: { orderheaderid },
});
return {
// `details: null` for an order with no lines is as common here as `[]`;
// see the note on `api.list`.
items: envelope.details ?? [],
amount: envelope.pricedetails?.orderamount ?? 0,
tax: envelope.pricedetails?.totaltaxamount ?? 0,
};
},
deliverySummary: (tenantid: number, range: DateRange = {}) =>
api.get<DeliverySummary>(`${WEB}/deliveries/deliverysummary`, { tenantid, ...range }),

View File

@@ -192,6 +192,24 @@ export const posUsersApi = {
locationid,
})
.then((page) => (Array.isArray(page?.shifts) ? page.shifts : [])),
/**
* Open a shift window at one branch.
*
* The endpoint has existed since till staff were built; nothing in the console
* called it. So `getstaffshifts` answered `{"shifts": []}` at every branch —
* the comment on StoreStaffPage says exactly that — and the picker on this
* drawer offered "Any shift" and nothing else, for everyone, permanently.
*
* `weekdays` is a seven-character mask starting Monday; empty means every day.
* The server rejects anything that is not seven 0/1 characters, so it is sent
* as the mask rather than as a list the console would have to encode twice.
*/
createShift: (
tenantid: number,
locationid: number,
shift: { name: string; start_time: string; end_time: string; weekdays?: string },
) => api.post<StaffShift>(`${WEB}/tenants/createstaffshift`, { tenantid, locationid, ...shift }),
};
/**

View File

@@ -44,6 +44,52 @@ export interface FiestaEnvelope<T> {
token?: string;
/** Unix seconds. The tab closing normally ends the session well before this. */
tokenexpiresat?: number;
/**
* Order totals, from `orders/getorderdetails` only.
*
* Beside `details` rather than inside it because the line items are a list
* and this is one figure about the order as a whole. `OrderDetail.Orderamount`
* is tagged `json:"-"` on the server, so the authoritative total exists HERE
* and nowhere else in the response — summing the lines is an approximation of
* a number Fiesta has already worked out.
*/
pricedetails?: { orderamount?: number; totaltaxamount?: number };
}
/* ────────────────────────────────────────────────────────────────────────────
Order line items — models/order.go:OrderDetail
──────────────────────────────────────────────────────────────────────────── */
/**
* One product on an order.
*
* Returned by `orders/getorderdetails`, which is the ONLY read that carries
* them — the list endpoints give an order's totals and never what is in it.
* That is why every screen showing an order has, until now, been able to say
* what it cost but not what it was.
*/
export interface OrderItem {
orderdetailid: number;
orderheaderid: number;
productid: number;
productname: string;
productdescription?: string;
/** What was ordered. A float because some products sell by weight. */
orderqty: number;
/** What the shop could actually supply — less than `orderqty` is a short fill. */
supplyqty?: number;
price: number;
unitname?: string;
taxamount?: number;
discountamount?: number;
/** The line total as Fiesta computed it: quantity, tax and discount applied. */
productsumprice?: number;
itemstatus?: string;
/**
* Always empty today. The column is `gorm:"-"` on the server, so it is
* serialised and never populated — do not build a thumbnail on it.
*/
productimage?: string;
}
/* ────────────────────────────────────────────────────────────────────────────