Skip to content

Commit

Permalink
[IMP] l10n_do_accounting: added unitest for _get_l10n_do_line_amounts…
Browse files Browse the repository at this point in the history
…() function (#1153)
  • Loading branch information
jose-pcg authored Apr 15, 2024
1 parent 7b73c8d commit 0941636
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
2 changes: 1 addition & 1 deletion l10n_do_accounting/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"category": "Localization",
"license": "LGPL-3",
"website": "https://github.com/odoo-dominicana",
"version": "16.0.1.5.2",
"version": "16.0.1.5.3",
# any module necessary for this one to work correctly
"depends": ["l10n_latam_invoice_document", "l10n_do"],
# always loaded
Expand Down
11 changes: 11 additions & 0 deletions l10n_do_accounting/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ def setUpClass(cls, chart_template_ref="l10n_do.do_chart_template"):
street="dummy address",
country_id=cls.env.ref("base.do").id,
)["company"]

# multi-currency variables
cls.usd_currency = cls.env.ref("base.USD")
cls.env["res.currency.rate"].create(
{
"currency_id": cls.usd_currency.id,
"rate": 0.01694915254,
"company_id": cls.do_company.id,
}
)

cls.fiscal_partner = cls.env["res.partner"].create(
{
"name": "ITERATIVO SRL",
Expand Down
92 changes: 92 additions & 0 deletions l10n_do_accounting/tests/test_account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,95 @@ def test_010_ncf_format(self):

with self.assertRaises(ValidationError):
self._create_l10n_do_invoice(data={"document_number": "B310000000001"})

def test_011_get_l10n_do_line_amounts(self):
invoice_1 = self._create_l10n_do_invoice(
data={
"document_number": "B0100000001",
}
)
self.assertDictEqual(
invoice_1._get_l10n_do_amounts(),
{
"base_amount": 100.0,
"exempt_amount": 0,
"isr_withholding_amount": 0,
"isr_withholding_base_amount": 0,
"itbis_0_base_amount": 0,
"itbis_0_tax_amount": 0,
"itbis_16_base_amount": 0,
"itbis_16_tax_amount": 0,
"itbis_18_base_amount": 100.0,
"itbis_18_tax_amount": 18.0,
"itbis_withholding_amount": 0,
"itbis_withholding_base_amount": 0,
"l10n_do_invoice_total": 118.0,
},
)

invoice_2 = self._create_l10n_do_invoice(
data={
"partner": self.consumo_partner,
"document_number": "B1100000001",
"expense_type": "02",
},
invoice_type="in_invoice",
)

self.assertDictEqual(
invoice_2._get_l10n_do_amounts(),
{
"base_amount": 100.0,
"exempt_amount": 0,
"isr_withholding_amount": 10.0,
"isr_withholding_base_amount": 100.0,
"itbis_0_base_amount": 0,
"itbis_0_tax_amount": 0,
"itbis_16_base_amount": 0,
"itbis_16_tax_amount": 0,
"itbis_18_base_amount": 100.0,
"itbis_18_tax_amount": 18.0,
"itbis_withholding_amount": 18.0,
"itbis_withholding_base_amount": 100.0,
"l10n_do_invoice_total": 118.0,
},
)

invoice_3 = self._create_l10n_do_invoice(
data={
"document_number": "B0100000002",
"currency": self.usd_currency,
}
)

self.assertDictEqual(
invoice_3._get_l10n_do_amounts(),
{
"base_amount": 100.0,
"base_amount_currency": 5900.000000825999,
"exempt_amount": 0,
"exempt_amount_currency": 0.0,
"isr_withholding_amount": 0,
"isr_withholding_amount_currency": 0.0,
"isr_withholding_base_amount": 0,
"isr_withholding_base_amount_currency": 0.0,
"itbis_0_base_amount": 0,
"itbis_0_base_amount_currency": 0.0,
"itbis_0_tax_amount": 0,
"itbis_0_tax_amount_currency": 0.0,
"itbis_16_base_amount": 0,
"itbis_16_base_amount_currency": 0.0,
"itbis_16_tax_amount": 0,
"itbis_16_tax_amount_currency": 0.0,
"itbis_18_base_amount": 100.0,
"itbis_18_base_amount_currency": 5900.000000825999,
"itbis_18_tax_amount": 18.0,
"itbis_18_tax_amount_currency": 1062.0000001486799,
"itbis_withholding_amount": 0,
"itbis_withholding_amount_currency": 0.0,
"itbis_withholding_base_amount": 0,
"itbis_withholding_base_amount_currency": 0.0,
"l10n_do_invoice_total": 118.0,
"l10n_do_invoice_total_currency": 6962.000000974679,
},
)

0 comments on commit 0941636

Please sign in to comment.