This commit is contained in:
2026-09-03 11:21:12 +05:30
parent da0e9d987e
commit 7ed821e8b0
3 changed files with 124 additions and 2 deletions

View File

@@ -336,6 +336,17 @@ func (s *productService) ImportCatalogueProduct(reqs []models.ImportCataloguePro
// The fallback is not dead code and will not become so: products
// imported before `imageid` existed carry only the id, and a re-import is
// how they acquire the stable key.
// The price the product goes live at.
//
// The caller wins whenever it sends one — a merchant who typed a price
// is never overwritten by a catalogue suggestion. Only when it sends
// nothing does the catalogue’s own range fill the gap, so an imported
// product shows a price in the app instead of ₹0, which reads as free.
retail := req.Retailprice
if retail <= 0 {
retail = SuggestedPriceFrom(catalogueProduct.PriceRange)
}
existing, err := s.repo.FindTenantProductByImageID(req.Tenantid, catalogueProduct.ImageID)
if err != nil {
return err
@@ -350,7 +361,7 @@ func (s *productService) ImportCatalogueProduct(reqs []models.ImportCataloguePro
productID := 0
if existing != nil {
productID = existing.Productid
if err := s.repo.UpdateProductPricing(productID, req.Retailprice, req.Productcost, req.Taxpercent); err != nil {
if err := s.repo.UpdateProductPricing(productID, retail, req.Productcost, req.Taxpercent); err != nil {
return err
}
// Re-importing corrects the CATEGORY too, not just the price.
@@ -400,7 +411,7 @@ func (s *productService) ImportCatalogueProduct(reqs []models.ImportCataloguePro
Imageid: catalogueProduct.ImageID,
Productunit: catalogueProduct.Size,
Productcost: req.Productcost,
Retailprice: req.Retailprice,
Retailprice: retail,
Taxpercent: req.Taxpercent,
Approve: 1,
}