Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

<!-- fineract-charge module: -->
<class>org.apache.fineract.portfolio.charge.domain.Charge</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeCalculationTypeConverter</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargePaymentModeConverter</class>

<!-- fineract-core module: -->
<class>org.apache.fineract.accounting.glaccount.domain.GLAccount</class>
Expand Down Expand Up @@ -83,6 +85,7 @@
<class>org.apache.fineract.useradministration.domain.AppUser</class>
<class>org.apache.fineract.useradministration.domain.Permission</class>
<class>org.apache.fineract.useradministration.domain.Role</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeTimeTypeConverter</class>

<!-- fineract-tax module: -->
<class>org.apache.fineract.portfolio.tax.domain.TaxComponent</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

<!-- fineract-charge module: -->
<class>org.apache.fineract.portfolio.charge.domain.Charge</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeCalculationTypeConverter</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargePaymentModeConverter</class>

<!-- fineract-core module: -->
<class>org.apache.fineract.accounting.glaccount.domain.GLAccount</class>
Expand Down Expand Up @@ -89,6 +91,7 @@
<class>org.apache.fineract.useradministration.domain.AppUser</class>
<class>org.apache.fineract.useradministration.domain.Permission</class>
<class>org.apache.fineract.useradministration.domain.Role</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeTimeTypeConverter</class>

<!-- fineract-tax module: -->
<class>org.apache.fineract.portfolio.tax.domain.TaxComponent</class>
Expand All @@ -98,7 +101,7 @@

