FINERACT-1932: Add starter configuration class for portfolio.repaymentwithpostdatedchecks module

This commit is contained in:
Mohamed Magdi-Abdelmonem
2023-10-02 15:14:22 +02:00
committed by Arnold Gálovics
parent 4bcf465ac0
commit 01e68e34ce
4 changed files with 64 additions and 31 deletions
@@ -27,23 +27,17 @@ import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class RepaymentWithPostDatedChecksAssembler {
private final FromJsonHelper fromApiJsonHelper;
@Autowired
public RepaymentWithPostDatedChecksAssembler(final FromJsonHelper fromJsonHelper) {
this.fromApiJsonHelper = fromJsonHelper;
}
public Set<PostDatedChecks> fromParsedJson(final String json, final Loan loan) {
final Set<PostDatedChecks> postDatedChecks = new HashSet<>();
final JsonElement jsonElement = this.fromApiJsonHelper.parse(json);
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallmentRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
@@ -30,11 +31,9 @@ import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.data.PostDated
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.exception.PostDatedCheckNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class RepaymentWithPostDatedChecksReadPlatformServiceImpl implements RepaymentWithPostDatedChecksReadPlatformService {
@@ -42,15 +41,6 @@ public class RepaymentWithPostDatedChecksReadPlatformServiceImpl implements Repa
private final LoanRepository loanRepository;
private final LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository;
@Autowired
public RepaymentWithPostDatedChecksReadPlatformServiceImpl(final PostDatedChecksRepository postDatedChecksRepository,
final LoanRepository loanRepository,
final LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository) {
this.postDatedChecksRepository = postDatedChecksRepository;
this.loanRepository = loanRepository;
this.loanRepaymentScheduleInstallmentRepository = loanRepaymentScheduleInstallmentRepository;
}
@Override
public List<PostDatedChecksData> getPostDatedChecks(final Long id) {
final Loan loan = this.loanRepository.findById(id).orElseThrow(() -> new LoanNotFoundException(id));
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
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;
@@ -45,13 +46,11 @@ import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.data.PostDated
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.exception.PostDatedCheckNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
public class RepaymentWithPostDatedChecksWritePlatformServiceImpl implements RepaymentWithPostDatedChecksWritePlatformService {
public static final String NAME = "name";
@@ -71,14 +70,6 @@ public class RepaymentWithPostDatedChecksWritePlatformServiceImpl implements Rep
private final FromJsonHelper fromApiJsonHelper;
private final LoanRepository loanRepository;
@Autowired
public RepaymentWithPostDatedChecksWritePlatformServiceImpl(final PostDatedChecksRepository postDatedChecksRepository,
final FromJsonHelper fromApiJsonHelper, final LoanRepository loanRepository) {
this.postDatedChecksRepository = postDatedChecksRepository;
this.fromApiJsonHelper = fromApiJsonHelper;
this.loanRepository = loanRepository;
}
@Transactional
@Override
public CommandProcessingResult updatePostDatedChecks(JsonCommand command) {
@@ -0,0 +1,58 @@
/**
* 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.repaymentwithpostdatedchecks.starter;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallmentRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksAssembler;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksReadPlatformService;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksReadPlatformServiceImpl;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksWritePlatformService;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksWritePlatformServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RepaymentWithPostDatedChecksConfiguration {
@Bean
@ConditionalOnMissingBean(RepaymentWithPostDatedChecksAssembler.class)
public RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler(FromJsonHelper fromJsonHelper) {
return new RepaymentWithPostDatedChecksAssembler(fromJsonHelper);
}
@Bean
@ConditionalOnMissingBean(RepaymentWithPostDatedChecksReadPlatformService.class)
public RepaymentWithPostDatedChecksReadPlatformService repaymentWithPostDatedChecksReadPlatformService(
PostDatedChecksRepository postDatedChecksRepository, LoanRepository loanRepository,
LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository) {
return new RepaymentWithPostDatedChecksReadPlatformServiceImpl(postDatedChecksRepository, loanRepository,
loanRepaymentScheduleInstallmentRepository);
}
@Bean
@ConditionalOnMissingBean(RepaymentWithPostDatedChecksWritePlatformService.class)
public RepaymentWithPostDatedChecksWritePlatformService repaymentWithPostDatedChecksWritePlatformService(
PostDatedChecksRepository postDatedChecksRepository, FromJsonHelper fromApiJsonHelper, LoanRepository loanRepository) {
return new RepaymentWithPostDatedChecksWritePlatformServiceImpl(postDatedChecksRepository, fromApiJsonHelper, loanRepository);
}
}