Library / Finance, Invoices & Accounting
Finance, Invoices & Accounting
Create draft Moloni invoice-receipts with Portuguese NIF validation
Runs manually to check Portuguese NIF numbers and VAT rates, match or create the customer, and create a draft invoice-receipt in Moloni.
What it does
## Create draft invoice-receipts in Moloni with Portuguese NIF validation ### Who's it for Businesses in Portugal that invoice in Moloni and want to try its API from n8n. ### How it works 1. Sample payment data holds one payment: customer, NIF (Portuguese tax ID), amount with VAT and VAT rate. 2. The NIF is checked with the Portuguese check-digit rule. Without a valid NIF, the draft is made out to the final consumer (consumidor final). 3. The workflow gets a Moloni access token and confirms that each configured VAT tax_id has the right percentage. 4. It finds the customer by NIF, or creates it. 5. It creates a draft invoice-receipt (fatura-recibo) and shows its document ID. ### Setup 1. Create a Custom Auth credential with your Moloni API details and select it in Moloni: get access token: { "qs": { "client_id": "…", "client_secret": "…", "username": "…", "password": "…" } }. The developer ID and client secret are in Moloni under Configurações → Developers. 2. In Configuration, enter your company, document set, product, payment method, maturity date and language IDs, and the tax_id of each VAT rate in taxas_iva (the Moloni API …/getAll methods list them). 3. Edit Sample payment data and click Execute workflow, first on Moloni's demo account. ### Requirements - A Moloni account with API access. - Tested on n8n 2.41.6 (self-hosted) with a simulated Moloni API built from the official docs; not yet tested on a real Moloni account. ### Customization tips Replace the manual trigger with a Webhook or Form trigger. Field names are Portuguese: nome (name), valor (amount with VAT), taxa_iva (VAT rate). ### Full version The full version on Gumroad issues the final invoice right after a Stripe or webhook payment, emails the PDF, never duplicates invoices and alerts you by email when something fails. Em português: valida o NIF e cria um rascunho de fatura-recibo na Moloni.
The steps
- Run with sample data
- Sample payment data
- Configuration
- Prepare payment
- Validate payment and NIF
- Moloni: get access token
- Moloni: list VAT rates
- Check configured VAT rates
- Moloni: find customer by NIF
- Read customer search result
- Customer exists?
- Moloni: create customer
- Read created customer
- Build draft invoice-receipt
17 steps in total.
Similar automations
Finance, Invoices & AccountingCreate draft InvoiceXpress receipts with Portuguese NIF validation10 stepsFinance, Invoices & AccountingCreate and Email Invoice Ninja Invoices from Sheets4 stepsFinance, Invoices & AccountingSave Gmail Receipts to Drive and Sheets with OpenAI12 stepsFinance, Invoices & AccountingExtract expense receipts from Gmail with Gemini and log them to Google Sheets13 steps