<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving" value="static"/>
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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.portfolio.charge.domain;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter
public class ChargeCalculationTypeConverter implements AttributeConverter<ChargeCalculationType, Integer> {

@Override
public Integer convertToDatabaseColumn(ChargeCalculationType attribute) {
return attribute == null ? null : attribute.getValue();
}

@Override
public ChargeCalculationType convertToEntityAttribute(Integer dbData) {
return dbData == null ? null : ChargeCalculationType.fromInt(dbData);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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.portfolio.charge.domain;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter
public class ChargePaymentModeConverter implements AttributeConverter<ChargePaymentMode, Integer> {

@Override
public Integer convertToDatabaseColumn(ChargePaymentMode attribute) {
return attribute == null ? null : attribute.getValue();
}

@Override
public ChargePaymentMode convertToEntityAttribute(Integer dbData) {
return dbData == null ? null : ChargePaymentMode.fromInt(dbData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,6 @@ public interface ChargeReadPlatformService {
List<ChargeData> retrieveSharesApplicableCharges();

List<ChargeData> retrieveShareProductCharges(Long shareProductId);

List<ChargeData> retrieveWorkingCapitalLoanAccountApplicableCharges(Long resolvedLoanId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

<!-- fineract-charge module: -->
<class>org.apache.fineract.portfolio.charge.domain.Charge</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeCalculationTypeConverter</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargePaymentModeConverter</class>

<!-- fineract-core module: -->
<class>org.apache.fineract.accounting.glaccount.domain.GLAccount</class>
Expand Down Expand Up @@ -74,6 +76,7 @@
<class>org.apache.fineract.useradministration.domain.AppUser</class>
<class>org.apache.fineract.useradministration.domain.Permission</class>
<class>org.apache.fineract.useradministration.domain.Role</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeTimeTypeConverter</class>

<!-- fineract-tax module: -->
<class>org.apache.fineract.portfolio.tax.domain.TaxComponent</class>
Expand All @@ -83,7 +86,7 @@

<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving" value="static"/>
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
import org.apache.fineract.client.feign.services.WorkingCapitalBreachApi;
import org.apache.fineract.client.feign.services.WorkingCapitalLoanAccountLockApi;
import org.apache.fineract.client.feign.services.WorkingCapitalLoanBreachScheduleApi;
import org.apache.fineract.client.feign.services.WorkingCapitalLoanChargesApi;
import org.apache.fineract.client.feign.services.WorkingCapitalLoanCobCatchUpApi;
import org.apache.fineract.client.feign.services.WorkingCapitalLoanDelinquencyActionsApi;
import org.apache.fineract.client.feign.services.WorkingCapitalLoanDelinquencyRangeScheduleApi;
Expand Down Expand Up @@ -785,6 +786,10 @@ public WorkingCapitalLoansApi workingCapitalLoans() {
return create(WorkingCapitalLoansApi.class);
}

public WorkingCapitalLoanChargesApi workingCapitalLoanCharges() {
return create(WorkingCapitalLoanChargesApi.class);
}

public WorkingCapitalLoanTransactionsApi workingCapitalLoanTransactions() {
return create(WorkingCapitalLoanTransactionsApi.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@
<class>org.apache.fineract.useradministration.domain.AppUser</class>
<class>org.apache.fineract.useradministration.domain.Permission</class>
<class>org.apache.fineract.useradministration.domain.Role</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeTimeTypeConverter</class>

<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving" value="static"/>
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private CommandWrapperConstants() {}
public static final String ENTITY_CLIENT = "CLIENT";
public static final String ENTITY_DATATABLE = "DATATABLE";
public static final String ENTITY_LOANCHARGE = "LOANCHARGE";
public static final String ENTITY_WORKINGCAPITALLOANCHARGE = "WORKINGCAPITALLOANCHARGE";
public static final String ENTITY_REPAYMENT_WITH_POSTDATEDCHECKS = "REPAYMENT_WITH_POSTDATEDCHECKS";
public static final String ENTITY_DISBURSEMENTDETAIL = "DISBURSEMENTDETAIL";
public static final String ENTITY_GLIMLOAN = "GLIMLOAN";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_USER;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_WAIVECHARGE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_WORKINGCAPITALLOAN;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_WORKINGCAPITALLOANCHARGE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_WORKINGCAPITALLOANPRODUCT;
import static org.apache.fineract.useradministration.service.AppUserConstants.PASSWORD;
import static org.apache.fineract.useradministration.service.AppUserConstants.REPEAT_PASSWORD;
Expand Down Expand Up @@ -1120,6 +1121,14 @@ public CommandWrapperBuilder createLoanCharge(final Long loanId) {
return this;
}

public CommandWrapperBuilder createWorkingCapitalLoanCharge(final Long loanId) {
this.actionName = ACTION_CREATE;
this.entityName = ENTITY_WORKINGCAPITALLOANCHARGE;
this.loanId = loanId;
this.href = "/loans/" + loanId + "/charges";
return this;
}

public CommandWrapperBuilder updateLoanCharge(final Long loanId, final Long loanChargeId) {
this.actionName = ACTION_UPDATE;
this.entityName = ENTITY_LOANCHARGE;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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.portfolio.charge.domain;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter
public class ChargeTimeTypeConverter implements AttributeConverter<ChargeTimeType, Integer> {

@Override
public Integer convertToDatabaseColumn(ChargeTimeType attribute) {
return attribute == null ? null : attribute.getValue();
}

@Override
public ChargeTimeType convertToEntityAttribute(Integer dbData) {
return dbData == null ? null : ChargeTimeType.fromInt(dbData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<class>org.apache.fineract.useradministration.domain.AppUser</class>
<class>org.apache.fineract.useradministration.domain.Permission</class>
<class>org.apache.fineract.useradministration.domain.Role</class>
<class>org.apache.fineract.portfolio.charge.domain.ChargeTimeTypeConverter</class>

<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
Expand All @@ -35,13 +36,19 @@
import org.apache.fineract.client.models.ChargeRequest;
import org.apache.fineract.client.models.EnumOptionData;
import org.apache.fineract.client.models.GetChargesResponse;
import org.apache.fineract.client.models.GetLoansLoanIdChargesChargeIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdChargesTemplateResponse;
import org.apache.fineract.client.models.PostChargesResponse;
import org.apache.fineract.client.models.PostLoansLoanIdChargesRequest;
import org.apache.fineract.client.models.PostLoansLoanIdChargesResponse;
import org.apache.fineract.client.models.PostWorkingCapitalLoansResponse;
import org.apache.fineract.test.data.ChargeCalculationType;
import org.apache.fineract.test.data.ChargeProductAppliesTo;
import org.apache.fineract.test.data.ChargeTimeType;
import org.apache.fineract.test.factory.WorkingCapitalChargeRequestFactory;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.junit.jupiter.api.Assertions;

@Slf4j
@RequiredArgsConstructor
Expand Down Expand Up @@ -108,6 +115,55 @@ public void retrieveAndVerifyPaymentModeRegular() {
log.info("Verified WCL charge ID {} has Regular payment mode", id);
}

@Then("Admin retrieves working capital loan charge template by loan id")
public void getWorkingCapitalLoanChargesTemplateByLoanId() {
Long loanId = getLoanId();
Long chargeId = getChargeId();
Assertions.assertNotNull(chargeId);

GetLoansLoanIdChargesTemplateResponse response = ok(
() -> fineractClient.workingCapitalLoanCharges().retrieveTemplateWorkingCapitalLoanCharge(loanId));

Assertions.assertNotNull(response.getChargeOptions());

boolean anyMatch = response.getChargeOptions().stream().anyMatch(cO -> chargeId.equals(cO.getId()));
Assertions.assertTrue(anyMatch);

}

@Then("Admin add working capital loan charge by loan id and charge id with amount {double} and due date {string}")
public void admin_add_working_capital_loan_charge_by_loan_id_and_charge_id_with_amount(Double amount, String dueDate) {
Long loanId = getLoanId();
Assertions.assertNotNull(loanId);
Long chargeId = getChargeId();
Assertions.assertNotNull(chargeId);

PostLoansLoanIdChargesRequest request = new PostLoansLoanIdChargesRequest() //
.chargeId(chargeId).amount(amount).dueDate(dueDate).dateFormat("dd-MM-yyyy").locale("en");
PostLoansLoanIdChargesResponse response = ok(() -> fineractClient.workingCapitalLoanCharges().createLoanCharge(loanId, request));
Assertions.assertNotNull(response);
Assertions.assertNotNull(response.getResourceId());

addLoanChargeId(response.getResourceId());

}

@Then("Working Capital Loan has the created charges")
public void verifyWorkingCapitalLoanChargesAreCreated() {
Long loanId = getLoanId();
Assertions.assertNotNull(loanId);
List<GetLoansLoanIdChargesChargeIdResponse> responses = ok(
() -> fineractClient.workingCapitalLoanCharges().retrieveAllWorkingCapitalLoanChargesByLoanId(loanId));
Assertions.assertNotNull(responses);
List<Long> loanChargeIds = getLoanChargeIds();
for (GetLoansLoanIdChargesChargeIdResponse response : responses) {
Assertions.assertTrue(loanChargeIds.contains(response.getId()));
}
for (Long chargeId : loanChargeIds) {
ok(() -> fineractClient.workingCapitalLoanCharges().retrieveWorkingCapitalLoanCharge(loanId, chargeId));
}
}

@Then("Admin retrieves the charge template for Working Capital Loan")
public void retrieveChargeTemplateForWcl() {
final ChargeData templateData = ok(() -> fineractClient.charges()
Expand Down Expand Up @@ -180,12 +236,34 @@ private Long getChargeId() {
return testContext().get(TestContextKey.WORKING_CAPITAL_CHARGE_ID);
}

private void addLoanChargeId(Long loanChargeId) {
List<Long> loanChargeIds = getLoanChargeIds();
if (!loanChargeIds.contains(loanChargeId)) {
loanChargeIds.add(loanChargeId);
}
}

private List<Long> getLoanChargeIds() {
List<Long> ids = testContext().get(TestContextKey.WORKING_CAPITAL_LOAN_CHARGE_IDS);
if (ids == null) {
ids = new ArrayList<>();
testContext().set(TestContextKey.WORKING_CAPITAL_LOAN_CHARGE_IDS, ids);
}
return ids;
}

private ChargeData getChargeTemplate() {
final ChargeData templateData = testContext().get(TestContextKey.WORKING_CAPITAL_CHARGE_TEMPLATE);
assertThat(templateData).as("Charge template should not be null").isNotNull();
return templateData;
}

private Long getLoanId() {
PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
Assertions.assertNotNull(loanResponse);
return loanResponse.getLoanId();
}

// Assertion Helpers
private void assertHttpStatus(final CallFailedRuntimeException exception, final int expectedStatus) {
assertThat(exception.getStatus()).as("HTTP status code should be " + expectedStatus).isEqualTo(expectedStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ public abstract class TestContextKey {
public static final String WC_LOAN_ACTION_TEMPLATE_RESPONSE = "wcLoanActionTemplateResponse";
public static final String WORKING_CAPITAL_LOAN_RATE_CHANGE_ID = "wcLoanRateChangeId";
public static final String WORKING_CAPITAL_CHARGE_ID = "workingCapitalChargeId";
public static final String WORKING_CAPITAL_LOAN_CHARGE_IDS = "workingCapitalLoanChargeIds";
public static final String WORKING_CAPITAL_CHARGE_TEMPLATE = "workingCapitalChargeTemplate";
public static final String LAST_SAVINGS_ACCOUNT_ID = "lastSavingsAccountId";
}
Loading
Loading