Sunday, February 22, 2015

Mahmoud caused me another sleepless night ;-) He inpired me to find a solution for a problem in Lino Così which had been dangling around for too long: how to manage grouped payments when entering a bank statement or other financial document.

The problem is about what happens when you enter the partner of a row of a BankStatement. Lino should analyze existing movements of this partner and suggest an amount for this row. For example, if the partner has an open sales invoice, Lino should suggest that invoice’s amount on the Income side. Or if the partner has an open purchase invoice, Lino should suggest that invoice’s amount on the Expense side.

While we solved together some simple cases, the current solution was in no way usable in more complex situations like users who need to manually select a few invoices from a list of many open invoices, or a payment of the balance of a series of sales and purchase invoices.

The solution is that we need a new type of financial document, which I’ll call finan.Grouper (whose rows are stored in finan.GrouperItem accordingly). Groupers are regular vouchers which need their own journal and which will be included in the general ledger. Unlike other vouchers they are generated automatically on the fly.

I started with the implementation:

But decided to leave this half-finished because two production releases for Lino Welfare are more urgent.

Upgrade in Eupen

Continued in lino.modlib.contenttypes.models. Renamed StaleGenericRelated to BrokenGFKs, and only now it starts to be useful and complete.

New unit test https://www.lino-framework.org/tutorials/gfks/index.html brings another observation to my problem discovered yestarday (described in test_broken_gfks).

Restoring the database from snapshot (without migration) gave an error message Deferred IncomeConfirmation #24 (u'Auslxe4nderbeihilfe/5/1/12/6517/24') : 'Role' object has no attribute 'language' on two objects.