Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up XML template files #23

Merged
merged 6 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions facturx/facturx.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def __getitem__(self, field_name):
value = datetime.strptime(value, '%Y%m%d')
return value


def __setitem__(self, field_name, value):
path = self.flavor._get_xml_path(field_name)
res = self.xml.xpath(path, namespaces=self._namespaces)
Expand All @@ -129,7 +128,6 @@ def is_valid(self):
"""
pass


def write_pdf(self, path):
pdfwriter = FacturXPDFWriter(self)
with open(path, 'wb') as output_f:
Expand Down
140 changes: 70 additions & 70 deletions facturx/flavors/factur-x/xml/basic.xml
Original file line number Diff line number Diff line change
@@ -1,165 +1,165 @@
<rsm:CrossIndustryInvoice xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<rsm:ExchangedDocumentContext>
<ram:BusinessProcessSpecifiedDocumentContextParameter>
<ram:ID>A1</ram:ID>
<ram:ID/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will lxml expand the tag again? I would have expected to see <ram:ID></ram:ID> for an empty tag.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the tags are expanded when any data is added. It's good practice to have empty tags as <tag/> rather than <tag></tag>.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are expanded it's fine.

</ram:BusinessProcessSpecifiedDocumentContextParameter>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:factur-x.eu:1p0:basic</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID>2017-TEST-04</ram:ID>
<ram:TypeCode>380</ram:TypeCode>
<ram:ID/>
<ram:TypeCode>0</ram:TypeCode>
<ram:IssueDateTime>
<udt:DateTimeString format="102">20171031</udt:DateTimeString>
<udt:DateTimeString format="102">00000000</udt:DateTimeString>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so many 00 and not an empty tag?

Copy link
Author

@duskybomb duskybomb Jun 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because dates have 8 digits?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use an empty tag, like you did with all other tags? You said that's good practice. Why add placeholders for this one?

</ram:IssueDateTime>
<ram:IncludedNote>
<ram:Content>FOURNISSEUR F SARL au capital de 50 000 EUR</ram:Content>
<ram:SubjectCode>REG</ram:SubjectCode>
<ram:Content/>
<ram:SubjectCode/>
</ram:IncludedNote>
<ram:IncludedNote>
<ram:Content>RCS NANTERRE 999 888 777</ram:Content>
<ram:SubjectCode>ABL</ram:SubjectCode>
<ram:Content/>
<ram:SubjectCode/>
</ram:IncludedNote>
<ram:IncludedNote>
<ram:Content>Taux de pénalités de retard de paiement égal au taux de refinancement de la Banque Centrale Européenne majorée de 10 points de pourcentage</ram:Content>
<ram:SubjectCode>PMD</ram:SubjectCode>
<ram:Content/>
<ram:SubjectCode/>
</ram:IncludedNote>
<ram:IncludedNote>
<ram:Content>Retard de paiement: Indemnité forfaitaire pour frais de recouvrement de 40 Euros</ram:Content>
<ram:SubjectCode>PMT</ram:SubjectCode>
<ram:Content/>
<ram:SubjectCode/>
</ram:IncludedNote>
<ram:IncludedNote>
<ram:Content>Aucun escompte en cas de paiement anticipé</ram:Content>
<ram:SubjectCode>AAB</ram:SubjectCode>
<ram:Content/>
<ram:SubjectCode/>
</ram:IncludedNote>
</rsm:ExchangedDocument>
<rsm:SupplyChainTradeTransaction>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>1</ram:LineID>
<ram:LineID>0</ram:LineID>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be 0. It's the line numbering.

</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:GlobalID schemeID="0160">1234567890123</ram:GlobalID>
<ram:Name>PRODUIT 1</ram:Name>
<ram:GlobalID schemeID="0160">0</ram:GlobalID>
<ram:Name/>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount currencyID="EUR">91.00</ram:ChargeAmount>
<ram:ChargeAmount currencyID="EUR">0.0</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="PCE">181</ram:BilledQuantity>
<ram:BilledQuantity unitCode="PCE">0</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>20</ram:RateApplicablePercent>
<ram:TypeCode/>
<ram:CategoryCode/>
<ram:RateApplicablePercent>0</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount currencyID="EUR">16471.00</ram:LineTotalAmount>
<ram:LineTotalAmount currencyID="EUR">0.0</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>CodeSERVICE A</ram:BuyerReference>
<ram:BuyerReference/>
<ram:SellerTradeParty>
<ram:ID schemeID="0002">99988877900017</ram:ID>
<ram:GlobalID schemeID="0002">99988877900017</ram:GlobalID>
<ram:Name>FOURNISSEUR F</ram:Name>
<ram:ID schemeID="0002">0</ram:ID>
<ram:GlobalID schemeID="0002">0</ram:GlobalID>
<ram:Name/>
<ram:SpecifiedLegalOrganization>
<ram:ID schemeID="0002">99988877900017</ram:ID>
<ram:ID schemeID="0002">0</ram:ID>
</ram:SpecifiedLegalOrganization>
<ram:PostalTradeAddress>
<ram:PostcodeCode>92120</ram:PostcodeCode>
<ram:LineOne>25 rue du Fournisseur</ram:LineOne>
<ram:CityName>MONTROUGE</ram:CityName>
<ram:CountryID>FR</ram:CountryID>
<ram:PostcodeCode>0</ram:PostcodeCode>
<ram:LineOne/>
<ram:CityName/>
<ram:CountryID/>
</ram:PostalTradeAddress>
<ram:URIUniversalCommunication>
<ram:URIID schemeID="SMTP">[email protected]</ram:URIID>
</ram:URIUniversalCommunication>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">FR34999888779</ram:ID>
<ram:ID schemeID="VA"/>
</ram:SpecifiedTaxRegistration>
</ram:SellerTradeParty>
<ram:BuyerTradeParty>
<ram:ID schemeID="0002">77788899100018</ram:ID>
<ram:Name>CLIENT 1</ram:Name>
<ram:ID schemeID="0002">0</ram:ID>
<ram:Name/>
<ram:SpecifiedLegalOrganization>
<ram:ID schemeID="0002">77788899100018</ram:ID>
<ram:ID schemeID="0002">0</ram:ID>
</ram:SpecifiedLegalOrganization>
<ram:PostalTradeAddress>
<ram:PostcodeCode>75015</ram:PostcodeCode>
<ram:LineOne>1 rue du Client</ram:LineOne>
<ram:CityName>PARIS</ram:CityName>
<ram:CountryID>FR</ram:CountryID>
<ram:PostcodeCode>0</ram:PostcodeCode>
<ram:LineOne/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you decide on using an empty tag vs. 0 as placeholder?

<ram:CityName/>
<ram:CountryID/>
</ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">FR51777888991</ram:ID>
<ram:ID schemeID="VA"/>
</ram:SpecifiedTaxRegistration>
</ram:BuyerTradeParty>
<ram:BuyerOrderReferencedDocument>
<ram:IssuerAssignedID>CDE234</ram:IssuerAssignedID>
<ram:IssuerAssignedID/>
</ram:BuyerOrderReferencedDocument>
<ram:ContractReferencedDocument>
<ram:IssuerAssignedID>CT12345</ram:IssuerAssignedID>
<ram:IssuerAssignedID/>
</ram:ContractReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery>
<ram:ActualDeliverySupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">20171023</udt:DateTimeString>
<udt:DateTimeString format="102">00000000</udt:DateTimeString>
</ram:OccurrenceDateTime>
</ram:ActualDeliverySupplyChainEvent>
<ram:DespatchAdviceReferencedDocument>
<ram:IssuerAssignedID>BL45</ram:IssuerAssignedID>
<ram:IssuerAssignedID/>
</ram:DespatchAdviceReferencedDocument>
</ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement>
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
<ram:InvoiceCurrencyCode/>
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>42</ram:TypeCode>
<ram:TypeCode>0</ram:TypeCode>
<ram:PayeePartyCreditorFinancialAccount>
<ram:IBANID>FR99 3122 1234 0000 9999 1234 008</ram:IBANID>
<ram:IBANID/>
</ram:PayeePartyCreditorFinancialAccount>
</ram:SpecifiedTradeSettlementPaymentMeans>
<ram:ApplicableTradeTax>
<ram:CalculatedAmount currencyID="EUR">3195.37</ram:CalculatedAmount>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:BasisAmount currencyID="EUR">15976.87</ram:BasisAmount>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:DueDateTypeCode>5</ram:DueDateTypeCode>
<ram:RateApplicablePercent>20</ram:RateApplicablePercent>
<ram:CalculatedAmount currencyID="EUR">0.0</ram:CalculatedAmount>
<ram:TypeCode/>
<ram:BasisAmount currencyID="EUR">0.0</ram:BasisAmount>
<ram:CategoryCode/>
<ram:DueDateTypeCode>0</ram:DueDateTypeCode>
<ram:RateApplicablePercent>0</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeAllowanceCharge>
<ram:ChargeIndicator>
<udt:Indicator>false</udt:Indicator>
<udt:Indicator/>
</ram:ChargeIndicator>
<ram:CalculationPercent>3.00</ram:CalculationPercent>
<ram:BasisAmount currencyID="EUR">16471.00</ram:BasisAmount>
<ram:ActualAmount currencyID="EUR">494.13</ram:ActualAmount>
<ram:Reason>Remise négociation commerciale</ram:Reason>
<ram:CalculationPercent>0.0</ram:CalculationPercent>
<ram:BasisAmount currencyID="EUR">0.0</ram:BasisAmount>
<ram:ActualAmount currencyID="EUR">0.0</ram:ActualAmount>
<ram:Reason/>
<ram:CategoryTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:DueDateTypeCode>5</ram:DueDateTypeCode>
<ram:RateApplicablePercent>20</ram:RateApplicablePercent>
<ram:TypeCode/>
<ram:CategoryCode/>
<ram:DueDateTypeCode>0</ram:DueDateTypeCode>
<ram:RateApplicablePercent>0</ram:RateApplicablePercent>
</ram:CategoryTradeTax>
</ram:SpecifiedTradeAllowanceCharge>
<ram:SpecifiedTradePaymentTerms>
<ram:DueDateDateTime>
<udt:DateTimeString format="102">20171130</udt:DateTimeString>
<udt:DateTimeString format="102">00000000</udt:DateTimeString>
</ram:DueDateDateTime>
</ram:SpecifiedTradePaymentTerms>
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:LineTotalAmount currencyID="EUR">16471.00</ram:LineTotalAmount>
<ram:AllowanceTotalAmount currencyID="EUR">494.13</ram:AllowanceTotalAmount>
<ram:TaxBasisTotalAmount currencyID="EUR">15976.87</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">3195.37</ram:TaxTotalAmount>
<ram:GrandTotalAmount currencyID="EUR">19172.24</ram:GrandTotalAmount>
<ram:DuePayableAmount currencyID="EUR">19172.24</ram:DuePayableAmount>
<ram:LineTotalAmount currencyID="EUR">0.0</ram:LineTotalAmount>
<ram:AllowanceTotalAmount currencyID="EUR">0.0</ram:AllowanceTotalAmount>
<ram:TaxBasisTotalAmount currencyID="EUR">0.0</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">0.0</ram:TaxTotalAmount>
<ram:GrandTotalAmount currencyID="EUR">0.0</ram:GrandTotalAmount>
<ram:DuePayableAmount currencyID="EUR">0.0</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
Expand Down
Loading