package eform import "time" // ===================================================== // MODIFICATION STRUCTURE // ===================================================== // Modification represents changes to existing contracts type Modification struct { ID string `json:"id" xml:"id" validate:"required,modIDFormat"` OriginalContractID string `json:"original_contract_id" xml:"original_contract_id" validate:"required,conIDFormat"` Reason ModificationReason `json:"reason" xml:"reason" validate:"required"` ReasonDescription string `json:"reason_description" xml:"reason_description" validate:"required,max=10000"` ValueBefore Money `json:"value_before" xml:"value_before" validate:"required"` ValueAfter Money `json:"value_after" xml:"value_after" validate:"required"` ValueChange Money `json:"value_change" xml:"value_change"` PercentageChange float64 `json:"percentage_change" xml:"percentage_change"` DurationBefore *Duration `json:"duration_before,omitempty" xml:"duration_before,omitempty"` DurationAfter *Duration `json:"duration_after,omitempty" xml:"duration_after,omitempty"` ModificationDescription string `json:"modification_description" xml:"modification_description" validate:"required,max=10000"` ModificationDate time.Time `json:"modification_date" xml:"modification_date" validate:"required"` ContractorChange bool `json:"contractor_change" xml:"contractor_change"` NewContractorIDs []string `json:"new_contractor_ids,omitempty" xml:"new_contractor_ids,omitempty"` } // ModificationReason represents the reason for contract modification type ModificationReason string const ( ModReasonAdditionalWorks ModificationReason = "add-wks" ModReasonUnforeseen ModificationReason = "unforeseen" ModReasonDesignDefect ModificationReason = "design-defect" ModReasonAdditionalNeed ModificationReason = "additional-need" ModReasonRepeatSimilar ModificationReason = "repeat-similar" ModReasonRatePriceUpdate ModificationReason = "rate-price-update" ModReasonSuspendCall ModificationReason = "suspend-call" ModReasonOther ModificationReason = "other" ) // CalculateModificationChange calculates value change for modifications func (m *Modification) CalculateModificationChange() { if m.ValueBefore.Currency == m.ValueAfter.Currency { change := m.ValueAfter.Amount - m.ValueBefore.Amount m.ValueChange = Money{ Amount: change, Currency: m.ValueBefore.Currency, } if m.ValueBefore.Amount != 0 { m.PercentageChange = (change / m.ValueBefore.Amount) * 100 } } }