eshaham / israeli-ynab-updater

A tool for updating YNAB using israeli-bank-scrapers
MIT License
53 stars 15 forks source link

Convert foreign currencies to ILS #22

Open asfktz opened 6 years ago

asfktz commented 6 years ago

Hi @eshaham!

A few weeks ago, while working with this lib to import my bank data to YNAB, I noticed that all the transactions that made with currencies other than ILS, are actually imported is if they were in ILS.

For example, this iTunes payment is 19.90$, not ₪19.90

111

I think having something like this will be nicer: 222

Notice how the outflow in ILS changes according to the date the transaction was made on.

I implemented support for currency conversion in my fork, It works like this:

eshaham commented 6 years ago

@asfktz hmmm, this feels more like a bug in https://github.com/eshaham/israeli-bank-scrapers then a feature in this tool. The scrapers repo returns 3 relevant fields:

{
  ...
  originalAmount: double,
  originalCurrency: string,
  chargedAmount: double,
  ...
}

originalAmount should hold the original amount of the transaction in the original currency. originalCurrency should hold the original currency of the transaction. chargedAmount should hold the actual charged amount in ILS

From what I see in the screenshot above, it seems like chargedAmount for that specific scraper holds in the the amount in the original currency, which is a bug.

asfktz commented 6 years ago

In Isracard, I noticed that transactions under עסקות חו"ל are paid from my מט"ח account in Bank Hapoalim

For example, this 50$ payment to YNAB:

Isracard: isracard

Bank Hapoalim (מט"ח): poalim

So I believe it's not converted directly because I have to explicitly buy USD in my מט"ח account.

Edit: This is the original txn values from isracard:

{
  "specificDate": null,
  "cardIndex": "0",
  "dealsInbound": null,
  "supplierId": null,
  "supplierName": null,
  "dealSumType": null,
  "paymentSumSign": null,
  "purchaseDate": null,
  "fullPurchaseDate": null,
  "moreInfo": null,
  "horaatKeva": null,
  "voucherNumber": "0016171",
  "voucherNumberRatz": null,
  "solek": null,
  "purchaseDateOutbound": "18/01",
  "fullPurchaseDateOutbound": "18/01/2018",
  "currencyId": "USD",
  "currentPaymentCurrency": "USD",
  "city": "LEHI",
  "supplierNameOutbound": "YOU NEED A BUDG",
  "fullSupplierNameOutbound": "YOU NEED A BUDGET",
  "paymentDate": "21/01",
  "fullPaymentDate": "21/01/2018",
  "isShowDealsOutbound": "_",
  "adendum": null,
  "voucherNumberRatzOutbound": "183141595",
  "isShowLinkForSupplierDetails": null,
  "dealSum": null,
  "paymentSum": null,
  "fullSupplierNameHeb": null,
  "dealSumOutbound": "50.00",
  "paymentSumOutbound": "50.00",
  "isHoraatKeva": "false",
  "stage": null,
  "returnCode": null,
  "message": null,
  "returnMessage": null,
  "displayProperties": null,
  "tablePageNum": "0",
  "isError": "false",
  "isCaptcha": "false",
  "isButton": "false",
  "siteName": null,
  "clientIpAddress": null
}
asfktz commented 6 years ago

@eshaham The referenced PR contains only changes that related to currency conversion.

eshaham commented 6 years ago

@asfktz ok, now I get it. So what actually happens is that chargedAmount holds the dollar amount, and not the amount in shekels. Step one would definitely be to add a chargedCurrency property. I added an issue in the scrapers repo: https://github.com/eshaham/israeli-bank-scrapers/issues/80

As for your PR for exchanging rates, I'm going to need to think about that one. While it makes sense to convert transactions with foreign currencies to ILS, since YNAB only allows one currency per budget, I'm not convinced this is the solution. Don't know, maybe you're right. I'll think about it 😄

eshaham commented 6 years ago

@asfktz you know what, I'm convinced I have a lot of comments about the PR, will add them there