Merge remote-tracking branch 'origin/main'

This commit is contained in:
Suriya
2026-08-03 17:48:21 +05:30
9 changed files with 326 additions and 98 deletions

View File

@@ -390,10 +390,13 @@ func (ctl *OrderController) UploadOfflineSales(c *fiber.Ctx) error {
})
}
if input.Tenantid <= 0 || input.Locationid <= 0 {
// locationid is optional: 0 means the bills carry their own branch, which
// is how one workbook covers every outlet a merchant runs. Supplying it
// pins the upload to that branch and rejects anything else in the file.
if input.Tenantid <= 0 {
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": "tenantid and locationid are required",
"message": "tenantid is required",
"status": false,
})
}

View File

@@ -310,19 +310,21 @@ 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.
// spreadsheet.
//
// locationid is optional and defaults to 0, meaning every branch the tenant
// runs — one workbook for the whole business, with each row carrying the branch
// its stock belongs to. A store user passes their own locationid to get just
// theirs. tenantid is required: without it there is no scope at all.
func (ctl *ProductController) GetSaleTemplate(c *fiber.Ctx) error {
tenantID, _ := strconv.Atoi(c.Query("tenantid"))
locationID, _ := strconv.Atoi(c.Query("locationid"))
locationID, _ := strconv.Atoi(c.Query("locationid", "0"))
if tenantID <= 0 || locationID <= 0 {
if tenantID <= 0 {
return c.JSON(fiber.Map{
"status": false,
"code": http.StatusBadRequest,
"message": "tenantid and locationid are required",
"message": "tenantid is required",
})
}