FINERACT-2152: API update and delete interest pause

This commit is contained in:
Andrii Kulminskyi
2025-01-08 16:18:44 +01:00
committed by Adam Saghy
parent d2afd1aac7
commit 8663c054a0
18 changed files with 674 additions and 130 deletions
@@ -159,8 +159,7 @@ public class CommandSource extends AbstractPersistableCustom<Long> {
.transactionId(command.getTransactionId()) //
.creditBureauId(command.getCreditBureauId()) //
.organisationCreditBureauId(command.getOrganisationCreditBureauId()) //
.loanExternalId(command.getLoanExternalId()) //
.build(); //
.loanExternalId(command.getLoanExternalId()).build(); //
}
public String getPermissionCode() {
@@ -251,8 +251,16 @@ public class CommandWrapper {
return this.entityName.equalsIgnoreCase("INTEREST_PAUSE");
}
public boolean isInterestPauseExternalIdResource() {
return this.entityName.equalsIgnoreCase("INTEREST_PAUSE") && this.href.contains("/external-id/");
public boolean isInterestPauseCreateResource() {
return this.entityName.equalsIgnoreCase("INTEREST_PAUSE") && "CREATE".equalsIgnoreCase(this.actionName);
}
public boolean isInterestPauseUpdateResource() {
return this.entityName.equalsIgnoreCase("INTEREST_PAUSE") && "UPDATE".equalsIgnoreCase(this.actionName);
}
public boolean isInterestPauseDeleteResource() {
return this.entityName.equalsIgnoreCase("INTEREST_PAUSE") && "DELETE".equalsIgnoreCase(this.actionName);
}
public Long commandId() {
@@ -3732,4 +3732,22 @@ public class CommandWrapperBuilder {
this.href = "/v1/loans/external-id/" + loanExternalId + "/interest-pauses";
return this;
}
public CommandWrapperBuilder deleteInterestPause(final long loanId, final long variationId) {
this.actionName = "DELETE";
this.entityName = "INTEREST_PAUSE";
this.loanId = loanId;
this.entityId = variationId;
this.href = "/v1/loans/" + loanId + "/interest-pauses/" + variationId;
return this;
}
public CommandWrapperBuilder updateInterestPause(final long loanId, final long variationId) {
this.actionName = "UPDATE";
this.entityName = "INTEREST_PAUSE";
this.loanId = loanId;
this.entityId = variationId;
this.href = "/v1/loans/" + loanId + "/interest-pauses/" + variationId;
return this;
}
}
@@ -249,8 +249,16 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isInterestPauseResource() || wrapper.isInterestPauseExternalIdResource()) {
handler = applicationContext.getBean("interestPauseCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestPauseResource()) {
if (wrapper.isInterestPauseCreateResource()) {
handler = applicationContext.getBean("createInterestPauseCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestPauseUpdateResource()) {
handler = applicationContext.getBean("updateInterestPauseCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestPauseDeleteResource()) {
handler = applicationContext.getBean("deleteInterestPauseCommandHandler", NewCommandSourceHandler.class);
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else {
handler = commandHandlerProvider.getHandler(wrapper.entityName(), wrapper.actionName());
}