package eform // ===================================================== // AWARD CRITERIA // ===================================================== // AwardCriteria defines how tenders will be evaluated type AwardCriteria struct { Type AwardCriteriaType `json:"type" xml:"type" validate:"required"` PriceWeight *float64 `json:"price_weight,omitempty" xml:"price_weight,omitempty" validate:"omitempty,min=0,max=100"` CriteriaStatement string `json:"criteria_statement,omitempty" xml:"criteria_statement,omitempty" validate:"max=10000"` Criteria []AwardCriterion `json:"criteria,omitempty" xml:"criteria,omitempty" validate:"dive"` CostCalculation string `json:"cost_calculation,omitempty" xml:"cost_calculation,omitempty" validate:"max=10000"` } // AwardCriteriaType represents the evaluation approach type AwardCriteriaType string const ( AwardTypePrice AwardCriteriaType = "price" AwardTypeCost AwardCriteriaType = "cost" AwardTypeQualPrice AwardCriteriaType = "qual-price" ) // AwardCriterion represents an individual evaluation criterion type AwardCriterion struct { ID string `json:"id" xml:"id" validate:"required,acIDFormat"` Name string `json:"name" xml:"name" validate:"required,max=200"` Description string `json:"description,omitempty" xml:"description,omitempty" validate:"max=2000"` Weight float64 `json:"weight" xml:"weight" validate:"required,min=0,max=100"` Type AwardCriterionType `json:"type" xml:"type" validate:"required"` SubCriteria []AwardCriterion `json:"sub_criteria,omitempty" xml:"sub_criteria,omitempty" validate:"dive"` } // AwardCriterionType represents the type of criterion type AwardCriterionType string const ( CriterionQuality AwardCriterionType = "quality" CriterionCost AwardCriterionType = "cost" CriterionPrice AwardCriterionType = "price" CriterionSocial AwardCriterionType = "social" CriterionEnvironmental AwardCriterionType = "environmental" CriterionInnovative AwardCriterionType = "innovative" ) // CalculateTotalAwardCriteriaWeight validates criteria weights sum to 100 func (ac *AwardCriteria) CalculateTotalAwardCriteriaWeight() float64 { var total float64 for _, criterion := range ac.Criteria { total += criterion.Weight } return total }