From 2def11ba83760b5be1361f10c3756cc0e9cfd165 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 14 八月 2023 09:32:13 +0800 Subject: [PATCH] merge --- model/serviceContract.go | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 deletions(-) diff --git a/model/serviceContract.go b/model/serviceContract.go index 94acee1..05eed61 100644 --- a/model/serviceContract.go +++ b/model/serviceContract.go @@ -35,10 +35,11 @@ ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:鏈嶅姟娆℃暟"` Terms string `json:"terms" gorm:"column:terms;type:text;comment:鏉℃"` Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"` - AmountReceivable decimal.Decimal `gorm:"amount_receivable" json:"amountReceivable"` // 搴旀敹閲戦 - AmountReceived decimal.Decimal `gorm:"amount_received" json:"amountReceived"` // 宸叉敹閲戦 - AmountInvoiced decimal.Decimal `gorm:"amount_invoiced" json:"amountInvoiced"` // 宸插紑绁ㄩ噾棰� - AmountUnInvoiced decimal.Decimal `gorm:"-" json:"amountUnInvoiced"` // 鏈紑绁ㄩ噾棰� + AmountReceivable decimal.Decimal `gorm:"column:amount_receivable;type:decimal(12,2);comment:搴旀敹閲戦" json:"amountReceivable"` // 搴旀敹閲戦 + 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:"-"` } @@ -216,3 +217,40 @@ 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}) +} -- Gitblit v1.8.0