Enhance tender approval and submission handling
- Added a new error for submission sync failures, improving error handling in the tender approval process. - Updated the `ToggleTenderApproval` method to handle the new error, providing clearer responses for sync issues. - Introduced a method to reopen terminal submissions when tender approvals are resubmitted, enhancing submission state management. - Implemented optimistic locking in the repository to prevent concurrent updates, improving data integrity. - Added unit tests for new submission handling logic, ensuring robust functionality and error management. This update strengthens the tender approval workflow and submission handling, ensuring better error reporting and state management.
This commit is contained in:
@@ -113,6 +113,12 @@ func (ts *TenderSubmission) AddStatusChange(status SubmissionStatus, reason, cha
|
||||
ts.SetUpdatedAt(time.Now().Unix())
|
||||
}
|
||||
|
||||
// ReopenForApproval resets a terminal submission when the tender is approved again.
|
||||
// This is only used by the approval sync path, not by user-initiated status updates.
|
||||
func (ts *TenderSubmission) ReopenForApproval(changedBy, description string) {
|
||||
ts.AddStatusChange(StatusOpportunity, "approval_resubmitted", changedBy, description)
|
||||
}
|
||||
|
||||
func NewTenderSubmission(tenderID, companyID, customerID string) *TenderSubmission {
|
||||
now := time.Now().Unix()
|
||||
ts := &TenderSubmission{
|
||||
|
||||
Reference in New Issue
Block a user