mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into Fix/BE/Purchase-rejected
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user