diff --git a/account_invoice_import_invoice2data/readme/CONFIGURE.rst b/account_invoice_import_invoice2data/readme/CONFIGURE.rst index 246216c2d3..c61fa8cdb7 100644 --- a/account_invoice_import_invoice2data/readme/CONFIGURE.rst +++ b/account_invoice_import_invoice2data/readme/CONFIGURE.rst @@ -95,6 +95,7 @@ Invoice line Fields | uom | char | The name of the unit of measure, internally if will be mapped to the unece code. Example L will be mapped to unece_code LTR | | price_unit | float | The unit price of the item. (excluding taxes) | | discount | float | The amount of discount for this line. Eg 20 for 20% discount or 0.0 for no discount | +| price_total | float | The total amount of the invoice line including taxes. It can be used to select the correct tax tag. | | price_subtotal | float | The total amount of the invoice line excluding taxes. It can be used to create adjustment lines when the decimal precision is insufficient. | | line_tax_percent | float | The percentage of tax | | line_tax_amount | float | The fixed amount of tax applied to the line | diff --git a/account_invoice_import_invoice2data/readme/ROADMAP.rst b/account_invoice_import_invoice2data/readme/ROADMAP.rst index c7a4fba02f..8e930c6a85 100644 --- a/account_invoice_import_invoice2data/readme/ROADMAP.rst +++ b/account_invoice_import_invoice2data/readme/ROADMAP.rst @@ -3,6 +3,5 @@ Known Issues * The input module is hard coded to use pdftotext parser and as a fallback to tesseract. -* support for invoices with all tax included is not fully implemented. * Creation of the templates is still quite hard. * The addres and company specific fields are parsed. Meaning it is possible to import an invoice which is issued to another company than yours! diff --git a/account_invoice_import_invoice2data/tests/test_invoice_import.py b/account_invoice_import_invoice2data/tests/test_invoice_import.py index 39ddb950e5..24efb35bc0 100644 --- a/account_invoice_import_invoice2data/tests/test_invoice_import.py +++ b/account_invoice_import_invoice2data/tests/test_invoice_import.py @@ -3,6 +3,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import base64 +import logging +from unittest import mock from odoo import fields from odoo.tests.common import TransactionCase @@ -27,6 +29,18 @@ def setUp(self): ) internet_product.supplier_taxes_id = [(6, 0, [frtax.id])] + def test_have_invoice2data_unavailable(self): + with mock.patch.dict("sys.modules", {"invoice2data": None}): + with self.assertLogs("", level="DEBUG") as cm: + logging.getLogger("").debug("Cannot import invoice2data") + self.assertEqual(cm.output, ["DEBUG:root:Cannot import invoice2data"]) + + def test_have_tesseract_unavailable(self): + with mock.patch.dict("sys.modules", {"tesseract": None}): + with self.assertLogs("", level="DEBUG") as cm: + logging.getLogger("").debug("Cannot import tesseract") + self.assertEqual(cm.output, ["DEBUG:root:Cannot import tesseract"]) + def test_import_free_invoice(self): filename = "invoice_free_fiber_201507.pdf" f = file_open("account_invoice_import_invoice2data/tests/pdf/" + filename, "rb") diff --git a/account_invoice_import_invoice2data/wizard/account_invoice_import.py b/account_invoice_import_invoice2data/wizard/account_invoice_import.py index 98fecc5280..770b9272a4 100644 --- a/account_invoice_import_invoice2data/wizard/account_invoice_import.py +++ b/account_invoice_import_invoice2data/wizard/account_invoice_import.py @@ -42,6 +42,7 @@ def fallback_parse_pdf_invoice(self, file_data): def parse_invoice2data_taxes(self, line): taxes = [] type_code = "VAT" + price_include = False # CategoryCode assume standard rate s for standard or low rate AA categ_code = "" # AA percentage = line.get("line_tax_percent") @@ -52,13 +53,15 @@ def parse_invoice2data_taxes(self, line): elif fixed_amount: amount_type = "fixed" amount = fixed_amount + elif line.get("price_total") and not line.get("price_subtotal"): + price_include = True else: return taxes taxes.append( { "amount_type": amount_type, "amount": float(amount), - # "price_include": True, # todo + "price_include": price_include, "unece_type_code": type_code, "unece_categ_code": categ_code, # "unece_due_date_code": due_date_code,