public GetLoanResponse createLoan(CreateLoanRequest createLoanRequest) {
        String loanId = UUID.randomUUID().toString();
        LoanDto loanDto = new LoanDto(
                loanId,
                createLoanRequest.term(),
                createLoanRequest.originatedAmount(),
                createLoanRequest.currency(),
                createLoanRequest.targetInterestRate(),
                createLoanRequest.effectiveInterestRate(),
                createLoanRequest.externalReference(),
                createLoanRequest.startDate(),
                createLoanRequest.endDate(),
                LoanStatus.CREATED,
                createLoanRequest.timezone(),
                createLoanRequest.region(),
                createLoanRequest.state()
        );
        List<Installment> newInstallments = calculator.newInstallments(LoanTransformer.transformForNewInstallments(createLoanRequest));
        List<LoanInstallmentDto> loanInstallmentDtos = LoanInstallmentTransformer.transform(newInstallments, loanId);
        // TODO(hubert): Add transactions
        loanInstallmentDtos.forEach(loanInstallmentDao::insert);
        loanDao.insert(loanDto);
        loanInstallmentDtos = loanInstallmentDao.findByLoanId(loanId);
        LOGGER.info("Creating new Loan: %s\nInstallments: %s".formatted(loanDto, loanInstallmentDtos));

        return new GetLoanResponse(
                LoanTransformer.transformToLoanInfo(
                        loanDto,
                        loanInstallmentDtos
                ));

    }
@Test
    public void testCreateLoan_BNPL() {
        int term = 4;
        BigDecimal originatedAmount = BigDecimal.valueOf(100.0);
        String currency = "USD";
        String externalReference = UUID.randomUUID().toString();
        LocalDate startDate = LocalDate.of(2023, 1, 1);
        LocalDate endDate = startDate;
        String timezone = "America/Los_Angeles";
        String region = "USA";
        String state = "CA";

        CreateLoanRequest createLoanRequest = new CreateLoanRequest(
                term,
                originatedAmount,
                currency,
                BigDecimal.valueOf(0),
                BigDecimal.valueOf(0),
                externalReference,
                startDate,
                endDate,
                timezone,
                region,
                state
        );

        GetLoanResponse loanResponse = loanResourceManager.createLoan(createLoanRequest);

        // Verify that all expected fields are set correctly in the response
        assertEquals(loanResponse.loanInfo().term(), term);
        assertEquals(loanResponse.loanInfo().targetInterestRate(), BigDecimal.valueOf(0));
        assertEquals(loanResponse.loanInfo().effectiveInterestRate(), BigDecimal.valueOf(0));
        assertEquals(loanResponse.loanInfo().currency(), currency);
        assertEquals(loanResponse.loanInfo().externalReference(), externalReference);
        assertEquals(loanResponse.loanInfo().startDate(), startDate);
        assertEquals(loanResponse.loanInfo().endDate(), endDate);
        assertEquals(loanResponse.loanInfo().timezone(), timezone);
        assertEquals(loanResponse.loanInfo().region(), region);
        assertEquals(loanResponse.loanInfo().state(), state);

        // Verify that the installment schedule is correct
        List<LoanInstallmentInfo> loanInstallmentInfoList = loanResponse.loanInfo().loanInstallments();
        assertEquals(loanInstallmentInfoList.size(), 4);

        // Each installment's principal should be $100/4 = $25 and its interest should be $0
        for (int i = 0; i < 4; i++) {
            LoanInstallmentInfo installment = loanInstallmentInfoList.get(i);
            assertEquals(installment.loanId(), loanResponse.loanInfo().loanId());
            assertEquals(installment.status(), InstallmentStatus.OWED);
            assertEquals(installment.principalAmount(), BigDecimal.valueOf(25).setScale(2));
            assertEquals(installment.interestAmount(), BigDecimal.valueOf(0).setScale(2));
        }
    }