mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +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,
|
Amount: templateModifyReq.SourceAmount,
|
||||||
RelatedAccountId: templateModifyReq.DestinationAccountId,
|
RelatedAccountId: templateModifyReq.DestinationAccountId,
|
||||||
RelatedAccountAmount: templateModifyReq.DestinationAmount,
|
RelatedAccountAmount: templateModifyReq.DestinationAmount,
|
||||||
|
HideAmount: templateModifyReq.HideAmount,
|
||||||
Comment: templateModifyReq.Comment,
|
Comment: templateModifyReq.Comment,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +222,7 @@ func (a *TransactionTemplatesApi) TemplateModifyHandler(c *core.Context) (any, *
|
|||||||
newTemplate.Amount == template.Amount &&
|
newTemplate.Amount == template.Amount &&
|
||||||
newTemplate.RelatedAccountId == template.RelatedAccountId &&
|
newTemplate.RelatedAccountId == template.RelatedAccountId &&
|
||||||
newTemplate.RelatedAccountAmount == template.RelatedAccountAmount &&
|
newTemplate.RelatedAccountAmount == template.RelatedAccountAmount &&
|
||||||
|
newTemplate.HideAmount == template.HideAmount &&
|
||||||
newTemplate.Comment == template.Comment {
|
newTemplate.Comment == template.Comment {
|
||||||
return nil, errs.ErrNothingWillBeUpdated
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ type TransactionTemplate struct {
|
|||||||
Amount int64 `xorm:"NOT NULL"`
|
Amount int64 `xorm:"NOT NULL"`
|
||||||
RelatedAccountId int64 `xorm:"NOT NULL"`
|
RelatedAccountId int64 `xorm:"NOT NULL"`
|
||||||
RelatedAccountAmount int64 `xorm:"NOT NULL"`
|
RelatedAccountAmount int64 `xorm:"NOT NULL"`
|
||||||
|
HideAmount bool `xorm:"NOT NULL"`
|
||||||
Comment string `xorm:"VARCHAR(255) NOT NULL"`
|
Comment string `xorm:"VARCHAR(255) NOT NULL"`
|
||||||
DisplayOrder int32 `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
DisplayOrder int32 `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
||||||
Hidden bool `xorm:"NOT NULL"`
|
Hidden bool `xorm:"NOT NULL"`
|
||||||
@@ -68,6 +69,7 @@ type TransactionTemplateModifyRequest struct {
|
|||||||
DestinationAccountId int64 `json:"destinationAccountId,string" binding:"min=0"`
|
DestinationAccountId int64 `json:"destinationAccountId,string" binding:"min=0"`
|
||||||
SourceAmount int64 `json:"sourceAmount" binding:"min=-99999999999,max=99999999999"`
|
SourceAmount int64 `json:"sourceAmount" binding:"min=-99999999999,max=99999999999"`
|
||||||
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
||||||
|
HideAmount bool `json:"hideAmount"`
|
||||||
TagIds []string `json:"tagIds"`
|
TagIds []string `json:"tagIds"`
|
||||||
Comment string `json:"comment" binding:"max=255"`
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
}
|
}
|
||||||
@@ -121,7 +123,7 @@ func (t *TransactionTemplate) ToTransactionInfoResponse(utcOffset int16) *Transa
|
|||||||
DestinationAccountId: t.RelatedAccountId,
|
DestinationAccountId: t.RelatedAccountId,
|
||||||
SourceAmount: t.Amount,
|
SourceAmount: t.Amount,
|
||||||
DestinationAmount: t.RelatedAccountAmount,
|
DestinationAmount: t.RelatedAccountAmount,
|
||||||
HideAmount: false,
|
HideAmount: t.HideAmount,
|
||||||
TagIds: tagIds,
|
TagIds: tagIds,
|
||||||
Comment: t.Comment,
|
Comment: t.Comment,
|
||||||
GeoLocation: nil,
|
GeoLocation: nil,
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func (s *TransactionTemplateService) ModifyTemplate(c *core.Context, template *m
|
|||||||
template.UpdatedUnixTime = time.Now().Unix()
|
template.UpdatedUnixTime = time.Now().Unix()
|
||||||
|
|
||||||
return s.UserDataDB(template.Uid).DoTransaction(c, func(sess *xorm.Session) error {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+2
-1
@@ -536,7 +536,7 @@ export default {
|
|||||||
name
|
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', {
|
return axios.post('v1/transaction/templates/modify.json', {
|
||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
@@ -545,6 +545,7 @@ export default {
|
|||||||
destinationAccountId,
|
destinationAccountId,
|
||||||
sourceAmount,
|
sourceAmount,
|
||||||
destinationAmount,
|
destinationAmount,
|
||||||
|
hideAmount,
|
||||||
tagIds,
|
tagIds,
|
||||||
comment
|
comment
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ export const useTransactionTemplatesStore = defineStore('transactionTemplates',
|
|||||||
sourceAmount: template.sourceAmount,
|
sourceAmount: template.sourceAmount,
|
||||||
destinationAccountId: '0',
|
destinationAccountId: '0',
|
||||||
destinationAmount: 0,
|
destinationAmount: 0,
|
||||||
|
hideAmount: template.hideAmount,
|
||||||
tagIds: template.tagIds,
|
tagIds: template.tagIds,
|
||||||
comment: template.comment
|
comment: template.comment
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -466,6 +466,7 @@ export default {
|
|||||||
destinationAccountId: template.destinationAccountId,
|
destinationAccountId: template.destinationAccountId,
|
||||||
sourceAmount: template.sourceAmount,
|
sourceAmount: template.sourceAmount,
|
||||||
destinationAmount: template.destinationAmount,
|
destinationAmount: template.destinationAmount,
|
||||||
|
hideAmount: template.hideAmount,
|
||||||
tagIds: template.tagIds,
|
tagIds: template.tagIds,
|
||||||
comment: template.comment
|
comment: template.comment
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<v-progress-circular indeterminate size="22" class="ml-2" v-if="loading"></v-progress-circular>
|
<v-progress-circular indeterminate size="22" class="ml-2" v-if="loading"></v-progress-circular>
|
||||||
</div>
|
</div>
|
||||||
<v-btn density="comfortable" color="default" variant="text" class="ml-2" :icon="true"
|
<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-icon :icon="icons.more" />
|
||||||
<v-menu activator="parent">
|
<v-menu activator="parent">
|
||||||
<v-list>
|
<v-list>
|
||||||
@@ -24,13 +24,13 @@
|
|||||||
:title="$t('Swap Account and Amount')"
|
:title="$t('Swap Account and Amount')"
|
||||||
v-if="transaction.type === allTransactionTypes.Transfer"
|
v-if="transaction.type === allTransactionTypes.Transfer"
|
||||||
@click="swapTransactionData(true, true)"></v-list-item>
|
@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"
|
<v-list-item :prepend-icon="icons.show"
|
||||||
:title="$t('Show Amount')"
|
: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"
|
<v-list-item :prepend-icon="icons.hide"
|
||||||
:title="$t('Hide Amount')"
|
: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-list>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|||||||
Reference in New Issue
Block a user