def test_loan_security_unpledge(self): pledge = [{"loan_security": "Test Security 1", "qty": 4000.00}] loan_application = create_loan_application("_Test Company", self.applicant2, "Demand Loan", pledge) create_pledge(loan_application) loan = create_demand_loan(self.applicant2, "Demand Loan", loan_application, posting_date="2019-10-01") loan.submit() self.assertEqual(loan.loan_amount, 1000000) first_date = "2019-10-01" last_date = "2019-10-30" no_of_days = date_diff(last_date, first_date) + 1 no_of_days += 5 accrued_interest_amount = ( loan.loan_amount * loan.rate_of_interest * no_of_days) / (days_in_year(get_datetime(first_date).year) * 100) make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=first_date) process_loan_interest_accrual_for_demand_loans(posting_date=last_date) repayment_entry = create_repayment_entry( loan.name, self.applicant2, add_days(last_date, 5), flt(loan.loan_amount + accrued_interest_amount), ) repayment_entry.submit() request_loan_closure(loan.name) loan.load_from_db() self.assertEqual(loan.status, "Loan Closure Requested") unpledge_request = unpledge_security(loan=loan.name, save=1) unpledge_request.submit() unpledge_request.status = "Approved" unpledge_request.save() loan.load_from_db() pledged_qty = get_pledged_security_qty(loan.name) self.assertEqual(loan.status, "Closed") self.assertEqual(sum(pledged_qty.values()), 0) amounts = amounts = calculate_amounts(loan.name, add_days(last_date, 5)) self.assertEqual(amounts["pending_principal_amount"], 0) self.assertEqual(amounts["payable_principal_amount"], 0.0) self.assertEqual(amounts["interest_amount"], 0)
def test_loan_security_unpledge(self): pledge = [{"loan_security": "Test Security 1", "qty": 4000.00}] loan_application = create_loan_application('_Test Company', self.applicant2, 'Demand Loan', pledge) create_pledge(loan_application) loan = create_demand_loan(self.applicant2, "Demand Loan", loan_application, posting_date=get_first_day(nowdate())) loan.submit() self.assertEquals(loan.loan_amount, 1000000) first_date = '2019-10-01' last_date = '2019-10-30' no_of_days = date_diff(last_date, first_date) + 1 no_of_days += 6 accrued_interest_amount = (loan.loan_amount * loan.rate_of_interest * no_of_days) \ / (days_in_year(get_datetime(first_date).year) * 100) make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=first_date) process_loan_interest_accrual_for_demand_loans(posting_date=last_date) repayment_entry = create_repayment_entry( loan.name, self.applicant2, add_days(last_date, 6), "Loan Closure", flt(loan.loan_amount + accrued_interest_amount)) repayment_entry.submit() loan.load_from_db() self.assertEquals(loan.status, "Loan Closure Requested") unpledge_request = unpledge_security(loan=loan.name, save=1) unpledge_request.submit() unpledge_request.status = 'Approved' unpledge_request.save() loan.load_from_db() pledged_qty = get_pledged_security_qty(loan.name) self.assertEqual(loan.status, 'Closed') self.assertEquals(sum(pledged_qty.values()), 0) amounts = amounts = calculate_amounts(loan.name, add_days(last_date, 6), "Regular Repayment") self.assertEqual(amounts['pending_principal_amount'], 0) self.assertEqual(amounts['payable_principal_amount'], 0) self.assertEqual(amounts['interest_amount'], 0)
def test_partial_loan_security_unpledge(self): pledge = [ { "loan_security": "Test Security 1", "qty": 2000.00 }, { "loan_security": "Test Security 2", "qty": 4000.00 }, ] loan_application = create_loan_application("_Test Company", self.applicant2, "Demand Loan", pledge) create_pledge(loan_application) loan = create_demand_loan(self.applicant2, "Demand Loan", loan_application, posting_date="2019-10-01") loan.submit() self.assertEqual(loan.loan_amount, 1000000) first_date = "2019-10-01" last_date = "2019-10-30" make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=first_date) process_loan_interest_accrual_for_demand_loans(posting_date=last_date) repayment_entry = create_repayment_entry(loan.name, self.applicant2, add_days(last_date, 5), 600000) repayment_entry.submit() unpledge_map = {"Test Security 2": 2000} unpledge_request = unpledge_security(loan=loan.name, security_map=unpledge_map, save=1) unpledge_request.submit() unpledge_request.status = "Approved" unpledge_request.save() unpledge_request.submit() unpledge_request.load_from_db() self.assertEqual(unpledge_request.docstatus, 1)
def test_santined_loan_security_unpledge(self): pledge = [{ "loan_security": "Test Security 1", "qty": 4000.00 }] loan_application = create_loan_application('_Test Company', self.applicant2, 'Demand Loan', pledge) create_pledge(loan_application) loan = create_demand_loan(self.applicant2, "Demand Loan", loan_application, posting_date='2019-10-01') loan.submit() self.assertEquals(loan.loan_amount, 1000000) unpledge_map = {'Test Security 1': 4000} unpledge_request = unpledge_security(loan=loan.name, security_map = unpledge_map, save=1) unpledge_request.submit() unpledge_request.status = 'Approved' unpledge_request.save() unpledge_request.submit()