Add sum_max config property
This commit is contained in:
parent
774ca114dd
commit
9a04c8deb2
@ -21,6 +21,7 @@ type ConfigTransactionTypes struct {
|
||||
Names []string `json:"names,omitempty"`
|
||||
MccCodes []int `json:"mcc_codes,omitempty"`
|
||||
Firefly3 ConfigTransactionTypeFirefly3 `json:"firefly3,omitempty"`
|
||||
SumMax int `json:"sum_max,omitempty"`
|
||||
}
|
||||
|
||||
type ConfigTransactionTypeFirefly3 struct {
|
||||
|
@ -52,5 +52,12 @@
|
||||
"destination": "Mono White"
|
||||
}
|
||||
},
|
||||
{
|
||||
"names": ["Novapay"],
|
||||
"firefly3": {
|
||||
"description": "NovaPoshta: delivery"
|
||||
},
|
||||
"sum_max": 150
|
||||
}
|
||||
]
|
||||
}
|
@ -81,6 +81,10 @@ func handleWebhook(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
for _, row := range config.TransactionTypes {
|
||||
if slices.Contains(row.Names, monobankTransaction.Data.StatementItem.Description) || slices.Contains(row.MccCodes, monobankTransaction.Data.StatementItem.Mcc) {
|
||||
sum, _ := strconv.Atoi(firefly3Transaction.Amount)
|
||||
|
||||
// check max sum
|
||||
if row.SumMax == 0 || sum <= row.SumMax {
|
||||
switch row.Firefly3.Type {
|
||||
case "withdrawal":
|
||||
firefly3Transaction.Type_ = &firefly3TransactionTypeWithdrawal
|
||||
@ -100,6 +104,7 @@ func handleWebhook(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// record transfer fee
|
||||
if monobankTransaction.Data.StatementItem.CommissionRate > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user