Automated Invoicing System for Brazil’s Nota Fiscal eletronica running natively on Mac

Seen running on the background movie, this is our geekiest project to date by far. Designed to integrate with the customer’s proprietary ERP and run on both their client stations and server — all Mac — it was built as 5 separate CLI (command line interfaces) running whenever a new data file was added to an Applescript-automated folder.

One by one, they convert the data file to XML, digitally sign it, connect to tax services servers to upload it, then wait, connect again, gather processing output and notify users through ERP depending on output.

The project’s main challenge was compatibility between our 100% Mac / Swift solution and the tax service’s fully Microsoft .NET services. Once working, though, it ran stable for 5+ years (and 2 major XML format updates) until the proprietary ERP was retired.

In Brazil, instead of invoicing clients directly, companies are legally required to notify the government of their sales (and corresponding taxes). The government will then invoices their clients on their behalf.
Besides information on buyer and seller, the notification must include excruciating details on items sold, quantities, payment formats, transportation modals, and 5 to 7 different taxes that vary by item sold, who it was sold to, buyer fiscal residence and status, even where and whom the items will be delivered to…

This alone would make the Nota Fiscal eletronica invoicing excessively complicated. It goes further, though. After formatting all this in XML, it must be digitally signed following Microsoft’s .NET protocols, then transmitted over SSL to web services on the tax service’s servers, after authenticating with your Tax ID digital certificate. Phew!

The total specs file for the XML information format would exceed 300 pages if printed — and that’s not the implementation guide, that’s the XML Scheme for .NET in computer language!!

Want to see for yourself? Download XSD files →

Previous
Previous

Financial Modeling

Next
Next

Hoplon SA