From 528164c9b1d94f2774e3513a1993383dcee7f970 Mon Sep 17 00:00:00 2001 From: Pablo Montenegro Date: Wed, 14 Aug 2024 13:46:30 -0300 Subject: [PATCH] [IMP] l10n_ar_withholding_ux: apply ratio on base amount Tarea: 42355 --- l10n_ar_account_withholding/models/account_tax.py | 4 ++-- l10n_ar_withholding_ux/__manifest__.py | 2 +- l10n_ar_withholding_ux/models/account_tax.py | 8 ++++++++ l10n_ar_withholding_ux/views/account_tax_view.xml | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/l10n_ar_account_withholding/models/account_tax.py b/l10n_ar_account_withholding/models/account_tax.py index 813eeba3c..51f12525f 100644 --- a/l10n_ar_account_withholding/models/account_tax.py +++ b/l10n_ar_account_withholding/models/account_tax.py @@ -66,7 +66,7 @@ def get_withholding_vals(self, payment): base_amount = vals['withholdable_base_amount'] if self.withholding_type == 'partner_tax': - amount = base_amount * (alicuota) + amount = base_amount * (alicuota) * self.ratio / 100 vals['comment'] = "%s x %s" % ( base_amount, alicuota) vals['period_withholding_amount'] = amount @@ -255,7 +255,7 @@ def _compute_amount( if not date or str(date) == '1970-01-01': date = fields.Date.context_today(self) partner = partner and partner.sudo() - return base_amount * self.sudo().get_partner_alicuota_percepcion(partner, date) + return base_amount * self.sudo().get_partner_alicuota_percepcion(partner, date) * self.ratio / 100 else: return super(AccountTax, self)._compute_amount( base_amount, price_unit, quantity=quantity, product=product, diff --git a/l10n_ar_withholding_ux/__manifest__.py b/l10n_ar_withholding_ux/__manifest__.py index e1fc1768f..e780ca24f 100644 --- a/l10n_ar_withholding_ux/__manifest__.py +++ b/l10n_ar_withholding_ux/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'Argentinian withholding UX', - 'version': "17.0.1.2.0", + 'version': "17.0.1.4.0", 'category': 'Localization/Argentina', 'sequence': 14, 'author': 'ADHOC SA', diff --git a/l10n_ar_withholding_ux/models/account_tax.py b/l10n_ar_withholding_ux/models/account_tax.py index 591182e6d..ac02cb4f3 100644 --- a/l10n_ar_withholding_ux/models/account_tax.py +++ b/l10n_ar_withholding_ux/models/account_tax.py @@ -80,6 +80,7 @@ class AccountTax(models.Model): 'tax_withholding_id', 'Rules', ) + ratio = fields.Float(required=True, default=100, help="Ratio to apply to tax base amount") @api.constrains( 'withholding_non_taxable_amount', @@ -220,3 +221,10 @@ def get_withholding_vals(self, payment, force_withholding_amount_type=None): 'automatic': True, 'comment': comment, } + + @api.constrains('ratio') + def _check_line_ids_percent(self): + """ Check that the total percent is not bigger than 100.0 """ + for tax in self: + if not (0 < tax.ratio <= 100.0): + raise ValidationError(_('The total percentage (%s) should be less or equal to 100!', tax.ratio)) diff --git a/l10n_ar_withholding_ux/views/account_tax_view.xml b/l10n_ar_withholding_ux/views/account_tax_view.xml index b1690489a..87dd08ec4 100644 --- a/l10n_ar_withholding_ux/views/account_tax_view.xml +++ b/l10n_ar_withholding_ux/views/account_tax_view.xml @@ -47,6 +47,7 @@ +