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-1971: Added reamortization foundational work
- Loading branch information
Showing
21 changed files
with
669 additions
and
4 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
26 changes: 26 additions & 0 deletions
26
...in/java/org/apache/fineract/portfolio/loanaccount/api/LoanReAmortizationApiConstants.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,26 @@ | ||
/** | ||
* 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.api; | ||
|
||
public interface LoanReAmortizationApiConstants { | ||
|
||
String localeParameterName = "locale"; | ||
String dateFormatParameterName = "dateFormat"; | ||
String externalIdParameterName = "externalId"; | ||
} |
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
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
36 changes: 36 additions & 0 deletions
36
...siness/domain/loan/transaction/reamortization/LoanReAmortizeTransactionBusinessEvent.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,36 @@ | ||
/** | ||
* 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.reamortization; | ||
|
||
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanTransactionBusinessEvent; | ||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; | ||
|
||
public class LoanReAmortizeTransactionBusinessEvent extends LoanTransactionBusinessEvent { | ||
|
||
private static final String TYPE = "LoanReAmortizeTransactionBusinessEvent"; | ||
|
||
public LoanReAmortizeTransactionBusinessEvent(LoanTransaction value) { | ||
super(value); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ss/domain/loan/transaction/reamortization/LoanUndoReAmortizeTransactionBusinessEvent.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,36 @@ | ||
/** | ||
* 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.reamortization; | ||
|
||
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanTransactionBusinessEvent; | ||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; | ||
|
||
public class LoanUndoReAmortizeTransactionBusinessEvent extends LoanTransactionBusinessEvent { | ||
|
||
private static final String TYPE = "LoanUndoReAmortizeTransactionBusinessEvent"; | ||
|
||
public LoanUndoReAmortizeTransactionBusinessEvent(LoanTransaction value) { | ||
super(value); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...t/portfolio/loanaccount/handler/loan/reamortization/LoanReAmortizationCommandHandler.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,50 @@ | ||
/** | ||
* 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.handler.loan.reamortization; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.apache.fineract.commands.annotation.CommandType; | ||
import org.apache.fineract.commands.handler.NewCommandSourceHandler; | ||
import org.apache.fineract.infrastructure.DataIntegrityErrorHandler; | ||
import org.apache.fineract.infrastructure.core.api.JsonCommand; | ||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; | ||
import org.apache.fineract.portfolio.loanaccount.service.reamortization.LoanReAmortizationServiceImpl; | ||
import org.springframework.dao.DataIntegrityViolationException; | ||
import org.springframework.orm.jpa.JpaSystemException; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@CommandType(entity = "LOAN", action = "REAMORTIZE") | ||
public class LoanReAmortizationCommandHandler implements NewCommandSourceHandler { | ||
|
||
private final LoanReAmortizationServiceImpl loanReAmortizationService; | ||
private final DataIntegrityErrorHandler dataIntegrityErrorHandler; | ||
|
||
@Override | ||
public CommandProcessingResult processCommand(JsonCommand command) { | ||
try { | ||
return loanReAmortizationService.reAmortize(command.getLoanId(), command); | ||
} catch (final JpaSystemException | DataIntegrityViolationException dve) { | ||
dataIntegrityErrorHandler.handleDataIntegrityIssues(command, dve.getMostSpecificCause(), dve, "loan.reAmortize", | ||
"Error while handling re-amortizing"); | ||
return CommandProcessingResult.empty(); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...rtfolio/loanaccount/handler/loan/reamortization/LoanUndoReAmortizationCommandHandler.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,50 @@ | ||
/** | ||
* 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.handler.loan.reamortization; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.apache.fineract.commands.annotation.CommandType; | ||
import org.apache.fineract.commands.handler.NewCommandSourceHandler; | ||
import org.apache.fineract.infrastructure.DataIntegrityErrorHandler; | ||
import org.apache.fineract.infrastructure.core.api.JsonCommand; | ||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; | ||
import org.apache.fineract.portfolio.loanaccount.service.reamortization.LoanReAmortizationServiceImpl; | ||
import org.springframework.dao.DataIntegrityViolationException; | ||
import org.springframework.orm.jpa.JpaSystemException; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@CommandType(entity = "LOAN", action = "UNDO_REAMORTIZE") | ||
public class LoanUndoReAmortizationCommandHandler implements NewCommandSourceHandler { | ||
|
||
private final LoanReAmortizationServiceImpl loanReAmortizationService; | ||
private final DataIntegrityErrorHandler dataIntegrityErrorHandler; | ||
|
||
@Override | ||
public CommandProcessingResult processCommand(JsonCommand command) { | ||
try { | ||
return loanReAmortizationService.undoReAmortize(command.getLoanId(), command); | ||
} catch (final JpaSystemException | DataIntegrityViolationException dve) { | ||
dataIntegrityErrorHandler.handleDataIntegrityIssues(command, dve.getMostSpecificCause(), dve, "loan.undoReAmortize", | ||
"Error while handling undo re-amortizing"); | ||
return CommandProcessingResult.empty(); | ||
} | ||
} | ||
} |
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.