minor fix

This commit is contained in:
Wilson Gomez 2023-09-14 15:09:55 -05:00
parent a212b24abc
commit d92eacd1cd
1 changed files with 35 additions and 5 deletions

View File

@ -378,7 +378,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
if account_id not in grouped.keys():
grouped[account_id] = {
'amount': [],
'description': line.description,
'description': line.description,
'lines': [],
}
grouped[account_id]['amount'].append(amount_line)
@ -389,7 +389,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
if account_id not in grouped.keys():
grouped[account_id] = {
'amount': [],
'description': line.description,
'description': line.description,
'lines': [],
}
grouped[account_id]['amount'].append(line.amount)
@ -476,8 +476,9 @@ class Liquidation(Workflow, ModelSQL, ModelView):
date_start = self.start_period.start
if self.contract.start_date > self.start_period.start:
date_start = self.contract.start_date
# date_end = self.end_period.end
date_end = self.contract.finished_date
date_end = self.end_period.end
if self.kind == 'contract':
date_end = self.contract.finished_date
return date_start, date_end
@classmethod
@ -503,7 +504,6 @@ class Liquidation(Workflow, ModelSQL, ModelView):
('move.origin', '=', None),
])
lines = MoveLine.search(domain)
return lines
@classmethod
@ -520,6 +520,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
super(Liquidation, cls).delete(records)
def set_liquidation_lines(self):
print('ingresa a liq lines')
pool = Pool()
Payroll = pool.get('staff.payroll')
LiquidationMove = pool.get('staff.liquidation.line-move.line')
@ -534,6 +535,9 @@ class Liquidation(Workflow, ModelSQL, ModelView):
wages = {}
wages_target = {}
moves = [p.move.id for p in payrolls]
for p in payrolls:
print(p.move for p in payrolls)
print(moves, 'validate moves', payrolls)
for payroll in payrolls:
for l in payroll.lines:
if not l.wage_type.contract_finish:
@ -545,6 +549,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
continue
if l.wage_type.id not in wages_target.keys():
print('ingresa a este punto')
mlines = self.get_moves_lines_pending(
payroll.employee, l.wage_type, date_end, moves
)
@ -579,6 +584,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
self.write([self], {'lines': [('create', wages.values())]})
if self.kind == 'contract':
self.process_loans_to_pay()
self.calculate_discounts()
def get_line_(self, wage, amount, days, account_id, party=None):
value = {
@ -592,6 +598,30 @@ class Liquidation(Workflow, ModelSQL, ModelView):
}
return value
def calculate_discounts(self):
LiquidationLine = Pool().get('staff.liquidation.line')
wage_no_salary = [mw for mw in self.employee.mandatory_wages \
if not mw.wage_type.salary_constitute and mw.wage_type.definition == 'deduction']
lines_to_create = []
for mw in wage_no_salary:
wage = mw.wage_type
concepts_salary = [c.id for c in wage.concepts_salary]
if concepts_salary:
salary_full = sum(
line.amount for line in self.lines if line.wage.id in concepts_salary)
amount = wage.compute_unit_price(
wage.unit_price_formula,
{'salary': salary_full})
if amount > 0:
value = self.get_line_(
wage, amount * -1,
1,
wage.deduction_account.id,
party=mw.party)
value['liquidation'] = self
lines_to_create.append(value)
LiquidationLine.create(lines_to_create)
def process_loans_to_pay(self):
pool = Pool()
MoveLine = pool.get('account.move.line')