Enhance procurement lot estimated value aggregation and add unit tests
- Updated the `AggregateProcurementLotEstimatedValue` function to reject mixed currencies and allow empty lot currencies, ensuring accurate aggregation of estimated values. - Introduced new unit tests in `entity_test.go` to validate the behavior of the aggregation function under various scenarios, including mixed currencies and empty lot currencies. - Refactored budget calculation in `budget_test.go` to utilize the new aggregation logic, improving consistency in budget retrieval. This update improves the handling of estimated values in procurement lots, enhancing the reliability of the tender management system.
This commit is contained in:
@@ -56,3 +56,29 @@ func TestContractNoticeGetBudgetSumsAllLots(t *testing.T) {
|
||||
t.Fatalf("expected EUR, got %q", currency)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContractNoticeGetBudgetRejectsMixedCurrencies(t *testing.T) {
|
||||
cn := ContractNotice{
|
||||
ProcurementProjectLots: []ProcurementProjectLot{
|
||||
{
|
||||
ProcurementProject: &ProcurementProject{
|
||||
RequestedTenderTotal: &RequestedTenderTotal{
|
||||
EstimatedOverallContractAmount: CurrencyText{CurrencyID: "EUR", Text: "100000"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ProcurementProject: &ProcurementProject{
|
||||
RequestedTenderTotal: &RequestedTenderTotal{
|
||||
EstimatedOverallContractAmount: CurrencyText{CurrencyID: "USD", Text: "250000"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
amount, currency := cn.GetBudget()
|
||||
if amount != "" || currency != "" {
|
||||
t.Fatalf("expected no budget for mixed currencies, got amount=%q currency=%q", amount, currency)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user