mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
support hiding transaction amount
This commit is contained in:
@@ -693,6 +693,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
TimezoneUtcOffset: transactionModifyReq.UtcOffset,
|
TimezoneUtcOffset: transactionModifyReq.UtcOffset,
|
||||||
AccountId: transactionModifyReq.SourceAccountId,
|
AccountId: transactionModifyReq.SourceAccountId,
|
||||||
Amount: transactionModifyReq.SourceAmount,
|
Amount: transactionModifyReq.SourceAmount,
|
||||||
|
HideAmount: transactionModifyReq.HideAmount,
|
||||||
Comment: transactionModifyReq.Comment,
|
Comment: transactionModifyReq.Comment,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,6 +709,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
newTransaction.Amount == transaction.Amount &&
|
newTransaction.Amount == transaction.Amount &&
|
||||||
(transaction.Type != models.TRANSACTION_DB_TYPE_TRANSFER_OUT || newTransaction.RelatedAccountId == transaction.RelatedAccountId) &&
|
(transaction.Type != models.TRANSACTION_DB_TYPE_TRANSFER_OUT || newTransaction.RelatedAccountId == transaction.RelatedAccountId) &&
|
||||||
(transaction.Type != models.TRANSACTION_DB_TYPE_TRANSFER_OUT || newTransaction.RelatedAccountAmount == transaction.RelatedAccountAmount) &&
|
(transaction.Type != models.TRANSACTION_DB_TYPE_TRANSFER_OUT || newTransaction.RelatedAccountAmount == transaction.RelatedAccountAmount) &&
|
||||||
|
newTransaction.HideAmount == transaction.HideAmount &&
|
||||||
newTransaction.Comment == transaction.Comment &&
|
newTransaction.Comment == transaction.Comment &&
|
||||||
utils.Int64SliceEquals(tagIds, transactionTagIds) {
|
utils.Int64SliceEquals(tagIds, transactionTagIds) {
|
||||||
return nil, errs.ErrNothingWillBeUpdated
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
@@ -992,6 +994,7 @@ func (a *TransactionsApi) createNewTransactionModel(uid int64, transactionCreate
|
|||||||
TimezoneUtcOffset: transactionCreateReq.UtcOffset,
|
TimezoneUtcOffset: transactionCreateReq.UtcOffset,
|
||||||
AccountId: transactionCreateReq.SourceAccountId,
|
AccountId: transactionCreateReq.SourceAccountId,
|
||||||
Amount: transactionCreateReq.SourceAmount,
|
Amount: transactionCreateReq.SourceAmount,
|
||||||
|
HideAmount: transactionCreateReq.HideAmount,
|
||||||
Comment: transactionCreateReq.Comment,
|
Comment: transactionCreateReq.Comment,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type Transaction struct {
|
|||||||
RelatedId int64 `xorm:"NOT NULL"`
|
RelatedId 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"`
|
||||||
CreatedUnixTime int64
|
CreatedUnixTime int64
|
||||||
UpdatedUnixTime int64
|
UpdatedUnixTime int64
|
||||||
@@ -62,6 +63,7 @@ type TransactionCreateRequest 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"`
|
||||||
}
|
}
|
||||||
@@ -76,6 +78,7 @@ type TransactionModifyRequest 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"`
|
||||||
}
|
}
|
||||||
@@ -181,6 +184,7 @@ type TransactionInfoResponse struct {
|
|||||||
DestinationAccount *AccountInfoResponse `json:"destinationAccount,omitempty"`
|
DestinationAccount *AccountInfoResponse `json:"destinationAccount,omitempty"`
|
||||||
SourceAmount int64 `json:"sourceAmount"`
|
SourceAmount int64 `json:"sourceAmount"`
|
||||||
DestinationAmount int64 `json:"destinationAmount,omitempty"`
|
DestinationAmount int64 `json:"destinationAmount,omitempty"`
|
||||||
|
HideAmount bool `json:"hideAmount"`
|
||||||
TagIds []string `json:"tagIds"`
|
TagIds []string `json:"tagIds"`
|
||||||
Tags []*TransactionTagInfoResponse `json:"tags,omitempty"`
|
Tags []*TransactionTagInfoResponse `json:"tags,omitempty"`
|
||||||
Comment string `json:"comment"`
|
Comment string `json:"comment"`
|
||||||
@@ -304,6 +308,7 @@ func (t *Transaction) ToTransactionInfoResponse(tagIds []int64, editable bool) *
|
|||||||
DestinationAccountId: destinationAccountId,
|
DestinationAccountId: destinationAccountId,
|
||||||
SourceAmount: sourceAmount,
|
SourceAmount: sourceAmount,
|
||||||
DestinationAmount: destinationAmount,
|
DestinationAmount: destinationAmount,
|
||||||
|
HideAmount: t.HideAmount,
|
||||||
TagIds: utils.Int64ArrayToStringArray(tagIds),
|
TagIds: utils.Int64ArrayToStringArray(tagIds),
|
||||||
Comment: t.Comment,
|
Comment: t.Comment,
|
||||||
Editable: editable,
|
Editable: editable,
|
||||||
|
|||||||
@@ -512,6 +512,10 @@ func (s *TransactionService) ModifyTransaction(transaction *models.Transaction,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if transaction.HideAmount != oldTransaction.HideAmount {
|
||||||
|
updateCols = append(updateCols, "hide_amount")
|
||||||
|
}
|
||||||
|
|
||||||
if transaction.Comment != oldTransaction.Comment {
|
if transaction.Comment != oldTransaction.Comment {
|
||||||
updateCols = append(updateCols, "comment")
|
updateCols = append(updateCols, "comment")
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -258,7 +258,7 @@ export default {
|
|||||||
getTransaction: ({ id }) => {
|
getTransaction: ({ id }) => {
|
||||||
return axios.get(`v1/transactions/get.json?id=${id}&trim_account=true&trim_category=true&trim_tag=true`);
|
return axios.get(`v1/transactions/get.json?id=${id}&trim_account=true&trim_category=true&trim_tag=true`);
|
||||||
},
|
},
|
||||||
addTransaction: ({ type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment, utcOffset }) => {
|
addTransaction: ({ type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, comment, utcOffset }) => {
|
||||||
return axios.post('v1/transactions/add.json', {
|
return axios.post('v1/transactions/add.json', {
|
||||||
type,
|
type,
|
||||||
categoryId,
|
categoryId,
|
||||||
@@ -267,12 +267,13 @@ export default {
|
|||||||
destinationAccountId,
|
destinationAccountId,
|
||||||
sourceAmount,
|
sourceAmount,
|
||||||
destinationAmount,
|
destinationAmount,
|
||||||
|
hideAmount,
|
||||||
tagIds,
|
tagIds,
|
||||||
comment,
|
comment,
|
||||||
utcOffset
|
utcOffset
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
modifyTransaction: ({ id, type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment, utcOffset }) => {
|
modifyTransaction: ({ id, type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, comment, utcOffset }) => {
|
||||||
return axios.post('v1/transactions/modify.json', {
|
return axios.post('v1/transactions/modify.json', {
|
||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
@@ -282,6 +283,7 @@ export default {
|
|||||||
destinationAccountId,
|
destinationAccountId,
|
||||||
sourceAmount,
|
sourceAmount,
|
||||||
destinationAmount,
|
destinationAmount,
|
||||||
|
hideAmount,
|
||||||
tagIds,
|
tagIds,
|
||||||
comment,
|
comment,
|
||||||
utcOffset
|
utcOffset
|
||||||
|
|||||||
@@ -787,6 +787,8 @@ export default {
|
|||||||
'Income Amount': 'Income Amount',
|
'Income Amount': 'Income Amount',
|
||||||
'Transfer Out Amount': 'Transfer Out Amount',
|
'Transfer Out Amount': 'Transfer Out Amount',
|
||||||
'Transfer In Amount': 'Transfer In Amount',
|
'Transfer In Amount': 'Transfer In Amount',
|
||||||
|
'Show Amount': 'Show Amount',
|
||||||
|
'Hide Amount': 'Hide Amount',
|
||||||
'Category': 'Category',
|
'Category': 'Category',
|
||||||
'Account': 'Account',
|
'Account': 'Account',
|
||||||
'Source Account': 'Source Account',
|
'Source Account': 'Source Account',
|
||||||
|
|||||||
@@ -787,6 +787,8 @@ export default {
|
|||||||
'Income Amount': '收入金额',
|
'Income Amount': '收入金额',
|
||||||
'Transfer Out Amount': '转出金额',
|
'Transfer Out Amount': '转出金额',
|
||||||
'Transfer In Amount': '转入金额',
|
'Transfer In Amount': '转入金额',
|
||||||
|
'Show Amount': '显示金额',
|
||||||
|
'Hide Amount': '隐藏金额',
|
||||||
'Category': '分类',
|
'Category': '分类',
|
||||||
'Account': '账户',
|
'Account': '账户',
|
||||||
'Source Account': '来源账户',
|
'Source Account': '来源账户',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
||||||
<f7-nav-title :title="$t(title)"></f7-nav-title>
|
<f7-nav-title :title="$t(title)"></f7-nav-title>
|
||||||
<f7-nav-right>
|
<f7-nav-right>
|
||||||
|
<f7-link icon-f7="ellipsis" @click="showMoreActionSheet = true" v-if="mode !== 'view'"></f7-link>
|
||||||
<f7-link :class="{ 'disabled': inputIsEmpty || submitting }" :text="$t(saveButtonTitle)" @click="save" v-if="mode !== 'view'"></f7-link>
|
<f7-link :class="{ 'disabled': inputIsEmpty || submitting }" :text="$t(saveButtonTitle)" @click="save" v-if="mode !== 'view'"></f7-link>
|
||||||
</f7-nav-right>
|
</f7-nav-right>
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
:class="{ 'color-theme-teal': transaction.type === $constants.transaction.allTransactionTypes.Expense, 'color-theme-red': transaction.type === $constants.transaction.allTransactionTypes.Income }"
|
:class="{ 'color-theme-teal': transaction.type === $constants.transaction.allTransactionTypes.Expense, 'color-theme-red': transaction.type === $constants.transaction.allTransactionTypes.Income }"
|
||||||
:style="{ fontSize: sourceAmountFontSize + 'px' }"
|
:style="{ fontSize: sourceAmountFontSize + 'px' }"
|
||||||
:header="$t(sourceAmountName)"
|
:header="$t(sourceAmountName)"
|
||||||
:title="transaction.sourceAmount | currency"
|
:title="transaction.sourceAmount | finalAmount(transaction.hideAmount) | currency"
|
||||||
@click="showSourceAmountSheet = true"
|
@click="showSourceAmountSheet = true"
|
||||||
>
|
>
|
||||||
<number-pad-sheet :min-value="$constants.transaction.minAmount"
|
<number-pad-sheet :min-value="$constants.transaction.minAmount"
|
||||||
@@ -62,7 +63,7 @@
|
|||||||
link="#" no-chevron
|
link="#" no-chevron
|
||||||
:style="{ fontSize: destinationAmountFontSize + 'px' }"
|
:style="{ fontSize: destinationAmountFontSize + 'px' }"
|
||||||
:header="$t('Transfer In Amount')"
|
:header="$t('Transfer In Amount')"
|
||||||
:title="transaction.destinationAmount | currency"
|
:title="transaction.destinationAmount | finalAmount(transaction.hideAmount) | currency"
|
||||||
@click="showDestinationAmountSheet = true"
|
@click="showDestinationAmountSheet = true"
|
||||||
v-if="transaction.type === $constants.transaction.allTransactionTypes.Transfer"
|
v-if="transaction.type === $constants.transaction.allTransactionTypes.Transfer"
|
||||||
>
|
>
|
||||||
@@ -254,6 +255,16 @@
|
|||||||
</f7-card-content>
|
</f7-card-content>
|
||||||
</f7-card>
|
</f7-card>
|
||||||
|
|
||||||
|
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
||||||
|
<f7-actions-group>
|
||||||
|
<f7-actions-button v-if="transaction.hideAmount" @click="transaction.hideAmount = false">{{ $t('Show Amount') }}</f7-actions-button>
|
||||||
|
<f7-actions-button v-if="!transaction.hideAmount" @click="transaction.hideAmount = true">{{ $t('Hide Amount') }}</f7-actions-button>
|
||||||
|
</f7-actions-group>
|
||||||
|
<f7-actions-group>
|
||||||
|
<f7-actions-button bold close>{{ $t('Cancel') }}</f7-actions-button>
|
||||||
|
</f7-actions-group>
|
||||||
|
</f7-actions>
|
||||||
|
|
||||||
<f7-toolbar tabbar bottom v-if="mode !== 'view'">
|
<f7-toolbar tabbar bottom v-if="mode !== 'view'">
|
||||||
<f7-link :class="{ 'disabled': inputIsEmpty || submitting }" @click="save">
|
<f7-link :class="{ 'disabled': inputIsEmpty || submitting }" @click="save">
|
||||||
{{ $t(saveButtonTitle) }}
|
{{ $t(saveButtonTitle) }}
|
||||||
@@ -294,6 +305,7 @@ export default {
|
|||||||
destinationAccountId: '',
|
destinationAccountId: '',
|
||||||
sourceAmount: 0,
|
sourceAmount: 0,
|
||||||
destinationAmount: 0,
|
destinationAmount: 0,
|
||||||
|
hideAmount: false,
|
||||||
tagIds: [],
|
tagIds: [],
|
||||||
comment: ''
|
comment: ''
|
||||||
},
|
},
|
||||||
@@ -301,6 +313,7 @@ export default {
|
|||||||
loadingError: null,
|
loadingError: null,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
showAccountBalance: self.$settings.isShowAccountBalance(),
|
showAccountBalance: self.$settings.isShowAccountBalance(),
|
||||||
|
showMoreActionSheet: false,
|
||||||
showSourceAmountSheet: false,
|
showSourceAmountSheet: false,
|
||||||
showDestinationAmountSheet: false,
|
showDestinationAmountSheet: false,
|
||||||
showCategorySheet: false,
|
showCategorySheet: false,
|
||||||
@@ -659,6 +672,7 @@ export default {
|
|||||||
self.transaction.destinationAmount = transaction.destinationAmount;
|
self.transaction.destinationAmount = transaction.destinationAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.transaction.hideAmount = transaction.hideAmount;
|
||||||
self.transaction.tagIds = transaction.tagIds || [];
|
self.transaction.tagIds = transaction.tagIds || [];
|
||||||
self.transaction.comment = transaction.comment;
|
self.transaction.comment = transaction.comment;
|
||||||
}
|
}
|
||||||
@@ -697,6 +711,7 @@ export default {
|
|||||||
sourceAmount: self.transaction.sourceAmount,
|
sourceAmount: self.transaction.sourceAmount,
|
||||||
destinationAccountId: '0',
|
destinationAccountId: '0',
|
||||||
destinationAmount: 0,
|
destinationAmount: 0,
|
||||||
|
hideAmount: self.transaction.hideAmount,
|
||||||
tagIds: self.transaction.tagIds,
|
tagIds: self.transaction.tagIds,
|
||||||
comment: self.transaction.comment,
|
comment: self.transaction.comment,
|
||||||
utcOffset: self.transaction.utcOffset
|
utcOffset: self.transaction.utcOffset
|
||||||
@@ -802,6 +817,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
|
finalAmount(amount, hideAmount) {
|
||||||
|
if (hideAmount) {
|
||||||
|
return '***';
|
||||||
|
}
|
||||||
|
|
||||||
|
return amount;
|
||||||
|
},
|
||||||
primaryCategoryName(categoryId, allCategories) {
|
primaryCategoryName(categoryId, allCategories) {
|
||||||
for (let i = 0; i < allCategories.length; i++) {
|
for (let i = 0; i < allCategories.length; i++) {
|
||||||
for (let j = 0; j < allCategories[i].subCategories.length; j++) {
|
for (let j = 0; j < allCategories[i].subCategories.length; j++) {
|
||||||
|
|||||||
@@ -329,8 +329,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div slot="after" class="transaction-amount" v-if="transaction.sourceAccount"
|
<div slot="after" class="transaction-amount" v-if="transaction.sourceAccount"
|
||||||
:class="{ 'text-color-teal': transaction.type === $constants.transaction.allTransactionTypes.Expense, 'text-color-red': transaction.type === $constants.transaction.allTransactionTypes.Income }">
|
:class="{ 'text-color-teal': transaction.type === $constants.transaction.allTransactionTypes.Expense, 'text-color-red': transaction.type === $constants.transaction.allTransactionTypes.Income }">
|
||||||
<span v-if="!query.accountId || query.accountId === '0' || (transaction.sourceAccount && transaction.sourceAccount.id === query.accountId)">{{ transaction.sourceAmount | currency(transaction.sourceAccount.currency) }}</span>
|
<span v-if="!query.accountId || query.accountId === '0' || (transaction.sourceAccount && transaction.sourceAccount.id === query.accountId)">{{ transaction.sourceAmount | finalAmount(transaction.hideAmount) | currency(transaction.sourceAccount.currency) }}</span>
|
||||||
<span v-else-if="query.accountId && query.accountId !== '0' && transaction.destinationAccount && transaction.destinationAccount.id === query.accountId">{{ transaction.destinationAmount | currency(transaction.destinationAccount.currency) }}</span>
|
<span v-else-if="query.accountId && query.accountId !== '0' && transaction.destinationAccount && transaction.destinationAccount.id === query.accountId">{{ transaction.destinationAmount | finalAmount(transaction.hideAmount) | currency(transaction.destinationAccount.currency) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<f7-swipeout-actions right>
|
<f7-swipeout-actions right>
|
||||||
<f7-swipeout-button color="primary" close
|
<f7-swipeout-button color="primary" close
|
||||||
@@ -840,6 +840,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
|
finalAmount(amount, hideAmount) {
|
||||||
|
if (hideAmount) {
|
||||||
|
return '***';
|
||||||
|
}
|
||||||
|
|
||||||
|
return amount;
|
||||||
|
},
|
||||||
transactionTypeName(type, allTransactionTypes) {
|
transactionTypeName(type, allTransactionTypes) {
|
||||||
if (type === allTransactionTypes.Income) {
|
if (type === allTransactionTypes.Income) {
|
||||||
return 'Income';
|
return 'Income';
|
||||||
|
|||||||
Reference in New Issue
Block a user