-
-
Notifications
You must be signed in to change notification settings - Fork 784
custom RDF metadata for PDF/A, especially for Factur-X eInvoices #2338
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
Conversation
|
Hi! Thanks for your PR, supporting ZUGFeRD / Factur-X could be a really good thing for WeasyPrint! Everything seems to be OK with this code, I’ve only changed a couple of minor things (mainly removed types that we don’t want to use in WeasyPrint). Could I have rights to push the commit to your branch? (Or I can start another branch from your commit and create a new PR if you prefer.) Before merging, could you please share some code you could use to generate Factur-X documents? We’d like to be sure about the API we’ll have to maintain. 😄 If you already have some content written for your blog post, don’t hesitate to share, we could add some documentation in this PR too. |
|
Just invited you to the repository. May I ask why you don't use typing? That's a bit uncommon / unexpected :) Wanted to start writing the blog post as soon as I got a positive reaction from this MR, so I will start now. The method I would set at Will write a full examples in my blogpost, in a few days I will be able to provide more :) |
Thank you!
Sure: Kozea/Pyphen#50 (comment)
Thanks a lot! I’ll take a look and see if it’s there’s anything I’d like to change. |
|
About typing: this really helps IDEs like pyCharm, and it's actually the same reason: pyCharm has pretty good auto complete features and hints where you do something wrong if you provide proper typing. So I guess that's another way of being lazy: it's something the IDE can do a lot for you if you do the typing, and something where you don't have to think about that much any more. At python 3.5 / 3.6, I was not convinced, either, but starting with 3.8 and especially with 3.10, typing really makes sense - at least for for me :) And, maybe an obvious question about the code: why didn't I add the whole Factur-X extension RDF to weasyprint? Well, two reasons:
|
|
Blog article is finished and published: https://binary-butterfly.de/artikel/factur-x-zugferd-e-invoices-with-python/ . Which parts do you think are interesting for the weasyprint docs, @liZe ? :) |
|
@the-infinity Thanks a lot for sharing. I think that I will adapt the code in "Use both XMLs to generate a PDF/A with attachment" as a small snippet, and add a link to your blog entry for more detailed information, if it’s OK for you. About the API, we may want to change minor things:
|
Sounds good :)
Ok, that was an question where I had to look deeper. Turns out: that was not true, it was just a wrong assumption I had at some point based on an issue I saw ... somewhere. So, removed it. Updated the demo code above.
A requirement is that if you regenerate the same invoice, it should give the same identifier. Thiis would be broken when generating a random identifier.
Okay :) |
603295d to
8a7c72e
Compare
|
Hi @the-infinity! I think that this PR is almost ready to be merged. There are some minor changes required for your blog article (name and parameters of I’ve included a full example in the documentation, tested with FNFE-MPE’s online validator (free account required). Thanks a lot for your hard work! |
|
Hello guys, do I see correctly that EU eInvoices can now be generated with Weasyprint? If yes @the-infinity you we talking about writing a blog article, is this still your plan? Also @liZe this info might be added to the docs maybe? Me, and probably thousands of other developers in the EU, would really really appreciate it! :) And btw, thanks for all of your awesome work everyone! |
|
Wow I take everything back, sorry! Maybe I didnt find it because it doesnt include the word eInvoice. Googling "weasyprint einvoice" only leads to this PR. |
|
@MickL the blog article is also linked in the docs :) |
|
You guys are insane! Great blog article, too!! Why doesnt both docs and blog article come up first thing when googling for it 🙄 Happy we chose to use WeasyPrint! |
This MR adds a way to add custom RDF metadata for PDF/A s. It's implemented using a custom generator function, because RDF extensions get pretty difficult, and usually you want to write an own generator.
Background: EN 16931 / ZUGFeRD / Factur-X eInvoices require a custom RDF metadata extension to be valid, something like this: https://www.pdflib.com/fileadmin/pdf-knowledge-base/zugferd/Factur-X_extension_schema.xmp . This cannot be added with the existing mechanisms. So far, we monkey-patched weasyprint to generate valid eInvoices, which works, but is unstable and not the way how it should be done. Therefore, this MR. :)
Larger background: Germany enforces eInvoices starting 01.01.2025 for B2B customers with a transition period of two years. Other EU countries have similar plans. Therefore, there will be a growing interest for proper FOSS tools. :)
I will write a blog article how to use weasyprint for eInvoices as soon as I don't have to recommend monkeypatching. I would be fine using parts of the blog article in weasyprints documentation, too.
I hope the MR is ok for you as this is my first MR in this project. I tried to stay close to your code style, but added typing as I think it makes sense to do so "on the way". If you want any changes or additional documentation, feel free to request it.