Mapping JSON Invoice Fields to Facturae XML (3.2.2)

Invoice Field Mapping Guide (B2Brouter API ↔ Business Terms ↔ Facturae XPath)

This guide maps the B2Brouter Invoice API fields and the corresponding EN 16931 Business Terms (BT) to XML paths in Facturae 3.2.2. For clarity, XPaths are shown without namespace prefixes.


Header-Level Mapping

BTBusiness TermAPI Field (B2Brouter)Facturae XPath
BT-1Invoice numberinvoice.numberInvoices/Invoice/InvoiceHeader/InvoiceNumber
Invoice seriesinvoice.series_codeInvoices/Invoice/InvoiceHeader/InvoiceSeriesCode
Document type(derived)Invoices/Invoice/InvoiceHeader/InvoiceDocumentType
Invoice class(derived)Invoices/Invoice/InvoiceHeader/InvoiceClass
BT-2Issue Dateinvoice.dateInvoices/Invoice/InvoiceIssueData/IssueDate
BT-7Operation Dateinvoice.tax_point_date (preferred) or invoice.delivery_date (fallback)Invoices/Invoice/InvoiceIssueData/OperationDate
BT-5Currencyinvoice.currencyInvoices/Invoice/InvoiceIssueData/InvoiceCurrencyCode
Languageinvoice.languageInvoices/Invoice/InvoiceIssueData/LanguageName
Exchange Rateinvoice.exchange_rateInvoices/Invoice/InvoiceIssueData/ExchangeRateDetails/ExchangeRate
Exchange Rate Dateinvoice.exchange_dateInvoices/Invoice/InvoiceIssueData/ExchangeRateDetails/ExchangeRateDate
BT-22Note (Header)invoice.extra_infoInvoices/Invoice/AdditionalData/InvoiceAdditionalInformation
Legal literalsinvoice.legal_literalsInvoices/Invoice/LegalLiterals/LegalReference
Notes:
  • ExchangeRateDetails is only emitted when the invoice currency differs from EUR. exchange_rate and exchange_date are not settable via the API; they are derived from account/system settings.
  • If both tax_point_date and delivery_date are present, delivery_date is appended to InvoiceAdditionalInformation.
  • Several fields are packed into InvoiceAdditionalInformation (see Additional Information Fields).

Payment

BTBusiness TermAPI Field (B2Brouter)Facturae XPath
BT-9Due Dateinvoice.due_dateInvoices/Invoice/PaymentDetails/Installment/InstallmentDueDate
Installment Amount(calculated).../Installment/InstallmentAmount
BT-81Payment meansinvoice.payment_method.../Installment/PaymentMeans
BT-82Payment means textinvoice.payment_method_text.../Installment/CollectionAdditionalInformation
BT-84Seller bank account (IBAN)invoice.bank_account.iban.../Installment/AccountToBeCredited/IBAN
BT-86Seller bank account (BIC)invoice.bank_account.bic.../Installment/AccountToBeCredited/BIC
BT-84Seller bank account (number, non-IBAN)invoice.bank_account.number.../Installment/AccountToBeCredited/AccountNumber
BT-91Buyer bank account (IBAN, direct debit)invoice.contact_iban.../Installment/AccountToBeDebited/IBAN
Buyer bank account (number, non-IBAN)invoice.contact_bank_account_number.../Installment/AccountToBeDebited/AccountNumber
Buyer bank account (BIC, direct debit)invoice.contact_bic.../Installment/AccountToBeDebited/BIC
BT-10Buyer Referenceinvoice.buyer_reference.../Installment/DebitReconciliationReference
Payment Reconciliation Referenceinvoice.payment_reconciliation_ref.../Installment/PaymentReconciliationReference
Notes:
  • PaymentDetails/Installment is emitted only when payment/terms are defined.
  • contact_bank_account_number and payment_reconciliation_ref are not currently in the API permitted params; they are populated from stored contact/invoice data.

