FINERACT-2181: No need for explicit serialization

This commit is contained in:
Adam Saghy
2025-06-04 21:24:21 +02:00
parent 83905d627d
commit 6e5c6c4913
4 changed files with 9 additions and 11 deletions
@@ -61,8 +61,8 @@ public class EmbeddableProgressiveLoanScheduleGenerator {
}
@Override
public String writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) {
return "";
public ProgressiveLoanInterestScheduleModel writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) {
return null;
}
@Override
@@ -31,7 +31,7 @@ public interface InterestScheduleModelRepositoryWrapper {
Optional<ProgressiveLoanInterestScheduleModel> extractModel(Optional<ProgressiveLoanModel> progressiveLoanModel);
String writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model);
ProgressiveLoanInterestScheduleModel writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model);
Optional<ProgressiveLoanInterestScheduleModel> readProgressiveLoanInterestScheduleModel(Long loanId,
LoanProductMinimumRepaymentScheduleRelatedDetail detail, Integer installmentAmountInMultipliesOf);
@@ -50,7 +50,7 @@ public class InterestScheduleModelRepositoryWrapperImpl implements InterestSched
@Transactional
@Override
public String writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) {
public ProgressiveLoanInterestScheduleModel writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) {
if (model == null) {
return null;
}
@@ -66,7 +66,7 @@ public class InterestScheduleModelRepositoryWrapperImpl implements InterestSched
progressiveLoanModel.setJsonModel(jsonModel);
loanModelRepository.save(progressiveLoanModel);
});
return jsonModel;
return model;
}
@Override
@@ -76,16 +76,14 @@ public class InternalProgressiveLoanApiResource implements InitializingBean {
@Produces({ MediaType.APPLICATION_JSON })
@Path("{loanId}/model")
@Operation(summary = "Fetch ProgressiveLoanInterestScheduleModel", description = "DO NOT USE THIS IN PRODUCTION!")
public String fetchModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) {
public ProgressiveLoanInterestScheduleModel fetchModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) {
Loan loan = loanRepository.findOneWithNotFoundDetection(loanId);
if (!loan.isProgressiveSchedule()) {
throw new IllegalArgumentException("The loan is not progressive.");
}
return writePlatformService
.readProgressiveLoanInterestScheduleModel(loanId, loan.getLoanRepaymentScheduleDetail(),
loan.getLoanProduct().getInstallmentAmountInMultiplesOf())
.map(progressiveLoanInterestScheduleModelParserService::toJson).orElse(null);
return writePlatformService.readProgressiveLoanInterestScheduleModel(loanId, loan.getLoanRepaymentScheduleDetail(),
loan.getLoanProduct().getInstallmentAmountInMultiplesOf()).orElse(null);
}
private ProgressiveLoanInterestScheduleModel reprocessTransactionsAndGetModel(final Loan loan) {
@@ -110,7 +108,7 @@ public class InternalProgressiveLoanApiResource implements InitializingBean {
@Path("{loanId}/model")
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update and Save ProgressiveLoanInterestScheduleModel", description = "DO NOT USE THIS IN PRODUCTION!")
public String updateModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) {
public ProgressiveLoanInterestScheduleModel updateModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) {
Loan loan = loanRepository.findOneWithNotFoundDetection(loanId);
if (!loan.isProgressiveSchedule()) {
throw new IllegalArgumentException("The loan is not progressive.");