fix on shelf

This commit is contained in:
2026-08-31 15:51:36 +05:30
parent 4bce5ac854
commit d55f101834
11 changed files with 704 additions and 55 deletions

View File

@@ -47,21 +47,35 @@ type Productvariant struct {
}
type Products struct {
Productid int `json:"productid" gorm:"primaryKey;autoIncrement"`
AppLocationid int `json:"applocationid" gorm:"column:applocationid"`
Productlocationid int `json:"productlocationid" gorm:"->"`
Tenantid int `json:"tenantid,omitempty"`
Categoryid int `json:"categoryid"`
Categoryname string `json:"categoryname" gorm:"->"`
Subcategoryid int `json:"subcategoryid,omitempty"`
Subcategoryname string `json:"Subcategoryname" gorm:"->"`
Catalogueid int `json:"catalogueid,omitempty"`
Addonid int `json:"addonid,omitempty"`
Discountid int `json:"discountid"`
Discountvalue float64 `json:"discountvalue"`
Pricingid int `json:"pricingid,omitempty"`
Productname string `json:"productname,omitempty"`
Productimage string `json:"productimage,omitempty"`
Productid int `json:"productid" gorm:"primaryKey;autoIncrement"`
AppLocationid int `json:"applocationid" gorm:"column:applocationid"`
Productlocationid int `json:"productlocationid" gorm:"->"`
Tenantid int `json:"tenantid,omitempty"`
Categoryid int `json:"categoryid"`
Categoryname string `json:"categoryname" gorm:"->"`
Subcategoryid int `json:"subcategoryid,omitempty"`
Subcategoryname string `json:"Subcategoryname" gorm:"->"`
Catalogueid int `json:"catalogueid,omitempty"`
// The catalogue's own stable key for this product, e.g. `cheetos_chips_2d6bf74f`.
//
// `catalogueid` cannot do this job and never could. The catalogue is
// rebuilt by scrape and every row is renumbered when it is: pepsico's live
// ids run 3, 6, 9 … 27, 30, so a product imported when it was id 26 now
// points at nothing. Eleven of the nineteen links on the platform were
// dangling this way, and none could be repaired — the re-scrape had also
// changed the pack sizes, so the product they named no longer existed.
//
// `image_id` is the key the catalogue itself deduplicates on and it
// survives both. Written on import; `catalogueid` is kept beside it for
// rows imported before this column existed, and as the id the import call
// still addresses.
Imageid string `json:"imageid,omitempty" gorm:"column:imageid"`
Addonid int `json:"addonid,omitempty"`
Discountid int `json:"discountid"`
Discountvalue float64 `json:"discountvalue"`
Pricingid int `json:"pricingid,omitempty"`
Productname string `json:"productname,omitempty"`
Productimage string `json:"productimage,omitempty"`
// Every photo the product has, as a JSON array of URLs.
//
@@ -77,23 +91,23 @@ type Products struct {
// Held as a string rather than a []string because GORM's raw scan-into-struct
// silently drops slice-kind destination fields — the same reason
// `catalogueProductColumns` casts its text[] columns to text.
Productimages string `json:"productimages,omitempty" gorm:"column:productimages;type:jsonb"`
Productimages string `json:"productimages,omitempty" gorm:"column:productimages;type:jsonb"`
Productdesc string `json:"productdesc,omitempty"`
Productsku string `json:"productsku,omitempty"`
Brandid int `json:"brandid,omitempty"`
Productbrand string `json:"productbrand,omitempty"`
Productunit string `json:"productunit,omitempty"`
Unitvalue string `json:"unitvalue,omitempty"`
Toppicks string `json:"toppicks,omitempty"`
Productcost float64 `json:"productcost,omitempty"`
Taxamount float64 `json:"taxamount,omitempty"`
Taxpercent float64 `json:"taxpercent,omitempty"`
Producttax int `json:"producttax" gorm:"default:0"`
Productstock int `json:"productstock" gorm:"default:0"`
Productcombo int `json:"productcombo" gorm:"default:0"`
Variants int `json:"variants" gorm:"default:0"`
Quantity int `json:"quantity"`
Productdesc string `json:"productdesc,omitempty"`
Productsku string `json:"productsku,omitempty"`
Brandid int `json:"brandid,omitempty"`
Productbrand string `json:"productbrand,omitempty"`
Productunit string `json:"productunit,omitempty"`
Unitvalue string `json:"unitvalue,omitempty"`
Toppicks string `json:"toppicks,omitempty"`
Productcost float64 `json:"productcost,omitempty"`
Taxamount float64 `json:"taxamount,omitempty"`
Taxpercent float64 `json:"taxpercent,omitempty"`
Producttax int `json:"producttax" gorm:"default:0"`
Productstock int `json:"productstock" gorm:"default:0"`
Productcombo int `json:"productcombo" gorm:"default:0"`
Variants int `json:"variants" gorm:"default:0"`
Quantity int `json:"quantity"`
// Price is the EFFECTIVE selling price at the location a query was scoped
// to: productlocations.price when the store has set one, otherwise the
// master Retailprice below. Read-only — it is computed by the query, never
@@ -101,13 +115,13 @@ type Products struct {
// a price the admin sets per store can never reach the customer app: they
// returned only Retailprice, which the admin catalogue never writes.
// Same meaning as Locationproducts.Price, so both product feeds agree.
Price float64 `json:"price" gorm:"->"`
Retailprice float64 `json:"retailprice,omitempty"`
Diffprice float64 `json:"diffprice,omitempty"`
Diffpercent float64 `json:"diffpercent,omitempty"`
Othercost float64 `json:"othercost,omitempty"`
Approve int `json:"approve"`
Productstatus string `json:"productstatus" `
Price float64 `json:"price" gorm:"->"`
Retailprice float64 `json:"retailprice,omitempty"`
Diffprice float64 `json:"diffprice,omitempty"`
Diffpercent float64 `json:"diffpercent,omitempty"`
Othercost float64 `json:"othercost,omitempty"`
Approve int `json:"approve"`
Productstatus string `json:"productstatus" `
// Populated only by queries scoped to a specific location (e.g.
// GetProductByVariant when locationid is passed): Productstock becomes
// the live SUM(in)-SUM(out) balance from productstocks — the same
@@ -313,6 +327,13 @@ type TenantCategory struct {
type ImportedCatalogueRef struct {
Brand string `json:"brand"`
Catalogueid int64 `json:"catalogueid"`
// The stable key, when the product carries one.
//
// A browse screen should match on this in preference to the id: the id is
// renumbered by every re-scrape, so a tick placed by catalogueid lands on
// whatever product now holds that number, or on nothing at all. Empty for a
// product imported before the column existed.
Imageid string `json:"imageid"`
}
// ImportCatalogueProductRequest is the payload for importing a product from