frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
20.37k stars 7.08k forks source link

[Proposal] E-Invoicing for Italy #16259

Closed gaurav-naik closed 5 years ago

gaurav-naik commented 5 years ago

Feature Goals (Use cases)

E-Invoicing is mandatory for Italian companies from January 1 2019. #15468

Goals:

  1. Generate data from Sales Invoices and returns for e-invoicing as per specifications.
  2. Export generated data as XML (zipped for multiple invoices) for uploading to government portals.

Simplified structure of XML output with important fields:

    <InvoiceHeader>
        <TransmissionData></TransmissionData>
        <CompanyInfo></CompanyInfo>
        <CustomerInfo></CustomerInfo>
    </InvoiceHeader>
    <InvoiceBody>
        <Items>
            <Item>
                <TaxRate>
            </Item>
        </Items>
        <Summary>
            <TaxRate>
            <TaxAmount>
            <TaxableAmount>
        </Summary>
    </InvoiceBody>
    ...
    <InvoiceBody>
        Details of n-th invoice
    </InvoiceBody>

Detailed XML structure (English Version is not up to date.):

Sample with comments IT0001234567_00024.zip

Additional samples (https://www.fatturapa.gov.it/export/fatturazione/it/a-3.htm)

Additional DocTypes and fields (with fieldtype, etc) if any.

DocTypes

    Natura {name, description}
    Regime Fiscale {name, description}

Custom Fields

Customer

    codice_fiscale: Data #applicable for Individual, different from tax_id
    electronic_invoicing_info: Code #Valid XML for Customer

Company

    regime_fiscale: Link (Fiscal System/Fiscal Category) (Type of Company?)
    esigibilita_iva: Select (How should VAT be collected)
    electronic_invoicing_info: Code #Valid XML for Company

Sales Taxes and Charges

    natura:Link (Explanation as to why zero VAT has been applied)

Item Tax

    natura:Link (Explanation as to why zero VAT has been applied)

Sales Invoice

    sb_electronic_invoicing: Section Break
    electronic_invoicing_info: Code

Discovery (how will the user find the feature you are building)

Button "Export e-invoices" in the Menu on Sales Invoice List and Sales Invoice

Business Logic

On Save (Customer, Company, Sales Invoice):

    Generate valid XML as per specifications and store in Sales Invoice in electronic_invoicing_output
    Code can be on doctypes or regional/italy/utils.py

Bulk Export:

On clicking "Export e-invoices" on Sales Invoice List:

    for company, customer in invoices:
        fetch and collate stored XML from company, customer, invoice
        save XML file
    zip all saved XML files and download.

Code can be in regional/italy/utils.py

Single Export:

    on clicking "Export e-invoices" on Sales Invoice
        collate stored XML
        save and download XML file (like pdf p)

Validations

Mandatory

Customer:
    Default address
    Tax ID or Codice Fiscale
Company
    Default address
    Tax ID
    Regime Fiscale
Invoice
    Taxes and Charges?

Calculations

  1. Tax calculations for each tax rate applicable in Sales Invoice
    1. If one item is at 22% and another is at 10%, Summary should contain two rows.

PR is underway

@mascor @cosimot

cosimot commented 5 years ago

Hello! Is there any chance to develop this feature urgently?

umairsy commented 5 years ago

Deliverable:

cosimot commented 5 years ago

Attention: the EU regulations do not accept Sales Invoice Numbers with -1 or -2, so if the invoice is SI18-00018-2 it must be exported like SI18-00018. In case the SI-00018 is already sent to the Interchange System we must make a Credit Note and a new Sales Invoice.

cosimot commented 5 years ago

@umairsy @gaurav-naik Table View translated_1.2.1.zip Here is the document with translations for each field and options

cosimot commented 5 years ago

@gaurav-naik I think this can be closed now

fthobe commented 4 years ago

Hi @gaurav-naik @cosimot ,

thank you for your awesome work. I am stuck with two questions:

1) it would have seemed more logical to place the information in the billing address to cover multiple billing addresses per customer, is there a particular reason why you choose to place the requiered fields inside the customer?

2) is it possible to fully deactivate the validations of the feature if somebody implemented his / her own implementation of e-invoicing?

cosimot commented 4 years ago

Hello @fthobe ! actually the feature let you export the addresses into the Sales Invoice itself, in our side we have no issue. About validation I don't know really. Another good thing is that we also have developed the passive invoice import, the pull request is done and merged into developement and hope it will be released soon.