Skip to content

Commit

Permalink
Add custom Configuration class for collateralmanagement module (FINER…
Browse files Browse the repository at this point in the history
…ACT-1932)
  • Loading branch information
abhinav7sinha authored and vidakovic committed Oct 26, 2023
1 parent 54ca135 commit 62811ad
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.collateralmanagement.data.ClientCollateralManagementData;
import org.apache.fineract.portfolio.collateralmanagement.data.LoanCollateralTemplateData;
Expand All @@ -33,25 +34,14 @@
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
import org.apache.fineract.portfolio.loanaccount.exception.LoanTransactionNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ClientCollateralManagementReadPlatformServiceImpl implements ClientCollateralManagementReadPlatformService {

private final PlatformSecurityContext context;
private final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper;
private final LoanTransactionRepository loanTransactionRepository;

@Autowired
public ClientCollateralManagementReadPlatformServiceImpl(final PlatformSecurityContext context,
final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper,
final LoanTransactionRepository loanTransactionRepository) {
this.context = context;
this.clientCollateralManagementRepositoryWrapper = clientCollateralManagementRepositoryWrapper;
this.loanTransactionRepository = loanTransactionRepository;
}

@Override
public List<ClientCollateralManagementData> getClientCollaterals(final Long clientId, final Long prodId) {
return this.clientCollateralManagementRepositoryWrapper.getClientCollateralData(clientId, prodId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
Expand All @@ -39,26 +40,14 @@
import org.apache.fineract.portfolio.collateralmanagement.exception.ClientCollateralNotFoundException;
import org.apache.fineract.portfolio.collateralmanagement.exception.CollateralNotFoundException;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ClientCollateralManagementWritePlatformServiceImpl implements ClientCollateralManagementWritePlatformService {

private final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper;
private final CollateralManagementRepositoryWrapper collateralManagementRepositoryWrapper;
private final ClientRepositoryWrapper clientRepositoryWrapper;

@Autowired
public ClientCollateralManagementWritePlatformServiceImpl(
final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper,
final CollateralManagementRepositoryWrapper collateralManagementRepositoryWrapper,
final ClientRepositoryWrapper clientRepositoryWrapper) {
this.clientCollateralManagementRepositoryWrapper = clientCollateralManagementRepositoryWrapper;
this.collateralManagementRepositoryWrapper = collateralManagementRepositoryWrapper;
this.clientRepositoryWrapper = clientRepositoryWrapper;
}

@Transactional
@Override
public CommandProcessingResult addClientCollateralProduct(final JsonCommand command) {
Expand Down Expand Up @@ -136,7 +125,7 @@ private void validateForUpdate(final JsonCommand command) {
}

BigDecimal totalQuantity = BigDecimal.ZERO;
if (clientCollateralManagement.getLoanCollateralManagementSet().size() > 0) {
if (!clientCollateralManagement.getLoanCollateralManagementSet().isEmpty()) {
for (LoanCollateralManagement loanCollateralManagement : clientCollateralManagement.getLoanCollateralManagementSet()) {
totalQuantity = totalQuantity.add(loanCollateralManagement.getQuantity());
}
Expand Down Expand Up @@ -167,7 +156,7 @@ private void validateForDeletion(final ClientCollateralManagement clientCollater
throw new CollateralNotFoundException(clientCollateralId);
}

if (clientCollateralManagement.getLoanCollateralManagementSet().size() > 0) {
if (!clientCollateralManagement.getLoanCollateralManagementSet().isEmpty()) {
for (LoanCollateralManagement loanCollateralManagement : clientCollateralManagement.getLoanCollateralManagementSet()) {
if (!loanCollateralManagement.isReleased()) {
throw new ClientCollateralCannotBeDeletedException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,18 @@

import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.collateralmanagement.data.CollateralManagementData;
import org.apache.fineract.portfolio.collateralmanagement.domain.CollateralManagementDomain;
import org.apache.fineract.portfolio.collateralmanagement.domain.CollateralManagementRepositoryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class CollateralManagementReadPlatformServiceImpl implements CollateralManagementReadPlatformService {

private final PlatformSecurityContext context;
private final CollateralManagementRepositoryWrapper collateralManagementRepositoryWrapper;

@Autowired
public CollateralManagementReadPlatformServiceImpl(final PlatformSecurityContext context,
final CollateralManagementRepositoryWrapper collateralManagementRepositoryWrapper) {
this.context = context;
this.collateralManagementRepositoryWrapper = collateralManagementRepositoryWrapper;
}

@Override
public CollateralManagementData getCollateralProduct(Long collateralId) {
final CollateralManagementDomain collateralManagementDomain = this.collateralManagementRepositoryWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
Expand All @@ -38,25 +39,15 @@
import org.apache.fineract.portfolio.collateralmanagement.domain.CollateralManagementRepositoryWrapper;
import org.apache.fineract.portfolio.collateralmanagement.exception.CollateralCannotBeDeletedException;
import org.apache.fineract.portfolio.collateralmanagement.exception.CollateralNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class CollateralManagementWritePlatformServiceImpl implements CollateralManagementWritePlatformService {

private final CollateralManagementRepositoryWrapper collateralManagementRepositoryWrapper;
private final ApplicationCurrencyRepository applicationCurrencyRepository;
private final FromJsonHelper fromApiJsonHelper;

@Autowired
public CollateralManagementWritePlatformServiceImpl(final CollateralManagementRepositoryWrapper collateralManagementRepositoryWrapper,
final ApplicationCurrencyRepository applicationCurrencyRepository, final FromJsonHelper fromApiJsonHelper) {
this.collateralManagementRepositoryWrapper = collateralManagementRepositoryWrapper;
this.applicationCurrencyRepository = applicationCurrencyRepository;
this.fromApiJsonHelper = fromApiJsonHelper;
}

@Transactional
@Override
public CommandProcessingResult createCollateral(final JsonCommand jsonCommand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.collateralmanagement.domain.ClientCollateralManagement;
Expand All @@ -33,27 +34,15 @@
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagement;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagementRepository;
import org.apache.fineract.portfolio.loanaccount.exception.InvalidAmountOfCollateralQuantity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class LoanCollateralAssembler {

private final FromJsonHelper fromApiJsonHelper;
private final CodeValueRepositoryWrapper codeValueRepository;
private final LoanCollateralManagementRepository loanCollateralRepository;
private final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper;

@Autowired
public LoanCollateralAssembler(final FromJsonHelper fromApiJsonHelper, final CodeValueRepositoryWrapper codeValueRepository,
final LoanCollateralManagementRepository loanCollateralRepository,
final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper) {
this.fromApiJsonHelper = fromApiJsonHelper;
this.codeValueRepository = codeValueRepository;
this.loanCollateralRepository = loanCollateralRepository;
this.clientCollateralManagementRepositoryWrapper = clientCollateralManagementRepositoryWrapper;
}

public Set<LoanCollateralManagement> fromParsedJson(final JsonElement element) {

final Set<LoanCollateralManagement> collateralItems = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,15 @@
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagementRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
public class LoanCollateralManagementReadPlatformServiceImpl implements LoanCollateralManagementReadPlatformService {

private final PlatformSecurityContext context;
private LoanCollateralManagementRepository loanCollateralManagementRepository;
private LoanRepository loanRepository;

@Autowired
public LoanCollateralManagementReadPlatformServiceImpl(final PlatformSecurityContext context,
final LoanCollateralManagementRepository loanCollateralManagementRepository, final LoanRepository loanRepository) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,22 @@
package org.apache.fineract.portfolio.collateralmanagement.service;

import java.math.BigDecimal;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.portfolio.collateralmanagement.domain.ClientCollateralManagement;
import org.apache.fineract.portfolio.collateralmanagement.domain.ClientCollateralManagementRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagement;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagementRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class LoanCollateralManagementWritePlatformServiceImpl implements LoanCollateralManagementWritePlatformService {

private final LoanCollateralManagementRepository loanCollateralManagementRepository;
private final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper;

@Autowired
public LoanCollateralManagementWritePlatformServiceImpl(final LoanCollateralManagementRepository loanCollateralManagementRepository,
final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper) {
this.loanCollateralManagementRepository = loanCollateralManagementRepository;
this.clientCollateralManagementRepositoryWrapper = clientCollateralManagementRepositoryWrapper;
}

@Transactional
@Override
public CommandProcessingResult deleteLoanCollateral(JsonCommand command) {
Expand Down
Loading

0 comments on commit 62811ad

Please sign in to comment.