Add option for recompute payrolls
This commit is contained in:
parent
e161a8b80c
commit
2aaf486368
49
payroll.py
49
payroll.py
|
@ -133,6 +133,7 @@ class Payroll(metaclass=PoolMeta):
|
|||
fields.Numeric('Worked Days Effective'), 'get_worked_days_effective')
|
||||
events = fields.Function(fields.One2Many('staff.event', None,
|
||||
'Assistance'), 'get_events')
|
||||
recompute = fields.Boolean('Recompute')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -159,6 +160,23 @@ class Payroll(metaclass=PoolMeta):
|
|||
raise RecordDuplicateError(gettext(
|
||||
'staff_payroll_co.msg_cannot_duplicate_record'))
|
||||
|
||||
@classmethod
|
||||
def process(cls, records):
|
||||
to_write = []
|
||||
cache_wage_dict = cls.create_cache_wage_types()
|
||||
for payroll in records:
|
||||
if payroll.recompute:
|
||||
payroll.recompute_lines(cache_wage_dict)
|
||||
to_write.append(payroll)
|
||||
if to_write:
|
||||
cls.write(to_write, {'recompute': False})
|
||||
super(Payroll, cls).process(records)
|
||||
|
||||
@fields.depends('recompute', 'lines')
|
||||
def on_change_lines(self):
|
||||
if self.lines:
|
||||
self.recompute = True
|
||||
|
||||
def create_move(self, wage_dict):
|
||||
super(Payroll, self).create_move(wage_dict)
|
||||
pool = Pool()
|
||||
|
@ -368,8 +386,8 @@ class Payroll(metaclass=PoolMeta):
|
|||
])
|
||||
else:
|
||||
dom_payroll.extend([
|
||||
('start', '>=', date(year, 1, 1)),
|
||||
('start', '<=', date(year, 12, 31)),
|
||||
('start', '>=', date(year, 1, 1)),
|
||||
('start', '<=', date(year, 12, 31)),
|
||||
])
|
||||
payrolls = self.search(dom_payroll)
|
||||
worked_days = Decimal(sum([p.worked_days for p in payrolls]))
|
||||
|
@ -378,7 +396,7 @@ class Payroll(metaclass=PoolMeta):
|
|||
salary_plus += wage.compute_formula(
|
||||
wage.unit_price_formula,
|
||||
precomputed_salary
|
||||
)
|
||||
)
|
||||
return salary_plus
|
||||
|
||||
def _get_payrolls_month(self):
|
||||
|
@ -463,16 +481,16 @@ class Payroll(metaclass=PoolMeta):
|
|||
wage_type = m.loan.wage_type
|
||||
amount = m.amount
|
||||
to_create = {
|
||||
'origin': m,
|
||||
'party': party,
|
||||
'quantity': 1,
|
||||
'uom': wage_type.uom,
|
||||
'unit_value': amount,
|
||||
'move_lines': [('add', move_lines)],
|
||||
'wage_type': wage_type,
|
||||
'description': wage_type.name,
|
||||
'payroll': self,
|
||||
}
|
||||
'origin': m,
|
||||
'party': party,
|
||||
'quantity': 1,
|
||||
'uom': wage_type.uom,
|
||||
'unit_value': amount,
|
||||
'move_lines': [('add', move_lines)],
|
||||
'wage_type': wage_type,
|
||||
'description': wage_type.name,
|
||||
'payroll': self,
|
||||
}
|
||||
|
||||
line, = PayrollLine.create([to_create])
|
||||
LoanLine.write([m], {'state': 'paid', 'origin': line})
|
||||
|
@ -747,8 +765,8 @@ class Payroll(metaclass=PoolMeta):
|
|||
if self.id in payrolls_ids:
|
||||
payrolls_ids.remove(self.id)
|
||||
interest_hoard = float(self._compute_hoard(
|
||||
payrolls_ids,
|
||||
[wage['id']]
|
||||
payrolls_ids,
|
||||
[wage['id']]
|
||||
))
|
||||
|
||||
interest = total_interest - interest_hoard
|
||||
|
@ -770,7 +788,6 @@ class Payroll(metaclass=PoolMeta):
|
|||
|
||||
def recompute_lines(self, cache_wage_dict):
|
||||
PayrollLine = Pool().get('staff.payroll.line')
|
||||
time_60_40 = time.time()
|
||||
amounts_60_40 = []
|
||||
amounts_60_40_app = amounts_60_40.append
|
||||
wages_60_40 = []
|
||||
|
|
|
@ -5,11 +5,13 @@ this repository contains the full copyright notices and license terms. -->
|
|||
|
||||
<xpath expr="/form/notebook/page[@id='information']/field[@name='kind']"
|
||||
position="after">
|
||||
<group colspan="2" col='4' id="group_check_box">
|
||||
<group colspan="2" col='6' id="group_check_box">
|
||||
<label name="last_payroll"/>
|
||||
<field name="last_payroll"/>
|
||||
<label name="sended_mail"/>
|
||||
<field name="sended_mail"/>
|
||||
<label name="recompute"/>
|
||||
<field name="recompute"/>
|
||||
</group>
|
||||
<label name="ibc"/>
|
||||
<field name="ibc"/>
|
||||
|
|
Loading…
Reference in New Issue