Electronic invoices with the Mustang Project
The creation and sending of electronic invoices in ZUGFeRD or Factur-X format is now standard in many industries. To automate and simplify this process, you can use FileMaker and the Mustang Project in conjunction with JSON as an exchange format. This step-by-step guide shows you how to create an electronic invoice with FileMaker, export it to JSON, convert it into a ZUGFeRD-compliant PDF with the Mustang Project and finally send it.
The Mustang Project is an open source Java library that makes it possible to create and process electronic invoices in ZUGFeRD and Factur-X format. In order to use this library on an Apple Mac or a Windows PC, a number of steps must be taken, including installing Java, downloading the Mustang Project library and setting up the development environment.
The Receiving electronic invoices with FileMaker We have described the use of on-board tools and the free BaseElements plugin in a separate article, in which we also mention other articles on generating electronic invoices with the MBS plugin.
Table of contents
- Electronic invoices with the Mustang Project
- What is the Mustang Project?
- Who runs the Mustang Project?
- Possibilities with FileMaker and the Mustang Project
- FileMaker ERP with us as an open license for a one-time purchase price
- Prerequisites
- Installation and setup of the Mustang Project
- Preparation of the database in FileMaker
- Example for the creation of a JSON invoice in FileMaker
- FileMaker Crash CourseLearn FileMaker quickly and effectively in 20 chapters.
- PDF creation of the invoice in FileMaker
- Creating the Java script for processing JSON
- Sending the electronic invoice
- Formats for electronic invoices
- Dispatch of electronic invoices already integrated in the gFM-Business ERP software.
- Frequently asked questions about FileMaker and e-invoices
- Summary
What is the Mustang Project?
The Mustang Project was developed to support the creation and processing of ZUGFeRD and Factur-X compliant invoices. These invoice formats combine PDF documents with machine-readable XML data that can be processed by both humans and automated systems. ZUGFeRD (Zentraler User Guide des Forums elektronische Rechnung Deutschland) and Factur-X are standardized formats that are mainly used in Germany and France to simplify the invoicing process between companies and public authorities.
The Mustang Project is a Java-based library developed to enable the embedding of ZUGFeRD and Factur-X data in PDF invoices. It offers a variety of functions that enable developers to generate electronic invoices that comply with current legal and technical standards.
Who runs the Mustang Project?
The Mustang Project is developed and maintained by an open source community focused on promoting the electronic exchange of invoices. The initiative is supported by Konik.io, a platform that provides tools for automated invoice processing. The developer community consists of experts in the field of electronic invoices who have made it their mission to offer a powerful and free solution for companies of all sizes.
The open source nature of the project allows anyone to contribute to the further development of the library. At the same time, companies and developers can use the library free of charge to develop their own solutions for electronic invoice exchange.
Possibilities with FileMaker and the Mustang Project
One of the main strengths of Mustang Project is its flexibility. The library can be integrated into various environments, including FileMaker. FileMaker users who want to generate invoices and output them as electronic ZUGFeRD or Factur-X invoices can use the Mustang Project to automate these processes. Here are some of the most important possibilities that the Mustang Project offers in conjunction with FileMaker:
1. creation of ZUGFeRD and Factur-X invoices
FileMaker enables companies to store, manage and process invoice data. By integrating the Mustang Project, it is possible to convert this invoice data into standardized electronic invoices that meet the requirements of ZUGFeRD and Factur-X. The process could look like this, for example:
- Invoice data is entered and saved in FileMaker.
- A PDF document of the invoice is generated with FileMaker.
- The Mustang Project is called up to generate the XML data and embed it in the PDF file.
- The finished ZUGFeRD or Factur-X invoice is then sent to the customer or the authority.
By automating this process, companies can not only save time, but also ensure that their invoices comply with the applicable standards.
2. processing of incoming electronic invoices
In addition to creating invoices, the Mustang Project also enables the processing of received electronic invoices. If a company receives a ZUGFeRD or Factur-X invoice, it can be read in with the Mustang Project and the relevant XML data extracted. This data can then be imported directly into FileMaker and used for further processing, for example for accounting or inventory management.
This makes it possible to automate the invoicing process and reduce errors in manual data entry. FileMaker can extract the XML data, feed it into the corresponding database fields and thus make the workflow more efficient.
3. cost-efficient solution for small and medium-sized enterprises
As the Mustang Project is available free of charge as an open source solution, it offers small and medium-sized companies in particular a cost-effective way to implement electronic invoices. By dispensing with expensive proprietary software solutions, companies can modernize their electronic invoice exchange and save costs at the same time.
FileMaker, as a flexible and user-friendly platform, allows companies to develop their own customized invoice processing solutions and seamlessly integrate the Mustang Project.
4. adaptation to specific company needs
Thanks to the openness and flexibility of FileMaker and the Mustang Project, companies can customize their solutions to their specific requirements. Mustang Project can be configured to support the company's specific business processes, while FileMaker serves as the central database and automation platform.
For example, a company operating in a specific industry could embed certain information in the ZUGFeRD invoice or make special adjustments for international invoices. By using FileMaker and Mustang Project, it is possible to implement these requirements in a customized solution.
The integration with FileMaker opens up numerous possibilities to automate the invoice workflow, increase efficiency and minimize errors. For companies looking to digitize their invoice processes, the combination of FileMaker and Mustang Project provides an ideal platform to achieve these goals. Whether it's creating invoices, receiving invoices or adapting to industry-specific requirements, Mustang Project offers a flexible and future-proof solution.
FileMaker ERP with us as an open license for a one-time purchase price
Request information
Prerequisites
- FileMaker Pro Advanced or FileMaker Server
- Java Runtime Environment (JRE) for the Mustang Project
- Mustang Project Library, downloaded from the official website (Mustang Project)
- Basic knowledge of FileMaker scripting and JSON
- A basic understanding of the ZUGFeRD/Factur-X standards
Installation and setup of the Mustang Project
- To run the Mustang Project, you need the Java Runtime Environment (JRE) or the Java Development Kit (JDK) on your computer.
- If Java is not installed, download the latest version of JDK or JRE from the official Oracle website and install it.
- Download the latest version of the Mustang Project JAR file from the official website.
- Create a directory in which you save the Mustang Project JAR file. You can do this in the terminal or via the Finder.
Execution of Mustang Project
Create a simple calculation using the Mustang Project library. Create a file called ZUGFeRDTest.java with the following content:
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3;
public class ZUGFeRDTest {
public static void main(String[] args) {
try {
ZUGFeRDExporterFromA3 exporter = new ZUGFeRDExporterFromA3();
exporter.load("input.pdf");
exporter.export("output_with_zugferd.pdf");
System.out.println("Invoice successfully created.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Save the file in the same directory as the JAR file.
Compiling and executing the script
Navigate to your directory in the terminal:
cd ~/Documents/mustang_project
Compile the Java program:
javac -cp mustangproject.jar ZUGFeRDTest.java
Execute the Java program:
java -cp .:mustangproject.jar ZUGFeRDTest
Make sure that in macOS : is used as a separator to separate multiple paths. If everything is set up correctly, you should see that the PDF invoice has been successfully created.
Preparation of the database in FileMaker
Creating an invoice table and item table
First you need to create two tables in FileMaker in which you save the invoice and item data. The two tables are linked via the invoice number (1:n). If you already have a FileMaker solution with corresponding tables, you can skip this step.
Below you will find the basic fields you need to create an invoice:
- Invoice number (Text)
- Invoice date (date)
- Customer data (Text or separate fields for name, address, tax ID)
- Articles/services/price per item (Position table)
Net amount (number) - Value added tax amount (number)
- Gross amount (number)
- Terms of payment (Text)
Prepare JSON data structure
You should convert your invoice data into a JSON structure that serves as an exchange format between FileMaker and the Mustang Project. Use FileMaker's JSONSetElement function to format the data.
Example for the creation of a JSON invoice in FileMaker
Create JSON for the invoice items
First, create a formula field in the invoice items table that contains the JSON object for each item. Let's call the field Position_JSON, for example.
Calculation definition for the Position_JSON field in the invoice items table:
JSONSetElement ( "{}" ;
["description"; Positions::Description ; JSONString] ;
["quantity"; Positions::Quantity ; JSONNumber] ;
["price"; Positions::Price ; JSONNumber]
)
This calculation creates a JSON object for each invoice item with the attributes description, quantity, and price.
Create JSON for the entire invoice
In the invoice table, you now use the list function to merge all items. This is inserted in the main calculation as an array of JSON objects under the key "items".
Main calculation formula in the calculation table:
Set variable [$json; Value:
JSONSetElement ( "{}" ;
["invoice_number"; invoices::invoice_number ; JSONString] ;
["invoice_date"; invoices::invoice_date ; JSONString] ;
["customer";
JSONSetElement ( "{}" ;
["name"; Invoices::Name ; JSONString] ;
["address"; invoices::address ; JSONString]
); JSONObject
] ;
["items";
"[" & Exchange ( List ( Invoice items::Position_JSON ) ; ¶ ; "," ) & "]" ; JSONRaw]
;
["total"; Invoices::Total amount ; JSONNumber]
)]
Explanation of the calculation
- Invoice number and invoice dateThis data is inserted into the JSON with JSONSetElement.
- Customer dataAnother JSONSetElement is used to save the customer data (name and address) as a nested JSON object under the key "customer".
- Invoice itemsHere we use List ( Invoice items::Item_JSON ) to collect all items from the Item_JSON calculation. The result of the List function contains each item on a new line. To make this work as a JSON array, we use substitutes to replace the line breaks (¶) with commas and place the items in square brackets ([ ]). We use JSONRaw so that FileMaker treats this string as a valid JSON array.
- Total amountThis is inserted as a JSONNumber.
Final result
After performing these calculations, you will receive a fully formatted JSON document containing the invoice with the corresponding items. This document can then be exported as a JSON file or processed further.
Example of the final JSON document
{
"invoice_number": "2024001",
"invoice_date": "2024-08-01",
"customer": {
"name": "Max Mustermann",
"address": "Musterstraße 1"
},
"items": [
{
"description": "Product A",
"quantity": 2,
"price": 50.00
},
{
"description": "Product B",
"quantity": 1,
"price": 100.00
}
],
"total": 200.00
}
The result of this script is a clean JSON structure that contains all relevant invoice information, including the item details.
FileMaker Crash Course
Fast and effective FileMaker
learning in 20 chapters.
Participate free of charge
PDF creation of the invoice in FileMaker
Create PDF from invoice data
As soon as the data is available in the invoice table, you must generate a PDF invoice. This is done using the FileMaker command "Save records as PDF". In this example, we assume that you generate the invoice from the data reference of the items.
Set variable [$path; Value: Get ( TemporaryPath ) & "Invoice_" & Invoices::Invoice number & ".pdf"]
Save data records as PDF [Dialog: Off; $path; Create directories: Off ; All called data records]
This script saves the invoice as a PDF file in the temporary directory.
Transfer JSON to Mustang Project
The Mustang Project is now used to process the JSON data and embed the ZUGFeRD data in the PDF.
Creating the Java script for processing JSON
The Mustang Project is a Java-based library that you can use to convert the JSON data into ZUGFeRD-compliant XML and embed it in the PDF file. A simple Java script can process the JSON data and integrate the ZUGFeRD data into the PDF invoice.
Example of a Java script
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3;
import org.json.JSONObject;
public class Main {
public static void main(String[] args) {
// Get JSON data from FileMaker (here as example hardcode, in reality from a file or DB)
String jsonString = "{\"invoice_number\": \"2024-001\", \"invoice_date\": \"2024-08-01\", \"customer\": {\"name\": \"sample customer\", \"address\": \"Musterstraße 12\"}, \"items\": [{\"description\": \"Consulting\", \"quantity\": 5, \"price\": 100.0}], \"total\": 500.0}";
JSONObject json = new JSONObject(jsonString);
// Initialize ZUGFeRDExporter
ZUGFeRDExporterFromA3 exporter = new ZUGFeRDExporterFromA3();
// Download invoice (PDF)
exporter.load("invoice.pdf");
// Extract and set ZUGFeRD data from JSON
exporter.setZUGFeRDInvoiceDetailsFromJSON(json);
// Exporting the ZUGFeRD-compliant PDF
exporter.export("rechnung_with_zugferd.pdf");
System.out.println("ZUGFeRD invoice successfully created from JSON data.");
}
}
This Java script reads the JSON data, converts it into ZUGFeRD XML and embeds this data in the PDF.
Transfer of the JSON data to the Java script
The JSON data that you have generated in FileMaker must be transferred to the Java script. This can be done via a text file that FileMaker creates or directly via the command line argument of the Java script.
ExampleSave the JSON data to a file:
Set variable [$jsonFilePath; Value: Get ( TemporaryPath ) & "invoice_data.json"]
Export all field values [Invoices::JSON_Data; "$jsonFilePath"]
You can then read and process this file in the Java script.
Executing the Java script from FileMaker
Use a shell script or batch script to call the Java script from FileMaker. This can be done using the Send Event command in FileMaker.
Example of a shell script
#!/bin/bash
java -cp mustangproject.jar org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3 -input "/path/to/invoice.pdf" -output "/path/to/invoice_with_zugferd.pdf" -json "/path/to/invoice_data.json"
This shell script executes the Java script that adds the ZUGFeRD data to the PDF.
Sending the electronic invoice
Once the ZUGFeRD-compliant PDF invoice has been created, you can send it directly to the customer by email via FileMaker.
Send PDF by e-mail
Use the FileMaker e-mail script to send the ZUGFeRD invoice as an attachment:
Send e-mail [Via e-mail client; To: Customer::e-mail; Subject: "Your invoice"; Message: "Dear customer, please find enclosed your electronic invoice."; Attachments: "$path_to_final_pdf"]
This script sends the finished PDF invoice by e-mail.
Formats for electronic invoices
The Java exporter ZUGFeRDExporterFromA3 is used to address various ZUGFeRD and Factur-X formats in the Mustang Project from FileMaker. The selection of the format and profile (e.g. Basic, Comfort, Extended or Factur-X EN16931) is defined via methods such as setProfile().
You can call the Java exporter from FileMaker using shell scripts or batch files and transfer the required parameters for the respective profile. The process looks like this:
- Collect invoice data in FileMaker and generate as PDF.
- Create a shell script that calls the ZUGFeRDExporterFromA3 with the corresponding profile (e.g. BASIC, EN16931).
- Transfer JSON or XML data and select the profile.
- The exported ZUGFeRD- or Factur-X-compliant PDF is then created and sent or saved to the recipient.
Example in Java
exporter.setProfile(ZUGFeRDProfile.BASIC);
The desired format is addressed directly by the parameter selection in the script.
The Mustang Project supports several formats for exporting electronic invoices, in particular in the ZUGFeRD and Factur-X standard. These standards define different profiles that determine the scope and type of embedded data. Here is a list of the main formats and profiles supported by the Mustang Project and their respective call names.
Dispatch of electronic invoices already integrated in the gFM-Business ERP software.
More information
Supported export formats and profiles in the Mustang Project
- ZUGFeRD 1.0 Basic
Name for the call: BASIC
Description: This profile contains basic data and is suitable for smaller invoices where detailed items are not required. - ZUGFeRD 1.0 Comfort
Name for the call: COMFORT
Description: Contains more detailed information than the Basic profile, including individual items of the invoice. It is suitable for most business transactions. - ZUGFeRD 1.0 Extended
Name for the call: EXTENDED
Description: The most comprehensive profile in ZUGFeRD 1.0, which also contains very detailed information for more complex invoices and international transactions. - ZUGFeRD 2.0 Basic
Name for the call: BASIC
Description: Provides basic invoice data, similar to ZUGFeRD 1.0 Basic, but in the improved 2.0 standard. Less detailed and intended for simple transactions. - ZUGFeRD 2.0 Comfort
Name for the call: COMFORT
Description: A medium profile that provides more detailed invoice data, but not as comprehensive as Extended. It is the standard for most business transactions. - ZUGFeRD 2.0 Extended
Name for the call: EXTENDED
Description: Contains the most complete information and also supports complex and international invoices. Suitable for companies with extended reporting requirements. - Factur-X Minimum
Name for the call: MINIMUM
Description: The Factur-X-Minimum profile is very simple and contains only basic information. It is intended for very simple calculations where only a small amount of data is required. - Factur-X Basic
Name for the call: BASIC
Description: Contains more information than the minimum profile and is suitable for small businesses and basic invoices. - Factur-X EN16931
Name for the call: EN16931
Description: This is the standard profile for electronic invoices that meets the requirements of EU standard EN 16931. It is used in Europe for cross-border transactions and B2G (Business-to-Government) invoices. - Factur-X Extended
Name for the call: EXTENDED
Description: The most comprehensive Factur-X profile, designed for complex invoices that need to contain detailed information.
Frequently asked questions about FileMaker and e-invoices
- What is the Mustang Project and what is it used for?
- The Mustang Project is an open source library that makes it possible to create electronic invoices in the ZUGFeRD format (Central User Guide of the German Electronic Invoicing Forum). It is used to create legally compliant electronic invoices that are readable by both humans and machines.
- How can I use the Mustang Project with FileMaker?
- You can integrate the Mustang Project via FileMaker scripts and plug-ins to generate ZUGFeRD-compliant electronic invoices directly from your FileMaker database. XML data is generated and embedded in PDF files, which can then be sent to customers.
- What is the ZUGFeRD format and why is it important?
- The ZUGFeRD format is a standard for electronic invoices that combines PDF files with embedded XML data. It enables invoices to be read by humans as well as automatically processed by machines. This is particularly important for companies that want to exchange electronic invoices efficiently and in compliance with the law.
- How do I create a ZUGFeRD invoice in FileMaker?
- To create a ZUGFeRD invoice in FileMaker, you first collect the invoice data (customer information, products, prices, etc.). With the integration of the Mustang Project, you can convert this data into a ZUGFeRD-compatible XML file and embed this file in a PDF invoice.
- What advantages does the Mustang Project offer for electronic invoices?
- The Mustang Project offers an easy way to create ZUGFeRD-compliant electronic invoices without the need for expensive commercial software. It supports companies in meeting legal requirements and automating invoice dispatch.
- Is there a charge for using the Mustang Project for FileMaker?
- No, the Mustang Project is open source and therefore free to use. It can be integrated into your FileMaker database to create electronic invoices without incurring license costs.
- How do I send electronic invoices from FileMaker by e-mail?
- Once the electronic invoice has been created in ZUGFeRD format with FileMaker and the Mustang Project, you can send the PDF file to your customers by email using a FileMaker script. The script can automatically trigger the dispatch as soon as the invoice has been generated.
- What information must be included in a ZUGFeRD invoice?
- A ZUGFeRD invoice must contain all legally required information, such as the customer's full address, the invoice number, the invoice date, the company's tax number, detailed product information, the total amount and the tax amount. This data is embedded in both the PDF and the XML file.
- Can I convert existing invoice data from FileMaker to ZUGFeRD?
- Yes, you can convert existing invoice data in FileMaker into the ZUGFeRD format with the Mustang Project. To do this, you enter the data as usual in FileMaker and use the Mustang Project to create a ZUGFeRD-compliant XML file that is embedded in the PDF.
- Is the ZUGFeRD format also suitable for sending invoices internationally?
- Yes, the ZUGFeRD format is not only recognized in Germany, but is also based on the international standard UN/CEFACT Cross Industry Invoice. It can also be used for sending invoices internationally, provided the recipients support this standard.
- How secure are electronic invoices in ZUGFeRD format?
- Electronic invoices in ZUGFeRD format are secure because they are embedded in an unalterable PDF container. You can also implement additional security measures in FileMaker, such as digital signatures, to ensure the authenticity of the invoice.
- How can I integrate the Mustang Project into my existing FileMaker database?
- You can either integrate the Mustang Project as a Java library into an existing FileMaker plugin or create an interface to the Mustang Project library using scripts. The integration requires some adjustments to the data flow in your FileMaker database in order to export the correct invoice data to the ZUGFeRD format.
Summary
With this guide, you can fully automate the process of creating and sending electronic ZUGFeRD invoices in FileMaker using the Mustang Project and JSON as the exchange format. By using JSON as the data format, the handling of invoice data is simplified and direct work with XML is avoided. The combination of FileMaker, Java and the Mustang Project offers a flexible and powerful solution for processing electronic invoices.
The Alternative The key to using the Mustang project to create electronic invoices is the direct implementation in FileMaker to create and, if required, read electronic invoices. FileMaker provides all script commands to create and read XML files. However, FileMaker cannot create PDF/A files in the ZUGFeRD standard with on-board tools; the MBS FileMaker plugin and the DynaPDF plugin are required for this. With this method, you have even more flexible options overall and can also integrate other formats such as XRechnung or UBL invoices, but then you have to integrate each individual XML format into FileMaker yourself.
