import influxframework


def execute():
	ld = influxframework.qb.DocType("Loan Disbursement").as_("ld")
	lr = influxframework.qb.DocType("Loan Repayment").as_("lr")
	loan = influxframework.qb.DocType("Loan")

	influxframework.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()

	influxframework.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()
