mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
allow user to limit time scope for editing transaction
This commit is contained in:
@@ -62,6 +62,7 @@ type TransactionCreateRequest struct {
|
||||
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
||||
TagIds []string `json:"tagIds"`
|
||||
Comment string `json:"comment" binding:"max=255"`
|
||||
UtcOffset int `json:"utcOffset" binding:"required,min=-720,max=840"`
|
||||
}
|
||||
|
||||
// TransactionModifyRequest represents all parameters of transaction modification request
|
||||
@@ -75,6 +76,7 @@ type TransactionModifyRequest struct {
|
||||
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
||||
TagIds []string `json:"tagIds"`
|
||||
Comment string `json:"comment" binding:"max=255"`
|
||||
UtcOffset int `json:"utcOffset" binding:"required,min=-720,max=840"`
|
||||
}
|
||||
|
||||
// TransactionListByMaxTimeRequest represents all parameters of transaction listing by max time request
|
||||
@@ -86,6 +88,7 @@ type TransactionListByMaxTimeRequest struct {
|
||||
MaxTime int64 `form:"max_time" binding:"min=0"`
|
||||
MinTime int64 `form:"min_time" binding:"min=0"`
|
||||
Count int `form:"count" binding:"required,min=1,max=50"`
|
||||
UtcOffset int `form:"utc_offset" binding:"required,min=-720,max=840"`
|
||||
}
|
||||
|
||||
// TransactionListInMonthByPageRequest represents all parameters of transaction listing by month request
|
||||
@@ -98,11 +101,13 @@ type TransactionListInMonthByPageRequest struct {
|
||||
Keyword string `form:"keyword"`
|
||||
Page int `form:"page" binding:"required,min=1"`
|
||||
Count int `form:"count" binding:"required,min=1,max=50"`
|
||||
UtcOffset int `form:"utc_offset" binding:"required,min=-720,max=840"`
|
||||
}
|
||||
|
||||
// TransactionGetRequest represents all parameters of transaction getting request
|
||||
type TransactionGetRequest struct {
|
||||
Id int64 `form:"id,string" binding:"required,min=1"`
|
||||
Id int64 `form:"id,string" binding:"required,min=1"`
|
||||
UtcOffset int `form:"utc_offset" binding:"required,min=-720,max=840"`
|
||||
}
|
||||
|
||||
// TransactionDeleteRequest represents all parameters of transaction deleting request
|
||||
@@ -133,7 +138,11 @@ type TransactionInfoPageWrapperResponse struct {
|
||||
}
|
||||
|
||||
// IsEditable returns whether this transaction can be edited
|
||||
func (t *Transaction) IsEditable(account *Account, relatedAccount *Account) bool {
|
||||
func (t *Transaction) IsEditable(currentUser *User, utcOffset int, account *Account, relatedAccount *Account) bool {
|
||||
if currentUser == nil || !currentUser.CanEditTransactionByTransactionTime(t.TransactionTime, utcOffset) {
|
||||
return false
|
||||
}
|
||||
|
||||
if account == nil || account.Hidden {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user