References & Periods

Header-level commercial references (InvoiceIssueData):

BTBusiness TermAPI Field (B2Brouter)Facturae XPath
BT-13Purchase Order Referenceinvoice.ponumberInvoices/Invoice/InvoiceIssueData/ReceiverTransactionReference
BT-11File referenceinvoice.file_referenceInvoices/Invoice/InvoiceIssueData/FileReference
Receiver contract referenceinvoice.receiver_contract_referenceInvoices/Invoice/InvoiceIssueData/ReceiverContractReference

Invoicing period (Header):

BTBusiness TermAPI FieldFacturae XPath
BT-73Invoicing Period Startinvoice.invoicing_period_startInvoices/Invoice/InvoiceIssueData/InvoicingPeriod/StartDate
BT-74Invoicing Period Endinvoice.invoicing_period_endInvoices/Invoice/InvoiceIssueData/InvoicingPeriod/EndDate

Corrective invoices (rectified):

BTFieldAPI FieldFacturae XPath
Method(derived from invoice.amended_number)Invoices/Invoice/InvoiceHeader/Corrective/CorrectionMethod
Method description(derived).../Corrective/CorrectionMethodDescription
Reason codeinvoice.amend_reason (defaults to '16').../Corrective/ReasonCode
Reason description(derived from amend_reason translation).../Corrective/ReasonDescription
Additional reason descriptioninvoice.extra_info.../Corrective/AdditionalReasonDescription
BT-25Corrected invoice numberinvoice.amended_number.../Corrective/InvoiceNumber (+ .../InvoiceSeriesCode if applicable)
BT-26Corrected invoice dateinvoice.amended_date.../Corrective/InvoiceIssueDate (3.2.2 only)
Tax period startinvoice.amended_invoicing_period_start.../Corrective/TaxPeriod/StartDate
Tax period endinvoice.amended_invoicing_period_end.../Corrective/TaxPeriod/EndDate
Notes:
  • CorrectionMethod is computed: '03' if amended_number == '?', otherwise '02'.

Parties Mapping (Issued Invoice)

If the invoice is received, swap SellerParty and BuyerParty.

Seller Party (Issuer)

BTBusiness TermAPI FieldFacturae XPath
BT-27Seller Nameaccount.nameParties/SellerParty/LegalEntity/CorporateName (or Individual/Name + FirstSurname)
BT-31Seller VAT IDaccount.tin_valueParties/SellerParty/TaxIdentification/TaxIdentificationNumber
Party Identificationinvoice.party_identificationParties/SellerParty/PartyIdentification
BT-35Seller Streetaccount.addressParties/SellerParty/LegalEntity/AddressInSpain/Address (or OverseasAddress/Address)
BT-38Seller Postal Codeaccount.postalcodeParties/SellerParty/LegalEntity/AddressInSpain/PostCode
BT-37Seller Cityaccount.cityParties/SellerParty/LegalEntity/AddressInSpain/Town
BT-39Seller Provinceaccount.provinceParties/SellerParty/LegalEntity/AddressInSpain/Province
BT-40Seller Countryaccount.countryParties/SellerParty/LegalEntity/AddressInSpain/CountryCode (ISO3)
BT-43Seller Emailaccount.emailParties/SellerParty/LegalEntity/ContactDetails/ElectronicMail
BT-42Seller Phoneaccount.phoneParties/SellerParty/LegalEntity/ContactDetails/Telephone
Seller Websiteaccount.websiteParties/SellerParty/LegalEntity/ContactDetails/WebAddress
BT-41Seller Contact Personaccount.contact_personParties/SellerParty/LegalEntity/ContactDetails/ContactPersons

Buyer Party (Receiver)

