This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 056a20f58e FINERACT-2169: Refactor standing instruction history api
controller;
056a20f58e is described below
commit 056a20f58e4f87264ff5a0033dabeba1aa12023a
Author: viktorpavlenko <[email protected]>
AuthorDate: Mon Mar 31 23:49:43 2025 +0300
FINERACT-2169: Refactor standing instruction history api controller;
---
.../account/data/PortfolioAccountData.java | 5 ++--
.../api/StandingInstructionHistoryApiResource.java | 15 ++---------
.../data/StandingInstructionHistoryData.java | 31 +++++++---------------
.../AccountTransfersReadPlatformServiceImpl.java | 7 ++---
...StandingInstructionReadPlatformServiceImpl.java | 5 ++--
5 files changed, 22 insertions(+), 41 deletions(-)
diff --git
a/fineract-core/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountData.java
b/fineract-core/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountData.java
index c3eb7d825a..3b8a869e3c 100644
---
a/fineract-core/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountData.java
+++
b/fineract-core/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountData.java
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.account.data;
import java.io.Serializable;
import java.math.BigDecimal;
+import java.util.Optional;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -69,7 +70,7 @@ public class PortfolioAccountData implements Serializable {
this.amtForTransfer = null;
}
- public String getCurrencyCode() {
- return this.currency.getCode();
+ public String getCurrencyCodeFromCurrency() {
+ return
Optional.ofNullable(getCurrency()).map(CurrencyData::getCode).orElse(null);
}
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java
index 6a54364e81..25209d0c8b 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java
@@ -30,17 +30,12 @@ import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.UriInfo;
import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
-import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
import org.apache.fineract.infrastructure.core.api.DateParam;
import org.apache.fineract.infrastructure.core.data.DateFormat;
-import
org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
-import
org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
@@ -57,8 +52,6 @@ import org.springframework.stereotype.Component;
public class StandingInstructionHistoryApiResource {
private final PlatformSecurityContext context;
- private final DefaultToApiJsonSerializer<StandingInstructionHistoryData>
toApiJsonSerializer;
- private final ApiRequestParameterHelper apiRequestParameterHelper;
private final StandingInstructionHistoryReadPlatformService
standingInstructionHistoryReadPlatformService;
private final SqlValidator sqlValidator;
@@ -70,7 +63,7 @@ public class StandingInstructionHistoryApiResource {
+ "standinginstructionrunhistory?orderBy=name&sortOrder=DESC\n" +
"\n" + "standinginstructionrunhistory?offset=10&limit=50")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content =
@Content(schema = @Schema(implementation =
StandingInstructionHistoryApiResourceSwagger.GetStandingInstructionRunHistoryResponse.class)))
})
- public String retrieveAll(@Context final UriInfo uriInfo,
+ public Page<StandingInstructionHistoryData> retrieveAll(
@QueryParam("externalId") @Parameter(description = "externalId")
final String externalId,
@QueryParam("offset") @Parameter(description = "offset") final
Integer offset,
@QueryParam("limit") @Parameter(description = "limit") final
Integer limit,
@@ -107,10 +100,6 @@ public class StandingInstructionHistoryApiResource {
StandingInstructionDTO standingInstructionDTO = new
StandingInstructionDTO(searchParameters, transferType, clientName, clientId,
fromAccount, fromAccountType, startDateRange, endDateRange);
- final Page<StandingInstructionHistoryData> history =
this.standingInstructionHistoryReadPlatformService
- .retrieveAll(standingInstructionDTO);
-
- final ApiRequestJsonSerializationSettings settings =
this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
- return this.toApiJsonSerializer.serialize(settings, history);
+ return
standingInstructionHistoryReadPlatformService.retrieveAll(standingInstructionDTO);
}
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/StandingInstructionHistoryData.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/StandingInstructionHistoryData.java
index ee9cd966ea..101677aca3 100755
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/StandingInstructionHistoryData.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/StandingInstructionHistoryData.java
@@ -18,14 +18,23 @@
*/
package org.apache.fineract.portfolio.account.data;
+import java.io.Serial;
+import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.organisation.office.data.OfficeData;
import org.apache.fineract.portfolio.client.data.ClientData;
+@Getter
@SuppressWarnings("unused")
-public class StandingInstructionHistoryData {
+@RequiredArgsConstructor
+public class StandingInstructionHistoryData implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
private final Long standingInstructionId;
private final String name;
@@ -42,24 +51,4 @@ public class StandingInstructionHistoryData {
private final LocalDate executionTime;
private final String errorLog;
- public StandingInstructionHistoryData(final Long standingInstructionId,
final String name, final OfficeData fromOffice,
- final ClientData fromClient, final EnumOptionData fromAccountType,
final PortfolioAccountData fromAccount,
- final EnumOptionData toAccountType, final PortfolioAccountData
toAccount, final OfficeData toOffice, final ClientData toClient,
- final BigDecimal amount, final String status, final LocalDate
executionTime, final String errorLog) {
- this.standingInstructionId = standingInstructionId;
- this.name = name;
- this.fromOffice = fromOffice;
- this.fromClient = fromClient;
- this.fromAccountType = fromAccountType;
- this.toAccountType = toAccountType;
- this.fromAccount = fromAccount;
- this.toAccount = toAccount;
- this.toOffice = toOffice;
- this.toClient = toClient;
- this.amount = amount;
- this.errorLog = errorLog;
- this.status = status;
- this.executionTime = executionTime;
- }
-
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersReadPlatformServiceImpl.java
index 5ad7d04361..ff1a853674 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersReadPlatformServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersReadPlatformServiceImpl.java
@@ -146,7 +146,7 @@ public class AccountTransfersReadPlatformServiceImpl
implements AccountTransfers
if (toAccountId != null && fromAccount != null) {
toAccount =
this.portfolioAccountReadPlatformService.retrieveOne(toAccountId,
mostRelevantToAccountType,
- fromAccount.getCurrencyCode());
+ fromAccount.getCurrencyCodeFromCurrency());
mostRelevantToClientId = toAccount.getClientId();
}
@@ -179,7 +179,8 @@ public class AccountTransfersReadPlatformServiceImpl
implements AccountTransfers
private Collection<PortfolioAccountData> retrieveToAccounts(final
PortfolioAccountData excludeThisAccountFromOptions,
final Integer toAccountType, final Long toClientId) {
- final String currencyCode = excludeThisAccountFromOptions != null ?
excludeThisAccountFromOptions.getCurrencyCode() : null;
+ final String currencyCode = excludeThisAccountFromOptions != null ?
excludeThisAccountFromOptions.getCurrencyCodeFromCurrency()
+ : null;
PortfolioAccountDTO portfolioAccountDTO = new
PortfolioAccountDTO(toAccountType, toClientId, currencyCode, null, null);
Collection<PortfolioAccountData> accountOptions =
this.portfolioAccountReadPlatformService
@@ -379,7 +380,7 @@ public class AccountTransfersReadPlatformServiceImpl
implements AccountTransfers
if (toAccountId != null && fromAccount != null) {
toAccount =
this.portfolioAccountReadPlatformService.retrieveOne(toAccountId,
mostRelevantToAccountType,
- fromAccount.getCurrencyCode());
+ fromAccount.getCurrencyCodeFromCurrency());
mostRelevantToClientId = toAccount.getClientId();
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionReadPlatformServiceImpl.java
index 751e1c406e..7e86160e27 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionReadPlatformServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionReadPlatformServiceImpl.java
@@ -188,7 +188,7 @@ public class StandingInstructionReadPlatformServiceImpl
implements StandingInstr
if (toAccountId != null && fromAccount != null) {
toAccount =
this.portfolioAccountReadPlatformService.retrieveOne(toAccountId,
mostRelevantToAccountType,
- fromAccount.getCurrencyCode());
+ fromAccount.getCurrencyCodeFromCurrency());
mostRelevantToClientId = toAccount.getClientId();
}
@@ -239,7 +239,8 @@ public class StandingInstructionReadPlatformServiceImpl
implements StandingInstr
private Collection<PortfolioAccountData> retrieveToAccounts(final
PortfolioAccountData excludeThisAccountFromOptions,
final Integer toAccountType, final Long toClientId) {
- final String currencyCode = excludeThisAccountFromOptions != null ?
excludeThisAccountFromOptions.getCurrencyCode() : null;
+ final String currencyCode = excludeThisAccountFromOptions != null ?
excludeThisAccountFromOptions.getCurrencyCodeFromCurrency()
+ : null;
PortfolioAccountDTO portfolioAccountDTO = new
PortfolioAccountDTO(toAccountType, toClientId, currencyCode, null, null);
Collection<PortfolioAccountData> accountOptions =
this.portfolioAccountReadPlatformService