def create_test_recovery(**kwargs): args = frappe._dict(kwargs) if not args.skip_dependencies: create_test_loan( loan_no=args.loan or '_Test Loan 1', loan_plan=args.loan_plan or '_Test Loan Plan Basic', loan_principal=args.loan_principal or 100000.0, ) create_test_disbursement( loan=args.loan or '_Test Loan 1', amount=args.amount or args.loan_principal or 100000.0, skip_dependencies=True, ) doc = frappe.new_doc('Microfinance Recovery') doc.update({ 'loan': args.loan or '_Test Loan 1', 'posting_date': args.posting_date or '2017-09-17', 'total_interests': args.total_interests or 0.0, 'principal_amount': args.principal_amount or 0.0, 'mode_of_payment': args.mode_of_payment or 'Cash', }) if args.charges: for item in args.charges: doc.append('charges', item) if args.mode_of_payment == 'Cheque': doc.update({ 'cheque_no': args.cheque_no or 'ABCABC', 'cheque_date': args.cheque_date or '2017-08-20', }) if not args.do_not_insert: doc.insert(ignore_if_duplicate=True) if not args.do_not_submit: doc.submit() return doc
def create_test_interest(**kwargs): args = frappe._dict(kwargs) if not args.skip_dependencies: create_test_loan( loan_no=args.loan or "_Test Loan 1", loan_principal=args.loan_principal or 100000.0, loan_plan=args.loan_plan or "_Test Loan Plan Eco", ) create_test_disbursement( loan=args.loan or "_Test Loan 1", amount=args.loan_principal or 100000.0, skip_dependencies=True, ) doc = frappe.new_doc("Microfinance Loan Interest") doc.update({ "loan": args.loan or "_Test Loan 1", "posting_date": args.posting_date or "2017-09-17", "start_date": args.start_date or "2017-08-19", "end_date": args.start_date or "2017-08-31", "billed_amount": args.billed_amount, }) if not args.do_not_insert: doc.insert(ignore_if_duplicate=True) if not args.do_not_submit: doc.submit() return doc
def create_test_write_off(**kwargs): args = frappe._dict(kwargs) if not args.skip_dependencies: create_test_loan( loan_no=args.loan or "_Test Loan 1", loan_principal=args.loan_principal or 100000.0, loan_plan=args.loan_plan or "_Test Loan Plan Eco", ) create_test_disbursement( loan=args.loan or "_Test Loan 1", amount=args.loan_principal or 100000.0, skip_dependencies=True, ) doc = frappe.new_doc("Microfinance Write Off") doc.update({ "loan": args.loan or "_Test Loan 1", "posting_date": args.posting_date or "2017-09-17", "amount": args.amount or 25000.0, "reason": args.reason or "_Test Write Off Reason", }) if not args.do_not_insert: doc.insert(ignore_if_duplicate=True) if not args.do_not_submit: doc.submit() return doc
def create_test_recovery(**kwargs): args = frappe._dict(kwargs) if not args.skip_dependencies: create_test_loan( loan_no=args.loan or "_Test Loan 1", loan_plan=args.loan_plan or "_Test Loan Plan Basic", loan_principal=args.loan_principal or 100000.0, ) create_test_disbursement( loan=args.loan or "_Test Loan 1", amount=args.amount or args.loan_principal or 100000.0, skip_dependencies=True, ) doc = frappe.new_doc("Microfinance Recovery") doc.update({ "loan": args.loan or "_Test Loan 1", "posting_date": args.posting_date or "2017-09-17", "total_interests": args.total_interests or 0.0, "principal_amount": args.principal_amount or 0.0, "mode_of_payment": args.mode_of_payment or "Cash", }) if args.charges: for item in args.charges: doc.append("charges", item) if args.mode_of_payment == "Cheque": doc.update({ "cheque_no": args.cheque_no or "ABCABC", "cheque_date": args.cheque_date or "2017-08-20", }) if not args.do_not_insert: doc.insert(ignore_if_duplicate=True) if not args.do_not_submit: doc.submit() return doc
def test_update_amounts_raises_when_less_than_disbursed(self): create_test_loan(loan_no="_Test Loan 1", loan_principal=50000.0, recovery_amount=5000.0) create_test_disbursement(skip_dependencies=True, loan="_Test Loan 1", amount=40000.0) with self.assertRaises(frappe.exceptions.ValidationError): update_amounts(name="_Test Loan 1", principal_amount=39000.0) remove_test_disbursement("_Test Loan 1", keep_dependencies=True)
def create_test_write_off(**kwargs): args = frappe._dict(kwargs) if not args.skip_dependencies: create_test_loan(loan_no=args.loan or '_Test Loan 1', loan_principal=args.loan_principal or 100000.0, loan_plan=args.loan_plan or '_Test Loan Plan Eco') create_test_disbursement( loan=args.loan or '_Test Loan 1', amount=args.loan_principal or 100000.0, skip_dependencies=True, ) doc = frappe.new_doc('Microfinance Write Off') doc.update({ 'loan': args.loan or '_Test Loan 1', 'posting_date': args.posting_date or '2017-09-17', 'amount': args.amount or 25000.0, 'reason': args.reason or '_Test Write Off Reason', }) if not args.do_not_insert: doc.insert(ignore_if_duplicate=True) if not args.do_not_submit: doc.submit() return doc
def create_test_interest(**kwargs): args = frappe._dict(kwargs) if not args.skip_dependencies: create_test_loan(loan_no=args.loan or '_Test Loan 1', loan_principal=args.loan_principal or 100000.0, loan_plan=args.loan_plan or '_Test Loan Plan Eco') create_test_disbursement( loan=args.loan or '_Test Loan 1', amount=args.loan_principal or 100000.0, skip_dependencies=True, ) doc = frappe.new_doc('Microfinance Loan Interest') doc.update({ 'loan': args.loan or '_Test Loan 1', 'posting_date': args.posting_date or '2017-09-17', 'start_date': args.start_date or '2017-08-19', 'end_date': args.start_date or '2017-08-31', 'billed_amount': args.billed_amount, }) if not args.do_not_insert: doc.insert(ignore_if_duplicate=True) if not args.do_not_submit: doc.submit() return doc