Update Tender Approval Status to Include Submitted State and Revise API Documentation

- Changed the approval status from "approved" to "submitted" in various locations, including entity definitions, forms, and service methods, to accurately reflect the tender approval process.
- Updated API documentation in Swagger JSON, YAML, and Go files to describe the new status options ("submitted" and "rejected") and their corresponding descriptions.
- Enhanced the tender approval statistics structures to include a count for submitted tenders, improving the overall data model for tender management.
- These changes ensure clarity in the tender approval workflow and enhance the usability of the API for clients interacting with tender approvals.
This commit is contained in:
n.nakhostin
2025-08-25 13:51:14 +03:30
parent 0e14a11daf
commit 3024998e7e
9 changed files with 89 additions and 88 deletions
+15 -15
View File
@@ -4080,7 +4080,7 @@ const docTemplate = `{
"BearerAuth": [] "BearerAuth": []
} }
], ],
"description": "Retrieve tender approvals filtered by their status (approved, rejected)", "description": "Retrieve tender approvals filtered by their status (submitted, rejected)",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -4094,7 +4094,7 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"enum": [ "enum": [
"approved", "submitted",
"rejected" "rejected"
], ],
"type": "string", "type": "string",
@@ -6018,11 +6018,11 @@ const docTemplate = `{
}, },
{ {
"enum": [ "enum": [
"approved", "submitted",
"rejected" "rejected"
], ],
"type": "string", "type": "string",
"description": "Filter by status Enums(approved, rejected)", "description": "Filter by status Enums(submitted, rejected)",
"name": "status", "name": "status",
"in": "query" "in": "query"
} }
@@ -7989,28 +7989,25 @@ const docTemplate = `{
"tender_approval.ApprovalStatus": { "tender_approval.ApprovalStatus": {
"type": "string", "type": "string",
"enum": [ "enum": [
"approved", "submitted",
"rejected" "rejected"
], ],
"x-enum-comments": { "x-enum-comments": {
"ApprovalStatusApproved": "Company approved the tender", "ApprovalStatusRejected": "Company rejected the tender",
"ApprovalStatusRejected": "Company rejected the tender" "ApprovalStatusSubmitted": "Company submitted the tender"
}, },
"x-enum-descriptions": [ "x-enum-descriptions": [
"Company approved the tender", "Company submitted the tender",
"Company rejected the tender" "Company rejected the tender"
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"ApprovalStatusApproved", "ApprovalStatusSubmitted",
"ApprovalStatusRejected" "ApprovalStatusRejected"
] ]
}, },
"tender_approval.CompanyTenderApprovalStatsResponse": { "tender_approval.CompanyTenderApprovalStatsResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"approved_tenders": {
"type": "integer"
},
"company_id": { "company_id": {
"type": "string" "type": "string"
}, },
@@ -8026,6 +8023,9 @@ const docTemplate = `{
"self_apply_count": { "self_apply_count": {
"type": "integer" "type": "integer"
}, },
"submitted_tenders": {
"type": "integer"
},
"total_approvals": { "total_approvals": {
"type": "integer" "type": "integer"
} }
@@ -8121,15 +8121,15 @@ const docTemplate = `{
"tender_approval.TenderApprovalStatsResponse": { "tender_approval.TenderApprovalStatsResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"approved_tenders": {
"type": "integer"
},
"last_updated": { "last_updated": {
"type": "integer" "type": "integer"
}, },
"rejected_tenders": { "rejected_tenders": {
"type": "integer" "type": "integer"
}, },
"submitted_tenders": {
"type": "integer"
},
"total_approvals": { "total_approvals": {
"type": "integer" "type": "integer"
} }
+15 -15
View File
@@ -4074,7 +4074,7 @@
"BearerAuth": [] "BearerAuth": []
} }
], ],
"description": "Retrieve tender approvals filtered by their status (approved, rejected)", "description": "Retrieve tender approvals filtered by their status (submitted, rejected)",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -4088,7 +4088,7 @@
"parameters": [ "parameters": [
{ {
"enum": [ "enum": [
"approved", "submitted",
"rejected" "rejected"
], ],
"type": "string", "type": "string",
@@ -6012,11 +6012,11 @@
}, },
{ {
"enum": [ "enum": [
"approved", "submitted",
"rejected" "rejected"
], ],
"type": "string", "type": "string",
"description": "Filter by status Enums(approved, rejected)", "description": "Filter by status Enums(submitted, rejected)",
"name": "status", "name": "status",
"in": "query" "in": "query"
} }
@@ -7983,28 +7983,25 @@
"tender_approval.ApprovalStatus": { "tender_approval.ApprovalStatus": {
"type": "string", "type": "string",
"enum": [ "enum": [
"approved", "submitted",
"rejected" "rejected"
], ],
"x-enum-comments": { "x-enum-comments": {
"ApprovalStatusApproved": "Company approved the tender", "ApprovalStatusRejected": "Company rejected the tender",
"ApprovalStatusRejected": "Company rejected the tender" "ApprovalStatusSubmitted": "Company submitted the tender"
}, },
"x-enum-descriptions": [ "x-enum-descriptions": [
"Company approved the tender", "Company submitted the tender",
"Company rejected the tender" "Company rejected the tender"
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"ApprovalStatusApproved", "ApprovalStatusSubmitted",
"ApprovalStatusRejected" "ApprovalStatusRejected"
] ]
}, },
"tender_approval.CompanyTenderApprovalStatsResponse": { "tender_approval.CompanyTenderApprovalStatsResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"approved_tenders": {
"type": "integer"
},
"company_id": { "company_id": {
"type": "string" "type": "string"
}, },
@@ -8020,6 +8017,9 @@
"self_apply_count": { "self_apply_count": {
"type": "integer" "type": "integer"
}, },
"submitted_tenders": {
"type": "integer"
},
"total_approvals": { "total_approvals": {
"type": "integer" "type": "integer"
} }
@@ -8115,15 +8115,15 @@
"tender_approval.TenderApprovalStatsResponse": { "tender_approval.TenderApprovalStatsResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"approved_tenders": {
"type": "integer"
},
"last_updated": { "last_updated": {
"type": "integer" "type": "integer"
}, },
"rejected_tenders": { "rejected_tenders": {
"type": "integer" "type": "integer"
}, },
"submitted_tenders": {
"type": "integer"
},
"total_approvals": { "total_approvals": {
"type": "integer" "type": "integer"
} }
+13 -12
View File
@@ -947,22 +947,20 @@ definitions:
type: object type: object
tender_approval.ApprovalStatus: tender_approval.ApprovalStatus:
enum: enum:
- approved - submitted
- rejected - rejected
type: string type: string
x-enum-comments: x-enum-comments:
ApprovalStatusApproved: Company approved the tender
ApprovalStatusRejected: Company rejected the tender ApprovalStatusRejected: Company rejected the tender
ApprovalStatusSubmitted: Company submitted the tender
x-enum-descriptions: x-enum-descriptions:
- Company approved the tender - Company submitted the tender
- Company rejected the tender - Company rejected the tender
x-enum-varnames: x-enum-varnames:
- ApprovalStatusApproved - ApprovalStatusSubmitted
- ApprovalStatusRejected - ApprovalStatusRejected
tender_approval.CompanyTenderApprovalStatsResponse: tender_approval.CompanyTenderApprovalStatsResponse:
properties: properties:
approved_tenders:
type: integer
company_id: company_id:
type: string type: string
last_updated: last_updated:
@@ -973,6 +971,8 @@ definitions:
type: integer type: integer
self_apply_count: self_apply_count:
type: integer type: integer
submitted_tenders:
type: integer
total_approvals: total_approvals:
type: integer type: integer
type: object type: object
@@ -1036,12 +1036,12 @@ definitions:
type: object type: object
tender_approval.TenderApprovalStatsResponse: tender_approval.TenderApprovalStatsResponse:
properties: properties:
approved_tenders:
type: integer
last_updated: last_updated:
type: integer type: integer
rejected_tenders: rejected_tenders:
type: integer type: integer
submitted_tenders:
type: integer
total_approvals: total_approvals:
type: integer type: integer
type: object type: object
@@ -3933,11 +3933,12 @@ paths:
get: get:
consumes: consumes:
- application/json - application/json
description: Retrieve tender approvals filtered by their status (approved, rejected) description: Retrieve tender approvals filtered by their status (submitted,
rejected)
parameters: parameters:
- description: Tender approval status - description: Tender approval status
enum: enum:
- approved - submitted
- rejected - rejected
in: path in: path
name: status name: status
@@ -5067,9 +5068,9 @@ paths:
in: query in: query
name: submission_mode name: submission_mode
type: string type: string
- description: Filter by status Enums(approved, rejected) - description: Filter by status Enums(submitted, rejected)
enum: enum:
- approved - submitted
- rejected - rejected
in: query in: query
name: status name: status
+7 -7
View File
@@ -9,7 +9,7 @@ import (
type ApprovalStatus string type ApprovalStatus string
const ( const (
ApprovalStatusApproved ApprovalStatus = "approved" // Company approved the tender ApprovalStatusSubmitted ApprovalStatus = "submitted" // Company submitted the tender
ApprovalStatusRejected ApprovalStatus = "rejected" // Company rejected the tender ApprovalStatusRejected ApprovalStatus = "rejected" // Company rejected the tender
) )
@@ -121,9 +121,9 @@ func (ta *TenderApproval) GetID() string {
return ta.ID.Hex() return ta.ID.Hex()
} }
// IsApproved returns true if the tender was approved // IsSubmitted returns true if the tender was submitted
func (ta *TenderApproval) IsApproved() bool { func (ta *TenderApproval) IsSubmitted() bool {
return ta.Status == ApprovalStatusApproved return ta.Status == ApprovalStatusSubmitted
} }
// IsRejected returns true if the tender was rejected // IsRejected returns true if the tender was rejected
@@ -133,12 +133,12 @@ func (ta *TenderApproval) IsRejected() bool {
// HasDecision returns true if a decision has been made // HasDecision returns true if a decision has been made
func (ta *TenderApproval) HasDecision() bool { func (ta *TenderApproval) HasDecision() bool {
return ta.Status == ApprovalStatusApproved || ta.Status == ApprovalStatusRejected return ta.Status == ApprovalStatusSubmitted || ta.Status == ApprovalStatusRejected
} }
// Approve approves the tender with optional notes // Approve approves the tender with optional notes
func (ta *TenderApproval) Approve() { func (ta *TenderApproval) Submit() {
ta.Status = ApprovalStatusApproved ta.Status = ApprovalStatusSubmitted
ta.CreatedAt = time.Now().Unix() ta.CreatedAt = time.Now().Unix()
} }
+6 -6
View File
@@ -4,13 +4,13 @@ package tender_approval
type CreateTenderApprovalForm struct { type CreateTenderApprovalForm struct {
TenderID string `json:"tender_id" valid:"required"` TenderID string `json:"tender_id" valid:"required"`
SubmissionMode SubmissionMode `json:"submission_mode" valid:"required,in(self-apply|partnership)"` SubmissionMode SubmissionMode `json:"submission_mode" valid:"required,in(self-apply|partnership)"`
Status ApprovalStatus `json:"status,omitempty" valid:"optional,in(approved|rejected)"` Status ApprovalStatus `json:"status,omitempty" valid:"optional,in(submitted|rejected)"`
} }
// UpdateTenderApprovalForm represents the form for updating a tender approval // UpdateTenderApprovalForm represents the form for updating a tender approval
type UpdateTenderApprovalForm struct { type UpdateTenderApprovalForm struct {
SubmissionMode *string `json:"submission_mode,omitempty" valid:"optional,in(self-apply|partnership)"` SubmissionMode *string `json:"submission_mode,omitempty" valid:"optional,in(self-apply|partnership)"`
Status *string `json:"status,omitempty" valid:"optional,in(approved|rejected)"` Status *string `json:"status,omitempty" valid:"optional,in(submitted|rejected)"`
} }
// ListTenderApprovalsForm represents the form for listing tender approvals with filters // ListTenderApprovalsForm represents the form for listing tender approvals with filters
@@ -62,7 +62,7 @@ type TenderApprovalSearchForm struct {
// TenderApproval statistics DTOs // TenderApproval statistics DTOs
type TenderApprovalStatsResponse struct { type TenderApprovalStatsResponse struct {
TotalApprovals int64 `json:"total_approvals"` TotalApprovals int64 `json:"total_approvals"`
ApprovedTenders int64 `json:"approved_tenders"` SubmittedTenders int64 `json:"submitted_tenders"`
RejectedTenders int64 `json:"rejected_tenders"` RejectedTenders int64 `json:"rejected_tenders"`
LastUpdated int64 `json:"last_updated"` LastUpdated int64 `json:"last_updated"`
} }
@@ -71,7 +71,7 @@ type TenderApprovalStatsResponse struct {
type CompanyTenderApprovalStatsResponse struct { type CompanyTenderApprovalStatsResponse struct {
CompanyID string `json:"company_id"` CompanyID string `json:"company_id"`
TotalApprovals int64 `json:"total_approvals"` TotalApprovals int64 `json:"total_approvals"`
ApprovedTenders int64 `json:"approved_tenders"` SubmittedTenders int64 `json:"submitted_tenders"`
RejectedTenders int64 `json:"rejected_tenders"` RejectedTenders int64 `json:"rejected_tenders"`
SelfApplyCount int64 `json:"self_apply_count"` SelfApplyCount int64 `json:"self_apply_count"`
PartnershipCount int64 `json:"partnership_count"` PartnershipCount int64 `json:"partnership_count"`
@@ -81,7 +81,7 @@ type CompanyTenderApprovalStatsResponse struct {
// ToggleTenderApprovalForm represents the form for toggling a tender approval // ToggleTenderApprovalForm represents the form for toggling a tender approval
type ToggleTenderApprovalForm struct { type ToggleTenderApprovalForm struct {
TenderID string `json:"tender_id" valid:"required"` TenderID string `json:"tender_id" valid:"required"`
Status ApprovalStatus `json:"status" valid:"required,in(approved|rejected)"` Status ApprovalStatus `json:"status" valid:"required,in(submitted|rejected)"`
SubmissionMode SubmissionMode `json:"submission_mode" valid:"required,in(self-apply|partnership)"` SubmissionMode SubmissionMode `json:"submission_mode" valid:"required,in(self-apply|partnership)"`
} }
@@ -95,7 +95,7 @@ type CompanyTenderApprovalStatsRequest struct {
type AggregatedCompanyStatsResponse struct { type AggregatedCompanyStatsResponse struct {
TotalCompanies int64 `json:"total_companies"` TotalCompanies int64 `json:"total_companies"`
TotalApprovals int64 `json:"total_approvals"` TotalApprovals int64 `json:"total_approvals"`
TotalApprovedTenders int64 `json:"total_approved_tenders"` TotalSubmittedTenders int64 `json:"total_submitted_tenders"`
TotalRejectedTenders int64 `json:"total_rejected_tenders"` TotalRejectedTenders int64 `json:"total_rejected_tenders"`
TotalSelfApplyCount int64 `json:"total_self_apply_count"` TotalSelfApplyCount int64 `json:"total_self_apply_count"`
TotalPartnershipCount int64 `json:"total_partnership_count"` TotalPartnershipCount int64 `json:"total_partnership_count"`
+7 -7
View File
@@ -130,7 +130,7 @@ func (h *Handler) GetTenderApprovalByTenderAndCompany(c echo.Context) error {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param submission_mode query string false "Filter by submission mode Enums(self-apply, partnership)" // @Param submission_mode query string false "Filter by submission mode Enums(self-apply, partnership)"
// @Param status query string false "Filter by status Enums(approved, rejected)" // @Param status query string false "Filter by status Enums(submitted, rejected)"
// @Success 200 {object} response.APIResponse{data=[]TenderApprovalWithTenderResponse} "Tender approvals retrieved successfully" // @Success 200 {object} response.APIResponse{data=[]TenderApprovalWithTenderResponse} "Tender approvals retrieved successfully"
// @Failure 400 {object} response.APIResponse "Bad request - Invalid company ID" // @Failure 400 {object} response.APIResponse "Bad request - Invalid company ID"
// @Failure 500 {object} response.APIResponse "Internal server error" // @Failure 500 {object} response.APIResponse "Internal server error"
@@ -160,8 +160,8 @@ func (h *Handler) PublicGetTenderApprovals(c echo.Context) error {
var status *ApprovalStatus var status *ApprovalStatus
if statusStr != "" { if statusStr != "" {
statusVal := ApprovalStatus(statusStr) statusVal := ApprovalStatus(statusStr)
if statusVal != ApprovalStatusApproved && statusVal != ApprovalStatusRejected { if statusVal != ApprovalStatusSubmitted && statusVal != ApprovalStatusRejected {
return response.BadRequest(c, "Invalid status value", "Must be 'approved' or 'rejected'") return response.BadRequest(c, "Invalid status value", "Must be 'submitted' or 'rejected'")
} }
status = &statusVal status = &statusVal
} }
@@ -258,11 +258,11 @@ func (h *Handler) GetCompanyTenderApprovalStats(c echo.Context) error {
// GetTenderApprovalsByStatus retrieves tender approvals by status // GetTenderApprovalsByStatus retrieves tender approvals by status
// @Summary Get tender approvals by status // @Summary Get tender approvals by status
// @Description Retrieve tender approvals filtered by their status (approved, rejected) // @Description Retrieve tender approvals filtered by their status (submitted, rejected)
// @Tags Admin-TenderApprovals // @Tags Admin-TenderApprovals
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param status path string true "Tender approval status" Enums(approved, rejected) // @Param status path string true "Tender approval status" Enums(submitted, rejected)
// @Param limit query integer false "Number of approvals per page (1-100)" minimum(1) maximum(100) default(20) // @Param limit query integer false "Number of approvals per page (1-100)" minimum(1) maximum(100) default(20)
// @Param offset query integer false "Number of approvals to skip for pagination" minimum(0) default(0) // @Param offset query integer false "Number of approvals to skip for pagination" minimum(0) default(0)
// @Success 200 {object} response.APIResponse{data=[]TenderApprovalResponse,meta=response.Meta} "Tender approvals retrieved successfully" // @Success 200 {object} response.APIResponse{data=[]TenderApprovalResponse,meta=response.Meta} "Tender approvals retrieved successfully"
@@ -275,8 +275,8 @@ func (h *Handler) GetTenderApprovalsByStatus(c echo.Context) error {
status := ApprovalStatus(statusStr) status := ApprovalStatus(statusStr)
// Validate status // Validate status
if status != ApprovalStatusApproved && status != ApprovalStatusRejected { if status != ApprovalStatusSubmitted && status != ApprovalStatusRejected {
return response.BadRequest(c, "Invalid tender approval status", "Must be approved or rejected") return response.BadRequest(c, "Invalid tender approval status", "Must be submitted or rejected")
} }
limit := 20 limit := 20
+7 -7
View File
@@ -475,12 +475,12 @@ func (r *tenderApprovalRepository) CountByCompanyID(ctx context.Context, company
func (r *tenderApprovalRepository) GetTenderApprovalStats(ctx context.Context) (*TenderApprovalStatsResponse, error) { func (r *tenderApprovalRepository) GetTenderApprovalStats(ctx context.Context) (*TenderApprovalStatsResponse, error) {
// Get basic counts // Get basic counts
totalApprovals, _ := r.Count(ctx) totalApprovals, _ := r.Count(ctx)
approvedTenders, _ := r.CountByStatus(ctx, ApprovalStatusApproved) submittedTenders, _ := r.CountByStatus(ctx, ApprovalStatusSubmitted)
rejectedTenders, _ := r.CountByStatus(ctx, ApprovalStatusRejected) rejectedTenders, _ := r.CountByStatus(ctx, ApprovalStatusRejected)
stats := &TenderApprovalStatsResponse{ stats := &TenderApprovalStatsResponse{
TotalApprovals: totalApprovals, TotalApprovals: totalApprovals,
ApprovedTenders: approvedTenders, SubmittedTenders: submittedTenders,
RejectedTenders: rejectedTenders, RejectedTenders: rejectedTenders,
LastUpdated: time.Now().Unix(), LastUpdated: time.Now().Unix(),
} }
@@ -494,23 +494,23 @@ func (r *tenderApprovalRepository) GetCompanyTenderApprovalStats(ctx context.Con
totalApprovals, _ := r.CountByCompanyID(ctx, companyID) totalApprovals, _ := r.CountByCompanyID(ctx, companyID)
// Count by status for this company // Count by status for this company
approvedFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusApproved)} submittedFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusSubmitted)}
approvedTenders, _ := r.ormRepo.Count(ctx, approvedFilter) submittedTenders, _ := r.ormRepo.Count(ctx, submittedFilter)
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
selfApplyFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusApproved), "submission_mode": string(SubmissionModeSelfApply)} selfApplyFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusSubmitted), "submission_mode": string(SubmissionModeSelfApply)}
selfApplyCount, _ := r.ormRepo.Count(ctx, selfApplyFilter) selfApplyCount, _ := r.ormRepo.Count(ctx, selfApplyFilter)
partnershipFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusApproved), "submission_mode": string(SubmissionModePartnership)} partnershipFilter := bson.M{"company_id": companyID, "status": string(ApprovalStatusSubmitted), "submission_mode": string(SubmissionModePartnership)}
partnershipCount, _ := r.ormRepo.Count(ctx, partnershipFilter) partnershipCount, _ := r.ormRepo.Count(ctx, partnershipFilter)
stats := &CompanyTenderApprovalStatsResponse{ stats := &CompanyTenderApprovalStatsResponse{
CompanyID: companyID, CompanyID: companyID,
TotalApprovals: totalApprovals, TotalApprovals: totalApprovals,
ApprovedTenders: approvedTenders, SubmittedTenders: submittedTenders,
RejectedTenders: rejectedTenders, RejectedTenders: rejectedTenders,
SelfApplyCount: selfApplyCount, SelfApplyCount: selfApplyCount,
PartnershipCount: partnershipCount, PartnershipCount: partnershipCount,
+6 -6
View File
@@ -696,7 +696,7 @@ func (s *tenderApprovalService) GetAggregatedCompanyStats(ctx context.Context) (
stats := &AggregatedCompanyStatsResponse{ stats := &AggregatedCompanyStatsResponse{
TotalCompanies: 1, // This should be calculated from actual company data TotalCompanies: 1, // This should be calculated from actual company data
TotalApprovals: generalStats.TotalApprovals, TotalApprovals: generalStats.TotalApprovals,
TotalApprovedTenders: generalStats.ApprovedTenders, TotalSubmittedTenders: generalStats.SubmittedTenders,
TotalRejectedTenders: generalStats.RejectedTenders, TotalRejectedTenders: generalStats.RejectedTenders,
CompanyStats: []*CompanyTenderApprovalStatsResponse{}, // Empty for now CompanyStats: []*CompanyTenderApprovalStatsResponse{}, // Empty for now
LastUpdated: time.Now().Unix(), LastUpdated: time.Now().Unix(),
@@ -1004,8 +1004,8 @@ func (s *tenderApprovalService) ToggleTenderApproval(ctx context.Context, req *T
return nil, err return nil, err
} }
if req.Status == ApprovalStatusApproved { if req.Status == ApprovalStatusSubmitted {
existing.Status = "unapproved" existing.Status = "unsubmitted"
} else { } else {
existing.Status = "unrejected" existing.Status = "unrejected"
} }
@@ -1024,10 +1024,10 @@ func (s *tenderApprovalService) ToggleTenderApproval(ctx context.Context, req *T
return existing.ToResponseWithTender(nil), nil return existing.ToResponseWithTender(nil), nil
} }
if existing.Status == ApprovalStatusApproved { if existing.Status == ApprovalStatusSubmitted {
existing.Reject() existing.Reject()
} else { } else {
existing.Approve() existing.Submit()
} }
err = s.repository.Update(ctx, existing) err = s.repository.Update(ctx, existing)
@@ -1055,7 +1055,7 @@ func (s *tenderApprovalService) GetCompanyTenderApprovalStats(ctx context.Contex
s.logger.Info("Company tender approval stats retrieved successfully", map[string]interface{}{ s.logger.Info("Company tender approval stats retrieved successfully", map[string]interface{}{
"company_id": companyID, "company_id": companyID,
"total_approvals": stats.TotalApprovals, "total_approvals": stats.TotalApprovals,
"approved_tenders": stats.ApprovedTenders, "submitted_tenders": stats.SubmittedTenders,
"rejected_tenders": stats.RejectedTenders, "rejected_tenders": stats.RejectedTenders,
"self_apply_count": stats.SelfApplyCount, "self_apply_count": stats.SelfApplyCount,
"partnership_count": stats.PartnershipCount, "partnership_count": stats.PartnershipCount,
+1 -1
View File
@@ -48,7 +48,7 @@ func IsValidSubmissionMode(mode string) bool {
// IsValidStatus validates if the approval status is valid // IsValidStatus validates if the approval status is valid
func IsValidStatus(status string) bool { func IsValidStatus(status string) bool {
validStatuses := []string{ validStatuses := []string{
string(ApprovalStatusApproved), string(ApprovalStatusSubmitted),
string(ApprovalStatusRejected), string(ApprovalStatusRejected),
} }