fix: chickin include stock allocation, fix calculation hpp

This commit is contained in:
Hafizh A. Y
2026-03-03 10:36:48 +07:00
parent d5a1751868
commit f6e25be76b
19 changed files with 665 additions and 59 deletions
@@ -1914,11 +1914,12 @@ func (s *purchaseService) resolveChickinLockedItemIDsByItemID(ctx context.Contex
if err := db.WithContext(ctx).
Model(&entity.StockAllocation{}).
Distinct("stockable_id").
Where("stockable_type = ? AND stockable_id IN ? AND usable_type = ? AND status IN ?",
Where("stockable_type = ? AND stockable_id IN ? AND usable_type = ? AND status IN ? AND allocation_purpose = ?",
fifo.StockableKeyPurchaseItems.String(),
itemIDs,
fifo.UsableKeyProjectChickin.String(),
[]string{entity.StockAllocationStatusActive, entity.StockAllocationStatusPending},
entity.StockAllocationPurposeConsume,
).
Pluck("stockable_id", &allocationLockedIDs).Error; err != nil {
return nil, err