BTBusiness TermAPI FieldFacturae XPath
BT-44Buyer Nameinvoice.contact.nameParties/BuyerParty/LegalEntity/CorporateName (or Individual/...)
BT-48Buyer VAT IDinvoice.contact.tin_valueParties/BuyerParty/TaxIdentification/TaxIdentificationNumber
BT-50Buyer Streetinvoice.contact.addressParties/BuyerParty/LegalEntity/AddressInSpain/Address
BT-53Buyer Postal Codeinvoice.contact.postalcodeParties/BuyerParty/LegalEntity/AddressInSpain/PostCode
BT-52Buyer Cityinvoice.contact.cityParties/BuyerParty/LegalEntity/AddressInSpain/Town
BT-54Buyer Provinceinvoice.contact.provinceParties/BuyerParty/LegalEntity/AddressInSpain/Province
BT-55Buyer Countryinvoice.contact.countryParties/BuyerParty/LegalEntity/AddressInSpain/CountryCode
BT-58Buyer Emailinvoice.contact.emailParties/BuyerParty/LegalEntity/ContactDetails/ElectronicMail
BT-57Buyer Phoneinvoice.contact.phoneParties/BuyerParty/LegalEntity/ContactDetails/Telephone
BT-56Buyer Contact Personinvoice.contact.contact_personParties/BuyerParty/LegalEntity/ContactDetails/ContactPersons
Additional Contact Detailsinvoice.contact_additional_detailsParties/BuyerParty/LegalEntity/ContactDetails/AdditionalContactDetails
Notes:
  • Use AddressInSpain vs OverseasAddress depending on the country.
  • PartyIdentification is only emitted when the value is a numeric string up to 10 digits.
  • contact.phone, contact.contact_person, and contact_additional_details are not settable via the invoice API contact params; they are read from the stored Contact record.

Administrative Centres (Spanish Public Sector)

For invoicing Spanish public administrations (FACe), administrative centres can be set with DIR3 codes:

FieldAPI FieldFacturae XPath
Accounting Officeinvoice.ocParties/BuyerParty/AdministrativeCentres/AdministrativeCentre[RoleTypeCode='01']/CentreCode
Management Bodyinvoice.ogParties/BuyerParty/AdministrativeCentres/AdministrativeCentre[RoleTypeCode='02']/CentreCode
Processing Unitinvoice.utParties/BuyerParty/AdministrativeCentres/AdministrativeCentre[RoleTypeCode='03']/CentreCode
Proposing Bodyinvoice.opParties/BuyerParty/AdministrativeCentres/AdministrativeCentre[RoleTypeCode='04']/CentreCode
Delivery Location IDinvoice.delivery_location_idUsed as CentreCode for role 04 when op is not set
Centre 1-3 Namesinvoice.cin1_name ... invoice.cin3_nameAdministrativeCentre[RoleTypeCode='01'-'03']/Name
Centre 4 Nameinvoice.cin4_nameAdministrativeCentre[RoleTypeCode='04']/Name
Notes:
  • Each administrative centre also carries the address and contact details from the buyer party.
  • Delivery address fields (delivery_address, delivery_city, delivery_province, delivery_postalcode) populate the address of the RoleTypeCode 04 centre.

Taxes & Totals (Header)

