FINERACT-1926: Asset Externalization on Fineract
This commit is contained in:
committed by
Adam Saghy
parent
6a90ce3f10
commit
4a2aeff350
+15
@@ -45,13 +45,16 @@ import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
||||
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.core.service.CommandParameterUtil;
|
||||
import org.apache.fineract.infrastructure.core.service.PagedRequest;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformUserRightsContext;
|
||||
import org.apache.fineract.investor.api.search.ExternalAssetOwnersSearchApiDelegate;
|
||||
import org.apache.fineract.investor.config.InvestorModuleIsEnabledCondition;
|
||||
import org.apache.fineract.investor.data.ExternalOwnerJournalEntryData;
|
||||
import org.apache.fineract.investor.data.ExternalOwnerTransferJournalEntryData;
|
||||
import org.apache.fineract.investor.data.ExternalTransferData;
|
||||
import org.apache.fineract.investor.data.ExternalTransferResponseData;
|
||||
import org.apache.fineract.investor.service.ExternalAssetOwnersReadService;
|
||||
import org.apache.fineract.investor.service.search.domain.ExternalAssetOwnerSearchRequest;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformServiceCommon;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -69,6 +72,7 @@ public class ExternalAssetOwnersApiResource {
|
||||
private final DefaultToApiJsonSerializer<ExternalTransferResponseData> postApiJsonSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final LoanReadPlatformServiceCommon loanReadPlatformService;
|
||||
private final ExternalAssetOwnersSearchApiDelegate delegate;
|
||||
|
||||
@POST
|
||||
@Path("/transfers/loans/{loanId}")
|
||||
@@ -190,6 +194,17 @@ public class ExternalAssetOwnersApiResource {
|
||||
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/search")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Operation(summary = "Search External Asset Owner Transfers by text or date ranges to settlement or effective dates")
|
||||
public Page<ExternalTransferData> searchInvestorData(@Parameter PagedRequest<ExternalAssetOwnerSearchRequest> request) {
|
||||
platformUserRightsContext.isAuthenticated();
|
||||
return delegate.searchInvestorData(request);
|
||||
|
||||
}
|
||||
|
||||
private String getResultByTransferId(Long id, String command) {
|
||||
final CommandWrapperBuilder builder = new CommandWrapperBuilder();
|
||||
CommandWrapper commandRequest;
|
||||
|
||||
+50
-49
@@ -28,60 +28,60 @@ final class ExternalAssetOwnersApiResourceSwagger {
|
||||
|
||||
private ExternalAssetOwnersApiResourceSwagger() {}
|
||||
|
||||
static final class GetExternalTransferPageItems {
|
||||
|
||||
private GetExternalTransferPageItems() {}
|
||||
|
||||
static final class GetExternalTransferOwner {
|
||||
|
||||
private GetExternalTransferOwner() {}
|
||||
|
||||
@Schema(example = "e1156fbe-38bb-42f8-b491-fca02075f40e")
|
||||
public String externalId;
|
||||
}
|
||||
|
||||
static final class GetExternalTransferLoan {
|
||||
|
||||
private GetExternalTransferLoan() {}
|
||||
|
||||
@Schema(example = "1")
|
||||
public Long loanId;
|
||||
|
||||
@Schema(example = "e1156fbe-38bb-42f8-b491-fca02075f40e")
|
||||
public String externalId;
|
||||
}
|
||||
|
||||
@Schema(example = "1")
|
||||
public Long transferId;
|
||||
|
||||
public GetExternalTransferOwner owner;
|
||||
|
||||
public GetExternalTransferLoan loan;
|
||||
|
||||
@Schema(example = "e1156fbe-38bb-42f8-b491-fca02075f40e")
|
||||
public String transferExternalId;
|
||||
|
||||
@Schema(example = "1")
|
||||
public String purchasePriceRatio;
|
||||
|
||||
@Schema(example = "[2023, 5, 23]")
|
||||
public LocalDate settlementDate;
|
||||
|
||||
@Schema(example = "PENDING")
|
||||
public ExternalTransferStatus status;
|
||||
|
||||
@Schema(example = "[2023, 5, 1]")
|
||||
public LocalDate effectiveFrom;
|
||||
|
||||
@Schema(example = "[2023, 5, 23]")
|
||||
public LocalDate effectiveTo;
|
||||
}
|
||||
|
||||
@Schema(description = "ExternalTransferResponse")
|
||||
public static final class GetExternalTransferResponse {
|
||||
|
||||
private GetExternalTransferResponse() {}
|
||||
|
||||
static final class GetExternalTransferPageItems {
|
||||
|
||||
private GetExternalTransferPageItems() {}
|
||||
|
||||
static final class GetExternalTransferOwner {
|
||||
|
||||
private GetExternalTransferOwner() {}
|
||||
|
||||
@Schema(example = "e1156fbe-38bb-42f8-b491-fca02075f40e")
|
||||
public String externalId;
|
||||
}
|
||||
|
||||
static final class GetExternalTransferLoan {
|
||||
|
||||
private GetExternalTransferLoan() {}
|
||||
|
||||
@Schema(example = "1")
|
||||
public Long loanId;
|
||||
|
||||
@Schema(example = "e1156fbe-38bb-42f8-b491-fca02075f40e")
|
||||
public String externalId;
|
||||
}
|
||||
|
||||
@Schema(example = "1")
|
||||
public Long transferId;
|
||||
|
||||
public GetExternalTransferOwner owner;
|
||||
|
||||
public GetExternalTransferLoan loan;
|
||||
|
||||
@Schema(example = "e1156fbe-38bb-42f8-b491-fca02075f40e")
|
||||
public String transferExternalId;
|
||||
|
||||
@Schema(example = "1")
|
||||
public String purchasePriceRatio;
|
||||
|
||||
@Schema(example = "[2023, 5, 23]")
|
||||
public LocalDate settlementDate;
|
||||
|
||||
@Schema(example = "PENDING")
|
||||
public ExternalTransferStatus status;
|
||||
|
||||
@Schema(example = "[2023, 5, 1]")
|
||||
public LocalDate effectiveFrom;
|
||||
|
||||
@Schema(example = "[2023, 5, 23]")
|
||||
public LocalDate effectiveTo;
|
||||
}
|
||||
|
||||
@Schema(example = "20")
|
||||
public Integer totalFilteredRecords;
|
||||
public Set<GetExternalTransferPageItems> pageItems;
|
||||
@@ -152,4 +152,5 @@ final class ExternalAssetOwnersApiResourceSwagger {
|
||||
public String purchasePriceRatio;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.investor.api.search;
|
||||
|
||||
import org.apache.fineract.infrastructure.core.service.PagedRequest;
|
||||
import org.apache.fineract.investor.data.ExternalTransferData;
|
||||
import org.apache.fineract.investor.service.search.domain.ExternalAssetOwnerSearchRequest;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface ExternalAssetOwnersSearchApi {
|
||||
|
||||
Page<ExternalTransferData> searchInvestorData(PagedRequest<ExternalAssetOwnerSearchRequest> request);
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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.investor.api.search;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.service.PagedRequest;
|
||||
import org.apache.fineract.investor.data.ExternalTransferData;
|
||||
import org.apache.fineract.investor.service.search.ExternalAssetOwnerSearchService;
|
||||
import org.apache.fineract.investor.service.search.domain.ExternalAssetOwnerSearchRequest;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ExternalAssetOwnersSearchApiDelegate implements ExternalAssetOwnersSearchApi {
|
||||
|
||||
private final ExternalAssetOwnerSearchService externalAssetOwnerSearchService;
|
||||
|
||||
@Override
|
||||
public Page<ExternalTransferData> searchInvestorData(PagedRequest<ExternalAssetOwnerSearchRequest> request) {
|
||||
return externalAssetOwnerSearchService.searchInvestorData(request);
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -19,9 +19,13 @@
|
||||
package org.apache.fineract.investor.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExternalTransferDataDetails {
|
||||
|
||||
private Long detailsId;
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 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.investor.domain.search;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
||||
import org.apache.fineract.investor.data.ExternalTransferStatus;
|
||||
import org.apache.fineract.investor.data.ExternalTransferSubStatus;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class SearchedExternalAssetOwner {
|
||||
|
||||
private final Long transferId;
|
||||
private final Long loanId;
|
||||
private final ExternalId externalLoanId;
|
||||
|
||||
private final ExternalId owner;
|
||||
private final ExternalId transferExternalId;
|
||||
|
||||
private final ExternalTransferStatus status;
|
||||
private final ExternalTransferSubStatus subStatus;
|
||||
|
||||
private final String purchasePriceRatio;
|
||||
private final LocalDate settlementDate;
|
||||
private final LocalDate effectiveFrom;
|
||||
private final LocalDate effectiveTo;
|
||||
|
||||
private final Long detailsId;
|
||||
private final BigDecimal totalOutstanding;
|
||||
private final BigDecimal principalOutstanding;
|
||||
private final BigDecimal interestOutstanding;
|
||||
private final BigDecimal feeOutstanding;
|
||||
private final BigDecimal penaltyOutstanding;
|
||||
private final BigDecimal totalOverpaid;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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.investor.domain.search;
|
||||
|
||||
import org.apache.fineract.infrastructure.core.service.PagedRequest;
|
||||
import org.apache.fineract.investor.service.search.domain.ExternalAssetOwnerSearchRequest;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface SearchingExternalAssetOwnerRepository {
|
||||
|
||||
Page<SearchedExternalAssetOwner> searchInvestorData(PagedRequest<ExternalAssetOwnerSearchRequest> searchRequest);
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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.investor.domain.search;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
import jakarta.persistence.criteria.Order;
|
||||
import jakarta.persistence.criteria.Path;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.infrastructure.core.jpa.CriteriaQueryFactory;
|
||||
import org.apache.fineract.infrastructure.core.service.PagedRequest;
|
||||
import org.apache.fineract.investor.domain.ExternalAssetOwner;
|
||||
import org.apache.fineract.investor.domain.ExternalAssetOwnerTransfer;
|
||||
import org.apache.fineract.investor.domain.ExternalAssetOwnerTransferDetails;
|
||||
import org.apache.fineract.investor.service.search.domain.ExternalAssetOwnerSearchRequest;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class SearchingExternalAssetOwnerRepositoryImpl implements SearchingExternalAssetOwnerRepository {
|
||||
|
||||
private final EntityManager entityManager;
|
||||
private final CriteriaQueryFactory criteriaQueryFactory;
|
||||
|
||||
@Override
|
||||
public Page<SearchedExternalAssetOwner> searchInvestorData(PagedRequest<ExternalAssetOwnerSearchRequest> searchRequest) {
|
||||
final ExternalAssetOwnerSearchRequest request = searchRequest.getRequest().get();
|
||||
final Pageable pageable = searchRequest.toPageable();
|
||||
|
||||
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<SearchedExternalAssetOwner> query = cb.createQuery(SearchedExternalAssetOwner.class);
|
||||
|
||||
Root<ExternalAssetOwnerTransfer> root = query.from(ExternalAssetOwnerTransfer.class);
|
||||
Path<ExternalAssetOwnerTransferDetails> details = root.join("externalAssetOwnerTransferDetails", JoinType.LEFT);
|
||||
Path<ExternalAssetOwner> owner = root.get("owner");
|
||||
|
||||
Specification<ExternalAssetOwnerTransfer> spec = (r, q, builder) -> {
|
||||
Path<ExternalAssetOwner> o = r.get("owner");
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (StringUtils.isNotBlank(request.getText())) {
|
||||
String searchLikeValue = "%" + request.getText() + "%";
|
||||
predicates.add(cb.or(cb.like(r.get("externalId"), searchLikeValue), cb.like(o.get("externalId"), searchLikeValue),
|
||||
cb.like(r.get("externalLoanId"), searchLikeValue)));
|
||||
}
|
||||
|
||||
if (request.getSubmittedFromDate() != null) {
|
||||
predicates.add(cb.greaterThanOrEqualTo(r.get("settlementDate"), request.getSubmittedFromDate()));
|
||||
}
|
||||
if (request.getSubmittedToDate() != null) {
|
||||
predicates.add(cb.lessThanOrEqualTo(r.get("settlementDate"), request.getSubmittedToDate()));
|
||||
}
|
||||
|
||||
if (request.getEffectiveFromDate() != null) {
|
||||
predicates.add(cb.greaterThanOrEqualTo(r.get("effectiveDateFrom"), request.getEffectiveFromDate()));
|
||||
}
|
||||
if (request.getEffectiveToDate() != null) {
|
||||
predicates.add(cb.lessThanOrEqualTo(r.get("effectiveDateTo"), request.getEffectiveToDate()));
|
||||
}
|
||||
|
||||
return cb.and(predicates.toArray(new Predicate[0]));
|
||||
};
|
||||
criteriaQueryFactory.applySpecificationToCriteria(root, spec, query);
|
||||
|
||||
List<Order> orders = criteriaQueryFactory.ordersFromPageable(pageable, cb, root, () -> cb.desc(root.get("settlementDate")));
|
||||
query.orderBy(orders);
|
||||
|
||||
query.select(cb.construct(SearchedExternalAssetOwner.class, root.get("id"), root.get("loanId"), root.get("externalLoanId"),
|
||||
owner.get("externalId"), root.get("externalId"), root.get("status"), root.get("subStatus"), root.get("purchasePriceRatio"),
|
||||
root.get("settlementDate"), root.get("effectiveDateFrom"), root.get("effectiveDateTo"), details.get("id"),
|
||||
details.get("totalOutstanding"), details.get("totalPrincipalOutstanding"), details.get("totalInterestOutstanding"),
|
||||
details.get("totalFeeChargesOutstanding"), details.get("totalPenaltyChargesOutstanding"), details.get("totalOverpaid")));
|
||||
|
||||
TypedQuery<SearchedExternalAssetOwner> queryToExecute = entityManager.createQuery(query);
|
||||
return criteriaQueryFactory.readPage(queryToExecute, ExternalAssetOwnerTransfer.class, pageable, spec);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.investor.service.search;
|
||||
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.service.PagedRequest;
|
||||
import org.apache.fineract.investor.data.ExternalTransferData;
|
||||
import org.apache.fineract.investor.domain.search.SearchingExternalAssetOwnerRepository;
|
||||
import org.apache.fineract.investor.service.search.domain.ExternalAssetOwnerSearchRequest;
|
||||
import org.apache.fineract.investor.service.search.mapper.ExternalAssetOwnerSearchDataMapper;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Component
|
||||
@Transactional(readOnly = true)
|
||||
@RequiredArgsConstructor
|
||||
public class ExternalAssetOwnerSearchService {
|
||||
|
||||
private final SearchingExternalAssetOwnerRepository externalAssetOwnerRepository;
|
||||
private final ExternalAssetOwnerSearchDataMapper externalAssetOwnerSearchDataMapper;
|
||||
|
||||
public Page<ExternalTransferData> searchInvestorData(PagedRequest<ExternalAssetOwnerSearchRequest> searchRequest) {
|
||||
validateTextSearchRequest(searchRequest);
|
||||
return executeSearch(searchRequest);
|
||||
}
|
||||
|
||||
private void validateTextSearchRequest(PagedRequest<ExternalAssetOwnerSearchRequest> searchRequest) {
|
||||
Objects.requireNonNull(searchRequest, "searchRequest must not be null");
|
||||
}
|
||||
|
||||
private Page<ExternalTransferData> executeSearch(PagedRequest<ExternalAssetOwnerSearchRequest> searchRequest) {
|
||||
return externalAssetOwnerRepository.searchInvestorData(searchRequest).map(externalAssetOwnerSearchDataMapper::map);
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.investor.service.search.domain;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExternalAssetOwnerSearchRequest {
|
||||
|
||||
private String text;
|
||||
private LocalDate submittedFromDate;
|
||||
private LocalDate submittedToDate;
|
||||
private LocalDate effectiveFromDate;
|
||||
private LocalDate effectiveToDate;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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.investor.service.search.mapper;
|
||||
|
||||
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
|
||||
import org.apache.fineract.investor.data.ExternalTransferData;
|
||||
import org.apache.fineract.investor.data.ExternalTransferDataDetails;
|
||||
import org.apache.fineract.investor.data.ExternalTransferLoanData;
|
||||
import org.apache.fineract.investor.data.ExternalTransferOwnerData;
|
||||
import org.apache.fineract.investor.data.ExternalTransferStatus;
|
||||
import org.apache.fineract.investor.data.ExternalTransferSubStatus;
|
||||
import org.apache.fineract.investor.domain.search.SearchedExternalAssetOwner;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
@Mapper(config = MapstructMapperConfig.class)
|
||||
public interface ExternalAssetOwnerSearchDataMapper {
|
||||
|
||||
@Mapping(target = "owner", source = "source", qualifiedByName = "toOwner")
|
||||
@Mapping(target = "loan", source = "source", qualifiedByName = "toLoanExternalId")
|
||||
@Mapping(target = "transferExternalId", source = "source", qualifiedByName = "toTransferExternalId")
|
||||
@Mapping(target = "status", source = "source", qualifiedByName = "toStatus")
|
||||
@Mapping(target = "subStatus", source = "source", qualifiedByName = "toSubStatus")
|
||||
@Mapping(target = "details", source = "source", qualifiedByName = "toDetails")
|
||||
ExternalTransferData map(SearchedExternalAssetOwner source);
|
||||
|
||||
@Named("toTransferExternalId")
|
||||
default String toTransferExternalId(SearchedExternalAssetOwner source) {
|
||||
return source.getTransferExternalId().getValue();
|
||||
}
|
||||
|
||||
@Named("toLoanExternalId")
|
||||
default ExternalTransferLoanData toLoanExternalId(SearchedExternalAssetOwner source) {
|
||||
return new ExternalTransferLoanData(source.getLoanId(), source.getExternalLoanId().getValue());
|
||||
}
|
||||
|
||||
@Named("toOwner")
|
||||
default ExternalTransferOwnerData toOwner(SearchedExternalAssetOwner source) {
|
||||
return new ExternalTransferOwnerData(source.getOwner().getValue());
|
||||
}
|
||||
|
||||
@Named("toStatus")
|
||||
default ExternalTransferStatus toStatus(SearchedExternalAssetOwner source) {
|
||||
return source.getStatus();
|
||||
}
|
||||
|
||||
@Named("toSubStatus")
|
||||
default ExternalTransferSubStatus toSubStatus(SearchedExternalAssetOwner source) {
|
||||
return source.getSubStatus();
|
||||
}
|
||||
|
||||
@Named("toDetails")
|
||||
default ExternalTransferDataDetails toDetails(SearchedExternalAssetOwner source) {
|
||||
if (source.getDetailsId() == null) {
|
||||
return null;
|
||||
}
|
||||
return new ExternalTransferDataDetails(source.getDetailsId(), source.getTotalOutstanding(), source.getPrincipalOutstanding(),
|
||||
source.getInterestOutstanding(), source.getFeeOutstanding(), source.getPenaltyOutstanding(), source.getTotalOverpaid());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user