Exemple #1
0
    def test_disbursal_check_with_shortfall(self):
        pledges = [{
            "loan_security": "Test Security 2",
            "qty": 8000.00,
            "haircut": 50,
        }]

        loan_application = create_loan_application(
            '_Test Company', self.applicant2, 'Stock Loan', pledges,
            "Repay Over Number of Periods", 12)

        create_pledge(loan_application)

        loan = create_loan_with_security(self.applicant2, "Stock Loan",
                                         "Repay Over Number of Periods", 12,
                                         loan_application)
        loan.submit()

        # Disbursing 7,00,000 from the allowed 10,00,000 according to security pledge
        make_loan_disbursement_entry(loan.name, 700000)

        frappe.db.sql(
            """UPDATE `tabLoan Security Price` SET loan_security_price = 100
			where loan_security='Test Security 2'""")

        create_process_loan_security_shortfall()
        loan_security_shortfall = frappe.get_doc("Loan Security Shortfall",
                                                 {"loan": loan.name})
        self.assertTrue(loan_security_shortfall)

        self.assertEqual(get_disbursal_amount(loan.name), 0)

        frappe.db.sql(
            """ UPDATE `tabLoan Security Price` SET loan_security_price = 250
			where loan_security='Test Security 2'""")
Exemple #2
0
    def test_security_shortfall(self):
        pledges = []
        pledges.append({
            "loan_security": "Test Security 2",
            "qty": 8000.00,
            "haircut": 50,
        })

        loan_security_pledge = create_loan_security_pledge(
            self.applicant2, pledges)

        loan = create_loan_with_security(self.applicant2, "Stock Loan",
                                         "Repay Over Number of Periods", 12,
                                         loan_security_pledge.name)
        loan.submit()

        make_loan_disbursement_entry(loan.name, loan.loan_amount)

        frappe.db.sql(
            """UPDATE `tabLoan Security Price` SET loan_security_price = 100
			where loan_security='Test Security 2'""")

        create_process_loan_security_shortfall()
        loan_security_shortfall = frappe.get_doc("Loan Security Shortfall",
                                                 {"loan": loan.name})
        self.assertTrue(loan_security_shortfall)

        self.assertEquals(loan_security_shortfall.loan_amount, 1000000.00)
        self.assertEquals(loan_security_shortfall.security_value, 400000.00)
        self.assertEquals(loan_security_shortfall.shortfall_amount, 600000.00)

        frappe.db.sql(
            """ UPDATE `tabLoan Security Price` SET loan_security_price = 250
			where loan_security='Test Security 2'""")