Enhance tender and company context handling with new features and error management
continuous-integration/drone/push Build is passing

- Introduced `PickAssignedCompanyID` function to determine the appropriate company ID for company-scoped operations, improving company assignment logic.
- Added `ResolveMongoID` method in the tender service to map MongoDB IDs and AI procedure references to canonical tender IDs, enhancing ID resolution.
- Updated `ToggleTenderApproval` to handle company ID validation and improve error handling, ensuring robust processing of tender approvals.
- Enhanced logging for error scenarios in the tender approval service, providing better insights into failures during operations.
- Refactored the `GetByID` and `GetByTenderAndCompany` methods in the tender approval repository to utilize custom error types for improved clarity.

This update significantly improves the handling of company and tender operations, enhancing error management and overall service reliability.
This commit is contained in:
Mazyar
2026-07-08 02:55:55 +03:30
parent 11e0b44ebe
commit 81a94b4879
7 changed files with 137 additions and 28 deletions
+9 -2
View File
@@ -249,12 +249,19 @@ func (r *tenderRepository) GetByIDs(ctx context.Context, ids []string) ([]Tender
objectIDs := make([]bson.ObjectID, 0, len(batch))
for _, id := range batch {
objectID, err := bson.ObjectIDFromHex(id)
objectID, err := bson.ObjectIDFromHex(strings.TrimSpace(id))
if err != nil {
return nil, err
r.logger.Warn("Skipping invalid tender ID in batch lookup", map[string]interface{}{
"tender_id": id,
"error": err.Error(),
})
continue
}
objectIDs = append(objectIDs, objectID)
}
if len(objectIDs) == 0 {
continue
}
pagination := orm.Pagination{
Limit: len(objectIDs),