Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Inbound Peppol documents

This page contains code snippets (lines starting with >>>), which are being tested during our development workflow. The following snippet initializes the demo project used throughout this page.

>>> from lino_book.projects.cosi2.startup import *

The tests in this document are skipped unless you also have Ibanity credentials installed. See How to set up your credentials for details.

>>> if dd.plugins.peppol.credentials is None:
...     pytest.skip('this doctest requires Ibanity credentials')
>>> ar = rt.login("robin")
>>> ses = dd.plugins.peppol.get_ibanity_session(ar)
>>> translation.activate('en')
>>> rt.show(peppol.Inbox)
>>> pytest.skip("Inbound docs aren't being tested in the integration environment")

In the beginning our Inbox is empty:

>>> rt.show(peppol.Inbox)
============================ ============= ============ =============== ================================================================ ===============
 Created at                   Invoice       Partner      Amount          Source document                                                  Voucher state
---------------------------- ------------- ------------ --------------- ---------------------------------------------------------------- ---------------
 2025-06-19 14:39:12.720000   INB 1/2024    Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 15:27:33.238000   INB 2/2024    Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 16:25:33.133000   INB 3/2024    Number One   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 16:26:04.295000   INB 4/2024    Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 19:36:05.646000   INB 5/2024    Number One   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 19:36:35.930000   INB 6/2024    Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 20:06:18.665000   INB 7/2024    Number One   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 20:55:25.830000   INB 8/2024    Number One   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-19 20:55:55.924000   INB 9/2024    Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-20 01:36:05.097000   INB 10/2024   Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 2025-06-20 01:49:27.181000   INB 11/2024   Number Two   1 151,70        `⎙ </media/uploads/2025/03/SLS-2024-45.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 **Total (11 rows)**                                     **12 668,70**
============================ ============= ============ =============== ================================================================ ===============

Now Lino can download the detail of every single document.

>>> with ar.print_logger("INFO"):
...     peppol.download_inbound(ses)
...
Download inbound documents
Found 10 inbound documents to download
Created INB 1/2024 from ...
Created INB 2/2024 from ...
Created INB 3/2024 from ...
Created INB 4/2024 from ...
Created INB 5/2024 from ...
Created INB 6/2024 from ...
Created INB 7/2024 from ...
Created INB 8/2024 from ...
Created INB 9/2024 from ...
Created INB 10/2024 from ...

Now the Lino invoice has been created but is not yet registered.

>>> rt.show(peppol.Inbox)
============================ ============ =============== ============ =============================================================== ===============
 Created at                   Invoice      Partner         Amount       Source document                                                 Voucher state
---------------------------- ------------ --------------- ------------ --------------------------------------------------------------- ---------------
 ...                          INB 1/2014   Rumma & Ko OÜ   822,57       `⎙ </media/uploads/2015/03/SLS-2014-3.pdf>`__, `⎆ <…>`__, [⏏]   Draft
 **Total (1 rows)**                                        **822,57**
============================ ============ =============== ============ =============================================================== ===============
>>> print(dd.plugins.peppol.inbox_dir)
/.../projects/cosi1/media/ibanity_inbox
>>> for fn in dd.plugins.peppol.inbox_dir.iterdir():
...     print(fn)
/.../projects/cosi1/media/ibanity_inbox/431cb851-5bb2-4526-8149-5655d648292f.xml