diff --git a/l10n_ar_account_withholding_ratio/README.rst b/l10n_ar_account_withholding_ratio/README.rst new file mode 100644 index 000000000..858322b1b --- /dev/null +++ b/l10n_ar_account_withholding_ratio/README.rst @@ -0,0 +1,61 @@ +.. |company| replace:: ADHOC SA + +.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png + :alt: ADHOC SA + :target: https://www.adhoc.com.ar + +.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png + +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +============================= +Argentinean Withholding Ratio +============================= + +Este módulo imlementa: + +* Permite establecer un ratio de 1 a 100 en el impuesto y representa el porcentaje de base imponible que se tendrá en cuenta para aplicar el impuesto siempre y cuando la alícuota del impuesto se obtenega del partner. Si bien se puede usar ese ratio para cualquier impuesto en principio fue solicitado solo para Córdoba. + + +Installation +============ + +To install this module, you need to: + +#. Only need to install the module + +Configuration +============= + +To configure this module, you need to: + +#. Nothing to configure + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: http://runbot.adhoc.com.ar/ + +Credits +======= + +Images +------ + +* |company| |icon| + +Contributors +------------ + +Maintainer +---------- + +|company_logo| + +This module is maintained by the |company|. + +To contribute to this module, please visit https://www.adhoc.com.ar. diff --git a/l10n_ar_account_withholding_ratio/__init__.py b/l10n_ar_account_withholding_ratio/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_ar_account_withholding_ratio/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_ar_account_withholding_ratio/__manifest__.py b/l10n_ar_account_withholding_ratio/__manifest__.py new file mode 100644 index 000000000..36f592315 --- /dev/null +++ b/l10n_ar_account_withholding_ratio/__manifest__.py @@ -0,0 +1,21 @@ +{ + 'name': 'Argentinean Withholding Ratio', + 'version': "17.0.1.0.0", + 'category': 'Localization/Argentina', + 'sequence': 14, + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'summary': '', + 'depends': [ + 'l10n_ar_withholding_ux', + ], + 'data': [ + 'views/account_tax_view.xml', + ], + 'demo': [ + ], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/l10n_ar_account_withholding_ratio/models/__init__.py b/l10n_ar_account_withholding_ratio/models/__init__.py new file mode 100644 index 000000000..1353d6f5f --- /dev/null +++ b/l10n_ar_account_withholding_ratio/models/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import account_tax diff --git a/l10n_ar_account_withholding_ratio/models/account_tax.py b/l10n_ar_account_withholding_ratio/models/account_tax.py new file mode 100644 index 000000000..791029661 --- /dev/null +++ b/l10n_ar_account_withholding_ratio/models/account_tax.py @@ -0,0 +1,30 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError + + +class AccountTax(models.Model): + _inherit = 'account.tax' + + ratio = fields.Float(default=100.00, help="Ratio to apply to tax base amount.") + + @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 tax.ratio or tax.ratio < 0.0 or tax.ratio > 100.0: + raise ValidationError(_('The total percentage (%s) should be higher than 0 and less or equal to 100.', tax.ratio)) + + def get_withholding_vals(self, payment): + vals = super().get_withholding_vals(payment) + if self.withholding_type == 'partner_tax' and self.ratio != 100: + vals['withholdable_base_amount'] *= self.ratio / 100 + vals['period_withholding_amount'] *= self.ratio / 100 + return vals + + def _compute_amount( + self, base_amount, price_unit, quantity, product, partner=None, fixed_multiplicator=1): + if self.amount_type == 'partner_tax' and self.ratio != 100: + date = self._context.get('invoice_date') or fields.Date.context_today(self) + partner = partner and partner.sudo() + return base_amount * self.sudo().get_partner_alicuota_percepcion(partner, date) * self.ratio / 100 + return super()._compute_amount(base_amount, price_unit, quantity, product, partner=partner, fixed_multiplicator=fixed_multiplicator) diff --git a/l10n_ar_account_withholding_ratio/views/account_tax_view.xml b/l10n_ar_account_withholding_ratio/views/account_tax_view.xml new file mode 100644 index 000000000..7fba2cbeb --- /dev/null +++ b/l10n_ar_account_withholding_ratio/views/account_tax_view.xml @@ -0,0 +1,20 @@ + + + + + account.tax.form + account.tax + + + + + + + + +