mirror of
https://bitbucket.org/presik/trytonpsk-staff_payroll_co.git
synced 2023-12-14 06:42:56 +01:00
add validate withholding in liquidation
This commit is contained in:
parent
462fa08eb3
commit
a02924f046
|
@ -195,11 +195,56 @@ class Liquidation(Workflow, ModelSQL, ModelView):
|
||||||
for rec in records:
|
for rec in records:
|
||||||
rec.create_move()
|
rec.create_move()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def validate_withholding(cls, liquidation):
|
||||||
|
rec = liquidation
|
||||||
|
pool = Pool()
|
||||||
|
UvtWithholding = pool.get('staff.payroll.uvt_withholding')
|
||||||
|
WageType = pool.get('staff.wage_type')
|
||||||
|
wage_tax = WageType.search([('type_concept', '=', 'tax')])
|
||||||
|
if wage_tax:
|
||||||
|
wage_tax = wage_tax[0]
|
||||||
|
deductions_month = sum([l.amount for l in rec.lines if l.wage.definition != 'payment'])
|
||||||
|
salary_full = rec.net_payment
|
||||||
|
payrolls = {p.end: p for p in rec.payrolls}
|
||||||
|
max_date = max(payrolls.keys())
|
||||||
|
if rec.liquidation_date.month == max_date.month:
|
||||||
|
payroll = payrolls[max_date]
|
||||||
|
line_tax = None
|
||||||
|
for line in payroll.lines:
|
||||||
|
if line.wage_type.type_concept == 'tax' and line.amount:
|
||||||
|
line_tax = line
|
||||||
|
if not line_tax:
|
||||||
|
deductions_month += payroll.get_deductions_month()
|
||||||
|
salary_args = payroll.get_salary_full(wage_tax)
|
||||||
|
salary_full += salary_args['salary']
|
||||||
|
|
||||||
|
print('Salary ----> ', salary_full)
|
||||||
|
print('Total Deductions ----> ', deductions_month)
|
||||||
|
base_salary_withholding = salary_full - deductions_month
|
||||||
|
amount_tax = UvtWithholding.compute_withholding(
|
||||||
|
base_salary_withholding)
|
||||||
|
amount_tax = rec.currency.round(Decimal(amount_tax))
|
||||||
|
if amount_tax:
|
||||||
|
create_tax = {
|
||||||
|
'sequence': wage_tax.sequence,
|
||||||
|
'wage': wage_tax.id,
|
||||||
|
'description': wage_tax.name,
|
||||||
|
'amount': amount_tax * -1,
|
||||||
|
'days': rec.time_contracting,
|
||||||
|
'account': wage_tax.credit_account,
|
||||||
|
}
|
||||||
|
cls.write([rec], {
|
||||||
|
'lines': [('create', [create_tax])]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
def compute_liquidation(cls, records):
|
def compute_liquidation(cls, records):
|
||||||
for rec in records:
|
for rec in records:
|
||||||
rec.set_liquidation_lines()
|
rec.set_liquidation_lines()
|
||||||
|
cls.validate_withholding(rec)
|
||||||
|
|
||||||
def get_dates(self, name):
|
def get_dates(self, name):
|
||||||
if name == 'start':
|
if name == 'start':
|
||||||
|
|
31
payroll.py
31
payroll.py
|
@ -66,35 +66,6 @@ ENTITY_ACCOUNTS = {
|
||||||
'890480023': (2370100105, 72057205),
|
'890480023': (2370100105, 72057205),
|
||||||
'890903790': (23700601, 72056801),
|
'890903790': (23700601, 72056801),
|
||||||
}
|
}
|
||||||
# ENTITY_ACCOUNTS = {
|
|
||||||
# '806008394': (23700501, 72056901),
|
|
||||||
# '860066942': (23700502, 72056902),
|
|
||||||
# '890300625': (23700503, 72056903),
|
|
||||||
# '900226715': (23700504, 72056904),
|
|
||||||
# '830003564': (23700505, 72056905),
|
|
||||||
# '800251440': (23700506, 72056906),
|
|
||||||
# '800088702': (23700507, 72056907),
|
|
||||||
# '901097473': (23700508, 72056908),
|
|
||||||
# '900156264': (23700509, 72056909),
|
|
||||||
# '800130907': (23700510, 72056910),
|
|
||||||
# '860045904': (23700511, 72056911),
|
|
||||||
# '890102044': (23700514, 72056914),
|
|
||||||
# '900336004': (23803001, 72057001),
|
|
||||||
# '800149496': (23803002, 72057002),
|
|
||||||
# '800144331': (23803004, 72057004),
|
|
||||||
# '800229739': (23803005, 72057005),
|
|
||||||
# '860013570': (2370100101, 72057201),
|
|
||||||
# '890102002': (2370100102, 72057202),
|
|
||||||
# '890903790': (23700601, 72057101),
|
|
||||||
# '830113831': (23700501, 72056901),
|
|
||||||
# '804002105': (23700513, 72056913),
|
|
||||||
# '900298372': (23700513, 72056913),
|
|
||||||
# '830009783': (23700516, 72056916),
|
|
||||||
# '800148514': (23803003, 72057003),
|
|
||||||
# '891780093': (2370100103, 72057203),
|
|
||||||
# '890480023': (2370100105, 72057205),
|
|
||||||
# '809102044': (23700514, 72056914),
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
class PayrollLine(metaclass=PoolMeta):
|
class PayrollLine(metaclass=PoolMeta):
|
||||||
|
@ -423,7 +394,7 @@ class Payroll(metaclass=PoolMeta):
|
||||||
if line.wage_type.month_application:
|
if line.wage_type.month_application:
|
||||||
salary_args = self.get_salary_full(line.wage_type)
|
salary_args = self.get_salary_full(line.wage_type)
|
||||||
unit_value = line.wage_type.compute_unit_price(salary_args)
|
unit_value = line.wage_type.compute_unit_price(salary_args)
|
||||||
elif line.wage_type.type_concept == 'interest':
|
if line.wage_type.type_concept == 'interest':
|
||||||
unit_value = self._compute_interest(line.wage_type, self.start)
|
unit_value = self._compute_interest(line.wage_type, self.start)
|
||||||
elif line.wage_type.type_concept == 'tax':
|
elif line.wage_type.type_concept == 'tax':
|
||||||
unit_value = self._compute_line_tax(line)
|
unit_value = self._compute_line_tax(line)
|
||||||
|
|
Loading…
Reference in a new issue