Skip to content

Commit

Permalink
Merge PR #833 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by alexis-via
  • Loading branch information
OCA-git-bot committed Nov 9, 2023
2 parents daab3b0 + 0d62da2 commit f8afdd0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions account_invoice_import_invoice2data/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 0 additions & 1 deletion account_invoice_import_invoice2data/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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!
14 changes: 14 additions & 0 deletions account_invoice_import_invoice2data/tests/test_invoice_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand Down

0 comments on commit f8afdd0

Please sign in to comment.