mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-08 15:05:22 +02:00
fix(transaction): Correct problems with SimpleFIN transaction negative values
This commit is contained in:
parent
a4bbc22b4c
commit
29f46e53e9
1 changed files with 4 additions and 5 deletions
|
@ -170,14 +170,13 @@ class SimpleFinAccount < ApplicationRecord
|
||||||
sf_transactions_data.each do |transaction_data|
|
sf_transactions_data.each do |transaction_data|
|
||||||
entry = self.account.entries.find_or_initialize_by(simple_fin_transaction_id: transaction_data["id"])
|
entry = self.account.entries.find_or_initialize_by(simple_fin_transaction_id: transaction_data["id"])
|
||||||
|
|
||||||
amount_from_sf = transaction_data["amount"].to_d
|
# SimpleFIN is always the inverse of maybe's transaction amount. I have no idea why.
|
||||||
account_type = self.account.accountable_type
|
amount_from_sf = transaction_data["amount"].to_d * -1
|
||||||
amount = SimpleFinAccount.get_adjusted_number(amount_from_sf, account_type)
|
# account_type = self.account.accountable_type
|
||||||
puts "AMOUNT #{amount} #{amount_from_sf} #{transaction_data}"
|
|
||||||
|
|
||||||
entry.assign_attributes(
|
entry.assign_attributes(
|
||||||
name: transaction_data["description"],
|
name: transaction_data["description"],
|
||||||
amount: amount,
|
amount: amount_from_sf,
|
||||||
currency: self.account.currency,
|
currency: self.account.currency,
|
||||||
date: Time.at(transaction_data["posted"].to_i).to_date,
|
date: Time.at(transaction_data["posted"].to_i).to_date,
|
||||||
source: "simple_fin"
|
source: "simple_fin"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue