Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into Fix/BE/Purchase-rejected

This commit is contained in:
ragilap
2026-02-02 15:24:11 +07:00
26 changed files with 713 additions and 157 deletions
@@ -1081,10 +1081,25 @@ func (s *purchaseService) ReceiveProducts(c *fiber.Ctx, id uint, req *validation
LoggableId: purchase.Id,
Notes: receiveNote,
}
stockLogs, err := stockLogRepoTx.GetByProductWarehouse(ctx, entry.pwID, 1)
if err != nil {
s.Log.Errorf("Failed to get stock logs: %+v", err)
return fiber.NewError(fiber.StatusInternalServerError, "Failed to get stock logs")
}
if len(stockLogs) > 0 {
latestStockLog := stockLogs[0]
log.Stock = latestStockLog.Stock
} else {
log.Stock = 0
}
if entry.delta > 0 {
log.Increase = entry.delta
log.Stock += log.Increase
} else {
log.Decrease = -entry.delta
log.Stock -= log.Decrease
}
logs = append(logs, log)
}