forked from apache/fineract
-
Notifications
You must be signed in to change notification settings - Fork 0
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 11, 2024
1 parent
832b84f
commit d0342c0
Showing
46 changed files
with
1,568 additions
and
1,203 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
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; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/AccrualAmountsData.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,87 @@ | ||
/** | ||
* 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.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.MonetaryCurrency; | ||
import org.apache.fineract.organisation.monetary.domain.Money; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
@RequiredArgsConstructor | ||
public class AccrualAmountsData { | ||
|
||
private final Integer installmentNumber; | ||
private final MonetaryCurrency currency; | ||
private Money interestAmount; | ||
private Money interestAccruable; | ||
private Money interestAccrued; | ||
private List<AccrualChargeData> charges; | ||
|
||
public AccrualAmountsData addCharge(AccrualChargeData charge) { | ||
if (charges == null) { | ||
charges = new ArrayList<>(); | ||
} | ||
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); | ||
} | ||
} |
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; | ||
|
||
} |
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
Oops, something went wrong.