fix compute_salary_full
This commit is contained in:
parent
081e9fe1c4
commit
3a7dffefcd
50
payroll.py
50
payroll.py
|
@ -303,13 +303,11 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
return {'salary': salary_full}
|
||||
|
||||
def compute_salary_full(self, wage):
|
||||
if wage['salary_constitute'] or not wage['concepts_salary']:
|
||||
return self.contract.get_salary_in_date(self.end) or 0
|
||||
|
||||
# wages_ids = [s.id for s in wage.concepts_salary]
|
||||
salary_full = sum(
|
||||
line.amount for line in self.lines if line.wage_type.id in wage['concepts_salary'])
|
||||
|
||||
if wage['concepts_salary']:
|
||||
salary_full = sum(
|
||||
line.amount for line in self.lines if line.wage_type.id in wage['concepts_salary'])
|
||||
else:
|
||||
salary_full = self.contract.get_salary_in_date(self.end) or 0
|
||||
return salary_full
|
||||
|
||||
def create_move(self, wage_dict):
|
||||
|
@ -517,8 +515,7 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
PayrollLine.create(values)
|
||||
|
||||
@classmethod
|
||||
def create_cache_wage_types(cls):
|
||||
Wage = Pool().get('staff.wage_type')
|
||||
def get_fields_names_wage_types(cls):
|
||||
fields_names = [
|
||||
'unit_price_formula', 'concepts_salary', 'salary_constitute',
|
||||
'name', 'sequence', 'definition', 'unit_price_formula',
|
||||
|
@ -529,6 +526,12 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
'debit_account.name', 'credit_account.name',
|
||||
'deduction_account.name', 'account_60_40.name'
|
||||
]
|
||||
return fields_names
|
||||
|
||||
@classmethod
|
||||
def create_cache_wage_types(cls):
|
||||
Wage = Pool().get('staff.wage_type')
|
||||
fields_names = cls.get_fields_names_wage_types()
|
||||
wages = Wage.search_read([], fields_names=fields_names)
|
||||
return {w['id']: w for w in wages}
|
||||
|
||||
|
@ -762,22 +765,27 @@ class PayrollLine(ModelSQL, ModelView):
|
|||
def on_change_wage_type(self):
|
||||
if not self.wage_type:
|
||||
return
|
||||
self.uom = self.wage_type.uom.id
|
||||
self.description = self.wage_type.name
|
||||
self.quantity = self.wage_type.default_quantity
|
||||
self.receipt = self.wage_type.receipt
|
||||
self.sequence = self.wage_type.sequence
|
||||
fields_names = self.payroll.get_fields_names_wage_types()
|
||||
wage_id = self.wage_type.id
|
||||
wage_type, = self.wage_type.search_read(
|
||||
[('id', '=', wage_id)],
|
||||
fields_names=fields_names)
|
||||
self.uom = wage_type['uom']
|
||||
self.description = wage_type['name']
|
||||
self.quantity = wage_type['default_quantity']
|
||||
self.receipt = wage_type['receipt']
|
||||
self.sequence = wage_type['sequence']
|
||||
parties = []
|
||||
for wage in self.payroll.employee.mandatory_wages:
|
||||
if wage.wage_type.id == self.wage_type.id and wage.party:
|
||||
if wage.wage_type.id == wage_id and wage.party:
|
||||
parties.append(wage.party.id)
|
||||
if parties:
|
||||
self.party = parties[0]
|
||||
|
||||
if self.wage_type.unit_price_formula:
|
||||
salary_args = self.payroll.get_salary_full(self.wage_type)
|
||||
if wage_type['unit_price_formula']:
|
||||
salary_args = self.payroll.get_salary_full(wage_type)
|
||||
self.unit_value = self.wage_type.compute_unit_price(
|
||||
self.wage_type.unit_price_formula, salary_args)
|
||||
wage_type['unit_price_formula'], salary_args)
|
||||
|
||||
def get_amount(self, name):
|
||||
return self.on_change_with_amount()
|
||||
|
@ -924,13 +932,13 @@ class PayrollGroup(Wizard):
|
|||
time_pre = time.time()
|
||||
payroll.set_preliquidation(config, {}, None, cache_wage_dict)
|
||||
time_pre2 = time.time()
|
||||
print(time_pre2-time_pre, 'time preliquidation')
|
||||
# print(time_pre2-time_pre, 'time preliquidation')
|
||||
if wages:
|
||||
payroll._create_payroll_lines(config, wages, None, {}, cache_wage_dict)
|
||||
# except Exception as e:
|
||||
# print('Fallo al crear nomina : ', payroll.employee.party.name, e)
|
||||
time_final = time.time()
|
||||
print(time_final - time_initial, 'final create payroll')
|
||||
# print(time_final - time_initial, 'final create payroll')
|
||||
return 'end'
|
||||
|
||||
def get_employees_dom(self, employees_w_payroll):
|
||||
|
@ -982,7 +990,7 @@ class PayrollPreliquidation(Wizard):
|
|||
time_1 = time.time()
|
||||
payroll.set_preliquidation(config, {}, None, cache_wage_dict)
|
||||
time_2 = time.time()
|
||||
print(time_2-time_1, 'time preliquidation')
|
||||
# print(time_2-time_1, 'time preliquidation')
|
||||
else:
|
||||
payroll.update_preliquidation({}, cache_wage_dict)
|
||||
return 'end'
|
||||
|
|
Loading…
Reference in New Issue