wesselt / bunq2ynab

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

Mastercard reservation not parsed correctly #32

Closed javydekoning closed 3 years ago

javydekoning commented 3 years ago

I had a reservation on my card. As Bunq provides Debit Mastercards it's deducted from my balance:

This was synced correctly. 2 weeks after the card reservation is returned:

However, as this is the same transaction they are somehow merged and the -200 transaction is deleted from YNAB. Only keeping the +200. Which causes my balance to run out of sync. In the Bunq app, this shows as a single transaction and the date is updated to April 5th.

Unfortunately I don't have any detailed logs from the event. And I don't have an idea to reproduce anytime soon.

Created 1 and patched 0 transactions.  There were 1 duplicates
wesselt commented 3 years ago

Sorry to hear that! There's no code that deletes transactions, but perhaps the earlier transaction got updated into the later. It would help to investigate the JSON that bunq returns from the v1/user/xxx/monetary-account/xxx/payment endpoint.

JSON is written at log level debug. What's a good way to get the JSON that describes those transactions?

javydekoning commented 3 years ago

They show as separate payments, so I'm a bit puzzled to what happened.

    "Payment": {
        "id": 462317496,
        "created": "2021-03-22 15:04:39.350019",
        "updated": "2021-03-22 15:04:39.350019",
        "monetary_account_id": <>,
        "amount": {
            "currency": "EUR",
            "value": "-200.00"
        },
        "description": "RENT A CAR\n",
        "type": "MASTERCARD",
        "merchant_reference": null,
        "alias": {
            "iban": "<>",
            "is_light": false,
            "display_name": "<>",
            "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": "<>",
                "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": "<>"
            },
            "country": "NL"
        },
        "counterparty_alias": {
            "iban": null,
            "is_light": null,
            "display_name": "RENT A CAR",
            "avatar": null,
            "label_user": {
                "uuid": null,
                "display_name": "RENT A CAR",
                "country": "ES",
                "avatar": null,
                "public_nick_name": "RENT A CAR"
            },
            "country": "ES",
            "merchant_category_code": "7512"
        },
        "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": ""
        },
        "payment_auto_allocate_instance": null
    }
},

"Payment": {
        "id": 470507405,
        "created": "2021-04-05 05:30:43.332529",
        "updated": "2021-04-05 05:30:43.332529",
        "monetary_account_id": <>,
        "amount": {
            "currency": "EUR",
            "value": "200.00"
        },
        "description": "Refund: RENT A CAR\n",
        "type": "MASTERCARD",
        "merchant_reference": null,
        "alias": {
            "iban": "<>",
            "is_light": false,
            "display_name": "<>",
            "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": "<>",
                "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": "<>"
            },
            "country": "NL"
        },
        "counterparty_alias": {
            "iban": null,
            "is_light": null,
            "display_name": "RENT A CAR",
            "avatar": null,
            "label_user": {
                "uuid": null,
                "display_name": "RENT A CAR",
                "country": "ES",
                "avatar": null,
                "public_nick_name": "RENT A CAR"
            },
            "country": "ES",
            "merchant_category_code": "7512"
        },
        "attachment": [],
        "geolocation": null,
        "batch_id": null,
        "scheduled_id": null,
        "address_billing": null,
        "address_shipping": null,
        "sub_type": "REVERSAL",
        "request_reference_split_the_bill": [],
        "balance_after_mutation": {
            "currency": "EUR",
            "value": ""
        },
        "payment_auto_allocate_instance": null
    }
wesselt commented 3 years ago

Thanks, those JSONs are very useful.

I don't have an explanation either. The transactions have separate dates. YNAB uses the date + amount + occurrence to identify transactions. So it's unlikely that the 2nd transaction could overwrite the first one.

Let's assume it's a one-off and investigate when it happens again?

javydekoning commented 3 years ago

I'm closing this issue as I haven't been able to reproduce since.