Skip to content

Commit

Permalink
chore: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbaburajan committed Nov 30, 2023
1 parent 2cefebe commit b0284bd
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def set_default_charge_account(self):
)

charge.account = account

def set_available_limit_amount(self):
self.available_limit_amount = self.maximum_limit_amount

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ def validate_disbursal_amount(self):
elif self.disbursed_amount > possible_disbursal_amount:
frappe.throw(_("Disbursed Amount cannot be greater than {0}").format(possible_disbursal_amount))

if (
if limit_details.available_limit_amount and self.disbursed_amount > flt(
limit_details.available_limit_amount
and self.disbursed_amount > flt(limit_details.available_limit_amount)
):
frappe.throw(_("Disbursement amount cannot be greater than available limit amount"))

Expand All @@ -295,13 +294,19 @@ def set_status_and_amounts(self, cancel=0):
"is_secured_loan",
"maximum_limit_amount",
"available_limit_amount",
"utilized_limit_amount"
"utilized_limit_amount",
],
filters={"name": self.against_loan},
)[0]

if cancel:
disbursed_amount, status, total_payment, new_available_limit_amount, new_utilized_limit_amount = self.get_values_on_cancel(loan_details)
(
disbursed_amount,
status,
total_payment,
new_available_limit_amount,
new_utilized_limit_amount,
) = self.get_values_on_cancel(loan_details)
else:
(
disbursed_amount,
Expand All @@ -310,7 +315,7 @@ def set_status_and_amounts(self, cancel=0):
total_interest_payable,
monthly_repayment_amount,
new_available_limit_amount,
new_utilized_limit_amount
new_utilized_limit_amount,
) = self.get_values_on_submit(loan_details)

frappe.db.set_value(
Expand Down Expand Up @@ -345,15 +350,29 @@ def get_values_on_cancel(self, loan_details):
status = "Disbursed"
else:
status = "Partially Disbursed"

new_available_limit_amount = loan_details.available_limit_amount + self.disbursed_amount if loan_details.available_limit_amount else 0.0
new_utilized_limit_amount = loan_details.utilized_limit_amount - self.disbursed_amount if loan_details.utilized_limit_amount else 0.0

return disbursed_amount, status, total_payment, new_available_limit_amount, new_utilized_limit_amount
new_available_limit_amount = (
loan_details.available_limit_amount + self.disbursed_amount
if loan_details.available_limit_amount
else 0.0
)
new_utilized_limit_amount = (
loan_details.utilized_limit_amount - self.disbursed_amount
if loan_details.utilized_limit_amount
else 0.0
)

return (
disbursed_amount,
status,
total_payment,
new_available_limit_amount,
new_utilized_limit_amount,
)

def get_values_on_submit(self, loan_details):
disbursed_amount = self.disbursed_amount + loan_details.disbursed_amount

total_payment = loan_details.total_payment
total_interest_payable = loan_details.total_interest_payable
monthly_repayment_amount = 0
Expand Down Expand Up @@ -390,11 +409,27 @@ def get_values_on_submit(self, loan_details):
status = "Disbursed"
else:
status = "Partially Disbursed"

new_available_limit_amount = loan_details.available_limit_amount - self.disbursed_amount if loan_details.maximum_limit_amount else 0.0
new_utilized_limit_amount = loan_details.utilized_limit_amount + self.disbursed_amount if loan_details.maximum_limit_amount else 0.0

return disbursed_amount, status, total_payment, total_interest_payable, monthly_repayment_amount, new_available_limit_amount, new_utilized_limit_amount
new_available_limit_amount = (
loan_details.available_limit_amount - self.disbursed_amount
if loan_details.maximum_limit_amount
else 0.0
)
new_utilized_limit_amount = (
loan_details.utilized_limit_amount + self.disbursed_amount
if loan_details.maximum_limit_amount
else 0.0
)

return (
disbursed_amount,
status,
total_payment,
total_interest_payable,
monthly_repayment_amount,
new_available_limit_amount,
new_utilized_limit_amount,
)

def make_gl_entries(self, cancel=0, adv_adj=0):
gle_map = []
Expand Down
10 changes: 7 additions & 3 deletions lending/loan_management/doctype/loan_repayment/loan_repayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,17 @@ def update_paid_amount(self):
"written_off_amount",
"maximum_limit_amount",
"available_limit_amount",
"utilized_limit_amount"
"utilized_limit_amount",
],
as_dict=1,
)

new_available_limit_amount = loan.available_limit_amount + self.principal_amount_paid if loan.maximum_limit_amount else 0.0
new_utilized_limit_amount = loan.utilized_limit_amount - self.principal_amount_paid if loan.maximum_limit_amount else 0.0
new_available_limit_amount = (
loan.available_limit_amount + self.principal_amount_paid if loan.maximum_limit_amount else 0.0
)
new_utilized_limit_amount = (
loan.utilized_limit_amount - self.principal_amount_paid if loan.maximum_limit_amount else 0.0
)

loan.update(
{
Expand Down

0 comments on commit b0284bd

Please sign in to comment.