BTBusiness TermAPI FieldFacturae XPath
BT-110VAT total (Outputs)(calculated)Invoices/Invoice/InvoiceTotals/TotalTaxOutputs + details in Invoices/Invoice/TaxesOutputs/Tax
Withheld (header)invoice.amounts_withheld_reason, invoice.withheld_percentInvoices/Invoice/InvoiceTotals/AmountsWithheld/(WithholdingReason|WithholdingRate|WithholdingAmount)
Gross amount before taxes(calculated)Invoices/Invoice/InvoiceTotals/TotalGrossAmountBeforeTaxes
BT-92Header Allowance Amountinvoice.discount_amountInvoices/Invoice/InvoiceTotals/GeneralDiscounts/Discount/DiscountAmount
BT-94Header Allowance Percentinvoice.discount_percentInvoices/Invoice/InvoiceTotals/GeneralDiscounts/Discount/DiscountRate
BT-97Header Allowance Reasoninvoice.discount_textInvoices/Invoice/InvoiceTotals/GeneralDiscounts/Discount/DiscountReason
BT-99Header Charge Amountinvoice.charge_amountInvoices/Invoice/InvoiceTotals/GeneralSurcharges/Charge/ChargeAmount
BT-104Header Charge Reasoninvoice.charge_reasonInvoices/Invoice/InvoiceTotals/GeneralSurcharges/Charge/ChargeReason
BT-113Prepaid Amountinvoice.payments_on_accountInvoices/Invoice/InvoiceTotals/PaymentsOnAccount/PaymentOnAccount/PaymentOnAccountAmount
Invoice total (payable)(calculated)Invoices/Invoice/InvoiceTotals/InvoiceTotal
Outstanding(calculated)Invoices/Invoice/InvoiceTotals/TotalOutstandingAmount
Executable(calculated)Invoices/Invoice/InvoiceTotals/TotalExecutableAmount
Reimbursable Expenses(from charges marked as reimbursable)Invoices/Invoice/InvoiceTotals/ReimbursableExpenses/ReimbursableExpense
Total Reimbursable Expenses(calculated)Invoices/Invoice/InvoiceTotals/TotalReimbursableExpenses
Notes:
  • TaxesOutputs/Tax/TaxTypeCode identifies the tax (e.g. 01 for VAT).

Invoice Line-Level Mapping

All attributes below are properties of objects in: invoice.invoice_lines_attributes[].

BTBusiness TermAPI Field (line)Facturae XPath
BT-153Item name/descriptiondescriptionInvoices/Invoice/Items/InvoiceLine/ItemDescription
BT-129Invoiced quantityquantity.../Quantity
BT-130Unit of measureunit.../UnitOfMeasure
BT-146Price amount (unit)price.../UnitPriceWithoutTax
BT-131Line extension amountextension_amount (or calculated).../GrossAmount (or .../TotalCost)
BT-155Seller Item IDarticle_code.../ArticleCode (Facturae 3.2 only)
BT-154Item notesnotes.../AdditionalLineItemInformation
BT-132Buyer line referencesequence_number.../SequenceNumber
BT-128Receiver transaction referenceponumber (fallback: invoice.ponumber).../ReceiverTransactionReference
File referencefile_reference (fallback: invoice.file_reference).../FileReference
File datefile_date.../FileDate
Delivery note numberdelivery_note_number (fallback: invoice.delivery_note_number).../DeliveryNotesReferences/DeliveryNote/DeliveryNoteNumber
Delivery note datedelivery_note_date (fallback: invoice.delivery_note_date).../DeliveryNotesReferences/DeliveryNote/DeliveryNoteDate
Issuer contract reference(from invoice.contract_number).../IssuerContractReference
Issuer contract dateinvoice.issuer_contract_date.../IssuerContractDate
Issuer transaction referenceissuer_transaction_reference.../IssuerTransactionReference
Issuer transaction dateissuer_transaction_date.../IssuerTransactionDate
Receiver contract referencereceiver_contract_reference (fallback: invoice.receiver_contract_reference).../ReceiverContractReference
Receiver contract datereceiver_contract_date.../ReceiverContractDate
Receiver transaction datereceiver_transaction_date.../ReceiverTransactionDate
BT-134Line Invoicing Period Startinvoicing_period_start.../LineItemPeriod/StartDate
BT-135Line Invoicing Period Endinvoicing_period_end.../LineItemPeriod/EndDate
BT-151Tax type code (per line)taxes_attributes[].category.../TaxesOutputs/Tax/TaxTypeCode
BT-152Tax percent (per line)taxes_attributes[].percent.../TaxesOutputs/Tax/TaxRate
BT-120Tax exemption/non-subject reasontaxes_attributes[].comment.../SpecialTaxableEvent/SpecialTaxableEventReason
Tax exemption/non-subject code(derived: '02' if category NS, else '01').../SpecialTaxableEvent/SpecialTaxableEventCode
BT-136Line Allowance Amountdiscount_amount.../DiscountsAndRebates/Discount/DiscountAmount
BT-138Line Allowance Percentdiscount_percent.../DiscountsAndRebates/Discount/DiscountRate
BT-139Line Allowance Reasondiscount_text.../DiscountsAndRebates/Discount/DiscountReason
BT-141Line Charge Amountcharge_amount.../Charges/Charge/ChargeAmount
BT-144Line Charge Reasoncharge_reason.../Charges/Charge/ChargeReason
Notes:
  • Several line-level fields are packed into AdditionalLineItemInformation: article_code2, classification_code, article_code_buyer, contact_reference.
  • issuer_contract_date is not in the API permitted params; it is derived from stored data.

