Files
tm_back/ted/budget_test.go
T
Mazyar 4cfca5aa55 Enhance tender estimated value resolution and add unit tests
- Updated the `ResolvedEstimatedValueAndCurrency` method to aggregate procurement lot values when the tender-level estimated value is not set, improving accuracy in value retrieval.
- Introduced the `AggregateProcurementLotEstimatedValue` function to sum estimated values from procurement lots and return the first found currency.
- Modified the `ToResponseWithLanguage` method to utilize the new estimated value resolution logic.
- Added unit tests for the new functionality, ensuring correct behavior for various scenarios in the `entity_test.go` and `budget_test.go` files.

This update improves the handling of estimated values in tenders, enhancing the overall reliability of the tender management system.
2026-06-20 12:29:47 +03:30

59 lines
1.5 KiB
Go

package ted
import "testing"
func TestCurrencyTextAmountAndCurrency(t *testing.T) {
t.Run("chardata", func(t *testing.T) {
amount, currency := (CurrencyText{CurrencyID: "EUR", Text: "1 234,56"}).AmountAndCurrency()
if amount != "1 234,56" {
t.Fatalf("unexpected amount %q", amount)
}
if currency != "EUR" {
t.Fatalf("unexpected currency %q", currency)
}
})
t.Run("value child", func(t *testing.T) {
amount, currency := (CurrencyText{CurrencyID: "EUR", Value: "500000"}).AmountAndCurrency()
if amount != "500000" {
t.Fatalf("unexpected amount %q", amount)
}
if currency != "EUR" {
t.Fatalf("unexpected currency %q", currency)
}
})
}
func TestContractNoticeGetBudgetSumsAllLots(t *testing.T) {
cn := ContractNotice{
ProcurementProjectLots: []ProcurementProjectLot{
{
ProcurementProject: &ProcurementProject{
RequestedTenderTotal: &RequestedTenderTotal{
EstimatedOverallContractAmount: CurrencyText{CurrencyID: "EUR", Text: "100000"},
},
},
},
{
ProcurementProject: &ProcurementProject{
RequestedTenderTotal: &RequestedTenderTotal{
EstimatedOverallContractAmount: CurrencyText{CurrencyID: "EUR", Text: "250000"},
},
},
},
},
}
amount, currency := cn.GetBudget()
value, ok := ParseEuropeanAmount(amount)
if !ok {
t.Fatalf("failed to parse budget amount %q", amount)
}
if value != 350000 {
t.Fatalf("expected 350000, got %v", value)
}
if currency != "EUR" {
t.Fatalf("expected EUR, got %q", currency)
}
}