Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IP-939]: Implementing e-invoicing flow #1103

Draft
wants to merge 40 commits into
base: development
Choose a base branch
from

Conversation

nielsdrost7
Copy link
Contributor

Originally by @Verony-makesIT

Description

The IP user can select which e-invoice format is appropriate for their customer/country.
A pdf, and the appropriate e-invoice format, is then generated and sent to the client.

Related Issue

Feature Request #939 "Implement e-invoicing for UBL/CII formats (EN 16931, Zugferd/Factur-X, PEPPOL, etc...) other than only Zugferd"
See my comments in Feature Request 939.

Motivation and Context

Worldwide, and certainly in Europe, governments, clients and accountants are switching to electronic invoices.
e-Invoices can be used to process these documents machine readable and automatically.
XML templates can be created specifically for a country or client.
How to add an XML template is described in the "About e-Invoicing templates.md" file located in the "helpers/XMLconfigs/" folder.
I have added 2 XML template example files.
The (old) IP Zugferdv10Xml.php file serves as "CII format" example and the Ublexamv20Xml.php file serves as "UBL format" example.

Screenshots (if appropriate):

  1. Template selection field on the client form page
    image
  2. Zugferd (CII) or EN16931 (UBL) format
    image

Pull Request Checklist

  • My code follows the code formatting guidelines.
  • I have an issue ID for this pull request.
  • I selected the corresponding branch.
  • I have rebased my changes on top of the corresponding branch.

Issue Type (Please check one or more)

#939

  • Bugfix
  • Improvement of an existing Feature
  • New Feature

@nielsdrost7 nielsdrost7 marked this pull request as draft October 30, 2024 07:55
@nielsdrost7
Copy link
Contributor Author

@Verony-makesIT I've moved your Pull-Request over to the InvoicePlane repository.
After I'm done with the code-review, I'll let you know and then you can take a look at it as well

@nielsdrost7 nielsdrost7 marked this pull request as ready for review October 31, 2024 07:05
@nielsdrost7
Copy link
Contributor Author

@Verony-makesIT Thank you for your pull-request.
I've gone over it and applied some styling.

I thought in the settings there used to be a setting for "Enable Zugferd", did you disable that?
Is your e-invoicing solution just now in plain sight?

E-Invoicing, at least the Ubl, has lots of formats.
Did you count on all those formats?

I see ZugFerd and Ubl, do you know of any others?
I thought there was at least one for Finnish users? Or Spanish?
That deviates from the European formats for Ubl?

@nielsdrost7 nielsdrost7 requested a review from mheiduk October 31, 2024 07:09
@nielsdrost7 nielsdrost7 marked this pull request as draft October 31, 2024 07:09
@Verony-makesIT
Copy link
Contributor

@nielsdrost7
1. The change "refactor: rename tab variable to activeTab" causes errors in the 'application\modules\clients\views\view.php' file because of the change of variable $tab to $activeTab.

2. I have indeed removed the setting "Include zugferd" in the "System settings - Invoices" because it is redundant in this functionality.
This can be reset by replacing the "zugferd code" in the file "partial_settings_invoices.php" from line 152 to 167.
What has become visible from my e-invoicing solution:

  • In the user data I have changed tax information and added bank information including BIC item. I have also added an invoice contact field here.
  • For the customer I have also added an invoice contact field and a selection field for the e-invoicing data format for that customer.
  • In the /libraries folder, the "ZugferdXml.php" has not yet been replaced.
  • In "application/libraries/XMLtemplates" and "application/helpers/XMLconfigs", the folders and files have been added.

3. Be careful! This is where it gets a bit more complex...
UBL is a global e-invoicing format developed by the OASIS organization. The EU released its EN 16931 guidelines (based on UBL V2.1) in 2017. Only 2 formats (UBL and CII) are allowed here. OpenPEPPOL is the network that ensures the receipt and sending of structured e-invoices worldwide (only UBL or CII). The Peppol BIS V3 format is a subset of the EN16931 format. Within this EN16931, each country can impose specific restrictions and/or extensions, i.e. in a CIUS. There are several countries (e.g. the Netherlands = NLCIUS) that use such a CIUS. This does not mean that this is a different format but only a (limited) adjustment.
In Germany, the CII formats Zugferd and XRechnung are used.
In France, the CII format Factur-X is used which is compatible with the German Zugferd from V 2.1.

