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 #977

Open
wants to merge 9 commits into
base: development
Choose a base branch
from

Conversation

Verony-makesIT
Copy link
Contributor

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

- 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
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.

application/modules/clients/views/form.php Show resolved Hide resolved
application/modules/users/views/form.php Show resolved Hide resolved
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.

👏 You fixed the issue(s)! Great work.

Copy link
Contributor Author

@Verony-makesIT Verony-makesIT left a comment

Choose a reason for hiding this comment

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

Suggestions and/or adjustments requested were implemented.

application/modules/users/views/form.php Show resolved Hide resolved
application/modules/setup/sql/040_2.0.0.sql Outdated Show resolved Hide resolved
application/modules/users/models/Mdl_users.php Outdated Show resolved Hide resolved
application/modules/clients/views/form.php Show resolved Hide resolved
@amauryverschooren
Copy link

Are there any updates on this pr? Is there still something not working? would klove to have this feature enabled.

@nielsdrost7
Copy link
Contributor

@amauryverschooren I haven't tested the PR yet.
Feel free to test it out, locally of course.

As soon as my test starts, I'll let you and the author of the PR know, and the results, of course

@Verony-makesIT
Copy link
Contributor Author

@amauryverschooren, @nielsdrost7,
For those who already want to test out this e-invoicing module....
The PR should be fully up and running without any problems ;-) (unless bugs pop up).
You can install it yourself by first adjusting your db's with the sql code from the "setup\sql\040_2.0.0.sql" file.

The principle of this module assumes that you set for your customers which e-invoicing format (if the template is present) they want to receive. While sending the pdf invoice, the chosen (e-invoicing) format will automatically be created and sent along with it.
For a German customer the Zugferd format will be embedded in the pdf invoice (idem for France with Factur-X).
For a customer from another (e.g. European?) country, this will probably be a UBL format sent as a separate XML file along with the pdf invoice.

Comments:

  • Since each country uses a (slightly) different e-invoicing format I have chosen to use (per format) a different template file that the user (or a programmer) will have to create himself for the benefit of his customers.
  • By default I have already added 2 example template files (Ublexamv20Xml.php and Zugferdv10Xml.php) in the "libraries\XMLtemplates" folder.
  • A brief explanation of the installation and implementation of the templates and configuration files is described in the "helpers\XMLconfigs\About e-Invoicing templates.md" file.

I hope this explanation provides some clarity.
If there are any uncertainties or questions, you can always ask them.

@amauryverschooren
Copy link

@amauryverschooren, @nielsdrost7, For those who already want to test out this e-invoicing module.... The PR should be fully up and running without any problems ;-) (unless bugs pop up). You can install it yourself by first adjusting your db's with the sql code from the "setup\sql\040_2.0.0.sql" file.

The principle of this module assumes that you set for your customers which e-invoicing format (if the template is present) they want to receive. While sending the pdf invoice, the chosen (e-invoicing) format will automatically be created and sent along with it. For a German customer the Zugferd format will be embedded in the pdf invoice (idem for France with Factur-X). For a customer from another (e.g. European?) country, this will probably be a UBL format sent as a separate XML file along with the pdf invoice.

Comments:

  • Since each country uses a (slightly) different e-invoicing format I have chosen to use (per format) a different template file that the user (or a programmer) will have to create himself for the benefit of his customers.
  • By default I have already added 2 example template files (Ublexamv20Xml.php and Zugferdv10Xml.php) in the "libraries\XMLtemplates" folder.
  • A brief explanation of the installation and implementation of the templates and configuration files is described in the "helpers\XMLconfigs\About e-Invoicing templates.md" file.

I hope this explanation provides some clarity.
If there are any uncertainties or questions, you can always ask them.

I tried to run it but it doesn't work for me. pulled the branch in and edited the ipconfig php file. then started the containers. i can connect to the db with mysql workbench en when i check the eocker logs it seems that everything is working. when i open my browser and surf to the ip or the ip/index.php/setup nothing happens. just a blank screen. no console logs for errors or something.

image

@amauryverschooren
Copy link

