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

DRAFT: 12.0 import customer facturae disable validation fix customer iban #4

Open
wants to merge 18 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 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
6 changes: 4 additions & 2 deletions account_invoice_import_facturae/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

{
'name': 'Account Invoice Import Facturae',
'version': '12.0.1.0.0',
'version': '12.0.2.0.0',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'summary': 'Import supplier invoices/refunds in facturae format',
'summary': 'Import supplier invoices/refunds and '
'customer invoices in facturae format',
'author': 'Creu Blanca, Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/l10n-spain',
'depends': [
Expand All @@ -19,6 +20,7 @@
'external_dependencies': {
'python': [
'xmlsig',
'schwifty',
]
},
'images': ['images/sshot-wizard1.png'],
Expand Down
252 changes: 252 additions & 0 deletions account_invoice_import_facturae/tests/files/facturae_customer_01.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
<?xml version='1.0' encoding='UTF-8'?>
<fe:Facturae xmlns:fe="http://www.facturae.es/Facturae/2009/v3.2/Facturae" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">

<FileHeader>
<SchemaVersion>3.2</SchemaVersion>
<Modality>I</Modality>
<InvoiceIssuerType>EM</InvoiceIssuerType>
<Batch>
<BatchIdentifier>INV/2021/000555020639Q</BatchIdentifier>
<InvoicesCount>1</InvoicesCount>
<TotalInvoicesAmount>
<TotalAmount>121.00</TotalAmount>
<EquivalentInEuros>121.00</EquivalentInEuros>
</TotalInvoicesAmount>
<TotalOutstandingAmount>
<TotalAmount>121.00</TotalAmount>
<EquivalentInEuros>121.00</EquivalentInEuros>
</TotalOutstandingAmount>
<TotalExecutableAmount>
<TotalAmount>121.00</TotalAmount>
<EquivalentInEuros>121.00</EquivalentInEuros>
</TotalExecutableAmount>
<InvoiceCurrencyCode>EUR</InvoiceCurrencyCode>
</Batch>
</FileHeader>
<Parties>
<SellerParty>


<TaxIdentification>
<PersonTypeCode>J</PersonTypeCode>
<ResidenceTypeCode>E</ResidenceTypeCode>
<TaxIdentificationNumber>55020639Q</TaxIdentificationNumber>
</TaxIdentification>


<LegalEntity>
<CorporateName>YourCompany</CorporateName>
<TradeName>YourCompany</TradeName>



<OverseasAddress>
<Address>1725 Slough Ave.</Address>
<PostCodeAndTown>18540Scranton</PostCodeAndTown>
<Province>Pennsylvania</Province>
<CountryCode>ESP</CountryCode>
</OverseasAddress>
<ContactDetails>
<Telephone>+1 555 123 8069</Telephone>

<WebAddress>http://www.example.com</WebAddress>
<ElectronicMail>info@yourcompany.example.com</ElectronicMail>
<ContactPersons>YourCompany</ContactPersons>



</ContactDetails>

</LegalEntity>


</SellerParty>
<BuyerParty>


<TaxIdentification>
<PersonTypeCode>J</PersonTypeCode>
<ResidenceTypeCode>E</ResidenceTypeCode>
<TaxIdentificationNumber>ES03421018K</TaxIdentificationNumber>
</TaxIdentification>


<LegalEntity>
<CorporateName>Azure Interior</CorporateName>
<TradeName>Azure Interior</TradeName>



<OverseasAddress>
<Address>3404 Edgewood Road</Address>
<PostCodeAndTown>72401Jonesboro</PostCodeAndTown>
<Province>Arkansas</Province>
<CountryCode>ESP</CountryCode>
</OverseasAddress>
<ContactDetails>
<Telephone>(870)-931-0505</Telephone>

<WebAddress>http://www.azure-interior.com</WebAddress>
<ElectronicMail>azure.Interior24@example.com</ElectronicMail>
<ContactPersons>Azure Interior</ContactPersons>



</ContactDetails>

</LegalEntity>


</BuyerParty>
</Parties>
<Invoices>
<Invoice>









<InvoiceHeader>
<InvoiceNumber>INV/2021/0005</InvoiceNumber>
<InvoiceSeriesCode/>
<InvoiceDocumentType>FC</InvoiceDocumentType>
<InvoiceClass>OO</InvoiceClass>

</InvoiceHeader>
<InvoiceIssueData>
<IssueDate>2021-04-09</IssueDate>



<InvoiceCurrencyCode>EUR</InvoiceCurrencyCode>

<TaxCurrencyCode>EUR</TaxCurrencyCode>
<LanguageName>en</LanguageName>

</InvoiceIssueData>
<TaxesOutputs>

<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21.00</TaxRate>
<TaxableBase>
<TotalAmount>100.00</TotalAmount>
<EquivalentInEuros>100.00</EquivalentInEuros>
</TaxableBase>
<TaxAmount>
<TotalAmount>21.00</TotalAmount>
<EquivalentInEuros>21.00</EquivalentInEuros>
</TaxAmount>




</Tax>

</TaxesOutputs>

<InvoiceTotals>
<TotalGrossAmount>100.00</TotalGrossAmount>




<TotalGrossAmountBeforeTaxes>100.00</TotalGrossAmountBeforeTaxes>
<TotalTaxOutputs>21.00</TotalTaxOutputs>
<TotalTaxesWithheld>0.00</TotalTaxesWithheld>
<InvoiceTotal>121.00</InvoiceTotal>




<TotalOutstandingAmount>121.00</TotalOutstandingAmount>


<TotalExecutableAmount>121.00</TotalExecutableAmount>


</InvoiceTotals>
<Items>
<InvoiceLine>
















<ItemDescription>test</ItemDescription>
<Quantity>1.0</Quantity>

<UnitPriceWithoutTax>100.000000</UnitPriceWithoutTax>

<TotalCost>100.000000</TotalCost>


<GrossAmount>100.000000</GrossAmount>

<TaxesOutputs>

<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21.00</TaxRate>
<TaxableBase>
<TotalAmount>100.00</TotalAmount>
<EquivalentInEuros>100.00</EquivalentInEuros>
</TaxableBase>
<TaxAmount>
<TotalAmount>21.00</TotalAmount>
<EquivalentInEuros>21.00</EquivalentInEuros>
</TaxAmount>
</Tax>

</TaxesOutputs>
<ArticleCode>VNAC</ArticleCode>






</InvoiceLine>
</Items>
<PaymentDetails>
<Installment>
<InstallmentDueDate>2021-05-31</InstallmentDueDate>
<InstallmentAmount>121.00</InstallmentAmount>
<PaymentMeans>04</PaymentMeans>



<AccountToBeCredited>
<IBAN>FR7642424242424242424242424</IBAN>


<BIC>PSSTFRPPXXX</BIC>
</AccountToBeCredited>



</Installment>
</PaymentDetails>



</Invoice>
</Invoices>


</fe:Facturae>
59 changes: 59 additions & 0 deletions account_invoice_import_facturae/tests/test_import_facturae.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
'country': 'DEU', 'vat': 'DE111111125', 'product_code': 'RX'},
}