In my e-invoicing solution you can add any "format" based on an (xml) template... that the user would like to receive.

@nielsdrost7
Copy link
Contributor Author

nielsdrost7 commented Nov 1, 2024

@Verony-makesIT thank you for that explanation.

There are several countries (e.g. the Netherlands = NLCIUS) that use such a CIUS. This does not mean that this is a different format but only a (limited) adjustment.
In Germany, the CII formats Zugferd and XRechnung are used.
In France, the CII format Factur-X is used which is compatible with the German Zugferd from V 2.1.

Maybe obsolete question, but humor me:
Let's say we make a release with this pull-request in it.
And someone wants to end an e-invoice to The Netherlands will he need to adjust the format?
So an extra format in the selectbox, especially for The Netherlands?

@Verony-makesIT
Copy link
Contributor

@nielsdrost7:
This is a fair question:
In the Netherlands, as in most EU countries, the EN 16931 (EU-N) standard (UBL V2.1 subset) is applied.
The format/syntax to be sent depends solely on which format "your client" wants to receive!
This means that if someone sends an e-invoice to a client in the Netherlands, that choice (template) must indeed be available in the selection box for that client.
You cannot simply assume that you can/may send a standard EU-N with NL-CIUS format to any client in the Netherlands.

FYI:
The NL-CIUS contains about 12 restrictions and/or extensions.
All the CIUSes in Europe usually only contain a small and limited number of changes to the EU-N.
Belgium does not have a CIUS (deviations) and uses the standard EU-N syntax.
However, if you send all your e-invoices via the PEPPOL network rather than via email, your service provider can take care of the conversion to the correct format.

@nielsdrost7
Copy link
Contributor Author

@Verony-makesIT thank you for the info. That sounds good man!

However, if you send all your e-invoices via the PEPPOL network rather than via email, your service provider can take care of the conversion to the correct format.

How do we send it through the PEPPOL Network?

@Verony-makesIT
Copy link
Contributor

