Thursday, December 5, 2019

Working on getlino test suite

I opened #3383 and then saw that Hamza had already done it :-) I saw that travis now says AttributeError: 'BaseDockerTest' object has no attribute 'docker_tag' and fixed that (it was a typo in my last commit). Next problem : I opened #3384 but didn’t start working on this.

Preparing a demo for cosi3

Summary of the demo tour:

  • create a person “Tom Testa”, register a sales invoice for him. Dated today (outside the dates of existing invoices)

  • create a company “Testers OÜ” and register a purchases invoice for them. Same date.

  • register a VAT declaration

At this point I saw that (1) it’s not easy to visualize which invoices are covered by a declaration and (2) The Estonian VAT declaration is currently just an adapted copy of the Belgian one. I started to adapt it to the Estonian law, but that’s not finished.

See invoices being declared by a VAT declaration

..currentmodule:: lino_xl.lib.vat

Two new tables PurchasesByDeclaration and SalesByDeclaration in lino_xl.lib.vat. These are included in the VatDeclaration detail view of lino_xl.lib.eevat (other national plugins will follow).

As a side effect we have a new model mixin VatVoucher. This mixin is needed as the model of the new table VatInvoices, which is the abstract base for our two new tables and the two existing tables IntracomSales and IntracomPurchases. A table on an abstract model calls –of course– only the setup_parameters of the abstract model. So we needed a mixin that extends VatDocument by inheriting also from lino_xl.lib.accounting.Voucher and lino_xl.lib.sepa.Payable. This was needed because otherwise the two new tables didn’t get the parameter fields start_period and end_period defined in lino_xl.lib.accounting.PeriodRangeObservable.

I fell into a subtle pit: IntracomPurchases had the following params_layout inherited from ledger.PartnerVouchers:

params_layout = "partner project state journal start_period end_period cleared"

and it has the following hidden_elements:

hidden_elements = frozenset(
    """entry_date journal__trade_type journal number
    journal__trade_type state user""".split())

The hidden_elements are meant for data fields, but two of them (journal and state) have the same name as a parameter field. I must explicitly remove them from the params_layout to avoid an error message about “expected 6 parameter values but got only 4”:

params_layout = "partner project start_period end_period cleared"