:date: 2017-10-12

==========================
Thursday, October 12, 2017
==========================

I had a session for :ticket:`2072` (a redesign of :ref:`care` without
tickets, as a result after the first experimental year).

This is currently rather intuitive work because the project
requirements are not very clear.  Basic idea is to remove the tickets
and to reduce the database to a catalog of helpers to be consulted by
dedicated social workers.

- delete care_de demo project because it was useless

- rename lino_book.projects.care to :mod:`lino_book.projects.anna`

- Misc changes in :mod:`lino_xl.lib.faculties`.

- A :class:`lino_xl.lib.notes.Note` is now
  :class:`lino_xl.lib.faculties.Feasible`. Actually we don't know
  whether they will one day and ask for having some kind of feasible


Lino's first SEPA payment initiation
====================================

Today we had a historic event: Lydia and I submitted the real first
payment order generated by a Lino application.

In a first attempt we got this error message from the bank::

     Code[BOOD-KD,D90092]  ;0;1;Datatype error: Type:InvalidDatatypeValueExce

Not very helpful...

But when I ran :mod:`lino.utils.xmlgen.sepa.validate` over the file, I
got::

  $ python -m lino.utils.xmlgen.sepa.validate finan.PaymentOrder-616.xml
  ...
  lxml.etree.DocumentInvalid: Element '{urn:iso:std:iso:20022:tech:xsd:pain.001.001.02}Id': [facet 'minLength'] The value has a length of '0'; this underruns the allowed minimum length of '1'., line 12

Aha, yes we simply didn't have their VAT id filled in. After settings
the :attr:`vat_id` of their
:attr:`lino.modlib.system.SiteConfig.site_company`.

I did some optimizations to make it more fool-proof:

I extended the printing API by adding a method
:meth:`get_printable_context
<lino.modlib.printing.actions.BasePrintAction.get_printable_context>`
to :class:`BasePrintAction
<lino.modlib.printing.actions.BasePrintAction>`.

I used that new feature for
:class:`lino_xl.lib.finan.WritePaymentsInitiation`
to add
fill some template variables already there, together with
some validation warnings;
:message:`You must specify a site owner`,
:message:`Site owner has no national ID` and
:message:`Site owner has invalid ID {}`.

The idea is that validation logic should come before parsing the
:xfile:`pain_001.xml` file if that leads to more useful error
messages.

Somewhere I read that for ``<InitgPty>`` and ``<Dbtr>`` the ``<Nm>``
is enough, i.e. the ``<Id>`` and its children aren't needed.

And then we now run
:func:`lino_xl.lib.finan.validate.validate_pain001` for every
generated file before returning it to the user.  To be observed: I
remember that some years ago we had problems when using lxml under
multi-threaded mod_wsgi.

It's clear that the gory details of payment orders will need testing
and and updates with every new supported bank. But our first guinea
pig was encourageingly easy to get done.