transaction template supports setting whether hide amount

This commit is contained in:
MaysWind
2024-07-30 00:08:48 +08:00
parent 4e16f963a8
commit b0b330903c
7 changed files with 14 additions and 7 deletions
+2
View File
@@ -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
}
+3 -1
View File
@@ -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,
+1 -1
View File
@@ -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
+2 -1
View File
@@ -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
});
+1
View File
@@ -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
};
+1
View File
@@ -466,6 +466,7 @@ export default {
destinationAccountId: template.destinationAccountId,
sourceAmount: template.sourceAmount,
destinationAmount: template.destinationAmount,
hideAmount: template.hideAmount,
tagIds: template.tagIds,
comment: template.comment
}
@@ -8,7 +8,7 @@
<v-progress-circular indeterminate size="22" class="ml-2" v-if="loading"></v-progress-circular>
</div>
<v-btn density="comfortable" color="default" variant="text" class="ml-2" :icon="true"
:disabled="loading || submitting" v-if="mode !== 'view' && (mode !== 'editTemplate' || transaction.type === allTransactionTypes.Transfer)">
:disabled="loading || submitting" v-if="mode !== 'view'">
<v-icon :icon="icons.more" />
<v-menu activator="parent">
<v-list>
@@ -24,13 +24,13 @@
:title="$t('Swap Account and Amount')"
v-if="transaction.type === allTransactionTypes.Transfer"
@click="swapTransactionData(true, true)"></v-list-item>
<v-divider v-if="mode !== 'editTemplate' && transaction.type === allTransactionTypes.Transfer" />
<v-divider v-if="transaction.type === allTransactionTypes.Transfer" />
<v-list-item :prepend-icon="icons.show"
:title="$t('Show Amount')"
v-if="mode !== 'editTemplate' && transaction.hideAmount" @click="transaction.hideAmount = false"></v-list-item>
v-if="transaction.hideAmount" @click="transaction.hideAmount = false"></v-list-item>
<v-list-item :prepend-icon="icons.hide"
:title="$t('Hide Amount')"
v-if="mode !== 'editTemplate' && !transaction.hideAmount" @click="transaction.hideAmount = true"></v-list-item>
v-if="!transaction.hideAmount" @click="transaction.hideAmount = true"></v-list-item>
</v-list>
</v-menu>
</v-btn>