wesselt / bunq2ynab

Upload bunq transactions to ynab
Other
72 stars 18 forks source link

[MINOR] Payee incorrect on subsequent transaction on same request. #33

Closed javydekoning closed 3 years ago

javydekoning commented 3 years ago

Went out for diner last Friday. I payed and shared a request with my friends.

Both transactions show in YNAB, but both show as "Friend A". 2 days later, friends C and D pay as well. Both of these transactions show as Friend C.

I can't figure out why from the JSON. They all have unique ID's

{
    "Response": [
        {
            "Payment": {
                "id": 515732444,
                "created": "2021-06-13 11:03:00.716094",
                "updated": "2021-06-13 11:03:00.716094",
                "monetary_account_id": 1234,
                "amount": {
                    "currency": "EUR",
                    "value": "47.00"
                },
                "description": "RESTAURANT, NL",
                "type": "IDEAL",
                "merchant_reference": null,
                "alias": {
                    "iban": "NL54BUNQ0000000000",
                    "is_light": false,
                    "display_name": "MYACCOUNNT",
                    "avatar": {
                        "uuid": "ea7982a6-7d5b-4e24-927a-50f5cd5a98ee",
                        "image": [
                            {
                                "attachment_public_uuid": "462ba3d5-8b1d-4363-b593-52d8efc8f84c",
                                "height": 2048,
                                "width": 2048,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                        "display_name": "MYACCOUNNT",
                        "country": "NL",
                        "avatar": {
                            "uuid": "6422a92a-d432-4b56-a190-7b2fe6334887",
                            "image": [
                                {
                                    "attachment_public_uuid": "f462b274-eb8c-48a5-b1e5-97a1dcc74160",
                                    "height": 764,
                                    "width": 764,
                                    "content_type": "image/jpeg"
                                }
                            ],
                            "anchor_uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                            "style": "NONE"
                        },
                        "public_nick_name": "Javy"
                    },
                    "country": "NL"
                },
                "counterparty_alias": {
                    "iban": "NL27RABO0000000000",
                    "is_light": null,
                    "display_name": "FRIEND-D",
                    "avatar": {
                        "uuid": "e4e10885-3e32-401a-b52c-1becd5f82463",
                        "image": [
                            {
                                "attachment_public_uuid": "360e6820-19c6-4565-a356-4ff031948224",
                                "height": 640,
                                "width": 640,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": null,
                        "display_name": "FRIEND-D",
                        "country": "NL",
                        "avatar": null,
                        "public_nick_name": "FRIEND-D"
                    },
                    "country": "NL"
                },
                "attachment": [],
                "geolocation": null,
                "batch_id": null,
                "scheduled_id": null,
                "address_billing": null,
                "address_shipping": null,
                "sub_type": "PAYMENT",
                "request_reference_split_the_bill": [],
                "balance_after_mutation": {
                    "currency": "EUR",
                    "value": "1234"
                },
                "payment_auto_allocate_instance": null
            }
        },
        {
            "Payment": {
                "id": 515691727,
                "created": "2021-06-13 09:22:41.133117",
                "updated": "2021-06-13 09:22:41.133117",
                "monetary_account_id": 1234,
                "amount": {
                    "currency": "EUR",
                    "value": "47.00"
                },
                "description": "RESTAURANT, NL",
                "type": "IDEAL",
                "merchant_reference": null,
                "alias": {
                    "iban": "NL54BUNQ0000000000",
                    "is_light": false,
                    "display_name": "MYACCOUNNT",
                    "avatar": {
                        "uuid": "ea7982a6-7d5b-4e24-927a-50f5cd5a98ee",
                        "image": [
                            {
                                "attachment_public_uuid": "462ba3d5-8b1d-4363-b593-52d8efc8f84c",
                                "height": 2048,
                                "width": 2048,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                        "display_name": "MYACCOUNNT",
                        "country": "NL",
                        "avatar": {
                            "uuid": "6422a92a-d432-4b56-a190-7b2fe6334887",
                            "image": [
                                {
                                    "attachment_public_uuid": "f462b274-eb8c-48a5-b1e5-97a1dcc74160",
                                    "height": 764,
                                    "width": 764,
                                    "content_type": "image/jpeg"
                                }
                            ],
                            "anchor_uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                            "style": "NONE"
                        },
                        "public_nick_name": "Javy"
                    },
                    "country": "NL"
                },
                "counterparty_alias": {
                    "iban": "NL55RABO0000000000",
                    "is_light": null,
                    "display_name": "FRIEND C",
                    "avatar": {
                        "uuid": "e4e10885-3e32-401a-b52c-1becd5f82463",
                        "image": [
                            {
                                "attachment_public_uuid": "360e6820-19c6-4565-a356-4ff031948224",
                                "height": 640,
                                "width": 640,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": null,
                        "display_name": "FRIEND C",
                        "country": "NL",
                        "avatar": null,
                        "public_nick_name": "FRIEND C"
                    },
                    "country": "NL"
                },
                "attachment": [],
                "geolocation": null,
                "batch_id": null,
                "scheduled_id": null,
                "address_billing": null,
                "address_shipping": null,
                "sub_type": "PAYMENT",
                "request_reference_split_the_bill": [],
                "balance_after_mutation": {
                    "currency": "EUR",
                    "value": "1234"
                },
                "payment_auto_allocate_instance": null
            }
        },
        {
            "Payment": {
                "id": 515069390,
                "created": "2021-06-11 19:04:23.032364",
                "updated": "2021-06-11 19:04:23.032364",
                "monetary_account_id": 1234,
                "amount": {
                    "currency": "EUR",
                    "value": "47.00"
                },
                "description": "RESTAURANT, NL",
                "type": "IDEAL",
                "merchant_reference": null,
                "alias": {
                    "iban": "NL54BUNQ0000000000",
                    "is_light": false,
                    "display_name": "MYACCOUNNT",
                    "avatar": {
                        "uuid": "ea7982a6-7d5b-4e24-927a-50f5cd5a98ee",
                        "image": [
                            {
                                "attachment_public_uuid": "462ba3d5-8b1d-4363-b593-52d8efc8f84c",
                                "height": 2048,
                                "width": 2048,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                        "display_name": "MYACCOUNNT",
                        "country": "NL",
                        "avatar": {
                            "uuid": "6422a92a-d432-4b56-a190-7b2fe6334887",
                            "image": [
                                {
                                    "attachment_public_uuid": "f462b274-eb8c-48a5-b1e5-97a1dcc74160",
                                    "height": 764,
                                    "width": 764,
                                    "content_type": "image/jpeg"
                                }
                            ],
                            "anchor_uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                            "style": "NONE"
                        },
                        "public_nick_name": "Javy"
                    },
                    "country": "NL"
                },
                "counterparty_alias": {
                    "iban": "NL58ABNA0000000000",
                    "is_light": null,
                    "display_name": "FRIEND B",
                    "avatar": {
                        "uuid": "abf4c4a5-b9be-4738-b768-e115b4c23069",
                        "image": [
                            {
                                "attachment_public_uuid": "74ac1a57-e4dc-4108-b6c2-2c993a4f58e5",
                                "height": 640,
                                "width": 640,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": null,
                        "display_name": "FRIEND B",
                        "country": "NL",
                        "avatar": null,
                        "public_nick_name": "FRIEND B"
                    },
                    "country": "NL"
                },
                "attachment": [],
                "geolocation": null,
                "batch_id": null,
                "scheduled_id": null,
                "address_billing": null,
                "address_shipping": null,
                "sub_type": "PAYMENT",
                "request_reference_split_the_bill": [],
                "balance_after_mutation": {
                    "currency": "EUR",
                    "value": "1234"
                },
                "payment_auto_allocate_instance": null
            }
        },
        {
            "Payment": {
                "id": 515067416,
                "created": "2021-06-11 18:59:00.319873",
                "updated": "2021-06-11 18:59:00.319873",
                "monetary_account_id": 1234,
                "amount": {
                    "currency": "EUR",
                    "value": "47.00"
                },
                "description": "RESTAURANT, NL",
                "type": "IDEAL",
                "merchant_reference": null,
                "alias": {
                    "iban": "NL54BUNQ0000000000",
                    "is_light": false,
                    "display_name": "MYACCOUNNT",
                    "avatar": {
                        "uuid": "ea7982a6-7d5b-4e24-927a-50f5cd5a98ee",
                        "image": [
                            {
                                "attachment_public_uuid": "462ba3d5-8b1d-4363-b593-52d8efc8f84c",
                                "height": 2048,
                                "width": 2048,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                        "display_name": "MYACCOUNNT",
                        "country": "NL",
                        "avatar": {
                            "uuid": "6422a92a-d432-4b56-a190-7b2fe6334887",
                            "image": [
                                {
                                    "attachment_public_uuid": "f462b274-eb8c-48a5-b1e5-97a1dcc74160",
                                    "height": 764,
                                    "width": 764,
                                    "content_type": "image/jpeg"
                                }
                            ],
                            "anchor_uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                            "style": "NONE"
                        },
                        "public_nick_name": "Javy"
                    },
                    "country": "NL"
                },
                "counterparty_alias": {
                    "iban": "NL25RABO0000000000",
                    "is_light": null,
                    "display_name": "FRIEND A",
                    "avatar": {
                        "uuid": "e4e10885-3e32-401a-b52c-1becd5f82463",
                        "image": [
                            {
                                "attachment_public_uuid": "360e6820-19c6-4565-a356-4ff031948224",
                                "height": 640,
                                "width": 640,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": null,
                        "display_name": "FRIEND A",
                        "country": "NL",
                        "avatar": null,
                        "public_nick_name": "FRIEND A"
                    },
                    "country": "NL"
                },
                "attachment": [],
                "geolocation": null,
                "batch_id": null,
                "scheduled_id": null,
                "address_billing": null,
                "address_shipping": null,
                "sub_type": "PAYMENT",
                "request_reference_split_the_bill": [],
                "balance_after_mutation": {
                    "currency": "EUR",
                    "value": "1234"
                },
                "payment_auto_allocate_instance": null
            }
        },
        {
            "Payment": {
                "id": 515066395,
                "created": "2021-06-11 18:56:28.168929",
                "updated": "2021-06-12 03:15:18.819849",
                "monetary_account_id": 1234,
                "amount": {
                    "currency": "EUR",
                    "value": "-235.00"
                },
                "description": "RESTAURANT, NL\n",
                "type": "MASTERCARD",
                "merchant_reference": null,
                "alias": {
                    "iban": "NL54BUNQ0000000000",
                    "is_light": false,
                    "display_name": "MYACCOUNNT",
                    "avatar": {
                        "uuid": "ea7982a6-7d5b-4e24-927a-50f5cd5a98ee",
                        "image": [
                            {
                                "attachment_public_uuid": "462ba3d5-8b1d-4363-b593-52d8efc8f84c",
                                "height": 2048,
                                "width": 2048,
                                "content_type": "image/jpeg"
                            }
                        ],
                        "anchor_uuid": null,
                        "style": "NONE"
                    },
                    "label_user": {
                        "uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                        "display_name": "MYACCOUNNT",
                        "country": "NL",
                        "avatar": {
                            "uuid": "6422a92a-d432-4b56-a190-7b2fe6334887",
                            "image": [
                                {
                                    "attachment_public_uuid": "f462b274-eb8c-48a5-b1e5-97a1dcc74160",
                                    "height": 764,
                                    "width": 764,
                                    "content_type": "image/jpeg"
                                }
                            ],
                            "anchor_uuid": "36c77ec0-c963-43d9-ae49-4d3dd4aaeb20",
                            "style": "NONE"
                        },
                        "public_nick_name": "Javy"
                    },
                    "country": "NL"
                },
                "counterparty_alias": {
                    "iban": null,
                    "is_light": null,
                    "display_name": "RESTAURANT",
                    "avatar": null,
                    "label_user": {
                        "uuid": null,
                        "display_name": "RESTAURANT",
                        "country": "NL",
                        "avatar": null,
                        "public_nick_name": "RESTAURANT"
                    },
                    "country": "NL",
                    "merchant_category_code": "5812"
                },
                "attachment": [],
                "geolocation": null,
                "batch_id": null,
                "scheduled_id": null,
                "address_billing": null,
                "address_shipping": null,
                "sub_type": "PAYMENT",
                "request_reference_split_the_bill": [],
                "balance_after_mutation": {
                    "currency": "EUR",
                    "value": "1234"
                },
                "payment_auto_allocate_instance": null
            }
        }
    ]
}
javydekoning commented 3 years ago

4 more transactions today with the same issue. Looks like the reason behind this is the duplicate detection:

https://github.com/wesselt/bunq2ynab/blob/master/lib/sync.py#L110-L148

wesselt commented 3 years ago

Thanks for the detailed report! Mixing up payees and the same amount on the same day does point at the "occurrence" calculation. I'm already looking into for the other open bug and hope to make some progress this week.

wesselt commented 3 years ago

This patch should fix it: https://github.com/wesselt/bunq2ynab/commit/0766cc86bfcc8a0d3fd95fced46addbe9551f1c9

How do we go about updating the serverless repository?

javydekoning commented 3 years ago

I'll publish to Serverless application repository tomorrow.

javydekoning commented 3 years ago

Published and deployed.

wesselt commented 3 years ago

Hi @javydekoning, thanks for updating the repository. What's the easiest way to upgrade existing instances to the new code?

javydekoning commented 3 years ago

Just redeploy for Serverless Application Repository. The existing configuration in SSM will persist, hence no further action should be required.

wesselt commented 3 years ago

I'm looking at this AWS console. How can I redeploy?

javydekoning commented 3 years ago

Same as the initial deployment as described in the README here: https://github.com/wesselt/bunq2ynab#deploying-the-function

wesselt commented 3 years ago

Ah right, so like a fresh install. I'll just copy the tokens from the parameter store.