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

[14.0] account_invoice_import_invoice2data: support for lines with taxes included #833

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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 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 @@
elif fixed_amount:
amount_type = "fixed"
amount = fixed_amount
elif line.get("price_total") and not line.get("price_subtotal"):
price_include = True

Check warning on line 57 in account_invoice_import_invoice2data/wizard/account_invoice_import.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_import_invoice2data/wizard/account_invoice_import.py#L57

Added line #L57 was not covered by tests
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
Loading