fix ompute withholding

This commit is contained in:
Wilson Gomez 2023-09-30 09:36:14 -05:00
parent 2a10c33628
commit 7f547ef6bd
3 changed files with 30 additions and 14 deletions

View File

@ -11,13 +11,13 @@ SOCIAL_SEGURITY = [
]
LIM_UVT_DEDUCTIBLE = {
'fvp_ind': Decimal(2500/12),
'afc_fvp': Decimal(3800/12),
'fvp_ind': Decimal(2500 / 12),
'afc_fvp': Decimal(3800 / 12),
'housing_interest': 100,
'health_prepaid': 16,
'dependents': 72,
'exempted_incom': Decimal(790/12),
'renta_deductions': Decimal(1340/12)
'dependents': 32,
'exempted_income': Decimal(790 / 12),
'renta_deductions': Decimal(1340 / 12)
}
LIM_PERCENT_DEDUCTIBLE = {

View File

@ -823,9 +823,13 @@ class Payroll(metaclass=PoolMeta):
) else None
res = 0
if field == 'dependents' and value_field:
value_percent = lim_percent * value_field/100 * base
value_percent = lim_percent * value_field / 100 * base
value_uvt = lim_uvt * uvt_config
res = min(value_percent, value_uvt)
elif field == 'exempted_income':
value_limit_uvt = uvt_config * lim_uvt
value_limit_percent = base * lim_percent / 100
res = min(value_limit_uvt, value_limit_percent)
else:
res = value_field
if lim_uvt:
@ -843,6 +847,8 @@ class Payroll(metaclass=PoolMeta):
salary_full = self.get_salary_full(wage)
amount_tax = line_tax.amount if line_tax.amount else 0
deductions_month = self.get_deductions_month() - amount_tax
print(salary_full, 'salary')
print(deductions_month, 'deductions')
salary_full = salary_full['salary']
if self.last_payroll:
payrolls_ids = self._get_payrolls_contract()
@ -865,19 +871,28 @@ class Payroll(metaclass=PoolMeta):
base_salary_withholding = salary_full - \
deductions_month - deductions_values['fvp_ind']
print(base_salary_withholding, 'base_salary_withholding')
deductions_values.pop('fvp_ind')
deductions_renta = sum(v for v in deductions_values.values())
lim_rete_deductions = base_salary_withholding * \
LIM_PERCENT_DEDUCTIBLE['renta_deductions'] / 100
if deductions_renta >= lim_rete_deductions:
deductions_renta = lim_rete_deductions
base_c = base_salary_withholding - deductions_renta
renta25c = self.check_limit(
None, 'exempte_income', base_c * LIM_PERCENT_DEDUCTIBLE['exempted_income']/100)
base_c, 'exempted_income', base_c * LIM_PERCENT_DEDUCTIBLE['exempted_income']/100)
deductions_renta_renta25c = deductions_renta + renta25c
if deductions_renta_renta25c > lim_rete_deductions:
ret_general = self.check_limit(base_salary_withholding, 'renta_deductions', deductions_renta_renta25c)
# percent_ret_general = base_salary_withholding * \
# LIM_PERCENT_DEDUCTIBLE['renta_deductions'] / 100
# ret_general = base_salary_withholding * \
# LIM_UVT_DEDUCTIBLE['renta_deductions'] / 100
# if deductions_renta >= lim_rete_deductions:
# deductions_renta = lim_rete_deductions
print(deductions_renta, 'renta')
print(renta25c, 'renta 25')
print(ret_general, 'renta general')
if deductions_renta_renta25c > ret_general:
deductions_renta_renta25c = lim_rete_deductions
base_salary_withholding -= deductions_renta
print(deductions_renta_renta25c, 'rr25', base_salary_withholding)
base_salary_withholding -= deductions_renta_renta25c
unit_value = UvtWithholding.compute_withholding(
base_salary_withholding)

3
uvt.py
View File

@ -49,9 +49,10 @@ class UvtWithholding(ModelSQL, ModelView):
uvt_config = Decimal(configuration.uvt_value)
percent_exent = Decimal('0.75')
# payment2uvt = Decimal(payment) / uvt_config
payment2uvt = Decimal(payment * percent_exent) / uvt_config
print(payment)
print('depurada', Decimal(payment * percent_exent))
# print('depurada', Decimal(payment * percent_exent))
uvt_withholdings = cls.search([
['AND', ['OR', [
('start_range', '<', payment2uvt),