-
Notifications
You must be signed in to change notification settings - Fork 2.5k
FINERACT-2421: Loan product basic detail endpoint #5569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adamsaghy
merged 1 commit into
apache:develop
from
openMF:FINERACT-2421/loan-product-basic-detail-endpoint
Mar 5, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
62 changes: 62 additions & 0 deletions
62
...in/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsDetailsApiResource.java
This file contains hidden or 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,62 @@ | ||
| /** | ||
| * 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.loanproduct.api; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.ws.rs.Consumes; | ||
| import jakarta.ws.rs.GET; | ||
| import jakarta.ws.rs.Path; | ||
| import jakarta.ws.rs.Produces; | ||
| import jakarta.ws.rs.core.Context; | ||
| import jakarta.ws.rs.core.MediaType; | ||
| import jakarta.ws.rs.core.UriInfo; | ||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; | ||
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData; | ||
| import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadBasicDetailsService; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Path("/v1/loanproducts") | ||
| @Component | ||
| @Tag(name = "Loan Products Details", description = "Loan product basic details to be listed") | ||
| @RequiredArgsConstructor | ||
| public class LoanProductsDetailsApiResource { | ||
|
|
||
| private static final String RESOURCE_NAME_FOR_PERMISSIONS = "LOANPRODUCT"; | ||
| private final PlatformSecurityContext context; | ||
| private final List<LoanProductReadBasicDetailsService> loanProductReadBasicDetailsServices; | ||
|
|
||
| @GET | ||
| @Path("basic-details") | ||
| @Consumes({ MediaType.APPLICATION_JSON }) | ||
| @Produces({ MediaType.APPLICATION_JSON }) | ||
| @Operation(summary = "List Loan Products with basic details", description = "Lists Loan Products with basic details to be listed") | ||
| public Collection<LoanProductBasicDetailsData> fetchProducts(@Context final UriInfo uriInfo) { | ||
| this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); | ||
|
|
||
| Collection<LoanProductBasicDetailsData> products = new ArrayList<>(); | ||
| loanProductReadBasicDetailsServices.forEach(service -> products.addAll(service.retrieveProducts())); | ||
| return products; | ||
| } | ||
|
|
||
| } | ||
36 changes: 36 additions & 0 deletions
36
...main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductBasicDetailsData.java
This file contains hidden or 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.portfolio.loanproduct.data; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.apache.fineract.organisation.monetary.data.CurrencyData; | ||
|
|
||
| @Data | ||
| @RequiredArgsConstructor | ||
| public class LoanProductBasicDetailsData { | ||
|
|
||
| private final String productType; | ||
| private final Long id; | ||
| private final String name; | ||
| private final String shortName; | ||
| private final String description; | ||
| private final CurrencyData currency; | ||
|
|
||
| } |
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
.../java/org/apache/fineract/portfolio/loanproduct/mapper/LoanProductBasicDetailsMapper.java
This file contains hidden or 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,45 @@ | ||
| /** | ||
| * 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.loanproduct.mapper; | ||
|
|
||
| import java.util.List; | ||
| import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig; | ||
| import org.apache.fineract.organisation.monetary.data.CurrencyData; | ||
| import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; | ||
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData; | ||
| import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct; | ||
| import org.mapstruct.Mapper; | ||
| import org.mapstruct.Mapping; | ||
| import org.mapstruct.Named; | ||
|
|
||
| @Mapper(config = MapstructMapperConfig.class) | ||
| public interface LoanProductBasicDetailsMapper { | ||
|
|
||
| @Mapping(target = "productType", constant = "loan") | ||
| @Mapping(target = "currency", source = "loanProductRelatedDetail.currency", qualifiedByName = "currencyData") | ||
| LoanProductBasicDetailsData map(LoanProduct source); | ||
|
|
||
| List<LoanProductBasicDetailsData> map(List<LoanProduct> source); | ||
|
|
||
| @Named("currencyData") | ||
| default CurrencyData currencyData(final MonetaryCurrency currency) { | ||
| return currency.toData(); | ||
| } | ||
|
|
||
| } |
28 changes: 28 additions & 0 deletions
28
...org/apache/fineract/portfolio/loanproduct/service/LoanProductReadBasicDetailsService.java
This file contains hidden or 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,28 @@ | ||
| /** | ||
| * 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.loanproduct.service; | ||
|
|
||
| import java.util.Collection; | ||
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData; | ||
|
|
||
| public interface LoanProductReadBasicDetailsService { | ||
|
|
||
| Collection<LoanProductBasicDetailsData> retrieveProducts(); | ||
|
|
||
| } |
43 changes: 43 additions & 0 deletions
43
...apache/fineract/portfolio/loanproduct/service/LoanProductReadBasicDetailsServiceImpl.java
This file contains hidden or 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,43 @@ | ||
| /** | ||
| * 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.loanproduct.service; | ||
|
|
||
| import java.util.Collection; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.apache.fineract.infrastructure.core.service.DateUtils; | ||
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData; | ||
| import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository; | ||
| import org.apache.fineract.portfolio.loanproduct.mapper.LoanProductBasicDetailsMapper; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @Transactional(readOnly = true) | ||
| @RequiredArgsConstructor | ||
| public class LoanProductReadBasicDetailsServiceImpl implements LoanProductReadBasicDetailsService { | ||
|
|
||
| private final LoanProductBasicDetailsMapper loanProductBasicDetailsMapper; | ||
| private final LoanProductRepository loanProductRepository; | ||
|
|
||
| @Override | ||
| public Collection<LoanProductBasicDetailsData> retrieveProducts() { | ||
| return loanProductBasicDetailsMapper.map(loanProductRepository.fetchActiveLoanProducts(DateUtils.getBusinessLocalDate())); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
...rtfolio/workingcapitalloanproduct/mapper/WorkingCapitalLoanProductBasicDetailsMapper.java
This file contains hidden or 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,45 @@ | ||
| /** | ||
| * 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.workingcapitalloanproduct.mapper; | ||
|
|
||
| import java.util.List; | ||
| import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig; | ||
| import org.apache.fineract.organisation.monetary.data.CurrencyData; | ||
| import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; | ||
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData; | ||
| import org.apache.fineract.portfolio.workingcapitalloanproduct.domain.WorkingCapitalLoanProduct; | ||
| import org.mapstruct.Mapper; | ||
| import org.mapstruct.Mapping; | ||
| import org.mapstruct.Named; | ||
|
|
||
| @Mapper(config = MapstructMapperConfig.class) | ||
| public interface WorkingCapitalLoanProductBasicDetailsMapper { | ||
|
|
||
| @Mapping(target = "productType", constant = "working-capital") | ||
| @Mapping(target = "currency", source = "currency", qualifiedByName = "currencyData") | ||
| LoanProductBasicDetailsData map(WorkingCapitalLoanProduct source); | ||
|
|
||
| List<LoanProductBasicDetailsData> map(List<WorkingCapitalLoanProduct> source); | ||
|
|
||
| @Named("currencyData") | ||
| default CurrencyData currencyData(final MonetaryCurrency currency) { | ||
| return currency.toData(); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
...rkingcapitalloanproduct/service/WorkingCapitalLoanProductReadBasicDetailsServiceImpl.java
This file contains hidden or 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,45 @@ | ||
| /** | ||
| * 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.workingcapitalloanproduct.service; | ||
|
|
||
| import java.util.Collection; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.apache.fineract.infrastructure.core.service.DateUtils; | ||
| import org.apache.fineract.portfolio.loanproduct.data.LoanProductBasicDetailsData; | ||
| import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadBasicDetailsService; | ||
| import org.apache.fineract.portfolio.workingcapitalloanproduct.mapper.WorkingCapitalLoanProductBasicDetailsMapper; | ||
| import org.apache.fineract.portfolio.workingcapitalloanproduct.repository.WorkingCapitalLoanProductRepository; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @Transactional(readOnly = true) | ||
| @RequiredArgsConstructor | ||
| public class WorkingCapitalLoanProductReadBasicDetailsServiceImpl implements LoanProductReadBasicDetailsService { | ||
|
|
||
| private final WorkingCapitalLoanProductBasicDetailsMapper workingCapitalLoanProductBasicDetailsMapper; | ||
| private final WorkingCapitalLoanProductRepository productRepository; | ||
|
|
||
| @Override | ||
| public Collection<LoanProductBasicDetailsData> retrieveProducts() { | ||
| return workingCapitalLoanProductBasicDetailsMapper | ||
| .map(productRepository.fetchActiveWorkingCapitalLoanProducts(DateUtils.getBusinessLocalDate())); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this into
fineract-loanmodule ;)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!