#1131 Adjustment of amountToPay in InvoiceLocal broken

1.2
open
5
2010-11-19
2010-11-19
jfirechief
No

DO NOT EDIT OR ANSWER THIS ISSUE. SEE THE ORIGINAL ISSUE INSTEAD:
https://www.jfire.org/modules/bugs/view.php?id=1855
ORIGINAL REPORTER: alex

The amount to pay ist not updated with payments any more.
Just tested with a fresh jfire trunk workspace.

Discussion

  • jfirechief
    jfirechief
    2010-11-19

    • labels: --> JFireTrade
    • milestone: --> 1.2
    • assigned_to: nobody --> fleque
     
  • jfirechief
    jfirechief
    2010-11-19

    ORIGINAL COMMENT BY alex, VIEW IT HERE:
    https://www.jfire.org/modules/bugs/view.php?id=1855

    First error I've found:

    !!!The sanity-check in LegalEntity was changed so the check was not performed. Payments were processed leaving the system in an incosistent state!!!

    The wrong code was in LegalEntity#checkIntegrity():

    Wrong code:

    if (firstContainer instanceof MoneyTransfer) {
    if (firstContainer.getClass().equals(MoneyTransfer.class)) {
    Map<CurrencyID,Balance> balanceMap = getBalanceMap();
    for (Balance balance : balanceMap.values()) {
    if (balance.amount != 0)
    throw new IllegalStateException("Balance for LegalEntity \""+getPrimaryKey()+"\" must be 0, but is "+balance.amount+" for currency \""+balance.currencyID+"\"!");
    }
    }
    }

    Correct code:

    if (firstContainer instanceof MoneyTransfer) {
    Map<CurrencyID,Balance> balanceMap = getBalanceMap();
    for (Balance balance : balanceMap.values()) {
    if (balance.amount != 0)
    throw new IllegalStateException("Balance for LegalEntity \""+getPrimaryKey()+"\" must be 0, but is "+balance.amount+" for currency \""+balance.currencyID+"\"!");
    }
    }

    On any MoneyTransfer the sanity has to be checkt.
    The condition is simple: no money left on the legal-entity.
    This has to be checked not only on the concrete class MoneyTransfer, but for all moneytransfers.

    @Chairat: If your change had a particular reason. Please explain and we will see what the correct solution will be. I'll check in my change now.

     
  • jfirechief
    jfirechief
    2010-11-19

    ORIGINAL COMMENT BY alex, VIEW IT HERE:
    https://www.jfire.org/modules/bugs/view.php?id=1855

    After the sanity-check was up again it failed, telling me that all money was left on the LegalEntity. This means the PartnerAccountant did not do his job correctly. After looking in the source I saw that it actually was not asked to do the job!!

    The registration of default-Accountants was changed, there are now delegates that can be registered to handle special types (Java classes) of MoneyTransfer. The registration and lookup mechanism however found only a responsible accountant when processing a concrete class: BookInvoiceMoneyTransfer. This means for Payments nothing was done.

    I change the registration to MoneyTransfer in general and the lookup mechanism to also take the type hierarchy into account.