Skip to content

Commit

Permalink
fix parsing amount for expense transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Oct 21, 2024
1 parent 54150a9 commit 1d0817b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/converters/gnucash/gnucash_transaction_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,14 @@ func (t *gnucashTransactionDataRowIterator) parseTransaction(ctx core.Context, u
toAccount = account1
}

if len(fromAmount) > 0 && fromAmount[0] == '-' {
amount, err := utils.ParseAmount(fromAmount)
amount, err := utils.ParseAmount(fromAmount)

if err != nil {
return nil, false, errs.ErrAmountInvalid
}

fromAmount = utils.FormatAmount(-amount)
if err != nil {
return nil, false, errs.ErrAmountInvalid
}

fromAmount = utils.FormatAmount(-amount)

data[datatable.TRANSACTION_DATA_TABLE_TRANSACTION_TYPE] = utils.IntToString(int(models.TRANSACTION_TYPE_EXPENSE))
data[datatable.TRANSACTION_DATA_TABLE_CATEGORY] = t.getCategoryName(toAccount)
data[datatable.TRANSACTION_DATA_TABLE_SUB_CATEGORY] = toAccount.Name
Expand Down

0 comments on commit 1d0817b

Please sign in to comment.