add total out

This commit is contained in:
Aditya Siregar
2025-08-14 01:35:19 +07:00
parent 07b3eda263
commit 13d8c75be7
7 changed files with 320 additions and 77 deletions
+28
View File
@@ -238,6 +238,34 @@ func (h *InventoryHandler) AdjustInventory(c *gin.Context) {
util.HandleResponse(c.Writer, c.Request, inventoryResponse, "InventoryHandler::AdjustInventory")
}
func (h *InventoryHandler) RestockInventory(c *gin.Context) {
ctx := c.Request.Context()
var req contract.RestockInventoryRequest
if err := c.ShouldBindJSON(&req); err != nil {
logger.FromContext(c.Request.Context()).WithError(err).Error("InventoryHandler::RestockInventory -> request binding failed")
validationResponseError := contract.NewResponseError(constants.MissingFieldErrorCode, constants.RequestEntity, err.Error())
util.HandleResponse(c.Writer, c.Request, contract.BuildErrorResponse([]*contract.ResponseError{validationResponseError}), "InventoryHandler::RestockInventory")
return
}
// TODO: Add validation for restock request
// validationError, validationErrorCode := h.inventoryValidator.ValidateRestockInventoryRequest(&req)
// if validationError != nil {
// validationResponseError := contract.NewResponseError(validationErrorCode, constants.RequestEntity, validationError.Error())
// util.HandleResponse(c.Writer, c.Request, contract.BuildErrorResponse([]*contract.ResponseError{validationResponseError}), "InventoryHandler::RestockInventory")
// return
// }
inventoryResponse := h.inventoryService.RestockInventory(ctx, &req)
if inventoryResponse.HasErrors() {
errorResp := inventoryResponse.GetErrors()[0]
logger.FromContext(ctx).WithError(errorResp).Error("InventoryHandler::RestockInventory -> Failed to restock inventory from service")
}
util.HandleResponse(c.Writer, c.Request, inventoryResponse, "InventoryHandler::RestockInventory")
}
func (h *InventoryHandler) GetLowStockItems(c *gin.Context) {
ctx := c.Request.Context()