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"`
|
Names []string `json:"names,omitempty"`
|
||||||
MccCodes []int `json:"mcc_codes,omitempty"`
|
MccCodes []int `json:"mcc_codes,omitempty"`
|
||||||
Firefly3 ConfigTransactionTypeFirefly3 `json:"firefly3,omitempty"`
|
Firefly3 ConfigTransactionTypeFirefly3 `json:"firefly3,omitempty"`
|
||||||
|
SumMax int `json:"sum_max,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigTransactionTypeFirefly3 struct {
|
type ConfigTransactionTypeFirefly3 struct {
|
||||||
|
@ -52,5 +52,12 @@
|
|||||||
"destination": "Mono White"
|
"destination": "Mono White"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"names": ["Novapay"],
|
||||||
|
"firefly3": {
|
||||||
|
"description": "NovaPoshta: delivery"
|
||||||
|
},
|
||||||
|
"sum_max": 150
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
35
webhook.go
35
webhook.go
@ -81,22 +81,27 @@ func handleWebhook(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
for _, row := range config.TransactionTypes {
|
for _, row := range config.TransactionTypes {
|
||||||
if slices.Contains(row.Names, monobankTransaction.Data.StatementItem.Description) || slices.Contains(row.MccCodes, monobankTransaction.Data.StatementItem.Mcc) {
|
if slices.Contains(row.Names, monobankTransaction.Data.StatementItem.Description) || slices.Contains(row.MccCodes, monobankTransaction.Data.StatementItem.Mcc) {
|
||||||
switch row.Firefly3.Type {
|
sum, _ := strconv.Atoi(firefly3Transaction.Amount)
|
||||||
case "withdrawal":
|
|
||||||
firefly3Transaction.Type_ = &firefly3TransactionTypeWithdrawal
|
|
||||||
break
|
|
||||||
case "transfer":
|
|
||||||
firefly3Transaction.Type_ = &firefly3TransactionTypeTransfer
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
firefly3Transaction.Type_ = &firefly3TransactionTypeWithdrawal
|
|
||||||
}
|
|
||||||
|
|
||||||
firefly3Transaction.Description = row.Firefly3.Description
|
// check max sum
|
||||||
firefly3Transaction.DestinationName = row.Firefly3.Destination
|
if row.SumMax == 0 || sum <= row.SumMax {
|
||||||
firefly3Transaction.CategoryName = row.Firefly3.Category
|
switch row.Firefly3.Type {
|
||||||
firefly3Transactions = append(firefly3Transactions, firefly3Transaction)
|
case "withdrawal":
|
||||||
break
|
firefly3Transaction.Type_ = &firefly3TransactionTypeWithdrawal
|
||||||
|
break
|
||||||
|
case "transfer":
|
||||||
|
firefly3Transaction.Type_ = &firefly3TransactionTypeTransfer
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
firefly3Transaction.Type_ = &firefly3TransactionTypeWithdrawal
|
||||||
|
}
|
||||||
|
|
||||||
|
firefly3Transaction.Description = row.Firefly3.Description
|
||||||
|
firefly3Transaction.DestinationName = row.Firefly3.Destination
|
||||||
|
firefly3Transaction.CategoryName = row.Firefly3.Category
|
||||||
|
firefly3Transactions = append(firefly3Transactions, firefly3Transaction)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user