@nielsdrost7:
Simply put via a Peppol service provider over SFTP or API.
Mostly they also want to use their own (UBL or json) format or in the worst case have their own invoicing app... ;-(

@nielsdrost7
Copy link
Contributor Author

nielsdrost7 commented Nov 8, 2024

@Verony-makesIT

This means that if someone sends an e-invoice to a client in the Netherlands, that choice (template) must indeed be available in the selection box for that client.

Let's make that NLCIUS template.
If we copy/paste the standard and rename it to the Dutch variation.
I would love to release InvoicePlane including that Dutch CIUS variation.


We probably need to make some documentation anyway, would you like to start on that.

@nielsdrost7 nielsdrost7 added this to the 1.6.2 milestone Nov 8, 2024
Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are accessibility issues in these changes.

<!-- ZUGFeRD Template Usage -->
<div class="form-group">
<label for="settings[use_zugferd]"><?php echo trans('use_zugferd'); ?></label>
<select name="settings[use_zugferd]" id="use_zugferd" class="form-control">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

<!-- Default UBL Template Type -->
<div class="form-group">
<label for="settings[default_template_type]"><?php echo trans('default_ubl_template_type'); ?></label>
<select name="settings[default_template_type]" id="default_template_type" class="form-control">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

Verony-makesIT and others added 13 commits November 10, 2024 02:52
- Added fields in tables ip_users and ip_clients.
- Removed zugferd selection in invoices - setting.
- Added e-Invoice format selection choice for client
- bank info input fields for user added and grouped
- placed xml configuration files in the folder helpers/XMLconfig
- placed xml-template files (Zugferd + UBL example) in the folder libraries/XMLtemplates
- created the readme file "About e-Invoicing templates" = How to add/setup XML-template files
- Added fields in tables ip_users and ip_clients.
- Removed zugferd selection in invoices - setting.
- Added e-Invoice format selection choice for client
- bank info input fields for user added and grouped
- placed xml configuration files in the folder helpers/XMLconfig
- placed xml-template files (Zugferd + UBL example) in the folder libraries/XMLtemplates
- created the readme file "About e-Invoicing templates" = How to add/setup XML-template files
@nielsdrost7 nielsdrost7 force-pushed the feature/939-peppol-zugferd-e-invoicing branch from 608d650 to c128ee3 Compare November 10, 2024 10:04
@nielsdrost7 nielsdrost7 marked this pull request as ready for review November 10, 2024 10:05
@nielsdrost7 nielsdrost7 marked this pull request as draft November 10, 2024 10:06
@nielsdrost7
Copy link
Contributor Author

@Verony-makesIT
I did a test for when stuff was not filled.

I'm sorry.
Every little click i did i got an error message. It was horrible.

Unless we can get a great test done, we have to postpone this PR man.

Example:
The XML Template for the default CIUS.
When $invoice->user_company isn't filled the XML generator gives an error message.

We have to deal with these error messages man

@Verony-makesIT
Copy link
Contributor

@nielsdrost7 ,
My e-invoicing functionality is only intended for B2B and B2G.
All those entities have some kind of VAT number and/or entrepreneur number.
There is no point in sending electronic invoices to private individuals in Europe.
Given your comment, I will look into building in some checks and providing information when a user makes the "e-invoicing" choice for his (business or government) customer.

Perhaps it is indeed better to postpone this (for a while until V2?) because in my opinion, building an e-invoicing template is not really easy for most programmers if all business rules have to be coded manually.

The programming itself is not difficult but applying all the business rules is certainly not easy!
In principle, these business rules are freely available in every country, but it is not always clear where to find them.
I am also looking into whether there is an easier (automatic) way to apply all business rules (using xslt files).

You cannot and may not assume that there is a standard template for a region (e.g. EU) that you could easily use for every country in that region. In principle, the government of each country has information available about which format (e.g. UBL, CII or other) and/or syntax suppliers must use.
In Europe, the standard is EN16931-1 (UBL/CII), Germany has Zugferd for B2B and XRechnung for B2G (CII syntax) and France has Factur-X V1.0x that is compatible with Zugferd V2.1 and higher. Other countries may use a different standard. e.g. Saudi Arabia (FATOORAH) where UBL- XML ​​or PDF with embedded XML can be used.

That is why I have not created a general template, but only provide 2 examples, i.e. an (old) (UBL) EN 16931-1 version and the version that is/was already present in IP, a (CII) Zugferd version 1.0.

A CIUS can only be used by an EU country that uses the EN 16931 standard. Those countries (e.g. NL, AT, ...) then set up separate Business rules (e.g. CIUS-AT-NAT: https://ecosio.com/en/blog/what-is-a-core-invoice-usage-specification/ ) that must be applied on top of the standard (EN 16931-1) to e-invoices that must be sent to clients in that country.
More info: eInvoicing Country Factsheets.

I hope the above makes it all a bit clearer...

Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are accessibility issues in these changes.

<!-- ZUGFeRD Template Usage -->
<div class="form-group">
<label for="settings[use_zugferd]"><?php echo trans('use_zugferd'); ?></label>
<select name="settings[use_zugferd]" id="use_zugferd" class="form-control">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

<!-- Default UBL Template Type -->
<div class="form-group">
<label for="settings[default_template_type]"><?php echo trans('default_ubl_template_type'); ?></label>
<select name="settings[default_template_type]" id="default_template_type" class="form-control">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

nielsdrost7 and others added 25 commits November 21, 2024 07:40
- Added fields in tables ip_users and ip_clients.
- Removed zugferd selection in invoices - setting.
- Added e-Invoice format selection choice for client
- bank info input fields for user added and grouped
- placed xml configuration files in the folder helpers/XMLconfig
- placed xml-template files (Zugferd + UBL example) in the folder libraries/XMLtemplates
- created the readme file "About e-Invoicing templates" = How to add/setup XML-template files
- Added fields in tables ip_users and ip_clients.
- Removed zugferd selection in invoices - setting.
- Added e-Invoice format selection choice for client
- bank info input fields for user added and grouped
- placed xml configuration files in the folder helpers/XMLconfig
- placed xml-template files (Zugferd + UBL example) in the folder libraries/XMLtemplates
- created the readme file "About e-Invoicing templates" = How to add/setup XML-template files
…nvoicePlane/InvoicePlane into feature/939-peppol-zugferd-e-invoicing
@nielsdrost7 nielsdrost7 mentioned this pull request Nov 30, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants