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

@@ -309,6 +309,40 @@ func (ctl *ProductController) GetLocationProducts(c *fiber.Ctx) error {
})
}
// GetSaleTemplate serves the data the web app turns into the offline-sales
// spreadsheet. Both tenantid and locationid are required rather than defaulted:
// a template generated against the wrong outlet would carry productids the
// import then rejects, which is a confusing failure a missing parameter should
// not be able to cause.
func (ctl *ProductController) GetSaleTemplate(c *fiber.Ctx) error {
tenantID, _ := strconv.Atoi(c.Query("tenantid"))
locationID, _ := strconv.Atoi(c.Query("locationid"))
if tenantID <= 0 || locationID <= 0 {
return c.JSON(fiber.Map{
"status": false,
"code": http.StatusBadRequest,
"message": "tenantid and locationid are required",
})
}
result, err := ctl.productService.GetSaleTemplate(tenantID, locationID)
if err != nil {
return c.JSON(fiber.Map{
"status": false,
"code": http.StatusInternalServerError,
"message": err.Error(),
})
}
return c.JSON(fiber.Map{
"status": true,
"code": http.StatusOK,
"message": "Success",
"details": result,
})
}
func (ctl *ProductController) GetLocationProductSummary(c *fiber.Ctx) error {
tenantID, _ := strconv.Atoi(c.Query("tenantid"))
locationID, _ := strconv.Atoi(c.Query("locationid"))