0cce9ef1b5
- Introduced the `tender_submission` domain, including entity, repository, service, and handler implementations for managing tender submissions. - Added new routes for both admin and public access to tender submissions, allowing for listing, ensuring, and retrieving submissions by ID and tender. - Enhanced the tender approval service to synchronize submission workflows with approval changes, ensuring proper state management. - Implemented validation and response structures for tender submission operations, improving API consistency and usability. - Added unit tests for tender submission status transitions and workflow logic, ensuring robust functionality. This update enhances the tender management system by providing comprehensive support for tender submissions, improving overall workflow and user experience.
101 lines
4.6 KiB
Go
101 lines
4.6 KiB
Go
package tender_submission
|
|
|
|
import "tm/pkg/response"
|
|
|
|
// UpdateSubmissionStatusForm updates the workflow status of a tender submission.
|
|
type UpdateSubmissionStatusForm struct {
|
|
Status SubmissionStatus `json:"status" valid:"required,in(opportunity|validating|partner_pending|applying|sent_waiting|rejected|contract|not_applied)"`
|
|
Reason string `json:"reason,omitempty" valid:"optional,length(0|500)"`
|
|
Description string `json:"description,omitempty" valid:"optional,length(0|1000)"`
|
|
}
|
|
|
|
// ListTenderSubmissionsForm filters company tender submissions.
|
|
type ListTenderSubmissionsForm struct {
|
|
TenderID *string `query:"tender_id" valid:"optional"`
|
|
CompanyID *string `query:"company_id" valid:"optional"`
|
|
Status []string `query:"status" valid:"optional"`
|
|
Stage []string `query:"stage" valid:"optional"`
|
|
From *int64 `query:"created_from" valid:"optional"`
|
|
To *int64 `query:"created_to" valid:"optional"`
|
|
Limit *int `query:"limit" valid:"optional,range(1|100)"`
|
|
Offset *int `query:"offset" valid:"optional,range(0|1000000)"`
|
|
SortBy *string `query:"sort_by" valid:"optional,in(created_at|updated_at|status|stage)"`
|
|
SortOrder *string `query:"sort_order" valid:"optional,in(asc|desc)"`
|
|
}
|
|
|
|
// TenderSubmissionResponse is the API response for a tender submission.
|
|
type TenderSubmissionResponse struct {
|
|
ID string `json:"id"`
|
|
TenderID string `json:"tender_id"`
|
|
CompanyID string `json:"company_id"`
|
|
CustomerID string `json:"customer_id,omitempty"`
|
|
Status string `json:"status"`
|
|
Stage string `json:"stage"`
|
|
History []StatusHistoryResponse `json:"status_history"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// StatusHistoryResponse is the API representation of a status change.
|
|
type StatusHistoryResponse struct {
|
|
Status string `json:"status"`
|
|
Reason string `json:"reason,omitempty"`
|
|
ChangedBy string `json:"changed_by"`
|
|
ChangedAt int64 `json:"changed_at"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
// TenderSubmissionWithTenderResponse includes tender details.
|
|
type TenderSubmissionWithTenderResponse struct {
|
|
TenderSubmissionResponse
|
|
Tender *TenderDetails `json:"tender,omitempty"`
|
|
}
|
|
|
|
// TenderSubmissionListResponse is a paginated list of submissions with tender details.
|
|
type TenderSubmissionListResponse struct {
|
|
Submissions []*TenderSubmissionWithTenderResponse `json:"submissions"`
|
|
Metadata *response.Meta `json:"metadata"`
|
|
}
|
|
|
|
// TenderDetails represents essential tender information for submission responses.
|
|
type TenderDetails struct {
|
|
ID string `json:"id"`
|
|
NoticePublicationID string `json:"notice_publication_id"`
|
|
PublicationDate int64 `json:"publication_date"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
ProcurementTypeCode string `json:"procurement_type_code"`
|
|
ProcedureCode string `json:"procedure_code"`
|
|
EstimatedValue float64 `json:"estimated_value"`
|
|
Currency string `json:"currency"`
|
|
Duration string `json:"duration"`
|
|
DurationUnit string `json:"duration_unit"`
|
|
TenderDeadline int64 `json:"tender_deadline"`
|
|
SubmissionDeadline int64 `json:"submission_deadline"`
|
|
CountryCode string `json:"country_code"`
|
|
BuyerOrganization *OrganizationResponse `json:"buyer_organization"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
// OrganizationResponse represents buyer organization info.
|
|
type OrganizationResponse struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// CompanySubmissionStatsResponse contains submission counts grouped by stage and status.
|
|
type CompanySubmissionStatsResponse struct {
|
|
CompanyID string `json:"company_id"`
|
|
Total int64 `json:"total"`
|
|
ByStage map[string]int64 `json:"by_stage"`
|
|
ByStatus map[string]int64 `json:"by_status"`
|
|
LastUpdated int64 `json:"last_updated"`
|
|
}
|
|
|
|
// AdminSubmissionStatsResponse contains global submission statistics.
|
|
type AdminSubmissionStatsResponse struct {
|
|
Total int64 `json:"total"`
|
|
ByStage map[string]int64 `json:"by_stage"`
|
|
ByStatus map[string]int64 `json:"by_status"`
|
|
LastUpdated int64 `json:"last_updated"`
|
|
}
|