Refactor tender approval logic to streamline submission mode handling
continuous-integration/drone/push Build is passing

- Removed the resetting of `SubmissionMode` in the `Reject` method of the `TenderApproval` entity, ensuring that the submission mode is preserved upon rejection.
- Updated the `GetCompanyTenderApprovalStats` method in the repository to count submissions by mode without filtering by status, enhancing the accuracy of statistics.
- Adjusted the `ToggleTenderApproval` method in the service to set the `SubmissionMode` when rejecting a tender, ensuring consistent handling of submission modes across approval states.

This update improves the clarity and functionality of tender approval processes, ensuring that submission modes are correctly managed during approval and rejection scenarios.
This commit is contained in:
Mazyar
2026-07-08 03:02:57 +03:30
parent 81a94b4879
commit 2fbf329182
3 changed files with 4 additions and 4 deletions
-1
View File
@@ -148,7 +148,6 @@ func (ta *TenderApproval) Submit() {
// Reject rejects the tender with a reason // Reject rejects the tender with a reason
func (ta *TenderApproval) Reject() { func (ta *TenderApproval) Reject() {
ta.Status = ApprovalStatusRejected ta.Status = ApprovalStatusRejected
ta.SubmissionMode = ""
ta.CreatedAt = time.Now().Unix() ta.CreatedAt = time.Now().Unix()
} }
+3 -3
View File
@@ -516,11 +516,11 @@ func (r *tenderApprovalRepository) GetCompanyTenderApprovalStats(ctx context.Con
rejectedFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusRejected)} rejectedFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusRejected)}
rejectedTenders, _ := r.ormRepo.Count(ctx, rejectedFilter) rejectedTenders, _ := r.ormRepo.Count(ctx, rejectedFilter)
// Count by submission mode for this company // Count by submission mode for this company (includes submitted and rejected decisions).
selfApplyFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusSubmitted), "submission_mode": string(SubmissionModeSelfApply)} selfApplyFilter := bson.M{"company_id": companyID, "submission_mode": string(SubmissionModeSelfApply)}
selfApplyCount, _ := r.ormRepo.Count(ctx, selfApplyFilter) selfApplyCount, _ := r.ormRepo.Count(ctx, selfApplyFilter)
partnershipFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusSubmitted), "submission_mode": string(SubmissionModePartnership)} partnershipFilter := bson.M{"company_id": companyID, "submission_mode": string(SubmissionModePartnership)}
partnershipCount, _ := r.ormRepo.Count(ctx, partnershipFilter) partnershipCount, _ := r.ormRepo.Count(ctx, partnershipFilter)
stats := &CompanyTenderApprovalStatsResponse{ stats := &CompanyTenderApprovalStatsResponse{
+1
View File
@@ -925,6 +925,7 @@ func (s *tenderApprovalService) ToggleTenderApproval(ctx context.Context, req *T
existing.SubmissionMode = req.SubmissionMode existing.SubmissionMode = req.SubmissionMode
} else if existing.Status == ApprovalStatusSubmitted && req.Status == ApprovalStatusRejected { } else if existing.Status == ApprovalStatusSubmitted && req.Status == ApprovalStatusRejected {
existing.Reject() existing.Reject()
existing.SubmissionMode = req.SubmissionMode
} else { } else {
existing.Status = req.Status existing.Status = req.Status
existing.SubmissionMode = req.SubmissionMode existing.SubmissionMode = req.SubmissionMode