support hiding transaction amount
This commit is contained in:
@@ -693,6 +693,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
||||
TimezoneUtcOffset: transactionModifyReq.UtcOffset,
|
||||
AccountId: transactionModifyReq.SourceAccountId,
|
||||
Amount: transactionModifyReq.SourceAmount,
|
||||
HideAmount: transactionModifyReq.HideAmount,
|
||||
Comment: transactionModifyReq.Comment,
|
||||
}
|
||||
|
||||
@@ -708,6 +709,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
||||
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.RelatedAccountAmount == transaction.RelatedAccountAmount) &&
|
||||
newTransaction.HideAmount == transaction.HideAmount &&
|
||||
newTransaction.Comment == transaction.Comment &&
|
||||
utils.Int64SliceEquals(tagIds, transactionTagIds) {
|
||||
return nil, errs.ErrNothingWillBeUpdated
|
||||
@@ -992,6 +994,7 @@ func (a *TransactionsApi) createNewTransactionModel(uid int64, transactionCreate
|
||||
TimezoneUtcOffset: transactionCreateReq.UtcOffset,
|
||||
AccountId: transactionCreateReq.SourceAccountId,
|
||||
Amount: transactionCreateReq.SourceAmount,
|
||||
HideAmount: transactionCreateReq.HideAmount,
|
||||
Comment: transactionCreateReq.Comment,
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ type Transaction struct {
|
||||
RelatedId 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"`
|
||||
CreatedUnixTime int64
|
||||
UpdatedUnixTime int64
|
||||
@@ -62,6 +63,7 @@ type TransactionCreateRequest 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"`
|
||||
}
|
||||
@@ -76,6 +78,7 @@ type TransactionModifyRequest 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"`
|
||||
}
|
||||
@@ -181,6 +184,7 @@ type TransactionInfoResponse struct {
|
||||
DestinationAccount *AccountInfoResponse `json:"destinationAccount,omitempty"`
|
||||
SourceAmount int64 `json:"sourceAmount"`
|
||||
DestinationAmount int64 `json:"destinationAmount,omitempty"`
|
||||
HideAmount bool `json:"hideAmount"`
|
||||
TagIds []string `json:"tagIds"`
|
||||
Tags []*TransactionTagInfoResponse `json:"tags,omitempty"`
|
||||
Comment string `json:"comment"`
|
||||
@@ -304,6 +308,7 @@ func (t *Transaction) ToTransactionInfoResponse(tagIds []int64, editable bool) *
|
||||
DestinationAccountId: destinationAccountId,
|
||||
SourceAmount: sourceAmount,
|
||||
DestinationAmount: destinationAmount,
|
||||
HideAmount: t.HideAmount,
|
||||
TagIds: utils.Int64ArrayToStringArray(tagIds),
|
||||
Comment: t.Comment,
|
||||
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 {
|
||||
updateCols = append(updateCols, "comment")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user