konnectors/tagandpass

Bank statements are not linked with bills

rclement opened this issue · 6 comments

Syncing Tag&Pass bills works great on production Cozy.
However, banks statements in Cozy Banks are not linked with Tag&Pass bills.

Maybe the culprit comes from a month mismatch in the dates:

  • Bills date refers to the monthly billed period (e.g. 2019-01)
  • Bank operations date refers to the payout day (e.g. 2019-02-12), which is a month later

Furthermore, the "+ My Invoices" button does not even show-up on the bank statements:
cozy-tagandpass-bank

@LucsT any ideas on how to fix this?

LucsT commented

Concerning the invoices button, it's because we need to add the connector here :
https://github.com/cozy/cozy-banks/blob/master/src/ducks/brandDictionary/brands.json
I can do it for you, and make the merge/publish quicker, but for now, we need to fix the matching problem first I think.

For matching, it failed because date of operation and date of bills are too far away : 1st of month N, to ~15th of month (N+1)
I have a second report of the same problem on my side.
Did you find anywhere the date of a past/future payout ? I didn't.

My proposal is :
Put the bill date to the last day of the month (libs like moment or date-fns can do it for you probably)
As matching is expect to be in a -15/+29 window, it should work out of the box for this situation.
Try to keep the filename constant, it will avoid duplication, and it's pretty good right now.

What do you think ?

LucsT commented

@rclement (forgot to notify you, not sure if needed)

@LucsT sounds good to me!

I'll try fixing the date metadata in a PR quickly, following your recommendations.

@LucsT I'm working on a PR to fix this right now.

Generating a new date to the last day of the month is pretty easy using moment.endOf.
As you mentioned, only the metadata date of the bill should be using this "artificial" date, not the output PDF filename to avoid duplication.
However, I am wondering if when performing the sync afterwards, will the database of imported data be updated with the new date metadata?

e.g. if a previous entry was:

    {
      "vendor": "semitag",
      "date": "2019-02-01T00:00:00.000Z",
      "amount": 1.45,
      "currency": "EUR",
      "fileurl": "https://tag-and-pass.tag.fr/api/account/factures/2019-02-01.pdf",
      "filename": "2019-02-01_tagandpass_1.45€_001136660219.pdf",
      "metadata": {
        "importDate": "2019-03-11T15:12:53.634Z",
        "version": 1
      },
      "invoice": "io.cozy.files:2019-02-01_tagandpass_1.45€_001136660219.pdf",
      "_id": "0403a4d2-5b7c-4b37-b7cf-3d285d0aa8d3"
    }

will it be transformed to:

    {
      "vendor": "semitag",
      "date": "2019-02-28T23:59:59.999Z",
      "amount": 1.45,
      "currency": "EUR",
      "fileurl": "https://tag-and-pass.tag.fr/api/account/factures/2019-02-01.pdf",
      "filename": "2019-02-01_tagandpass_1.45€_001136660219.pdf",
      "metadata": {
        "importDate": "2019-03-11T15:12:53.634Z",
        "version": 1
      },
      "invoice": "io.cozy.files:2019-02-01_tagandpass_1.45€_001136660219.pdf",
      "_id": "0403a4d2-5b7c-4b37-b7cf-3d285d0aa8d3"
    }

?

FYI, when trying to simulate locally the "afterward sync", the date field in importedData.json is not updated to disk (might be a limitation of yarn standalone dev mode).

LucsT commented

No, the bills will not be updated, so you will have duplicated bills, as they will not match any operations they will be 'invisible'.

If you want, put the attribute 'version' to '2'. I can do some cleaning afterward on your cozy and some others cozy of early adopters of tagandpass. Will be more easy with this discrimination.

Fixed by #18, released in version 1.2.0