pricing update
This commit is contained in:
@@ -942,6 +942,36 @@ export async function createProductLocation(input: CreateProductLocationInput):
|
||||
return fiestaSend<Row>('products/createproductlocation', 'POST', [payload]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same endpoint, one request for many outlets. `createproductlocation` takes an
|
||||
* array and upserts on (tenantid, locationid, productid), so this publishes or
|
||||
* reprices a product across every branch in a single round trip.
|
||||
*
|
||||
* `quantity` is deliberately 0. It is not a productlocations column at all —
|
||||
* models.Productlocations marks Quantity/Stocktype `gorm:"<-:false"`, so they
|
||||
* are never written; they only decide whether the backend appends a
|
||||
* `productstocks` ledger row, which it skips entirely when quantity is 0.
|
||||
* Sending 0 therefore prices every outlet while touching no stock anywhere.
|
||||
* Pricing must never move stock.
|
||||
*/
|
||||
export async function createProductLocations(
|
||||
inputs: Array<{ tenantid: number; locationid: number; productid: number; price?: number; status?: string }>,
|
||||
): Promise<Row> {
|
||||
const payload = inputs.map((i) => {
|
||||
const row: Record<string, unknown> = {
|
||||
tenantid: i.tenantid,
|
||||
locationid: i.locationid,
|
||||
productid: i.productid,
|
||||
quantity: 0,
|
||||
stocktype: 'in',
|
||||
status: i.status || 'Active',
|
||||
};
|
||||
if (num(i.price) > 0) row.price = i.price;
|
||||
return row;
|
||||
});
|
||||
return fiestaSend<Row>('products/createproductlocation', 'POST', payload);
|
||||
}
|
||||
|
||||
export interface DeleteProductLocationInput {
|
||||
tenantid: number;
|
||||
locationid: number;
|
||||
|
||||
Reference in New Issue
Block a user