diff --git a/pkg/api/transaction_templates.go b/pkg/api/transaction_templates.go index e35f4ba5..d6810496 100644 --- a/pkg/api/transaction_templates.go +++ b/pkg/api/transaction_templates.go @@ -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 } diff --git a/pkg/models/transaction_template.go b/pkg/models/transaction_template.go index 3fe1aaff..7dc90dde 100644 --- a/pkg/models/transaction_template.go +++ b/pkg/models/transaction_template.go @@ -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, diff --git a/pkg/services/transaction_templates.go b/pkg/services/transaction_templates.go index 0be94591..21de77cb 100644 --- a/pkg/services/transaction_templates.go +++ b/pkg/services/transaction_templates.go @@ -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 diff --git a/src/lib/services.js b/src/lib/services.js index 4e26dea2..b668adec 100644 --- a/src/lib/services.js +++ b/src/lib/services.js @@ -536,7 +536,7 @@ export default { name }); }, - modifyTransactionTemplate: ({ id, type, categoryId, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment }) => { + modifyTransactionTemplate: ({ id, type, categoryId, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, comment }) => { return axios.post('v1/transaction/templates/modify.json', { id, type, @@ -545,6 +545,7 @@ export default { destinationAccountId, sourceAmount, destinationAmount, + hideAmount, tagIds, comment }); diff --git a/src/stores/transactionTemplate.js b/src/stores/transactionTemplate.js index 0c72a8bc..e2661bf1 100644 --- a/src/stores/transactionTemplate.js +++ b/src/stores/transactionTemplate.js @@ -275,6 +275,7 @@ export const useTransactionTemplatesStore = defineStore('transactionTemplates', sourceAmount: template.sourceAmount, destinationAccountId: '0', destinationAmount: 0, + hideAmount: template.hideAmount, tagIds: template.tagIds, comment: template.comment }; diff --git a/src/views/desktop/templates/ListPage.vue b/src/views/desktop/templates/ListPage.vue index 52d729f9..95f194be 100644 --- a/src/views/desktop/templates/ListPage.vue +++ b/src/views/desktop/templates/ListPage.vue @@ -466,6 +466,7 @@ export default { destinationAccountId: template.destinationAccountId, sourceAmount: template.sourceAmount, destinationAmount: template.destinationAmount, + hideAmount: template.hideAmount, tagIds: template.tagIds, comment: template.comment } diff --git a/src/views/desktop/transactions/list/dialogs/EditDialog.vue b/src/views/desktop/transactions/list/dialogs/EditDialog.vue index d8e8dda1..381720e1 100644 --- a/src/views/desktop/transactions/list/dialogs/EditDialog.vue +++ b/src/views/desktop/transactions/list/dialogs/EditDialog.vue @@ -8,7 +8,7 @@ + :disabled="loading || submitting" v-if="mode !== 'view'"> @@ -24,13 +24,13 @@ :title="$t('Swap Account and Amount')" v-if="transaction.type === allTransactionTypes.Transfer" @click="swapTransactionData(true, true)"> - + + v-if="transaction.hideAmount" @click="transaction.hideAmount = false"> + v-if="!transaction.hideAmount" @click="transaction.hideAmount = true">