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.
This commit is contained in:
@@ -476,6 +476,16 @@ func (w *NoticeWorker) ToTender(n *notice.Notice) (*tender.Tender, error) {
|
||||
awardedEntities = mergeAwardedEntitiesByLotID(t.AwardedEntities, awardedEntities)
|
||||
title, description = mergeTitleAndDescriptionForMultiLot(t.Title, t.Description, title, description)
|
||||
|
||||
if estimatedVal == 0 && t.EstimatedValue > 0 {
|
||||
estimatedVal = t.EstimatedValue
|
||||
}
|
||||
if awardedVal == 0 && t.AwardedValue > 0 {
|
||||
awardedVal = t.AwardedValue
|
||||
}
|
||||
if currency == "" && t.Currency != "" {
|
||||
currency = t.Currency
|
||||
}
|
||||
|
||||
if strings.TrimSpace(previousNoticePublicationID) != "" && previousNoticePublicationID != n.NoticePublicationID {
|
||||
if n.EstimatedValue > 0 {
|
||||
estimatedVal = t.EstimatedValue + n.EstimatedValue
|
||||
@@ -495,6 +505,15 @@ func (w *NoticeWorker) ToTender(n *notice.Notice) (*tender.Tender, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if estimatedVal == 0 {
|
||||
if lotValue, lotCurrency := tender.AggregateProcurementLotEstimatedValue(procurementLots); lotValue > 0 {
|
||||
estimatedVal = lotValue
|
||||
if currency == "" {
|
||||
currency = lotCurrency
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Title and description stay in the notice language; English translation is handled by the AI service (translation worker).
|
||||
t.Title = title
|
||||
t.Description = description
|
||||
|
||||
Reference in New Issue
Block a user