def test_update_loan(self):
        loan_id = self.register_loan()

        fixed_payment = FixedPayment(amount=Money("10000"))
        periods = Periods(count=120, frequency=Frequency.MONTHLY)
        random_rate = random.random()

        updated_loan = Loan(
            agent_id=UUID("898be40f-a26e-43cb-b15c-679afdc7e278"),
            borrower_id=UUID("d12fd58d-5939-4dc2-9d57-7c3fd7ce9026"),
            lender_id=UUID("467001e0-0631-45c0-b7f1-02b4424fd526"),
            annual_rate=random_rate,
            benchmark=BenchmarkName.LIBOR_OVERNIGHT,
            commitment=Money("1000000"),
            compounding=Compounding.SIMPLE,
            day_count=DayCount.ACTUAL_360,
            fixed_payment=fixed_payment,
            origination_date="2020-05-27",
            time_zone_id="America/New_York",
            periods=periods,
        )

        resp = self.client.loan.update(loan_id=loan_id,
                                       loan=updated_loan).validate()

        self.assertIsNotNone(resp["loan_id"])
        self.assertEqual(str(loan_id), resp["loan_id"])
        self.assertAlmostEqual(random_rate, resp["annual_rate"])
 def test_create_payment(self):
     loan_id = self.register_loan()
     payment = Payment(amount=Money("5000"), date="2020-05-28")
     resp = self.client.loan.create_payment(loan_id=loan_id,
                                            payment=payment).validate()
     self.assertIsNotNone(resp["transaction_id"])
     return loan_id
 def test_draw_funds(self):
     loan_id = self.register_loan()
     draw = Draw(amount=Money("10000"), date="2020-05-28")
     resp = self.client.loan.draw_funds(loan_id=loan_id,
                                        draw=draw).validate()
     self.assertIsNotNone(resp["transaction_id"])
     return loan_id
 def test_list_loan_transactions(self):
     loan_id = self.register_loan()
     draw = Draw(amount=Money("10000"), date="2020-05-28")
     self.client.loan.draw_funds(loan_id=loan_id, draw=draw)
     resp = self.client.loan.list_transactions(
         loan_id=loan_id, transaction_type=TransactionType.DRAW).validate()
     self.assertTrue(isinstance(resp.data, list))
 def test_forgive_principal(self):
     loan_id = self.register_loan()
     forgiveness = Forgiveness(amount=Money("10000"), date="2020-01-01")
     resp = self.client.loan.forgive_principal(
         loan_id=loan_id, forgiveness=forgiveness).validate()
     self.assertIsNotNone(resp["loan_id"])
     self.assertEqual(str(loan_id), resp["loan_id"])
     self.assertIsNotNone(resp["transaction_id"])
 def test_charge_misc_fee(self):
     loan_id = self.register_loan()
     misc_fee = MiscFee(amount=Money("500"), date="2020-01-01")
     resp = self.client.loan.charge_misc_fee(loan_id=loan_id,
                                             misc_fee=misc_fee).validate()
     self.assertIsNotNone(resp["loan_id"])
     self.assertEqual(str(loan_id), resp["loan_id"])
     self.assertIsNotNone(resp["transaction_id"])
 def test_json(self):
     self.assertDictEqual(
         Forgiveness(date="2020-01-01", amount=Money("5000")).to_dict(), {
             "amount": {
                 "amount": "5000",
                 "currency": "USD"
             },
             "date": "2020-01-01"
         })
    def test_get_loan_invoice(self):
        loan_id = self.register_loan()
        draw = Draw(amount=Money("10000"), date="2020-05-28")
        self.client.loan.draw_funds(loan_id=loan_id, draw=draw)

        resp = self.client.loan.get_invoice(loan_id=loan_id,
                                            period_number=1).validate()
        self.assertIsNotNone(resp["loan_id"])
        self.assertIsNotNone(resp["period_number"])
Exemplo n.º 9
0
 def test_json(self):
     agent_id = UUID("cac761d1-9666-4c8e-8128-f3227b9ef6fe")
     borrower_id = UUID("01bf113e-4648-4859-8a2a-42bebb411a83")
     lender_id = UUID("b5ba849f-6975-4e90-b2e4-fbdec3514a68")
     fixed_payment = FixedPayment(amount=Money("10000"))
     periods = Periods(count=120, frequency=Frequency.MONTHLY)
     self.assertDictEqual(
         Loan(agent_id=agent_id, borrower_id=borrower_id, lender_id=lender_id, annual_rate=0.0475,
              benchmark=BenchmarkName.LIBOR_OVERNIGHT, commitment=Money("1000000"),
              compounding=Compounding.SIMPLE, day_count=DayCount.ACTUAL_360, fixed_payment=fixed_payment,
              origination_date="2020-05-27", time_zone_id="America/New_York", periods=periods).to_dict(),
         {
             "agent_id": agent_id,
             "annual_rate": "0.0475",
             "benchmark": "LIBOR_OVERNIGHT",
             "borrower_id": borrower_id,
             "commitment": {
                 "amount": "1000000",
                 "currency": "USD"
             },
             "compounding": "SIMPLE",
             "day_count": "ACTUAL_360",
             "fixed_payment": {
                 "amount": {
                     "amount": "10000",
                     "currency": "USD"
                 },
                 "type": "TOTAL"
             },
             "is_revolver": False,
             "lender_id": lender_id,
             "origination_date": "2020-05-27",
             "periods": {
                 "count": 120,
                 "frequency": "MONTHLY",
                 "count_deferred": 0,
                 "count_interest_only": 0,
                 "start_type": "DISBURSEMENT_DATE"
             },
             "time_zone_id": "America/New_York"
         }
     )
    def test_get_loan_transaction(self):
        loan_id = self.register_loan()

        payment = Payment(amount=Money("5000"), date="2020-05-28")
        resp = self.client.loan.create_payment(loan_id=loan_id,
                                               payment=payment)
        self.assertIsNotNone(resp["transaction_id"])
        transaction_id = UUID(resp["transaction_id"])
        resp = self.client.transaction.get(
            transaction_id=transaction_id).validate()

        self.assertIsNotNone(resp["transaction_id"])
        self.assertIsNotNone(resp["date"])
        self.assertEqual("2020-05-28", resp["date"])