Browse Source

[IMP] finalise end year operation for debt_fy.

pull/134/head
houssine 4 years ago
parent
commit
8b27d786f2
  1. 20
      easy_my_coop_loan_account/models/interest_line.py
  2. 6
      easy_my_coop_loan_account/wizard/end_of_year_operation.py

20
easy_my_coop_loan_account/models/interest_line.py

@ -26,7 +26,7 @@ class LoanInterestLine(models.Model):
move_line = { move_line = {
"date_maturity": self.due_date, "date_maturity": self.due_date,
"date": self.due_date, "date": self.due_date,
"move_id": move_id,
"move_id": move_id.id,
} }
if partner: if partner:
move_line["partner_id"] = partner.id move_line["partner_id"] = partner.id
@ -41,7 +41,7 @@ class LoanInterestLine(models.Model):
due_date = self.due_date due_date = self.due_date
return self.env["account.move"].create({ return self.env["account.move"].create({
"ref": self.loan_issue_id.reference,
"ref": self.name,
"date": due_date, "date": due_date,
"journal_id": self.company_id.loan_journal.id, "journal_id": self.company_id.loan_journal.id,
}) })
@ -54,8 +54,8 @@ class LoanInterestLine(models.Model):
company = line.company_id company = line.company_id
move = line.create_move() move = line.create_move()
debit_vals = line.get_move_line(line.partner_id)
loaner_vals = line.get_move_line(line.partner_id)
debit_vals = line.get_move_line(move, line.partner_id)
loaner_vals = line.get_move_line(move, line.partner_id)
debit_vals["debit"] = line.interest debit_vals["debit"] = line.interest
debit_vals["account_id"] = company.interest_account.id debit_vals["account_id"] = company.interest_account.id
@ -71,7 +71,7 @@ class LoanInterestLine(models.Model):
vals_list = [debit_vals, loaner_vals] vals_list = [debit_vals, loaner_vals]
if line.taxes_amount > 0: if line.taxes_amount > 0:
tax_vals = self.get_move_line()
tax_vals = self.get_move_line(move)
tax_vals["credit"] = line.taxes_amount tax_vals["credit"] = line.taxes_amount
tax_vals["account_id"] = company.tax_account.id tax_vals["account_id"] = company.tax_account.id
vals_list.append(tax_vals) vals_list.append(tax_vals)
@ -89,15 +89,15 @@ class LoanInterestLine(models.Model):
company = line.company_id company = line.company_id
move = line.create_move(date) move = line.create_move(date)
deb_vals = line.get_move_line(line.partner_id)
cred_vals = line.get_move_line(line.partner_id)
deb_vals = line.get_move_line(move, line.partner_id)
cred_vals = line.get_move_line(move, line.partner_id)
deb_vals["debit"] = line.due_loan_amount deb_vals["debit"] = line.due_loan_amount
deb_vals["date"] = date deb_vals["date"] = date
deb_vals["account_id"] = company.debt_long_term_account.id deb_vals["account_id"] = company.debt_long_term_account.id
cred_vals["credit"] = line.due_loan_amount cred_vals["credit"] = line.due_loan_amount
cred_vals["credit"] = date
cred_vals["date"] = date
cred_vals["account_id"] = company.debt_long_term_fy_account.id cred_vals["account_id"] = company.debt_long_term_fy_account.id
self.env["account.move.line"].create([deb_vals, cred_vals]) self.env["account.move.line"].create([deb_vals, cred_vals])
@ -113,8 +113,8 @@ class LoanInterestLine(models.Model):
company = line.company_id company = line.company_id
move = line.create_move(fields.Date.today()) move = line.create_move(fields.Date.today())
debit_vals = line.get_move_line(line)
credit_vals = line.get_move_line(line.partner_id)
debit_vals = line.get_move_line(move, line)
credit_vals = line.get_move_line(move, line.partner_id)
debit_vals["debit"] = line.due_loan_amount debit_vals["debit"] = line.due_loan_amount
debit_vals["account_id"] = company.debt_long_term_fy_account.id debit_vals["account_id"] = company.debt_long_term_fy_account.id

6
easy_my_coop_loan_account/wizard/end_of_year_operation.py

@ -36,9 +36,9 @@ class LoanEndOfYearOperation(models.TransientModel):
if self.operation_type == "eoy_debt": if self.operation_type == "eoy_debt":
if next_fy: if next_fy:
interest_lines = interest_line_obj.search([ interest_lines = interest_line_obj.search([
('due_date', '>=', next_fy.date_from),
('due_date', '<=', next_fy.date_to),
('due_loan_amount', '>', 0),
("due_date", ">=", next_fy.date_from),
("due_date", "<=", next_fy.date_to),
("due_loan_amount", ">", 0),
("loan_issue_id", "in", loan_issues.ids) ("loan_issue_id", "in", loan_issues.ids)
]) ])

Loading…
Cancel
Save