mirror of
https://bitbucket.org/presik/trytonpsk-staff_payroll_co.git
synced 2023-12-14 06:42:56 +01:00
Compare commits
2 commits
60570c29e2
...
75e8cc788c
Author | SHA1 | Date | |
---|---|---|---|
75e8cc788c | |||
d4764194a0 |
|
@ -2,7 +2,7 @@
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from trytond.model import fields
|
from trytond.model import fields
|
||||||
from trytond.pool import PoolMeta
|
from trytond.pool import PoolMeta
|
||||||
from trytond.pyson import Id
|
from trytond.pyson import Id, Eval
|
||||||
|
|
||||||
|
|
||||||
class Configuration(metaclass=PoolMeta):
|
class Configuration(metaclass=PoolMeta):
|
||||||
|
@ -26,3 +26,6 @@ class Configuration(metaclass=PoolMeta):
|
||||||
limit_shift_month = fields.Integer('Limit Shift Month')
|
limit_shift_month = fields.Integer('Limit Shift Month')
|
||||||
wage_shift_fixed = fields.Many2One('staff.wage_type',
|
wage_shift_fixed = fields.Many2One('staff.wage_type',
|
||||||
'Wage Shift Fixed')
|
'Wage Shift Fixed')
|
||||||
|
tax_withholding = fields.Many2One('account.tax', 'Tax Withholding',
|
||||||
|
domain=[('company', '=', Eval('company', -1))],
|
||||||
|
depends=['company'])
|
||||||
|
|
41
payroll.py
41
payroll.py
|
@ -49,18 +49,24 @@ class PayrollLine(metaclass=PoolMeta):
|
||||||
|
|
||||||
is_event = fields.Boolean('Is Event')
|
is_event = fields.Boolean('Is Event')
|
||||||
start_date = fields.Date('Start Date', depends=['is_event'],
|
start_date = fields.Date('Start Date', depends=['is_event'],
|
||||||
states={
|
states={'invisible': ~Eval('is_event')})
|
||||||
'invisible': ~Eval('is_event'),
|
|
||||||
})
|
|
||||||
end_date = fields.Date('End Date', depends=['is_event'],
|
end_date = fields.Date('End Date', depends=['is_event'],
|
||||||
states={
|
states={'invisible': ~Eval('is_event')})
|
||||||
'invisible': ~Eval('is_event'),
|
|
||||||
})
|
|
||||||
move_lines = fields.Many2Many('staff.payroll.line-move.line',
|
move_lines = fields.Many2Many('staff.payroll.line-move.line',
|
||||||
'line', 'move_line', 'Payroll Line - Move Line')
|
'line', 'move_line', 'Payroll Line - Move Line')
|
||||||
origin = fields.Reference("Origin", selection='get_origin')
|
origin = fields.Reference("Origin", selection='get_origin')
|
||||||
amount_60_40 = fields.Numeric('Amount 60/40', digits=(16, 2),
|
amount_60_40 = fields.Numeric('Amount 60/40', digits=(16, 2),
|
||||||
depends=['wage_type'])
|
depends=['wage_type'])
|
||||||
|
tax_base = fields.Numeric('Tax Base', digits=(16, 2), states={
|
||||||
|
'invisible': ~Eval('is_wage_tax', False)}, depends=['wage_type', 'is_wage_tax'])
|
||||||
|
is_wage_tax = fields.Function(fields.Boolean('Is wage tax'),
|
||||||
|
'on_change_with_is_wage_tax')
|
||||||
|
|
||||||
|
@fields.depends('wage_type')
|
||||||
|
def on_change_with_is_wage_tax(self, name=None):
|
||||||
|
if self.wage_type:
|
||||||
|
return self.wage_type.type_concept == 'tax'
|
||||||
|
return False
|
||||||
|
|
||||||
def get_expense_amount(self, wage_type):
|
def get_expense_amount(self, wage_type):
|
||||||
expense = super(PayrollLine, self).get_expense_amount(wage_type)
|
expense = super(PayrollLine, self).get_expense_amount(wage_type)
|
||||||
|
@ -164,8 +170,8 @@ class Payroll(metaclass=PoolMeta):
|
||||||
else:
|
else:
|
||||||
account_id = line.wage_type.debit_account.id
|
account_id = line.wage_type.debit_account.id
|
||||||
grouped.update({account_id: {
|
grouped.update({account_id: {
|
||||||
'lines': list(line.move_lines)
|
'lines': list(line.move_lines)
|
||||||
}})
|
}})
|
||||||
for p in self.move.lines:
|
for p in self.move.lines:
|
||||||
if p.account.id not in grouped or (
|
if p.account.id not in grouped or (
|
||||||
p.account.type.statement not in ('balance')) or p.reconciliation:
|
p.account.type.statement not in ('balance')) or p.reconciliation:
|
||||||
|
@ -669,6 +675,7 @@ class Payroll(metaclass=PoolMeta):
|
||||||
def update_wage_no_salary(self, cache_wage_dict):
|
def update_wage_no_salary(self, cache_wage_dict):
|
||||||
PayrollLine = Pool().get('staff.payroll.line')
|
PayrollLine = Pool().get('staff.payroll.line')
|
||||||
att_getter = attrgetter('wage_type.type_concept', 'wage_type.month_application')
|
att_getter = attrgetter('wage_type.type_concept', 'wage_type.month_application')
|
||||||
|
tax_base = None
|
||||||
for line in self.lines:
|
for line in self.lines:
|
||||||
wage = cache_wage_dict[line.wage_type.id]
|
wage = cache_wage_dict[line.wage_type.id]
|
||||||
type_concept, month_application = att_getter(line)
|
type_concept, month_application = att_getter(line)
|
||||||
|
@ -678,10 +685,14 @@ class Payroll(metaclass=PoolMeta):
|
||||||
if type_concept == 'interest':
|
if type_concept == 'interest':
|
||||||
unit_value = self._compute_interest(wage, self.start)
|
unit_value = self._compute_interest(wage, self.start)
|
||||||
elif type_concept == 'tax':
|
elif type_concept == 'tax':
|
||||||
unit_value = self._compute_line_tax(line, wage)
|
unit_value, tax_base = self._compute_line_tax(line, wage)
|
||||||
|
if unit_value > 0:
|
||||||
|
tax_base = Decimal(str(round(tax_base, 2)))
|
||||||
|
else:
|
||||||
|
tax_base = None
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
PayrollLine.write([line], {'unit_value': unit_value})
|
PayrollLine.write([line], {'unit_value': unit_value, 'tax_base': tax_base})
|
||||||
|
|
||||||
def _get_payrolls_contract(self):
|
def _get_payrolls_contract(self):
|
||||||
dom_payroll = [('employee', '=', self.employee.id)]
|
dom_payroll = [('employee', '=', self.employee.id)]
|
||||||
|
@ -880,24 +891,18 @@ class Payroll(metaclass=PoolMeta):
|
||||||
|
|
||||||
deductions_renta_renta25c = deductions_renta + renta25c
|
deductions_renta_renta25c = deductions_renta + renta25c
|
||||||
ret_general = self.check_limit(base_salary_withholding, 'renta_deductions', deductions_renta_renta25c)
|
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(deductions_renta, 'renta')
|
||||||
print(renta25c, 'renta 25')
|
print(renta25c, 'renta 25')
|
||||||
print(ret_general, 'renta general')
|
print(ret_general, 'renta general')
|
||||||
if deductions_renta_renta25c > ret_general:
|
if deductions_renta_renta25c > ret_general:
|
||||||
deductions_renta_renta25c = lim_rete_deductions
|
deductions_renta_renta25c = ret_general
|
||||||
print(deductions_renta_renta25c, 'rr25', base_salary_withholding)
|
print(deductions_renta_renta25c, 'rr25', base_salary_withholding)
|
||||||
base_salary_withholding -= deductions_renta_renta25c
|
base_salary_withholding -= deductions_renta_renta25c
|
||||||
|
|
||||||
unit_value = UvtWithholding.compute_withholding(
|
unit_value = UvtWithholding.compute_withholding(
|
||||||
base_salary_withholding)
|
base_salary_withholding)
|
||||||
unit_value = self.currency.round(Decimal(unit_value))
|
unit_value = self.currency.round(Decimal(unit_value))
|
||||||
return unit_value
|
return unit_value, base_salary_withholding
|
||||||
|
|
||||||
def get_non_fiscal_amount(self, name=None):
|
def get_non_fiscal_amount(self, name=None):
|
||||||
res = _ZERO
|
res = _ZERO
|
||||||
|
|
9
uvt.py
9
uvt.py
|
@ -48,10 +48,9 @@ class UvtWithholding(ModelSQL, ModelView):
|
||||||
return res
|
return res
|
||||||
uvt_config = Decimal(configuration.uvt_value)
|
uvt_config = Decimal(configuration.uvt_value)
|
||||||
|
|
||||||
percent_exent = Decimal('0.75')
|
# percent_exent = Decimal('0.75')
|
||||||
# payment2uvt = Decimal(payment) / uvt_config
|
# payment2uvt = Decimal(payment * percent_exent) / uvt_config
|
||||||
payment2uvt = Decimal(payment * percent_exent) / uvt_config
|
payment2uvt = Decimal(payment) / uvt_config
|
||||||
print(payment)
|
|
||||||
# print('depurada', Decimal(payment * percent_exent))
|
# print('depurada', Decimal(payment * percent_exent))
|
||||||
uvt_withholdings = cls.search([
|
uvt_withholdings = cls.search([
|
||||||
['AND', ['OR', [
|
['AND', ['OR', [
|
||||||
|
@ -75,5 +74,5 @@ class UvtWithholding(ModelSQL, ModelView):
|
||||||
# res = round(value, 1) * uvt_config
|
# res = round(value, 1) * uvt_config
|
||||||
res = value * uvt_config
|
res = value * uvt_config
|
||||||
print('respuesta >', res)
|
print('respuesta >', res)
|
||||||
res = Decimal(round(res, 2))
|
res = Decimal(round(res, -3))
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -20,6 +20,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="limit_shift_month"/>
|
<field name="limit_shift_month"/>
|
||||||
<label name="wage_shift_fixed"/>
|
<label name="wage_shift_fixed"/>
|
||||||
<field name="wage_shift_fixed"/>
|
<field name="wage_shift_fixed"/>
|
||||||
|
<label name="tax_withholding"/>
|
||||||
|
<field name="tax_withholding"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
expr="/form/field[@name='minimum_salary']" position="after">
|
expr="/form/field[@name='minimum_salary']" position="after">
|
||||||
|
|
|
@ -14,6 +14,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<xpath expr="/form/label[@name='party']" position="before">
|
<xpath expr="/form/label[@name='party']" position="before">
|
||||||
<label name="amount_60_40"/>
|
<label name="amount_60_40"/>
|
||||||
<field name="amount_60_40"/>
|
<field name="amount_60_40"/>
|
||||||
|
<label name="tax_base"/>
|
||||||
|
<field name="tax_base"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/field[@name='party']" position="after">
|
<xpath expr="/form/field[@name='party']" position="after">
|
||||||
<label name="origin"/>
|
<label name="origin"/>
|
||||||
|
|
Loading…
Reference in a new issue