jamsix / ib-edavki

Skripta, ki prevede XML poročilo trgovalnih poslov v platformi InteractiveBrokers v XML format primeren za uvoz v obrazce Doh-KDVP, D-IFI, Doh-Div in Doh-Obr v eDavkih Finančne uprave.
MIT License
173 stars 57 forks source link

Fixed the crash on missing dividend with existing withholding tax transactions #132

Closed ZigaSajovic closed 4 months ago

ZigaSajovic commented 4 months ago

This pull request fixes crashes in cases like https://github.com/jamsix/ib-edavki/issues/117.

Bug

The original code did not define the closestDividend variable in the case where there was no corresponding dividend, but continued execution. After the branch it assumed the existence of closestDividend, which caused the crash.

Fix

The code now records all the cases of missing correspondence and reports this to the user on detection before aborting execution. An example of the output can be seen bellow.

=============================================================================
CRITICAL ERROR IN THE INPUT DATA!
=============================================================================
Witholding tax transactions exist, that do not have a corresponding dividend.
This is either because:

  • you forgot to include exporting of dividends in the flex form, or
  • dividend and witholding tax were not processed in the same year
    and your input data does not cover one of those years

Errors:
Symbol_0: transaction_id0_0, transaction_id0_1, ... Symbol_1: transaction_id1_0, transaction_id1_1, ... Aborting

@pronebird if you still have the faulty input from yesterday, try it out please.

pronebird commented 4 months ago

Busy week (like always). I'll try it out over the weekend. Otherwise to reproduce the issue, the one could simply remove ordinary dividend entries from XML and see what happens

ZigaSajovic commented 4 months ago

@pronebird I did test it like that and it works. I just didn't want to say, it works, merge it :)