edocument_unece UNCL5189 / UNCL7161 code lists – correctness and EN 16931 validation

Hi,

I’m developing a Tryton module which using edocument_unece module and I’m working around allowances and charges. I looked at the UNCL5189 and UNCL7161 code lists added to edocument_unece in 8.0 (product.py) and I have a few questions and observations. I’d like to know whether they are intended or worth fixing.

What I understand of the design

product.template gets two fields, unece_allowance_charge_code (UNCL5189) and unece_special_service_code (UNCL7161), both visible only for services. The field names match the UNECE data elements.

Observations

  1. Trailing spaces in UNCL7161 keys
    Two-letter codes seem to be defined with a trailing space, e.g. ('AG ', ...), ('CB ', ...), ('DI ', ...), ('TX ', ...). If these values end up as-is in the UBL, they would not match the code list (EN 16931 rule BR-CL-20), since the code is CB, not CB .
  2. No distinction between allowance and charge
    EN 16931 / Peppol require allowance reason codes to be in UNCL5189 (BR-CL-19, and Peppol restricts it to a subset: 41, 42, 60, 62–68, 70, 71, 88, 95, 100, 102–105), and charge reason codes to be in UNCL7161 (BR-CL-20). The full UNCL5189 list is exposed, and it also contains charge codes (e.g. 80 Packing charge, 85 Warehousing charge, 101 Carbon footprint charge). So a user can select a code that is valid in EDIFACT but rejected by Peppol validation. Would it make sense to filter the selection to only keep codes supported by Peppol ?
  3. UNCL7161: completeness
    Some sequences have gaps (e.g. ADW, AEE), and the codes DAC and DAF–DAO (e.g. Assortment allowance, Dealer allowance, Multi-buy promotion) seem to be absent.I also wonder which directory version the list is meant to follow (EN 16931 refers to D.16B).
  4. Labels (cosmetic)
    Some labels differ from the D.16B names (e.g. AA “Advertising allowance” vs “Advertising”, AAC “Modification costs” vs “Technical modification”). It has no effect on validation, but it may matter if the lists are meant to mirror the official ones.

Questions

  • Is the goal to ship the full UN/EDIFACT lists, or the subsets used by EN 16931?
  • Is the allowance/charge distinction handled somewhere else (e.g. in the UBL template) ?
  • Would a patch (clean keys, missing codes, optional filtering/validation) be welcome ?

This is a copy/paste issue. I did not saw that some code had only 2 letters.

For me trying to replicate all the rules is time consuming for almost no benefit.
I think it is simpler to let the user responsible of the setup because if an invoice is rejected by PEPPOL rules, they can still fix it.

It was probably the last version found on the UNECE website: https://service.unece.org/trade/untdid/d98a/uncl/uncl7161.htm
But it could be updated.

Yep. I do not know why PEPPOL does not always reuse th UNECE labels.
As the module is about UNECE, we follow UNECE label.

Thanks for the answers.

Trailing spaces: good to know. If some 8.0 databases already stored values like 'CB ', a migration may be needed to strip them.

Filtering: that makes sense. I agree that edocument_unece shouldn’t replicate Peppol rules but maybe an option in configuration to restrict selection fields option to only peppol supported ones would be nice.

Directory version: this is where I think a change is needed. The Peppol and EN 16931 validation rules expect the D.16B version of UNCL5189 and UNCL7161. If the lists come from D.98A, codes added since then can’t be selected at all, which is different from a misconfiguration the user could fix.

Labels: understood, following the UNECE labels makes sense for this module.

I also have a question besides e-invoicing with Peppol, which use cases do you have in mind for the codes that Peppol doesn’t support? For example, the full UNCL5189 list contains many codes for banking commissions and fees (letters of credit, etc.), and they don’t seem relevant for invoices. Is the goal to provide the full UNECE lists for other EDI formats, or to use them in other documents ?

I guess D.16B was released in 2016 and D.98A in 1998.
So I guess we should update the list using https://unece.org/fileadmin/DAM/trade/untdid/d16b/tred/tred7161.htm and https://unece.org/fileadmin/DAM/trade/untdid/d16b/tred/tred5189.htm

The goal is to be complete so any business can use it.
So if a bank wants to manage its business with Tryton, they can reuse this module.

I created UNCL7161 code contains trailing spaces (#15135) · Issues · Tryton / Tryton · GitLab to be included in 8.2 series.

For the update of the code lists to D.16B, we can not rush it to 8.2 so I left it to anyone…

I found this UNCL7161 list on Peppol site which have more code (e.g. DAL, DAM, DAO, …) than the list you suggest for UNCL 7161: Peppol BIS Billing 3.0 - May 2026 Release | Rules

The PEPPOL release note show that they have added additional codes: Release notes for Peppol BIS Billing v3

It seems that PEPPOL is based on an more updated list but still present as D.16B.

So I guess we could add them with a comment.

I created Update UNECE lists to version D.16B (#15145) · Issues · Tryton / Tryton · GitLab

Here are the code lists you need i think (the ones used by PEPPOL)

  • UNCL 5189 (D24A)

https://service.unece.org/trade/untdid/d24a/tred/tred5189.htm

  • UNCL 7161 (D22B)

https://service.unece.org/trade/untdid/d22b/tred/tred7161.htm

I do not think so it should be the D.16B version according to Peppol BIS Billing 3.0 - May 2026 Release | Rules

And also D.16B version according to Peppol BIS Billing 3.0 - May 2026 Release | Rules

PEPPOL claiming D16B code lists but there not. Even if codes on the PEPPOL page are correct some of them are not in the UNCL D16B.

I found D24A and D22B version in french einvoicing reform documentation and since french rfe use peppol network to communicate between different approved platform, peppol must a least support them so that why I guessed PEPPOL used these version

This is very strange because D.16B is also repeated in Peppol BIS Billing and Peppol BIS Billing
But of D.24A and D.22B are the actual superset used by PEPPOL so I guess we should update to those versions.

I think that if we see D16B on the PEPPOL site might be cause they reused their old documentation, added new codes and forgot to update the version number, idk.

thanks for ur advises