Skip to content

Commit

Permalink
Merge PR OCA#1017 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 Sep 16, 2024
2 parents e9fe1a7 + b8e2ec8 commit 1e60c9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions account_invoice_import/tests/test_invoice_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def test_import_out_invoice(self):
"product": {"code": "AII-TEST-PRODUCT"},
"name": "Super product",
"qty": 3,
"price_unit": 10.22,
"discount": 10,
"price_unit": 100,
"date_start": "2017-08-01",
"date_end": "2017-08-31",
"taxes": [
Expand All @@ -334,8 +335,10 @@ def test_import_out_invoice(self):
.with_company(self.company.id)
.create_invoice(parsed_inv, import_config)
)
self.assertFalse(inv.currency_id.compare_amounts(inv.amount_untaxed, 30.66))
self.assertFalse(inv.currency_id.compare_amounts(inv.amount_total, 30.97))
self.assertFalse(
inv.currency_id.compare_amounts(inv.amount_untaxed, 270.00)
)
self.assertFalse(inv.currency_id.compare_amounts(inv.amount_total, 272.70))
self.assertEqual(
fields.Date.to_string(inv.invoice_date), parsed_inv["date"]
)
Expand Down
8 changes: 7 additions & 1 deletion account_invoice_import/wizard/account_invoice_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ def fallback_parse_pdf_invoice(self, file_data):
# },
# 'name': 'Gelierzucker Extra 250g',
# 'price_unit': 1.45, # price_unit without taxes
# 'discount': 10.0, # for 10% discount
# 'qty': 2.0,
# 'price_subtotal': 2.90, # not required, but needed
# 'price_subtotal': 2.61, # not required, but needed
# to be able to generate adjustment lines when decimal
# precision is not high enough in Odoo
# 'uom': {'unece_code': 'C62'},
Expand Down Expand Up @@ -424,6 +425,7 @@ def _prepare_line_vals_nline(self, partner, vals, parsed_inv, import_config):
{
"quantity": line["qty"],
"price_unit": line["price_unit"], # TODO fix for tax incl
"discount": line.get("discount", 0),
}
)
if start_end_dates_installed:
Expand Down Expand Up @@ -540,6 +542,7 @@ def pre_process_parsed_inv(self, parsed_inv):
if not parsed_inv.get("currency_rounding"):
self.get_precision_rounding_from_currency_helper(parsed_inv)
prec_pp = self.env["decimal.precision"].precision_get("Product Price")
prec_disc = self.env["decimal.precision"].precision_get("Discount")
prec_uom = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
Expand Down Expand Up @@ -583,6 +586,9 @@ def pre_process_parsed_inv(self, parsed_inv):
line["price_unit"] = float_round(
line["price_unit"], precision_digits=prec_pp
)
line["discount"] = float_round(
line.get("discount", 0), precision_digits=prec_disc
)
parsed_inv_for_log = dict(parsed_inv)
if "attachments" in parsed_inv_for_log:
parsed_inv_for_log.pop("attachments")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_import_azure_interior_invoice(self):
# self.assertEqual(inv.journal_id.payment_reference, "202309097001")
# self.assertEqual(inv.journal_id.incoterm_id, self.env.ref("account.incoterm_DPU")

self.assertEqual(len(inv.invoice_line_ids), 8)
self.assertEqual(len(inv.invoice_line_ids), 7)
iline = inv.invoice_line_ids[0]
self.assertEqual(iline.name, "--- Non Food ---")
self.assertEqual(iline.display_type, "line_section")
Expand Down Expand Up @@ -205,9 +205,9 @@ def test_import_azure_interior_invoice(self):
iline.product_id,
self.env.ref("account_invoice_import_invoice2data.olive_oil"),
)
# todo test discount, not yet implemented in account_invoice_import
self.assertEqual(float_compare(iline.quantity, 1.0, precision_digits=0), 0)
self.assertEqual(float_compare(iline.price_unit, 1.00, precision_digits=2), 0)
self.assertEqual(float_compare(iline.discount, 10, precision_digits=2), 0)
iline = inv.invoice_line_ids[5]
self.assertEqual(
iline.name, "Our Olive Oil is delivered in a re-usable glass container"
Expand Down

0 comments on commit 1e60c9d

Please sign in to comment.