new api for offline sales

This commit is contained in:
2026-07-30 17:25:09 +05:30
parent a11c4843ca
commit 583cd89063
10 changed files with 887 additions and 10 deletions

View File

@@ -327,6 +327,40 @@ type ProductLocationRef struct {
Productid int
}
// SaleTemplateRow is one line of the downloadable offline-sales spreadsheet:
// a product actually stocked at one outlet, with the numbers the person at the
// till needs to see before they type a sold quantity against it.
//
// Productid is the only field that identifies the product. It cannot be
// productsku: across the live catalogue 6,245 products share just 93 distinct
// sku values (one tenant has 463 products all carrying sku "1"), and 154 are
// blank, so a sku is not a key. Productname is nearly unique per tenant but
// not reliably ("rice" appears 6 times for one tenant), so it travels as a
// human-readable confirmation only and is never matched on. That is why the
// spreadsheet has to be generated from this endpoint rather than typed from
// scratch — the productid column is filled in for the user.
type SaleTemplateRow struct {
Productid int `json:"productid"`
Productname string `json:"productname"`
Productunit string `json:"productunit"`
Unitvalue string `json:"unitvalue"`
Categoryname string `json:"categoryname"`
Currentstock int `json:"currentstock"`
Price float64 `json:"price"`
Taxpercent float64 `json:"taxpercent"`
}
// SaleTemplate is the payload the web app turns into an .xlsx workbook. The
// tenant/location identity travels with it so the generated file records which
// outlet it belongs to, and the upload can be checked against the file it came
// from instead of trusting a hand-typed location.
type SaleTemplate struct {
Tenantid int `json:"tenantid"`
Locationid int `json:"locationid"`
Locationname string `json:"locationname"`
Products []SaleTemplateRow `json:"products"`
}
type ProductSubcategory struct {
Subcatid int `json:"subcatid"`
Categoryid int `json:"categoryid"`