Additional Information Fields

Several fields that have dedicated XML elements in UBL/CII are packed into InvoiceAdditionalInformation in Facturae. These are appended to invoice.extra_info:

BTAPI FieldPrefix in AdditionalInformation
BT-14invoice.sales_order_reference"Sales order reference:"
BT-15invoice.receiving_advice_reference"Receiving advice reference:"
BT-20invoice.payment_terms"Payment terms:"
BT-83invoice.remittance_information"Remittance information:"
BT-90invoice.bank_assigned_creditor_reference"Bank assigned creditor reference:"
BT-89invoice.mandate_reference_identifier"Mandate reference identifier:"
BT-19invoice.buyer_accounting_reference"Buyer accounting reference:"
BT-72invoice.delivery_date (when tax_point_date is also present)"Delivery date:"

Factoring Assignment Data

For invoice factoring (cession of credit), the following fields populate the FactoringAssignmentData block:

FieldAPI FieldFacturae XPath
Assignee tax IDinvoice.fa_taxcodeFactoringAssignmentData/Assignee/TaxIdentification/TaxIdentificationNumber
Assignee nameinvoice.fa_nameFactoringAssignmentData/Assignee/LegalEntity/CorporateName
Assignee addressinvoice.fa_addressFactoringAssignmentData/Assignee/LegalEntity/AddressInSpain/Address
Assignee postal codeinvoice.fa_postcodeFactoringAssignmentData/Assignee/LegalEntity/AddressInSpain/PostCode
Assignee cityinvoice.fa_townFactoringAssignmentData/Assignee/LegalEntity/AddressInSpain/Town
Assignee provinceinvoice.fa_provinceFactoringAssignmentData/Assignee/LegalEntity/AddressInSpain/Province
Assignee countryinvoice.fa_countryFactoringAssignmentData/Assignee/LegalEntity/AddressInSpain/CountryCode
Payment due dateinvoice.fa_duedateFactoringAssignmentData/PaymentDetails/Installment/InstallmentDueDate
Payment amountinvoice.fa_importFactoringAssignmentData/PaymentDetails/Installment/InstallmentAmount
Payment methodinvoice.fa_payment_methodFactoringAssignmentData/PaymentDetails/Installment/PaymentMeans
Assignee IBANinvoice.fa_ibanFactoringAssignmentData/PaymentDetails/Installment/AccountToBeCredited/IBAN
Assignee BICinvoice.fa_bicFactoringAssignmentData/PaymentDetails/Installment/AccountToBeCredited/BIC
Factoring clausesinvoice.fa_clausesFactoringAssignmentData/FactoringAssignmentClauses
Additional infoinvoice.fa_infoFactoringAssignmentData/Assignee/LegalEntity/ContactDetails/AdditionalContactDetails
Bank Codeinvoice.fa_bank_codeFactoringAssignmentData/PaymentDetails/Installment/AccountToBeCredited/BankCode