stocks change
This commit is contained in:
@@ -124,6 +124,11 @@ type Locationproducts struct {
|
||||
Productcombo int `json:"productcombo" gorm:"default:0"`
|
||||
Variants int `json:"variants" gorm:"default:0"`
|
||||
Quantity int `json:"quantity"`
|
||||
// Price is the per-store selling price from productlocations.price — the one
|
||||
// CreateProductLocation upserts. Read-only here: it comes from the joined
|
||||
// productlocations row, not from products. Without it a store could set a
|
||||
// price and never read it back, so the UI always showed the master price.
|
||||
Price float64 `json:"price" gorm:"->"`
|
||||
Retailprice float64 `json:"retailprice,omitempty"`
|
||||
Diffprice float64 `json:"diffprice,omitempty"`
|
||||
Diffpercent float64 `json:"diffpercent,omitempty"`
|
||||
|
||||
@@ -405,7 +405,11 @@ func (r *productRepository) GetLocationProducts(tenantID, locationID, subcategor
|
||||
|
||||
params := []interface{}{tenantID, locationID}
|
||||
|
||||
query := `SELECT a.*, b.productlocationid, b.status,
|
||||
// b.price is the per-store selling price. It has to be selected explicitly:
|
||||
// a.* only covers products (whose price column is retailprice, the master
|
||||
// price), so without this the catalogue could never read back a price set
|
||||
// for this outlet via CreateProductLocation.
|
||||
query := `SELECT a.*, b.productlocationid, b.status, b.price,
|
||||
COALESCE(SUM(CASE WHEN UPPER(c.stocktype) = 'IN' THEN c.quantity ELSE 0 END), 0) AS total_in,
|
||||
COALESCE(SUM(CASE WHEN UPPER(c.stocktype) = 'OUT' THEN c.quantity ELSE 0 END), 0) AS total_out,
|
||||
COALESCE(SUM(CASE WHEN UPPER(c.stocktype) = 'IN' THEN c.quantity ELSE 0 END) -
|
||||
@@ -427,7 +431,7 @@ func (r *productRepository) GetLocationProducts(tenantID, locationID, subcategor
|
||||
|
||||
query += ` GROUP BY a.productid, a.productname, a.productimage, a.categoryid, a.subcategoryid,
|
||||
a.productunit, a.productcost, a.taxpercent, a.taxamount, a.retailprice,
|
||||
b.tenantid, b.locationid, b.productlocationid, b.status
|
||||
b.tenantid, b.locationid, b.productlocationid, b.status, b.price
|
||||
ORDER BY a.productid DESC LIMIT ? OFFSET ?`
|
||||
|
||||
params = append(params, pagesize, offset)
|
||||
|
||||
Reference in New Issue
Block a user