| | |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | SaleChance SaleChance `json:"SaleChance" gorm:"foreignKey:SaleChanceId"` |
| | | SalesDetailsId int `json:"salesDetailsId" gorm:"column:sales_details_id;type:int;comment:合同订单id"` |
| | |
| | | AmountReceived decimal.Decimal `gorm:"column:amount_received;type:decimal(12,2);comment:已收金额" json:"amountReceived"` // 已收金额 |
| | | AmountInvoiced decimal.Decimal `gorm:"column:amount_invoiced;type:decimal(12,2);comment:已开票金额" json:"amountInvoiced"` // 已开票金额 |
| | | AmountUnInvoiced decimal.Decimal `gorm:"column:amount_not_invoiced;type:decimal(12,2);comment:未开票金额" json:"amountUnInvoiced"` // 未开票金额 |
| | | AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:价税合计" json:"amountTotal"` // 价税合计 |
| | | Products []*Product `json:"products" gorm:"many2many:service_contract_product;"` |
| | | gorm.Model `json:"-"` |
| | | } |
| | |
| | | Preload("Products"). |
| | | Preload("Client"). |
| | | Preload("ServiceContractType"). |
| | | Preload("ServiceContractStatus") |
| | | Preload("ServiceContractStatus"). |
| | | Preload("Contact") |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | return record, nil |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) AmountReceivableAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountReceivable.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_receivable": amount}) |
| | | } |
| | | func (slf *ServiceContractSearch) AmountReceivedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountReceived.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_received": amount}) |
| | | } |
| | | func (slf *ServiceContractSearch) AmountInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountInvoiced.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_invoiced": amount}) |
| | | } |
| | | func (slf *ServiceContractSearch) AmountNotInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountUnInvoiced.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_not_invoiced": amount}) |
| | | } |