Morphia
From a foreign supplier’s PDF to a FatturaPA integration XML, with a human review before it is generated.
The context
Foreign invoices, integrated by hand.
Morphia was built for a company that receives invoices from foreign suppliers in different languages and formats. Each one needs an integration document or a self-invoice (TD17, TD18 or TD19) to submit to SdI, Italy’s e-invoicing exchange system: data copied from the PDF and a tax decision to repeat every time.
The challenge
Automating without losing control.
Reading the PDF could be automated; the tax classification could not. Document type, VAT rate and nature code have precise consequences and must stay justified and verifiable. The invoices also contain personal data, so it mattered where they are processed.
The solution
Splitting the work between model, rules and people.
I split the work into three parts. A language model extracts only the data written on the document, a rules engine proposes TD17, TD18 or TD19 with a rationale and a legal reference, and the reviewer checks everything against the PDF and confirms. No XML is generated without a review, and the workflow also works on a phone.
The outcome
A validated XML, after review.
An uploaded PDF becomes a numbered FatturaPA XML, validated against the official schema and ready to submit through the channel already in use. The application runs on a dedicated installation and, by default, only accepts extraction services that process data in the European Union.
Inside the project
A closer look at the project.
From PDF to XML, with an explicit confirmation
Upload, extraction and the rules engine’s proposal, then generation: before the XML is created, the reviewer confirms they have checked the warnings against the PDF. Recording with demo data.
Enlarge the screen The document next to the proposal
The original invoice stays visible while you check the warnings, document type, VAT rate, rationale and legal reference of the applied rule. Demo data.
Enlarge the screen On a phone, the list turns into cards
Each invoice shows its status, supplier, amount and next action, with no table to scroll sideways. Demo data.
Enlarge the screen The proposal explains itself
For goods already in Italy, the engine proposes TD19 and cites the law; the fact behind it remains a visible choice for the reviewer. Demo data.
Enlarge the screen The XML is ready, on the go too
After generation, the sequence number, file name and download stay close at hand, with the option to edit and regenerate. Demo data.