oleksii-novikov-onix commented on code in PR #5580: URL: https://github.com/apache/fineract/pull/5580#discussion_r2909857934
########## fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalAmortizationScheduleStepDef.java: ########## @@ -0,0 +1,213 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.test.stepdef.loan; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.cucumber.datatable.DataTable; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.client.feign.FineractFeignClient; +import org.apache.fineract.client.feign.services.WorkingCapitalLoansApi; +import org.apache.fineract.client.models.ProjectedAmortizationScheduleData; +import org.apache.fineract.client.models.ProjectedAmortizationScheduleGenerateRequest; +import org.apache.fineract.client.models.ProjectedAmortizationScheduleInstallmentData; +import org.apache.fineract.test.helper.WorkingCapitalLoanTestHelper; +import org.apache.fineract.test.stepdef.AbstractStepDef; +import org.apache.fineract.test.support.TestContext; +import org.assertj.core.api.SoftAssertions; + +@Slf4j +@RequiredArgsConstructor +public class WorkingCapitalAmortizationScheduleStepDef extends AbstractStepDef { + + private static final String WC_LOAN_ID_KEY = "WC_AMORT_LOAN_ID"; + private static final String WC_AMORT_SCHEDULE_KEY = "WC_AMORT_SCHEDULE_RESPONSE"; + + private final FineractFeignClient fineractFeignClient; + private final WorkingCapitalLoanTestHelper wcLoanTestHelper; + + @Given("An active Working Capital Loan exists for amortization schedule testing") + public void createActiveLoan() { + final Long loanId = wcLoanTestHelper.insertActiveLoan(); + log.info("Created active WC loan with id: {}", loanId); + TestContext.INSTANCE.set(WC_LOAN_ID_KEY, loanId); + } + + @When("Admin generates a projected amortization schedule with principalAmount {double}, discountAmount {double}, netAmount {double}, totalPaymentValue {double}, periodPaymentRate {double}, npvDayCount {int}, startDate {string}") + public void generateAmortizationSchedule(final double principalAmount, final double discountAmount, final double netAmount, + final double totalPaymentValue, final double periodPaymentRate, final int npvDayCount, final String startDate) { + final Long loanId = TestContext.INSTANCE.<Long>get(WC_LOAN_ID_KEY); + final WorkingCapitalLoansApi api = fineractFeignClient.create(WorkingCapitalLoansApi.class); + + final ProjectedAmortizationScheduleGenerateRequest request = new ProjectedAmortizationScheduleGenerateRequest(); + request.setPrincipalAmount(BigDecimal.valueOf(principalAmount)); + request.setDiscountAmount(BigDecimal.valueOf(discountAmount)); + request.setNetAmount(BigDecimal.valueOf(netAmount)); Review Comment: I removed `principalAmount` because it duplicated `netAmount`. We are using `netAmount` to calculate the loan term and EIR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
