Compare commits
No commits in common. "7a2060efdcea047033dbaefb30d956a0dca92cb0" and "a8d62bc5e82626a9e322cff8ac83e54d758431ca" have entirely different histories.
7a2060efdc
...
a8d62bc5e8
@ -107,7 +107,7 @@ func (p *PurchaseOrderProcessorImpl) CreatePurchaseOrder(ctx context.Context, or
|
|||||||
// Calculate total amount
|
// Calculate total amount
|
||||||
totalAmount := 0.0
|
totalAmount := 0.0
|
||||||
for _, item := range req.Items {
|
for _, item := range req.Items {
|
||||||
totalAmount += calculatePurchaseOrderItemTotal(item.Quantity, item.Amount)
|
totalAmount += item.Amount
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create purchase order entity
|
// Create purchase order entity
|
||||||
@ -277,7 +277,7 @@ func (p *PurchaseOrderProcessorImpl) UpdatePurchaseOrder(ctx context.Context, id
|
|||||||
UnitID: unitID,
|
UnitID: unitID,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
}
|
}
|
||||||
totalAmount += calculatePurchaseOrderItemTotal(quantity, amount)
|
totalAmount += amount
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete and recreate only after all replacement items are valid.
|
// Delete and recreate only after all replacement items are valid.
|
||||||
@ -447,7 +447,7 @@ func (p *PurchaseOrderProcessorImpl) UpdatePurchaseOrderStatus(ctx context.Conte
|
|||||||
// Calculate unit cost in ingredient's base unit
|
// Calculate unit cost in ingredient's base unit
|
||||||
unitCost := 0.0
|
unitCost := 0.0
|
||||||
if quantityToAdd > 0 {
|
if quantityToAdd > 0 {
|
||||||
unitCost = calculatePurchaseOrderItemTotal(item.Quantity, item.Amount) / quantityToAdd
|
unitCost = item.Amount / quantityToAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create inventory movement for ingredient purchase
|
// Create inventory movement for ingredient purchase
|
||||||
@ -506,11 +506,3 @@ func (p *PurchaseOrderProcessorImpl) validatePurchaseCategory(ctx context.Contex
|
|||||||
|
|
||||||
return category, nil
|
return category, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculatePurchaseOrderItemTotal(quantity *float64, amount float64) float64 {
|
|
||||||
if quantity == nil {
|
|
||||||
return amount
|
|
||||||
}
|
|
||||||
|
|
||||||
return *quantity * amount
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user