Add custom AutoConfiguration class for tax service (FINERACT-1932)
This commit is contained in:
committed by
Arnold Gálovics
parent
2272174c24
commit
34fc1a2cc5
+2
-11
@@ -28,6 +28,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
|
||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
|
||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
|
||||
@@ -42,24 +43,14 @@ import org.apache.fineract.portfolio.tax.domain.TaxComponent;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxComponentRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxGroup;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxGroupMappings;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class TaxAssembler {
|
||||
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
private final GLAccountRepositoryWrapper glAccountRepositoryWrapper;
|
||||
private final TaxComponentRepositoryWrapper taxComponentRepositoryWrapper;
|
||||
|
||||
@Autowired
|
||||
public TaxAssembler(final FromJsonHelper fromApiJsonHelper, final GLAccountRepositoryWrapper glAccountRepositoryWrapper,
|
||||
final TaxComponentRepositoryWrapper taxComponentRepositoryWrapper) {
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
this.glAccountRepositoryWrapper = glAccountRepositoryWrapper;
|
||||
this.taxComponentRepositoryWrapper = taxComponentRepositoryWrapper;
|
||||
}
|
||||
|
||||
public TaxComponent assembleTaxComponentFrom(final JsonCommand command) {
|
||||
final JsonElement element = command.parsedJson();
|
||||
|
||||
|
||||
+2
-10
@@ -24,6 +24,7 @@ import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
|
||||
import org.apache.fineract.accounting.common.AccountingEnumerations;
|
||||
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
|
||||
@@ -33,12 +34,10 @@ import org.apache.fineract.portfolio.tax.data.TaxComponentData;
|
||||
import org.apache.fineract.portfolio.tax.data.TaxComponentHistoryData;
|
||||
import org.apache.fineract.portfolio.tax.data.TaxGroupData;
|
||||
import org.apache.fineract.portfolio.tax.data.TaxGroupMappingsData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TaxReadPlatformServiceImpl implements TaxReadPlatformService {
|
||||
|
||||
private static final TaxComponentMapper TAX_COMPONENT_MAPPER = new TaxComponentMapper();
|
||||
@@ -49,13 +48,6 @@ public class TaxReadPlatformServiceImpl implements TaxReadPlatformService {
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public TaxReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate,
|
||||
final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TaxComponentData> retrieveAllTaxComponents() {
|
||||
String sql = "select " + TAX_COMPONENT_MAPPER.getSchema();
|
||||
|
||||
+2
-15
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.tax.service;
|
||||
|
||||
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.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
@@ -31,10 +32,8 @@ import org.apache.fineract.portfolio.tax.domain.TaxGroupMappings;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxGroupRepository;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxGroupRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.tax.serialization.TaxValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TaxWritePlatformServiceImpl implements TaxWritePlatformService {
|
||||
|
||||
private final TaxValidator validator;
|
||||
@@ -44,18 +43,6 @@ public class TaxWritePlatformServiceImpl implements TaxWritePlatformService {
|
||||
private final TaxGroupRepository taxGroupRepository;
|
||||
private final TaxGroupRepositoryWrapper taxGroupRepositoryWrapper;
|
||||
|
||||
@Autowired
|
||||
public TaxWritePlatformServiceImpl(final TaxValidator validator, final TaxAssembler taxAssembler,
|
||||
final TaxComponentRepository taxComponentRepository, final TaxGroupRepository taxGroupRepository,
|
||||
final TaxComponentRepositoryWrapper taxComponentRepositoryWrapper, final TaxGroupRepositoryWrapper taxGroupRepositoryWrapper) {
|
||||
this.validator = validator;
|
||||
this.taxAssembler = taxAssembler;
|
||||
this.taxComponentRepository = taxComponentRepository;
|
||||
this.taxGroupRepository = taxGroupRepository;
|
||||
this.taxComponentRepositoryWrapper = taxComponentRepositoryWrapper;
|
||||
this.taxGroupRepositoryWrapper = taxGroupRepositoryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult createTaxComponent(final JsonCommand command) {
|
||||
this.validator.validateForTaxComponentCreate(command.json());
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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.tax.starter;
|
||||
|
||||
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
|
||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
|
||||
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxComponentRepository;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxComponentRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxGroupRepository;
|
||||
import org.apache.fineract.portfolio.tax.domain.TaxGroupRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.tax.serialization.TaxValidator;
|
||||
import org.apache.fineract.portfolio.tax.service.TaxAssembler;
|
||||
import org.apache.fineract.portfolio.tax.service.TaxReadPlatformService;
|
||||
import org.apache.fineract.portfolio.tax.service.TaxReadPlatformServiceImpl;
|
||||
import org.apache.fineract.portfolio.tax.service.TaxWritePlatformService;
|
||||
import org.apache.fineract.portfolio.tax.service.TaxWritePlatformServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
@Configuration
|
||||
public class TaxConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(TaxAssembler.class)
|
||||
public TaxAssembler taxAssembler(FromJsonHelper fromApiJsonHelper, GLAccountRepositoryWrapper glAccountRepositoryWrapper,
|
||||
TaxComponentRepositoryWrapper taxComponentRepositoryWrapper) {
|
||||
return new TaxAssembler(fromApiJsonHelper, glAccountRepositoryWrapper, taxComponentRepositoryWrapper);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(TaxReadPlatformService.class)
|
||||
public TaxReadPlatformService taxReadPlatformService(JdbcTemplate jdbcTemplate,
|
||||
AccountingDropdownReadPlatformService accountingDropdownReadPlatformService) {
|
||||
return new TaxReadPlatformServiceImpl(jdbcTemplate, accountingDropdownReadPlatformService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(TaxWritePlatformService.class)
|
||||
public TaxWritePlatformService taxWritePlatformService(TaxValidator validator, TaxAssembler taxAssembler,
|
||||
TaxComponentRepository taxComponentRepository, TaxGroupRepository taxGroupRepository,
|
||||
TaxComponentRepositoryWrapper taxComponentRepositoryWrapper, TaxGroupRepositoryWrapper taxGroupRepositoryWrapper) {
|
||||
return new TaxWritePlatformServiceImpl(validator, taxAssembler, taxComponentRepository, taxComponentRepositoryWrapper,
|
||||
taxGroupRepository, taxGroupRepositoryWrapper);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user