summaryrefslogtreecommitdiff
path: root/addons/l10n_it_edi/tests
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/l10n_it_edi/tests
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/l10n_it_edi/tests')
-rw-r--r--addons/l10n_it_edi/tests/__init__.py4
-rw-r--r--addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml113
-rw-r--r--addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml.p7mbin0 -> 7083 bytes
-rw-r--r--addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_DT_001.xml71
-rw-r--r--addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_RC_001.xml72
-rw-r--r--addons/l10n_it_edi/tests/test_ir_mail_server.py160
6 files changed, 420 insertions, 0 deletions
diff --git a/addons/l10n_it_edi/tests/__init__.py b/addons/l10n_it_edi/tests/__init__.py
new file mode 100644
index 00000000..c2bcfc21
--- /dev/null
+++ b/addons/l10n_it_edi/tests/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import test_ir_mail_server
diff --git a/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml
new file mode 100644
index 00000000..936b6d4a
--- /dev/null
+++ b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:FatturaElettronica versione="FPR12" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd">
+ <FatturaElettronicaHeader>
+ <DatiTrasmissione>
+ <IdTrasmittente>
+ <IdPaese>IT</IdPaese>
+ <IdCodice>01234560157</IdCodice>
+ </IdTrasmittente>
+ <ProgressivoInvio>00001</ProgressivoInvio>
+ <FormatoTrasmissione>FPR12</FormatoTrasmissione>
+ <CodiceDestinatario>ABC1234</CodiceDestinatario>
+ <ContattiTrasmittente/>
+ </DatiTrasmissione>
+ <CedentePrestatore>
+ <DatiAnagrafici>
+ <IdFiscaleIVA>
+ <IdPaese>IT</IdPaese>
+ <IdCodice>01234560157</IdCodice>
+ </IdFiscaleIVA>
+ <Anagrafica>
+ <Denominazione>SOCIETA' ALPHA SRL</Denominazione>
+ </Anagrafica>
+ <RegimeFiscale>RF19</RegimeFiscale>
+ </DatiAnagrafici>
+ <Sede>
+ <Indirizzo>VIALE ROMA 543</Indirizzo>
+ <CAP>07100</CAP>
+ <Comune>SASSARI</Comune>
+ <Provincia>SS</Provincia>
+ <Nazione>IT</Nazione>
+ </Sede>
+ </CedentePrestatore>
+ <CessionarioCommittente>
+ <DatiAnagrafici>
+ <CodiceFiscale>01234560157</CodiceFiscale>
+ <Anagrafica>
+ <Denominazione>DITTA BETA</Denominazione>
+ </Anagrafica>
+ </DatiAnagrafici>
+ <Sede>
+ <Indirizzo>VIA TORINO 38-B</Indirizzo>
+ <CAP>00145</CAP>
+ <Comune>ROMA</Comune>
+ <Provincia>RM</Provincia>
+ <Nazione>IT</Nazione>
+ </Sede>
+ </CessionarioCommittente>
+ </FatturaElettronicaHeader>
+ <FatturaElettronicaBody>
+ <DatiGenerali>
+ <DatiGeneraliDocumento>
+ <TipoDocumento>TD01</TipoDocumento>
+ <Divisa>EUR</Divisa>
+ <Data>2014-12-18</Data>
+ <Numero>01234567890</Numero>
+ <Causale>LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR SSSSSSSSSSSSSS</Causale>
+ <Causale>SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA BBBBBBBBBBBBBBBBB</Causale>
+ </DatiGeneraliDocumento>
+ <DatiOrdineAcquisto>
+ <RiferimentoNumeroLinea>1</RiferimentoNumeroLinea>
+ <IdDocumento>66685</IdDocumento>
+ <NumItem>1</NumItem>
+ </DatiOrdineAcquisto>
+ <DatiContratto>
+ <RiferimentoNumeroLinea>1</RiferimentoNumeroLinea>
+ <IdDocumento>01234567890</IdDocumento>
+ <Data>2012-09-01</Data>
+ <NumItem>5</NumItem>
+ <CodiceCUP>01234567890abc</CodiceCUP>
+ <CodiceCIG>456def</CodiceCIG>
+ </DatiContratto>
+ <DatiTrasporto>
+ <DatiAnagraficiVettore>
+ <IdFiscaleIVA>
+ <IdPaese>IT</IdPaese>
+ <IdCodice>24681012141</IdCodice>
+ </IdFiscaleIVA>
+ <Anagrafica>
+ <Denominazione>Trasporto spa</Denominazione>
+ </Anagrafica>
+ </DatiAnagraficiVettore>
+ <DataOraConsegna>2012-10-22T16:46:12.000+02:00</DataOraConsegna>
+ </DatiTrasporto>
+ </DatiGenerali>
+ <DatiBeniServizi>
+ <DettaglioLinee>
+ <NumeroLinea>1</NumeroLinea>
+ <Descrizione>DESCRIZIONE DELLA FORNITURA</Descrizione>
+ <Quantita>5.00</Quantita>
+ <PrezzoUnitario>1.00</PrezzoUnitario>
+ <PrezzoTotale>5.00</PrezzoTotale>
+ <AliquotaIVA>22.00</AliquotaIVA>
+ </DettaglioLinee>
+ <DatiRiepilogo>
+ <AliquotaIVA>22.00</AliquotaIVA>
+ <ImponibileImporto>5.00</ImponibileImporto>
+ <Imposta>1.10</Imposta>
+ <EsigibilitaIVA>I</EsigibilitaIVA>
+ </DatiRiepilogo>
+ </DatiBeniServizi>
+ <DatiPagamento>
+ <CondizioniPagamento>TP01</CondizioniPagamento>
+ <DettaglioPagamento>
+ <ModalitaPagamento>MP01</ModalitaPagamento>
+ <DataScadenzaPagamento>2015-01-30</DataScadenzaPagamento>
+ <ImportoPagamento>6.10</ImportoPagamento>
+ </DettaglioPagamento>
+ </DatiPagamento>
+ </FatturaElettronicaBody>
+</p:FatturaElettronica>
diff --git a/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml.p7m b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml.p7m
new file mode 100644
index 00000000..ecb48417
--- /dev/null
+++ b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01.xml.p7m
Binary files differ
diff --git a/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_DT_001.xml b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_DT_001.xml
new file mode 100644
index 00000000..10788771
--- /dev/null
+++ b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_DT_001.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="DT_v1.0.xsl"?>
+<types:NotificaDecorrenzaTermini xmlns:types="http://www.fatturapa.gov.it/sdi/messaggi/v1.0" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" IntermediarioConDupliceRuolo="Si" versione="1.0" xsi:schemaLocation="http://www.fatturapa.gov.it/sdi/messaggi/v1.0 MessaggiTypes_v1.0.xsd http://www.w3.org/2000/09/xmldsig# xmldsig-core-schema.xsd">
+ <IdentificativoSdI>111</IdentificativoSdI>
+ <NomeFile>IT01234567890_FPR01.xml</NomeFile>
+ <Descrizione>Notifica di esempio</Descrizione>
+ <MessageId>123456</MessageId>
+ <Note>Esempio</Note>
+ <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature1">
+ <ds:SignedInfo>
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
+ <ds:Reference Id="reference-document" URI="">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
+ <XPath xmlns="http://www.w3.org/2002/06/xmldsig-filter2" Filter="subtract">/descendant::ds:Signature</XPath>
+ </ds:Transform>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+ <ds:DigestValue>g6h8KnGd+Y4DCdnGk5oIUbBwjJB3MMGlyizaFyCqH7I=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference Id="reference-signedpropeties" Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedProperties_1">
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+ <ds:DigestValue>LkOlfB97QK/evb7mYg+KkxW3BSiZre63y3Qeh/rV28E=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference Id="reference-keyinfo" URI="#KeyInfoId">
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+ <ds:DigestValue>BaZyFTXyxM8aIJhtiemem1lEwKR75ksXb33lsMqD89w=</ds:DigestValue>
+ </ds:Reference>
+ </ds:SignedInfo>
+ <ds:SignatureValue Id="SignatureValue1">
+Z8/Kt/ZF/syaHxYr6/qoTz+nTJe3IV1m9Hj3WPOl1CZ/p5intUORW0IinpMum4rvPkLYpKPVbi39
+WCJujEqVOVFw5xezZlwmrRghmUeyTyKazK7mKEEMXCad+FGCZ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
+bmFuemUuaXQvY24lM2RDQSUyMEFnZW56aWElMjBkZWxsZSUyMEVudHJhdGUsb3UlM2RTZXJ2aXpp
+JTIwVGVsZW1hdGljaSxvJTNkQWdlbnppYSUyMGRlbGxlJTIwRW50cmF0ZSxjJTNkaXQ/Y2VydGlm
+aWNhdGVSZXZvY2F0aW9uTGlzdDAdBgNVHQ4EFgQUn+JY07NI6xlrCUXERiHoFFN66dkwDQYJKoZI
+hvcNAQEFBQADggEBALZ0po2uLhLyZ8uiVfQUCAQd8s5o8ZJw2mcgZc/iaoNmDfcslZnTLWeuT6Gr
+UFgG0uc1rY0UwWx/R1UOyc0ZesRo7Z6+kFmVubT1tbjLMuLjjUIyt4zWeNjf4PwNS0+s6Y6eC8tx
+fOJmQNGQIbujWhAejoIteG01ciGeeII6AMnGK8KvbCA0UZmWl3Bou49zWajiEjtHFGkq/WNfDwRa
+Fd4UWjR+UWS3rLahV7iOfh/+Yy7h1F0RzQuPJk7TCm7iHyc9QtgwxHHCmknRyNXMv6DeTOfK8ciq
+uFWd6DasmblXLUm+uqhsWVRIkj2Bz63bpjuJU+8ptRfxHrVnzyCr9M4=
+</ds:X509Certificate>
+ </ds:X509Data>
+ </ds:KeyInfo>
+ <ds:Object>
+ <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="#Signature1">
+ <xades:SignedProperties Id="SignedProperties_1">
+ <xades:SignedSignatureProperties>
+ <xades:SigningTime>2014-06-05T14:27:51Z</xades:SigningTime>
+ </xades:SignedSignatureProperties>
+ </xades:SignedProperties>
+ </xades:QualifyingProperties>
+ </ds:Object>
+ </ds:Signature>
+</types:NotificaDecorrenzaTermini>
diff --git a/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_RC_001.xml b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_RC_001.xml
new file mode 100644
index 00000000..ab0725e4
--- /dev/null
+++ b/addons/l10n_it_edi/tests/expected_xmls/IT01234567890_FPR01_RC_001.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="RC_v1.0.xsl"?>
+<types:RicevutaConsegna xmlns:types="http://www.fatturapa.gov.it/sdi/messaggi/v1.0" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" IntermediarioConDupliceRuolo="Si" versione="1.0" xsi:schemaLocation="http://www.fatturapa.gov.it/sdi/messaggi/v1.0 MessaggiTypes_v1.0.xsd ">
+ <IdentificativoSdI>111</IdentificativoSdI>
+ <NomeFile>IT01234567890_FPR01.xml</NomeFile>
+ <DataOraRicezione>2013-06-06T12:00:00Z</DataOraRicezione>
+ <DataOraConsegna>2013-06-06T12:01:00Z</DataOraConsegna>
+ <Destinatario>
+ <Codice>AAA111</Codice>
+ <Descrizione>Amministrazione di prova</Descrizione>
+ </Destinatario>
+ <MessageId>123456</MessageId>
+ <Note>Esempio</Note>
+ <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature1">
+ <ds:SignedInfo>
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
+ <ds:Reference Id="reference-document" URI="">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
+ <XPath xmlns="http://www.w3.org/2002/06/xmldsig-filter2" Filter="subtract">/descendant::ds:Signature</XPath>
+ </ds:Transform>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+ <ds:DigestValue>c+5ntDV6t4+PxIKEU6rbCUGu3ne9RMxoADu4yK4XIak=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference Id="reference-signedpropeties" Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedProperties_1">
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+ <ds:DigestValue>AhiGZ+LPENybg4dQwMwjg0Nxdxzu+3M5i0w+UI6X89E=</ds:DigestValue>
+ </ds:Reference>
+ <ds:Reference Id="reference-keyinfo" URI="#KeyInfoId">
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+ <ds:DigestValue>BaZyFTXyxM8aIJhtiemem1lEwKR75ksXb33lsMqD89w=</ds:DigestValue>
+ </ds:Reference>
+ </ds:SignedInfo>
+ <ds:SignatureValue Id="SignatureValue1">G0FOBC+E8JKtJ5K2C+LBlvv3oarzkub7w2q5U1UQZnobWmFBbZ4WzgBNTMKUjdi2ZLkUpOSEwedf
+VLgl5SyhaKYY6TizDNbxededjUpqKhyIgaWBLc/iDI6H//x+3axnLU4WwFzdr3AwqPQjPuugGX07
+gOcjBHtbr7ie2Wr//o8=</ds:SignatureValue>
+ <ds:KeyInfo Id="KeyInfoId">
+ <ds:X509Data>
+ <ds:X509Certificate>MIIEYDCCA0igAwIBAgIDEIgbMA0GCSqGSIb3DQEBBQUAMG0xCzAJBgNVBAYTAklUMR4wHAYDVQQK
+ExVBZ2VuemlhIGRlbGxlIEVudHJhdGUxGzAZBgNVBAsTElNlcnZpemkgVGVsZW1hdGljaTEhMB8G
+A1UEAxMYQ0EgQWdlbnppYSBkZWxsZSBFbnRyYXRlMB4XDTExMDcwNDEzMTkyNFoXDTE0MDcwNDEz
+MTkyM1owdDELMAkGA1UEBhMCSVQxHjAcBgNVBAoTFUFnZW56aWEgZGVsbGUgRW50cmF0ZTEbMBkG
+A1UECxMSU2Vydml6aSBUZWxlbWF0aWNpMSgwJgYDVQQDEx9TaXN0ZW1hIEludGVyc2NhbWJpbyBG
+YXR0dXJhIFBBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMxOQj1dj6xgQBwB/S5naHvVqP
+FL25Y3GnAulrcaeO8ZFFK5fWKPgiBwfyJ7qdlzn/RF7y+w92XLgh9zROmN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+ <ds:Object>
+ <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="#Signature1">
+ <xades:SignedProperties Id="SignedProperties_1">
+ <xades:SignedSignatureProperties>
+ <xades:SigningTime>2014-06-05T14:24:28Z</xades:SigningTime>
+ </xades:SignedSignatureProperties>
+ </xades:SignedProperties>
+ </xades:QualifyingProperties>
+ </ds:Object>
+ </ds:Signature>
+</types:RicevutaConsegna>
diff --git a/addons/l10n_it_edi/tests/test_ir_mail_server.py b/addons/l10n_it_edi/tests/test_ir_mail_server.py
new file mode 100644
index 00000000..734c7246
--- /dev/null
+++ b/addons/l10n_it_edi/tests/test_ir_mail_server.py
@@ -0,0 +1,160 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import datetime
+import logging
+from collections import namedtuple
+from unittest.mock import patch
+import freezegun
+
+from odoo import tools
+from odoo.addons.account_edi.tests.common import AccountEdiTestCommon
+from odoo.addons.l10n_it_edi.tools.remove_signature import remove_signature
+
+_logger = logging.getLogger(__name__)
+
+
+class PecMailServerTests(AccountEdiTestCommon):
+ """ Main test class for the l10n_it_edi vendor bills XML import from a PEC mail account"""
+
+ fake_test_content = """<?xml version="1.0" encoding="UTF-8"?>
+ <p:FatturaElettronica versione="FPR12" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd">
+ <FatturaElettronicaHeader>
+ <CessionarioCommittente>
+ <DatiAnagrafici>
+ <CodiceFiscale>01234560157</CodiceFiscale>
+ </DatiAnagrafici>
+ </CessionarioCommittente>
+ </FatturaElettronicaHeader>
+ <FatturaElettronicaBody>
+ <DatiGenerali>
+ <DatiGeneraliDocumento>
+ <TipoDocumento>TD02</TipoDocumento>
+ </DatiGeneraliDocumento>
+ </DatiGenerali>
+ </FatturaElettronicaBody>
+ </p:FatturaElettronica>"""
+
+ @classmethod
+ def setUpClass(cls):
+ """ Setup the test class with a PEC mail server and a fake fatturaPA content """
+
+ super().setUpClass(chart_template_ref='l10n_it.l10n_it_chart_template_generic',
+ edi_format_ref='l10n_it_edi.edi_fatturaPA')
+
+ # Use the company_data_2 to test that the e-invoice is imported for the right company
+ cls.company = cls.company_data_2['company']
+
+ # Initialize the company's codice fiscale
+ cls.company.l10n_it_codice_fiscale = 'IT01234560157'
+
+ # Build test data.
+ # invoice_filename1 is used for vendor bill receipts tests
+ # invoice_filename2 is used for vendor bill tests
+ cls.invoice_filename1 = 'IT01234567890_FPR01.xml'
+ cls.invoice_filename2 = 'IT01234567890_FPR02.xml'
+ cls.signed_invoice_filename = 'IT01234567890_FPR01.xml.p7m'
+ cls.invoice_content = cls._get_test_file_content(cls.invoice_filename1)
+ cls.signed_invoice_content = cls._get_test_file_content(cls.signed_invoice_filename)
+ cls.invoice = cls.env['account.move'].create({
+ 'move_type': 'in_invoice',
+ 'ref': '01234567890'
+ })
+ cls.attachment = cls.env['ir.attachment'].create({
+ 'name': cls.invoice_filename1,
+ 'raw': cls.invoice_content,
+ 'res_id': cls.invoice.id,
+ 'res_model': 'account.move',
+ })
+ cls.edi_document = cls.env['account.edi.document'].create({
+ 'edi_format_id': cls.edi_format.id,
+ 'move_id': cls.invoice.id,
+ 'attachment_id': cls.attachment.id,
+ 'state': 'sent'
+ })
+
+ # Initialize the fetchmail server that has to be tested
+ cls.server = cls.env['fetchmail.server'].sudo().create({
+ 'name': 'test_server',
+ 'server_type': 'imap',
+ 'l10n_it_is_pec': True})
+
+ @classmethod
+ def _get_test_file_content(cls, filename):
+ """ Get the content of a test file inside this module """
+ path = 'l10n_it_edi/tests/expected_xmls/' + filename
+ with tools.file_open(path, mode='rb') as test_file:
+ return test_file.read()
+
+ def _create_invoice(self, content, filename):
+ """ Create an invoice from given attachment content """
+ with patch.object(self.server._cr, 'commit', return_value=None):
+ if filename.endswith(".p7m"):
+ content = remove_signature(content)
+ return self.server._create_invoice_from_mail(content, filename, 'fake@address.be')
+
+ # -----------------------------
+ #
+ # Vendor bills
+ #
+ # -----------------------------
+
+ def test_receive_vendor_bill(self):
+ """ Test a sample e-invoice file from https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2/IT01234567890_FPR01.xml """
+ invoices = self._create_invoice(self.invoice_content, self.invoice_filename2)
+ self.assertTrue(bool(invoices))
+
+ def test_receive_signed_vendor_bill(self):
+ """ Test a signed (P7M) sample e-invoice file from https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2/IT01234567890_FPR01.xml """
+ with freezegun.freeze_time('2020-04-06'):
+ invoices = self._create_invoice(self.signed_invoice_content, self.signed_invoice_filename)
+ self.assertRecordValues(invoices, [{
+ 'company_id': self.company.id,
+ 'name': 'BILL/2014/12/0001',
+ 'invoice_date': datetime.date(2014, 12, 18),
+ 'ref': '01234567890',
+ }])
+
+ def test_receive_same_vendor_bill_twice(self):
+ """ Test that the second time we are receiving a PEC mail with the same attachment, the second is discarded """
+ content = self.fake_test_content.encode()
+ for result in [True, False]:
+ invoice = self._create_invoice(content, self.invoice_filename2)
+ self.assertEqual(result, bool(invoice))
+
+ # -----------------------------
+ #
+ # Receipts
+ #
+ # -----------------------------
+
+ def _test_receipt(self, receipt_type, source_state, destination_state):
+ """ Test a receipt from the ones in the module's test files """
+
+ # Simulate the 'sent' state of the move, even if we didn't actually send an email in this test
+ self.invoice.l10n_it_send_state = source_state
+
+ # Create a fake receipt from the test file
+ receipt_filename = 'IT01234567890_FPR01_%s_001.xml' % receipt_type
+ receipt_content = self._get_test_file_content(receipt_filename).decode()
+
+ create_mail_attachment = namedtuple('Attachment', ('fname', 'content', 'info'))
+ receipt_mail_attachment = create_mail_attachment(receipt_filename, receipt_content, {})
+
+ # Simulate the arrival of the receipt
+ with patch.object(self.server._cr, 'commit', return_value=None):
+ self.server._message_receipt_invoice(receipt_type, receipt_mail_attachment)
+
+ # Check the Destination state of the edi_document
+ self.assertTrue(destination_state, self.edi_document.state)
+
+ def test_ricevuta_consegna(self):
+ """ Test a receipt adapted from https://www.fatturapa.gov.it/export/documenti/messaggi/v1.0/IT01234567890_11111_RC_001.xml """
+ self._test_receipt('RC', 'sent', 'delivered')
+
+ def test_decorrenza_termini(self):
+ """ Test a receipt adapted from https://www.fatturapa.gov.it/export/documenti/messaggi/v1.0/IT01234567890_11111_DT_001.xml """
+ self._test_receipt('DT', 'delivered', 'delivered_expired')