got it working now. i replaced the files that were changed. It's normal that it doesn't work when there is nothing in db etc. . i can see the drop down for selecting the ubl version for each client.
image

I did find a bug, when going to the default settings all the styling is gone as seen below:
image

@amauryverschooren
Copy link

amauryverschooren commented Dec 4, 2023

@Verony-makesIT got this error at the bottom of settings page
image

@nielsdrost7
Copy link
Contributor

I don't know where it's called, but it should be email_templates/**views**/template-tags-invoices

@amauryverschooren
Copy link

I don't know where it's called, but it should be email_templates/**views**/template-tags-invoices

yeah i used that. it's called in the partial_settings_invoices.php file at line 394. tried everything but it just doesn't work.

@Verony-makesIT What do you have in that file at that line and do you have an idea why it's giving me this eror bcs as far as i can tell there is nothing changed in that file except from the lines from zugfred that were taken awai.

@Verony-makesIT
Copy link
Contributor Author

@amauryverschooren,
Frankly, I have no idea... because this feature has been added to the development repo (IP 1.6.1-beta3) via "FR: payment QR code for web/pdf templates #995" and I developed my e-invoicing module based on the IP version 1.6.0.
So I think you should probably contact the creator(s) of this functionality for more explanation and/or support regarding your problem.... @nielsdrost7, @mheiduk can you help Amoury with this?
I would recommend turning off the "QR code setting" and see if the problem still occurs.
If you later need this QR code feature you can still activate it and see if this problem still occurs.

Personally, I am definitely not in favor of implementing the QR code feature in this way.
The IBAN number also already exists in the user db. Recipient (or payment contact), bank name, bic and remittance info are fields that I already added in my e-invoicing module (related to electronic payments) in the ip user db.
All these fields are related to the user and in my opinion should not be in the global 'invoice settings'.

When implementing this QR code feature and my e-invoicing module, this may start to cause conflicts because application users will no longer know where to enter (the same) aforementioned 'settings data' and/or fields.

@nielsdrost7
Copy link
Contributor

yeah i used that. it's called in the partial_settings_invoices.php file at line 394. tried everything but it just doesn't work.

So let me look if merging that PR introduced that bug.
@amauryverschooren would you mind making a post on the forums regarding this problem or in Slack? I might be able to better help you there.

@amauryverschooren
Copy link

yeah i used that. it's called in the partial_settings_invoices.php file at line 394. tried everything but it just doesn't work.

So let me look if merging that PR introduced that bug.

@amauryverschooren would you mind making a post on the forums regarding this problem or in Slack? I might be able to better help you there.

I just got it fixed. On line 394 I'm now using email_templates/template-tags and that's working.

@amauryverschooren
Copy link

@Verony-makesIT is there a way of transforming a xml example of the einvoice of your country to the php_template or is it just manual work of making a new one for your type?

@nielsdrost7
Copy link
Contributor

nielsdrost7 commented Dec 11, 2023

I thought that's what those examples were for: application/helpers/XMLconfigs/Ublexamv20.php transforms into ubl20, but it would help to invent some documentation, once the event comes that this PR gets merged. Here is the repository for the documentation: https://github.com/InvoicePlane/Wiki

@Verony-makesIT
Copy link
Contributor Author

@nielsdrost7,
I have no problem creating some additional documentation/information on e-invoicing.
I do have some questions regarding the wiki documentation.

  • Is there somewhere an explanation of how the wiki works?
  • Where (paragraph, section, folder, which version, module, ...) can I best add this (preliminary) documentation?
  • Do I add my info to the section 'templates' or do I create a new structure?

@nielsdrost7
Copy link
Contributor

nielsdrost7 commented Dec 12, 2023

Is there somewhere an explanation of how the wiki works?

Nope, no explanation, it's just markdown files as far as I know

Where (paragraph, section, folder, which version, module, ...) can I best add this (preliminary) documentation?

Version 1.6 is fine.
If you want you can create your own branch and work on that. We'll pull it on once the documentation is done.

I would add that documentation in the sections which you touched with the pull-request
So if it touched settings for Invoices, I would add the documentation there

