Modules
factur-x
Module to process Factur-X
factur-x
Module to process Factur-X
handle attached invoices
When an invoice is dropped on a craft form, you can retrieve any fields:
FACTURX_ATTACHMENT = "factur-x.xml"
attachements = get_attachments(upload_file, schema=False)
if FACTURX_ATTACHMENT in attachements:
fx = lib.get_facturx_dict(attachements[FACTURX_ATTACHMENT])
seller_name = fx["rsm CrossIndustryInvoice"]["rsm SupplyChainTradeTransaction"][
"ApplicableHeaderTradeAgreement"
]["SellerTradeParty"]["Name"]
buyer_name = fx["rsm CrossIndustryInvoice"]["rsm SupplyChainTradeTransaction"][
"ApplicableHeaderTradeAgreement"
]["BuyerTradeParty"]["Name"]
return UploadStatus(
status="accepted",
msg="Facture ajoutée",
stored=False,
form_overload={
"nom": seller_name,
"nom_client": buyer_name,
},
)
Here is a sample full factur-x payload as a Python dict:
{
"rsm CrossIndustryInvoice": {
"rsm ExchangedDocumentContext": {
"BusinessProcessSpecifiedDocumentContextParameter": {"ID": None},
"GuidelineSpecifiedDocumentContextParameter": {
"ID": "urn:factur-x.eu: 1p0:minimum"
},
},
"rsm ExchangedDocument": {
"ID": "00000001",
"TypeCode": "380",
"IssueDateTime": {
"urn:un:unece:uncefact:data:standard:UnqualifiedDataType: 100 DateTimeString": {
"@format": "102",
"@xmlns": {
"rsm": "urn:un:unece:uncefact:data:standard:CrossIndustryInvoice: 100",
"qdt": "urn:un:unece:uncefact:data:standard:QualifiedDataType: 100",
"ram": "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity: 100",
"udt": "urn:un:unece:uncefact:data:standard:UnqualifiedDataType: 100",
"xsi": "http: //www.w3.org/2001/XMLSchema-instance",
},
"#text": "20240709",
}
},
},
"rsm SupplyChainTradeTransaction": {
"ApplicableHeaderTradeAgreement": {
"SellerTradeParty": {
"Name": "BATITOUT",
"SpecifiedLegalOrganization": {
"ID": {"@schemeID": "0002", "#text": "91235689400010"}
},
"PostalTradeAddress": {
"PostcodeCode": None,
"LineOne": None,
"LineTwo": None,
"CityName": None,
"CountryID": "FR",
"CountrySubDivisionName": None,
},
"SpecifiedTaxRegistration": {
"ID": {"@schemeID": "VA", "#text": "FR14912356894"}
},
},
"BuyerTradeParty": {
"Name": "Dumont Micheline",
"SpecifiedLegalOrganization": {"ID": {"@schemeID": "0002"}},
"PostalTradeAddress": {
"PostcodeCode": None,
"LineOne": None,
"LineTwo": None,
"CityName": None,
"CountryID": None,
"CountrySubDivisionName": None,
},
"SpecifiedTaxRegistration": {"ID": {"@schemeID": "VA"}},
},
"BuyerOrderReferencedDocument": {"IssuerAssignedID": None},
},
"ApplicableHeaderTradeDelivery": None,
"ApplicableHeaderTradeSettlement": {
"InvoiceCurrencyCode": "EUR",
"SpecifiedTradeSettlementHeaderMonetarySummation": {
"TaxBasisTotalAmount": "12915.00",
"TaxTotalAmount": {"@currencyID": "EUR", "#text": "2583.00"},
"GrandTotalAmount": "15498.00",
"DuePayableAmount": "9800.00",
},
},
},
}
}
Old module
Previous versions to be deprecated:
- ref/common/factur_x/checkmodules/ffx_facture
- ref/common/factur_x/checkmodules/ffx_client
- ref/common/factur_x/checkmodules/ffx_fournisseur