ask again
This commit is contained in:
@@ -22,8 +22,20 @@ import type { StockRequest, StockStatementRow } from './types';
|
||||
* read back, which is enough to drive a queue but is not a state machine — the
|
||||
* backend will accept any string at all.
|
||||
*/
|
||||
/**
|
||||
* The ladder a request climbs.
|
||||
*
|
||||
* `Approved` sits between asking and arriving, and adding it is the point:
|
||||
* approving used to put the stock on the shelf immediately, so the count said
|
||||
* the goods were there from the moment the admin agreed to send them — which is
|
||||
* days before they arrive, and the branch sells against a shelf that is empty.
|
||||
*
|
||||
* Only `Received` moves the ledger. Fiesta keys the stock write on that exact
|
||||
* word, so `Approved` is a status and nothing else.
|
||||
*/
|
||||
export const STOCK_REQUEST_STATUS = {
|
||||
pending: 'Pending',
|
||||
approved: 'Approved',
|
||||
received: 'Received',
|
||||
rejected: 'Rejected',
|
||||
} as const;
|
||||
@@ -92,13 +104,25 @@ export const stockApi = {
|
||||
}),
|
||||
|
||||
/**
|
||||
* Approve a request — which means marking it Received.
|
||||
* Agree to send the stock. Nothing reaches the shelf yet.
|
||||
*
|
||||
* This adds `request.qty` to the branch's stock. There is no way to approve a
|
||||
* different amount: the service reads the quantity off the request row, not
|
||||
* off this call.
|
||||
* The shelf is written when the branch confirms the goods ARRIVED, not when
|
||||
* the admin agrees to send them — see `confirmArrival`.
|
||||
*/
|
||||
approve: (requestid: number) =>
|
||||
api.put<unknown>(`${WEB}/products/updatestockrequest`, {
|
||||
requestid,
|
||||
status: STOCK_REQUEST_STATUS.approved,
|
||||
}),
|
||||
|
||||
/**
|
||||
* The goods turned up. THIS is what adds `request.qty` to the branch's stock.
|
||||
*
|
||||
* There is no way to receive a different amount: the service reads the
|
||||
* quantity off the request row, not off this call. A short delivery has to be
|
||||
* corrected on the stock ledger afterwards.
|
||||
*/
|
||||
confirmArrival: (requestid: number) =>
|
||||
api.put<unknown>(`${WEB}/products/updatestockrequest`, {
|
||||
requestid,
|
||||
status: STOCK_REQUEST_STATUS.received,
|
||||
@@ -119,7 +143,9 @@ export const stockApi = {
|
||||
decideMany: (requestids: number[], status: StockRequestStatus) =>
|
||||
api.put<StockBatchOutcome>(`${WEB}/products/updatestockrequest`, { requestids, status }),
|
||||
|
||||
approveMany: (requestids: number[]) => stockApi.decideMany(requestids, STOCK_REQUEST_STATUS.received),
|
||||
approveMany: (requestids: number[]) => stockApi.decideMany(requestids, STOCK_REQUEST_STATUS.approved),
|
||||
confirmArrivalMany: (requestids: number[]) =>
|
||||
stockApi.decideMany(requestids, STOCK_REQUEST_STATUS.received),
|
||||
rejectMany: (requestids: number[]) => stockApi.decideMany(requestids, STOCK_REQUEST_STATUS.rejected),
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user