trytonpsk-staff_payroll_co/wage_type.py

84 lines
3.4 KiB
Python

#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta, Pool
from trytond.model import fields
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['WageType']
ROUND_AMOUNTS = [
('', ''),
('above_amount', 'Above Amount'),
('under_amount', 'Under Amount'),
('automatic', 'Automatic'),
]
class WageType(metaclass=PoolMeta):
__name__ = 'staff.wage_type'
minimal_amount = fields.Numeric('Minimal Amount')
month_application = fields.Boolean('Month Application')
apply_special_salary = fields.Boolean('Apply Special Salary')
adjust_days_worked = fields.Boolean('Adjust Days Worked',
help='If is true, rounded month work days on payroll to 30 indeed'
'if month has 31 days, or rounded to 15 indeed the biweekly'
'pay has 16 days')
round_amounts = fields.Selection(ROUND_AMOUNTS, 'Rounds amounts', help='Approximates the highest value in hundreds')
# minimal_expense = fields.Function(fields.Numeric('Minimun Expense Amount'),
# 'validate_minimum_amount')
# minimal_unit_price = fields.Function(fields.Numeric('Minimun Expense Amount'),
# 'validate_minimum_amount')
# limit_days = fields.Numeric('Limit Days', states={
# 'invisible': Eval('type_concept') != 'special',
# 'required': Eval('type_concept') == 'special',
# })
@classmethod
def __setup__(cls):
super(WageType, cls).__setup__()
new_sel = [
('health', 'Health'),
('retirement', 'Retirement'),
('risk', 'Risk'),
('box_family', 'Box Family'),
('commission', 'Commission'),
('bonus_service', 'Bonus Service'),
('food', 'Food'),
('unemployment', 'Unemployment'),
('allowance', 'Allowance'),
('transport', 'Transport'),
('interest', 'Interest'),
('bonus', 'Bonus'),
('tax', 'Tax'),
('holidays', 'Holidays'),
('syndicate', 'Syndicate'),
('fsp', 'FSP'),
('sena', 'SENA'),
('icbf', 'ICBF'),
('acquired_product', 'Acquired Product'),
('loan', 'Loan'),
('advance', 'Advance'),
]
if new_sel not in cls.type_concept.selection:
cls.type_concept.selection.extend(new_sel)
@classmethod
def __register__(cls, module_name):
super(WageType, cls).__register__(module_name)
cursor = Transaction().connection.cursor()
cursor.execute('ALTER TABLE staff_wage_type DROP COLUMN IF EXISTS amount_required')
# def validate_minimum_amount(self, name):
# config = Pool().get('staff.configuration')(1)
# if config:
# minimum_salary = config.minimum_salary
# num_subperiod = 30 / config.default_liquidation_period
# amount = minimum_salary / num_subperiod
# if name == 'minimal_unit_price':
# return self.compute_unit_price({'salary': amount})
# if name == 'minimal_expense':
# return self.compute_expense({'salary': amount})
# return 0