-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FINERACT-2060: Accrual reverse replay logic and Handling
- Loading branch information
Marta Jankovics
committed
Nov 20, 2024
1 parent
628f27b
commit d2ce08a
Showing
60 changed files
with
1,806 additions
and
2,418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...event/business/domain/loan/transaction/LoanAccrualAdjustmentTransactionBusinessEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* 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.infrastructure.event.business.domain.loan.transaction; | ||
|
||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; | ||
|
||
public class LoanAccrualAdjustmentTransactionBusinessEvent extends LoanTransactionBusinessEvent { | ||
|
||
private static final String TYPE = "LoanAccrualAdjustmentTransactionBusinessEvent"; | ||
|
||
public LoanAccrualAdjustmentTransactionBusinessEvent(LoanTransaction value) { | ||
super(value); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/AccrualChargeData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* 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.loanaccount.data; | ||
|
||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Accessors; | ||
import org.apache.fineract.organisation.monetary.domain.Money; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
@RequiredArgsConstructor | ||
public class AccrualChargeData { | ||
|
||
private final Long loanChargeId; | ||
private final Long loanInstallmentChargeId; | ||
private final boolean isPenalty; | ||
private Money chargeAmount; | ||
private Money chargeAccruable; | ||
private Money chargeAccrued; | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
...-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/AccrualPeriodData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* 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.loanaccount.data; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Accessors; | ||
import org.apache.fineract.infrastructure.core.service.MathUtil; | ||
import org.apache.fineract.organisation.monetary.domain.Money; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
@RequiredArgsConstructor | ||
public class AccrualPeriodData { | ||
|
||
private final Integer installmentNumber; | ||
private final boolean isFirstPeriod; | ||
private final LocalDate startDate; | ||
private final LocalDate dueDate; | ||
private Money interestAmount; | ||
private Money interestAccruable; | ||
private Money interestAccrued; | ||
private final List<AccrualChargeData> charges = new ArrayList<>(); | ||
|
||
public AccrualPeriodData addCharge(AccrualChargeData charge) { | ||
charges.add(charge); | ||
return this; | ||
} | ||
|
||
public Money getChargeAmount() { | ||
return charges.stream().map(AccrualChargeData::getChargeAmount).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getFeeAmount() { | ||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getChargeAmount).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getPenaltyAmount() { | ||
return charges.stream().filter(AccrualChargeData::isPenalty).map(AccrualChargeData::getChargeAmount).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getChargeAccrued() { | ||
return charges.stream().map(AccrualChargeData::getChargeAccrued).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getFeeAccrued() { | ||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getChargeAccrued).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getPenaltyAccrued() { | ||
return charges.stream().filter(AccrualChargeData::isPenalty).map(AccrualChargeData::getChargeAccrued).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getChargeAccruable() { | ||
return charges.stream().map(AccrualChargeData::getChargeAccruable).reduce(null, MathUtil::plus); | ||
} | ||
|
||
public Money getFeeAccruable() { | ||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getChargeAccruable).reduce(null, | ||
MathUtil::plus); | ||
} | ||
|
||
public Money getPenaltyAccruable() { | ||
return charges.stream().filter(AccrualChargeData::isPenalty).map(AccrualChargeData::getChargeAccruable).reduce(null, | ||
MathUtil::plus); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/AccrualPeriodsData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* 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.loanaccount.data; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Accessors; | ||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; | ||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
@RequiredArgsConstructor | ||
public class AccrualPeriodsData { | ||
|
||
private final MonetaryCurrency currency; | ||
private final List<AccrualPeriodData> periods = new ArrayList<>(); | ||
|
||
public AccrualPeriodsData addPeriod(AccrualPeriodData period) { | ||
periods.add(period); | ||
return this; | ||
} | ||
|
||
public static AccrualPeriodsData create(@NotNull List<LoanRepaymentScheduleInstallment> installments, Integer firstInstallmentNumber, | ||
MonetaryCurrency currency) { | ||
AccrualPeriodsData accrualPeriods = new AccrualPeriodsData(currency); | ||
for (LoanRepaymentScheduleInstallment installment : installments) { | ||
Integer installmentNumber = installment.getInstallmentNumber(); | ||
boolean isFirst = installmentNumber.equals(firstInstallmentNumber); | ||
accrualPeriods | ||
.addPeriod(new AccrualPeriodData(installmentNumber, isFirst, installment.getFromDate(), installment.getDueDate())); | ||
} | ||
return accrualPeriods; | ||
} | ||
|
||
public AccrualPeriodData getPeriodByInstallmentNumber(Integer installmentNumber) { | ||
return installmentNumber == null ? null | ||
: periods.stream().filter(p -> installmentNumber.equals(p.getInstallmentNumber())).findFirst().orElse(null); | ||
} | ||
|
||
public Integer getFirstInstallmentNumber() { | ||
return periods.stream().filter(AccrualPeriodData::isFirstPeriod).map(AccrualPeriodData::getInstallmentNumber).findFirst() | ||
.orElse(null); | ||
} | ||
} |
Oops, something went wrong.