Feat[BE]:: adjust marketing report API

This commit is contained in:
aguhh18
2025-12-17 11:30:49 +07:00
parent afe4b2ffe3
commit 40f192660d
5 changed files with 131 additions and 48 deletions
@@ -152,12 +152,22 @@ func (s *repportService) calculateHppPricePerKg(ctx context.Context, projectFloc
return 0
}
totalActualCost := float64(0)
costBop := float64(0)
for _, realization := range realizations {
cost := realization.Price * realization.Qty
totalActualCost += cost
category := ""
if realization.ExpenseNonstock != nil && realization.ExpenseNonstock.Expense != nil {
category = realization.ExpenseNonstock.Expense.Category
}
if category == "BOP" {
costBop += cost
}
}
totalActualCost := costBop
if totalActualCost == 0 {
return 0
}