invoice-x / factur-x-ng

Python lib for Factur-X, the e-invoicing standard for France and Germany
Other
34 stars 8 forks source link

Clean up XML template files #23

Closed duskybomb closed 6 years ago

duskybomb commented 6 years ago

Let's discuss it here. Issue #22

duskybomb commented 6 years ago

What should we do about this?

m3nu commented 6 years ago

I see you implemented a function to remove existing XML data from sample files. I don't think this is transparent enough since I can't easily look at the empty XML files and validate they are empty.

It would be better to split the current XML files into 2 folders. One for samples (to view and develop with) and one for empty templates.

duskybomb commented 6 years ago

Okay, so this way we don't need to create any function and can just copy empty XML templates.

m3nu commented 6 years ago

Yes. I think this is the most transparent solution. So we can just look at the empty XML and validate it. In the accounting industry, no mistake can happen. Like forgetting to remove some old value from an XML template. That's what I meant from the start. From the way you implemented it, I see now that I wasn't clear enough on the implementation step.

duskybomb commented 6 years ago

Like this?

<?xml version="1.0" encoding="UTF-8"?>
<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/>
        </ram:BusinessProcessSpecifiedDocumentContextParameter>
        <ram:GuidelineSpecifiedDocumentContextParameter>
            <ram:ID/>
        </ram:GuidelineSpecifiedDocumentContextParameter>
    </rsm:ExchangedDocumentContext>
    <rsm:ExchangedDocument>
        <ram:ID/>
        <ram:TypeCode>0</ram:TypeCode>
        <ram:IssueDateTime>
            <udt:DateTimeString format="102">00000000</udt:DateTimeString>
        </ram:IssueDateTime>
    </rsm:ExchangedDocument>
    <rsm:SupplyChainTradeTransaction>
        <ram:ApplicableHeaderTradeAgreement>
            <ram:BuyerReference/>
            <ram:SellerTradeParty>
                <ram:Name/>
                <ram:SpecifiedLegalOrganization>
                    <ram:ID schemeID="0002">0</ram:ID>
                </ram:SpecifiedLegalOrganization>
                <ram:PostalTradeAddress>
                    <ram:CountryID/>
                </ram:PostalTradeAddress>
                <ram:SpecifiedTaxRegistration>
                    <ram:ID schemeID="VA"/>
                </ram:SpecifiedTaxRegistration>
            </ram:SellerTradeParty>
            <ram:BuyerTradeParty>
                <ram:Name/>
                <ram:SpecifiedLegalOrganization>
                    <ram:ID schemeID="0002">0</ram:ID>
                </ram:SpecifiedLegalOrganization>
            </ram:BuyerTradeParty>
            <ram:BuyerOrderReferencedDocument>
                <ram:IssuerAssignedID/>
            </ram:BuyerOrderReferencedDocument>
        </ram:ApplicableHeaderTradeAgreement>
        <ram:ApplicableHeaderTradeDelivery/>
        <ram:ApplicableHeaderTradeSettlement>
            <ram:InvoiceCurrencyCode/>
            <ram:SpecifiedTradeSettlementHeaderMonetarySummation>
                <ram:TaxBasisTotalAmount currencyID="">0.0</ram:TaxBasisTotalAmount>
                <ram:TaxTotalAmount currencyID="">0.0</ram:TaxTotalAmount>
                <ram:GrandTotalAmount currencyID="">0.0</ram:GrandTotalAmount>
                <ram:DuePayableAmount currencyID="">0.0</ram:DuePayableAmount>
            </ram:SpecifiedTradeSettlementHeaderMonetarySummation>
        </ram:ApplicableHeaderTradeSettlement>
    </rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
duskybomb commented 6 years ago

I haven't tested all but minimum.xml. And it works just fine.

m3nu commented 6 years ago

Please provide a minimal example that I can run to see that the empty XML templates can be filled again. Can post it here as comment.

duskybomb commented 6 years ago

You can try this to check:

from facturx import *
factx = FacturX('invoice.pdf')  # where invoice.pdf doesn't contain any embedded metadata
factx['seller'] = 'Manu'
m3nu commented 6 years ago

Still need major changes before merging. See comments and

duskybomb commented 6 years ago

Can you provide me some resource from where I can understand the XML document?

m3nu commented 6 years ago

The XML represents an invoice. You can look at the sample invoice PDF content and see how they relate to the XML. Then try again.

duskybomb commented 6 years ago

Here are the things I have gathered till know:

m3nu commented 6 years ago

I don't know what you mean with your last comment. The stuff you write about the "only four fields can be changed" is simply not true. Maybe you want to check again.

m3nu commented 6 years ago

It seems you are mixing up the module for creating the PDF with the module responsible for the XML document. That's totally unrelated...

m3nu commented 6 years ago

It seems like you didn't adjust the code to use the new empty templates you created. That would be here.

duskybomb commented 6 years ago

I don't think there is any need to adjust the code, because the old templates are moved to sample and the new empty templates have been added in-place of older ones.