pricing update

This commit is contained in:
2026-08-06 10:58:34 +05:30
parent 13db63e219
commit ac6dbd7671
9 changed files with 304 additions and 107 deletions

View File

@@ -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;