configurations_customer = {
'facturae_customer_01.xml': {
'country': 'ESP', 'vat': 'ES03421018K', 'product_code': 'VNAC'
}
}


class TestImportFacturae(TransactionCase):
def setUp(self):
Expand Down Expand Up @@ -69,3 +75,56 @@ def check_config(self, config, vals):
def test_import(self):
for config in configurations:
self.check_config(config, configurations[config])


class TestImportCustomerFacturae(TransactionCase):
def setUp(self):
super().setUp()
self.config = self.env['account.invoice.import.config'].create({
'name': 'Facturae',
'invoice_line_method': 'nline_auto_product',
'type': 'customer'
})
self.tax = self.env['account.tax'].create({
'name': 'Test tax',
'type_tax_use': 'purchase',
'amount_type': 'percent',
'amount': 21.,
'description': 'TEST TAX',
})
self.product = self.env['product.product'].create({
'name': 'Product',
'supplier_taxes_id': [(4, self.tax.id)],
})

def check_config(self, config, vals):
country = self.env['res.country'].search([
('code', '=', vals['country'])])
country.ensure_one()
partner = self.env['res.partner'].create({
'name': 'Partner',
'invoice_import_ids': [(4, self.config.id)],
'country_id': country.id,
'vat': vals['vat'],
'customer': True,
})
self.product.default_code = vals['product_code']
filename = config
f = file_open(
'account_invoice_import_facturae/tests/files/' + filename, 'rb')
xml_file = f.read()
wiz = self.env['account.invoice.import'].with_context(
customer=True
).create({
'invoice_file': base64.b64encode(xml_file),
'invoice_filename': filename,
})
f.close()
action = wiz.import_invoice()
invoice = self.env['account.invoice'].browse(action['res_id'])
self.assertTrue(invoice)
self.assertEqual(invoice.partner_id, partner)

def test_import(self):
for config in configurations_customer:
self.check_config(config, configurations_customer[config])
Loading