Look at it this way:
Once we start testing your PR:

  • which setting should whe change at which page to get your functionality.
  • Then which field should we change at which page to get ... UBL for European companies (Ubl20?)
  • and I have a custom Ubl from the country ... Ireland (just an example). Which template should I copy/paste to make my own custom Ubl?
  • Now i want to send the Ubl with an invoice, in a template. Which setting should i change at which page to make that possible?

Do I add my info to the section 'templates' or do I create a new structure?

It all depends on which parts of InvoicePlane the pull-request has changed

@Verony-makesIT
Copy link
Contributor Author

@amauryverschooren,
as Nielsdrost7 points out, the sample files serve as a resource to create the final electronic invoice.
It depends on your customer which e-invoice format they wish to receive.
Just like the standard pdf and web templates in IP, these e-invoice templates are a base with which a user/developer can start to create either of the two possible XML invoice variants (UBL or CII).
I recommend creating a copy of a template and using that copy to develop your new e-invoice template file.
How to add a new template is described in the "IP160/application/helpers/XMLconfigs/About e-invoicing templates.md" file.
Via this link (https://github.com/ConnectingEurope/eInvoicing-EN16931/tree/master) to the EU einvoicing repo you can find some examples of both UBL (EN 16931/PEPPOL) and CII (zugferd/factur-X) formats.

Note: if you have customers in the Netherlands and Belgium, you can develop/use the UBL 2.1 (EN 16931) format for these two countries. Countries can specify restrictions and/or additions (CIUS) within the UBL 2.1 / EN 16931 format.
Belgium has not established any specific rules or restrictions. The Netherlands does.
The NLCIUS can be found here.

An example of NLCIUS mandatory restrictions compared to EN-16931:
BR-NL-1
Dutch supplier registration number (AccountingSupplierParty/Party/PartyLegalEntity/CompanyID);
With a Dutch supplier (NL), SchemeID may only contain 106 (Chamber of Commerce number) or 190 (OIN number).

Please take this into account when creating templates.

Should you not be able to figure it out then feel free to contact me via PM.

@amauryverschooren
Copy link

@amauryverschooren, as Nielsdrost7 points out, the sample files serve as a resource to create the final electronic invoice. It depends on your customer which e-invoice format they wish to receive. Just like the standard pdf and web templates in IP, these e-invoice templates are a base with which a user/developer can start to create either of the two possible XML invoice variants (UBL or CII). I recommend creating a copy of a template and using that copy to develop your new e-invoice template file. How to add a new template is described in the "IP160/application/helpers/XMLconfigs/About e-invoicing templates.md" file. Via this link (https://github.com/ConnectingEurope/eInvoicing-EN16931/tree/master) to the EU einvoicing repo you can find some examples of both UBL (EN 16931/PEPPOL) and CII (zugferd/factur-X) formats.

Note: if you have customers in the Netherlands and Belgium, you can develop/use the UBL 2.1 (EN 16931) format for these two countries. Countries can specify restrictions and/or additions (CIUS) within the UBL 2.1 / EN 16931 format. Belgium has not established any specific rules or restrictions. The Netherlands does. The NLCIUS can be found here.

An example of NLCIUS mandatory restrictions compared to EN-16931:
BR-NL-1
Dutch supplier registration number (AccountingSupplierParty/Party/PartyLegalEntity/CompanyID);
With a Dutch supplier (NL), SchemeID may only contain 106 (Chamber of Commerce number) or 190 (OIN number).

Please take this into account when creating templates.

Should you not be able to figure it out then feel free to contact me via PM.

it's mainly for belgium for me. is it correct the e-invoice is not downloadable and is only send with mail?

@Verony-makesIT
Copy link
Contributor Author

@amauryverschooren,
If all your customers are from Belgium then you basically don't have to consider CIUS restrictions or additions as mentioned above.
In IP you can indeed not download XML invoices.
However, you can find all your files in your "www.website.be/ip160/uploads/archive/" folder.

Just out of curiosity. Why would you need this (download) functionality?

@nielsdrost7 nielsdrost7 changed the title Implementing e-invoicing flow #939 [IP-939]: Implementing e-invoicing flow Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants