brotherton-erpnext/erpnext/patches/v13_0/update_accounts_in_loan_docs.py
2022-02-21 11:44:00 +05:30

38 lines
685 B
Python

import frappe
def execute():
ld = frappe.qb.DocType("Loan Disbursement").as_("ld")
lr = frappe.qb.DocType("Loan Repayment").as_("lr")
loan = frappe.qb.DocType("Loan")
frappe.qb.update(
ld
).inner_join(
loan
).on(
loan.name == ld.against_loan
).set(
ld.disbursement_account, loan.disbursement_account
).set(
ld.loan_account, loan.loan_account
).where(
ld.docstatus < 2
).run()
frappe.qb.update(
lr
).inner_join(
loan
).on(
loan.name == lr.against_loan
).set(
lr.payment_account, loan.payment_account
).set(
lr.loan_account, loan.loan_account
).set(
lr.penalty_income_account, loan.penalty_income_account
).where(
lr.docstatus < 2
).run()