Skip to content

Commit

Permalink
fix: Don't update DPD in loan if backdated
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Nov 13, 2024
1 parent 0a0d2ce commit 9e32300
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
32 changes: 17 additions & 15 deletions lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ def update_days_past_due_in_loans(
ignore_freeze=False,
is_backdated=0,
via_background_job=False,
force_update_dpd_in_loan=False,
):
from lending.loan_management.doctype.loan_repayment.loan_repayment import get_unpaid_demands

Expand Down Expand Up @@ -752,20 +753,21 @@ def update_days_past_due_in_loans(
days_past_due = 0
is_npa = 0

update_loan_and_customer_status(
demand.loan,
demand.company,
applicant_type,
applicant,
days_past_due,
is_npa,
posting_date or getdate(),
freeze_date=freeze_date,
loan_disbursement=disbursement,
is_backdated=is_backdated,
dpd_threshold=threshold,
via_background_job=via_background_job,
)
if posting_date == getdate() or force_update_dpd_in_loan:
update_loan_and_customer_status(
demand.loan,
demand.company,
applicant_type,
applicant,
days_past_due,
is_npa,
posting_date or getdate(),
freeze_date=freeze_date,
loan_disbursement=disbursement,
is_backdated=is_backdated,
dpd_threshold=threshold,
via_background_job=via_background_job,
)

create_dpd_record(
demand.loan, disbursement, posting_date, days_past_due, process_loan_classification
Expand Down Expand Up @@ -931,7 +933,7 @@ def update_loan_and_customer_status(
update_all_linked_loan_customer_npa_status(
is_npa, applicant_type, applicant, posting_date, loan, via_background_job=via_background_job
)

frappe.db.set_value(
"Loan",
loan,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"loan",
"payment_reference",
"is_backdated",
"force_update_dpd_in_loan",
"amended_from"
],
"fields": [
Expand Down Expand Up @@ -57,12 +58,18 @@
"fieldtype": "Check",
"label": "Is Backdated",
"read_only": 1
},
{
"default": "0",
"fieldname": "force_update_dpd_in_loan",
"fieldtype": "Check",
"label": "Force Update DPD in Loan"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-08-26 14:28:39.193631",
"modified": "2024-11-13 16:41:34.462122",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Process Loan Classification",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def on_submit(self):
self.name,
self.payment_reference,
self.is_backdated,
self.force_update_dpd_in_loan
)
else:
BATCH_SIZE = 5000
Expand All @@ -46,6 +47,7 @@ def on_submit(self):
classification_process=self.name,
payment_reference=self.payment_reference,
is_backdated=self.is_backdated,
force_update_dpd_in_loan=self.force_update_dpd_in_loan,
via_scheduler=True,
queue="long",
enqueue_after_commit=True,
Expand All @@ -59,6 +61,7 @@ def process_loan_classification_batch(
classification_process,
payment_reference,
is_backdated,
force_update_dpd_in_loan=False,
via_scheduler=False,
):
from lending.loan_management.doctype.loan.loan import update_days_past_due_in_loans
Expand All @@ -73,6 +76,7 @@ def process_loan_classification_batch(
ignore_freeze=True if payment_reference else False,
is_backdated=is_backdated,
via_background_job=via_scheduler,
force_update_dpd_in_loan=force_update_dpd_in_loan
)

if len(open_loans) > 1:
Expand Down

0 comments on commit 9e32300

Please sign in to comment.