From 2dc7e522e141ae57a4d7db86fabdcacb506b41a3 Mon Sep 17 00:00:00 2001 From: stuzer05 Date: Sun, 30 Jun 2024 14:31:43 +0300 Subject: [PATCH] Fix monobank refund --- app/import_transaction.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/import_transaction.go b/app/import_transaction.go index 0b23d5a..99d8f58 100644 --- a/app/import_transaction.go +++ b/app/import_transaction.go @@ -69,19 +69,22 @@ func ImportTransaction(monobankTransaction monobank.WebHookResponse) error { } // read monobank transaction - var monobankTransaction monobank.StatementItemsInner + var monobankTransaction monobank.WebHookResponse err = json.Unmarshal(notesBytes, &monobankTransaction) if err != nil { continue } // find transaction - sum := int(math.Abs(math.Round(monobankTransaction.Amount/100))) - int(math.Abs(math.Round(monobankTransaction.CommissionRate/100))) + sum := int(math.Abs(math.Round(monobankTransaction.Data.StatementItem.Amount/100))) - int(math.Abs(math.Round(monobankTransaction.Data.StatementItem.CommissionRate/100))) sum2, _ := strconv.ParseFloat(tRow.Amount, 64) - if slices.Contains(row.Names, monobankTransaction.Description) && sum == int(sum2) { + if slices.Contains(row.Names, monobankTransaction.Data.StatementItem.Description) && sum == int(sum2) { // delete transaction opts := firefly3.TransactionsApiDeleteTransactionOpts{} - App().Firefly3Client.TransactionsApi.DeleteTransaction(context.Background(), tRows.Id, &opts) + _, err := App().Firefly3Client.TransactionsApi.DeleteTransaction(context.Background(), tRows.Id, &opts) + if err != nil { + return err + } isDeleted = true }