mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
transaction template supports setting whether hide amount
This commit is contained in:
@@ -211,6 +211,7 @@ func (a *TransactionTemplatesApi) TemplateModifyHandler(c *core.Context) (any, *
|
||||
Amount: templateModifyReq.SourceAmount,
|
||||
RelatedAccountId: templateModifyReq.DestinationAccountId,
|
||||
RelatedAccountAmount: templateModifyReq.DestinationAmount,
|
||||
HideAmount: templateModifyReq.HideAmount,
|
||||
Comment: templateModifyReq.Comment,
|
||||
}
|
||||
|
||||
@@ -221,6 +222,7 @@ func (a *TransactionTemplatesApi) TemplateModifyHandler(c *core.Context) (any, *
|
||||
newTemplate.Amount == template.Amount &&
|
||||
newTemplate.RelatedAccountId == template.RelatedAccountId &&
|
||||
newTemplate.RelatedAccountAmount == template.RelatedAccountAmount &&
|
||||
newTemplate.HideAmount == template.HideAmount &&
|
||||
newTemplate.Comment == template.Comment {
|
||||
return nil, errs.ErrNothingWillBeUpdated
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ type TransactionTemplate struct {
|
||||
Amount int64 `xorm:"NOT NULL"`
|
||||
RelatedAccountId int64 `xorm:"NOT NULL"`
|
||||
RelatedAccountAmount int64 `xorm:"NOT NULL"`
|
||||
HideAmount bool `xorm:"NOT NULL"`
|
||||
Comment string `xorm:"VARCHAR(255) NOT NULL"`
|
||||
DisplayOrder int32 `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
||||
Hidden bool `xorm:"NOT NULL"`
|
||||
@@ -68,6 +69,7 @@ type TransactionTemplateModifyRequest struct {
|
||||
DestinationAccountId int64 `json:"destinationAccountId,string" binding:"min=0"`
|
||||
SourceAmount int64 `json:"sourceAmount" binding:"min=-99999999999,max=99999999999"`
|
||||
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
||||
HideAmount bool `json:"hideAmount"`
|
||||
TagIds []string `json:"tagIds"`
|
||||
Comment string `json:"comment" binding:"max=255"`
|
||||
}
|
||||
@@ -121,7 +123,7 @@ func (t *TransactionTemplate) ToTransactionInfoResponse(utcOffset int16) *Transa
|
||||
DestinationAccountId: t.RelatedAccountId,
|
||||
SourceAmount: t.Amount,
|
||||
DestinationAmount: t.RelatedAccountAmount,
|
||||
HideAmount: false,
|
||||
HideAmount: t.HideAmount,
|
||||
TagIds: tagIds,
|
||||
Comment: t.Comment,
|
||||
GeoLocation: nil,
|
||||
|
||||
@@ -125,7 +125,7 @@ func (s *TransactionTemplateService) ModifyTemplate(c *core.Context, template *m
|
||||
template.UpdatedUnixTime = time.Now().Unix()
|
||||
|
||||
return s.UserDataDB(template.Uid).DoTransaction(c, func(sess *xorm.Session) error {
|
||||
updatedRows, err := sess.ID(template.TemplateId).Cols("type", "category_id", "account_id", "tag_ids", "amount", "related_account_id", "related_account_amount", "comment", "updated_unix_time").Where("uid=? AND deleted=?", template.Uid, false).Update(template)
|
||||
updatedRows, err := sess.ID(template.TemplateId).Cols("type", "category_id", "account_id", "tag_ids", "amount", "related_account_id", "related_account_amount", "hide_amount", "comment", "updated_unix_time").Where("uid=? AND deleted=?", template.Uid, false).Update(template)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user