product on shelf
This commit is contained in:
@@ -130,3 +130,30 @@ func (ctl *CatalogueUploadController) MarkShelved(c *fiber.Ctx) error {
|
||||
}
|
||||
return c.JSON(fiber.Map{"code": 200, "message": "Shelving recorded", "status": true})
|
||||
}
|
||||
|
||||
// AttachSheet supplies the prices and opening stock for a receipt that has
|
||||
// none, so its products can still be put on a shelf.
|
||||
//
|
||||
// Needed because the receipt and the sheet used to part company. The ingest
|
||||
// service holds neither price nor stock — its catalogue is shared by every
|
||||
// merchant — so both live only in the spreadsheet, and a receipt written before
|
||||
// those rows were stored has no way to finish. Handing the file over again is
|
||||
// the only way back, and this is where it lands.
|
||||
func (ctl *CatalogueUploadController) AttachSheet(c *fiber.Ctx) error {
|
||||
var input struct {
|
||||
Batchid string `json:"batchid"`
|
||||
Sheetrows string `json:"sheetrows"`
|
||||
}
|
||||
if err := c.BodyParser(&input); err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusBadRequest, "message": "Invalid input", "status": false})
|
||||
}
|
||||
if strings.TrimSpace(input.Batchid) == "" || strings.TrimSpace(input.Sheetrows) == "" {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"code": http.StatusBadRequest, "message": "batchid and sheetrows are both required", "status": false,
|
||||
})
|
||||
}
|
||||
if err := ctl.service.AttachSheet(input.Batchid, input.Sheetrows); err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusInternalServerError, "message": err.Error(), "status": false})
|
||||
}
|
||||
return c.JSON(fiber.Map{"code": 200, "message": "Sheet attached", "status": true})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user