Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.tax.api;
package org.apache.fineract.accounting.adapter;

public interface TaxApiConstants {
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.springframework.stereotype.Component;

String nameParamName = "name";
String percentageParamName = "percentage";
String debitAccountTypeParamName = "debitAccountType";
String debitAccountIdParamName = "debitAccountId";
String creditAccountTypeParamName = "creditAccountType";
String creditAccountIdParamName = "creditAccountId";
@Slf4j
@RequiredArgsConstructor
@Component
public class AccountMappingOptionsAdapterImpl implements AccountMappingOptionsAdapter {

String startDateParamName = "startDate";
String endDateParamName = "endDate";

String chargeIncludesTaxParamName = "chargeIncludesTax";
String taxComponentsParamName = "taxComponents";
String idParamName = "id";
String taxComponentIdParamName = "taxComponentId";
private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService;

@Override
public Map<String, List<GLAccountData>> retrieve() {
return accountingDropdownReadPlatformService.retrieveAccountMappingOptions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.tax.domain;
package org.apache.fineract.accounting.adapter;

import org.apache.fineract.portfolio.tax.exception.TaxComponentNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.springframework.stereotype.Component;

@Slf4j
@RequiredArgsConstructor
@Component
public class TaxComponentRepositoryWrapper {
public class GLAccountTypeOptionsAdapterImpl implements GLAccountTypeOptionsAdapter {

private final TaxComponentRepository repository;
private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService;

@Autowired
public TaxComponentRepositoryWrapper(final TaxComponentRepository repository) {
this.repository = repository;
@Override
public List<EnumOptionData> retrieve() {
return accountingDropdownReadPlatformService.retrieveGLAccountTypeOptions();
}

public TaxComponent findOneWithNotFoundDetection(final Long id) {
return this.repository.findById(id).orElseThrow(() -> new TaxComponentNotFoundException(id));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public ChargeData toData() {
}
TaxGroupData taxGroupData = null;
if (this.taxGroup != null) {
taxGroupData = TaxGroupData.lookup(taxGroup.getId(), taxGroup.getName());
taxGroupData = TaxGroupData.builder().id(taxGroup.getId()).name(taxGroup.getName()).build();
}

PaymentTypeData paymentTypeData = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ private CommandConstants() {}
public static final String COMMAND_HTTP_HEADER_REQUEST_ID = "x-fineract-request-id";
public static final String COMMAND_HTTP_HEADER_TENANT_ID = "Fineract-Platform-TenantId";
public static final String COMMAND_HTTP_HEADER_IP = "IP";
public static final int COMMAND_HOOK_ORDER_HEADERS = 10;
public static final int COMMAND_HOOK_ORDER_TIMESTAMP = 11;
public static final int COMMAND_HOOK_ORDER_USERNAME = 12;
public static final int COMMAND_HOOK_ORDER_VALIDATION = 10;
public static final int COMMAND_HOOK_ORDER_HEADERS = 11;
public static final int COMMAND_HOOK_ORDER_TIMESTAMP = 12;
public static final int COMMAND_HOOK_ORDER_USERNAME = 13;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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.command.hook;

import static org.apache.fineract.command.core.CommandConstants.COMMAND_HOOK_ORDER_VALIDATION;

import jakarta.validation.Validator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.command.core.Command;
import org.apache.fineract.command.core.CommandHookBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@RequiredArgsConstructor
@Component
@Order(COMMAND_HOOK_ORDER_VALIDATION)
@ConditionalOnProperty(value = "fineract.command.hooks.validation-pre", havingValue = "true")
final class ValidationCommandHook implements CommandHookBefore<Object> {

private final Validator validator;

@Override
public void onBefore(Command<Object> command) {
if (command.getPayload() != null) {
var violations = validator.validate(command.getPayload());

if (!violations.isEmpty()) {
// TODO: enable when all packages are migrated to new command processing and remove all @Valid
// annotations
// handle validation errors, throw Exceptions, to legacy exceptions and add localized messages?

if (log.isDebugEnabled()) {
log.debug("Validation errors: {}", violations);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ fineract.command.enabled=true
fineract.command.hooks.servlet-header-pre=${FINERACT_COMMAND_PROCESSORS_SERVLET_HEADER_PRE:true}
fineract.command.hooks.timestamp-pre=${FINERACT_COMMAND_PROCESSORS_TIMESTAMP_PRE:true}
fineract.command.hooks.username-pre=${FINERACT_COMMAND_PROCESSORS_USERNAME_PRE:true}
fineract.command.hooks.validation-pre=${FINERACT_COMMAND_PROCESSORS_VALIDATION_PRE:false}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.tax.service;
package org.apache.fineract.accounting.adapter;

import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import java.util.List;
import java.util.Map;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;

public interface TaxWritePlatformService {

CommandProcessingResult createTaxComponent(JsonCommand command);

CommandProcessingResult updateTaxComponent(Long id, JsonCommand command);

CommandProcessingResult createTaxGroup(JsonCommand command);

CommandProcessingResult updateTaxGroup(Long id, JsonCommand command);
@FunctionalInterface
public interface AccountMappingOptionsAdapter {

Map<String, List<GLAccountData>> retrieve();
}
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.accounting.adapter;

import java.util.List;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;

@FunctionalInterface
public interface GLAccountTypeOptionsAdapter {

List<EnumOptionData> retrieve();
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_CHARGE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_CLIENT;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_CLIENTIDENTIFIER;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_CLIENT_COLLATERAL_PRODUCT;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_CODE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_CODEVALUE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_COLLATERAL;
Expand Down Expand Up @@ -205,14 +204,12 @@
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_LOANCHARGE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_LOANPRODUCT;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_LOAN_AVAILABLE_DISBURSEMENT_AMOUNT;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_LOAN_COLLATERAL_PRODUCT;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_LOAN_ORIGINATOR;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_OFFICE;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_OFFICETRANSACTION;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_ORGANISATIONCREDITBUREAU;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_PERIODICACCRUALACCOUNTING;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_PERMISSION;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_PRODUCTMIX;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_PROVISIONCATEGORY;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_PROVISIONCRITERIA;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_PROVISIONENTRIES;
Expand All @@ -232,8 +229,6 @@
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_SMSCAMPAIGN;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_STANDINGINSTRUCTION;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_SURVEY;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_TAXCOMPONENT;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_TAXGROUP;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_TELLER;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_TWOFACTOR_ACCESSTOKEN;
import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_TWOFACTOR_CONFIGURATION;
Expand Down Expand Up @@ -2276,24 +2271,6 @@ public CommandWrapperBuilder updateCollateral(final Long loanId, final Long coll
return this;
}

public CommandWrapperBuilder updateClientCollateralProduct(final Long clientId, final Long collateralId) {
this.actionName = ACTION_UPDATE;
this.entityName = ENTITY_CLIENT_COLLATERAL_PRODUCT;
this.entityId = collateralId;
this.clientId = clientId;
this.href = "/clients/" + clientId + "/collateral/" + collateralId;
return this;
}

public CommandWrapperBuilder deleteLoanCollateral(final Long loanId, final Long collateralId) {
this.actionName = ACTION_DELETE;
this.entityName = ENTITY_LOAN_COLLATERAL_PRODUCT;
this.entityId = collateralId;
this.loanId = loanId;
this.href = "/loans/" + loanId + "/collateral/" + collateralId;
return this;
}

public CommandWrapperBuilder deleteCollateral(final Long loanId, final Long collateralId) {
this.actionName = ACTION_DELETE;
this.entityName = ENTITY_COLLATERAL;
Expand All @@ -2303,23 +2280,6 @@ public CommandWrapperBuilder deleteCollateral(final Long loanId, final Long coll
return this;
}

public CommandWrapperBuilder deleteClientCollateralProduct(final Long collateralId, final Long clientId) {
this.actionName = ACTION_DELETE;
this.entityName = ENTITY_CLIENT_COLLATERAL_PRODUCT;
this.entityId = collateralId;
this.clientId = clientId;
this.href = "/clients/" + clientId + "/collateral-management/" + collateralId;
return this;
}

public CommandWrapperBuilder addClientCollateralProduct(final Long clientId) {
this.actionName = ACTION_CREATE;
this.entityName = ENTITY_CLIENT_COLLATERAL_PRODUCT;
this.clientId = clientId;
this.href = "/clients/" + clientId + "/collateral-management";
return this;
}

public CommandWrapperBuilder createCenter() {
this.actionName = ACTION_CREATE;
this.entityName = ENTITY_CENTER;
Expand Down Expand Up @@ -2498,38 +2458,6 @@ public CommandWrapperBuilder updateClientSavingsAccount(final Long clientId) {
return this;
}

public CommandWrapperBuilder createProductMix(final Long productId) {
this.actionName = ACTION_CREATE;
this.entityName = ENTITY_PRODUCTMIX;
this.entityId = null;
this.productId = productId;
this.href = "/loanproducts/" + productId + "/productmix";
return this;
}

public CommandWrapperBuilder updateProductMix(final Long productId) {
this.actionName = ACTION_UPDATE;
this.entityName = ENTITY_PRODUCTMIX;
this.entityId = null;
this.productId = productId;
this.href = "/loanproducts/" + productId + "/productmix";
return this;
}

public CommandWrapperBuilder deleteProductMix(final Long productId) {
this.actionName = ACTION_DELETE;
this.entityName = ENTITY_PRODUCTMIX;
this.entityId = null;
this.productId = productId;
this.href = "/loanproducts/" + productId + "/productmix";
return this;
}

public CommandWrapperBuilder withProduct(final Long productId) {
this.productId = productId;
return this;
}

public CommandWrapperBuilder updateJobDetail(final Long jobId) {
this.actionName = ACTION_UPDATE;
this.entityName = ENTITY_SCHEDULER;
Expand Down Expand Up @@ -3339,38 +3267,6 @@ public CommandWrapperBuilder createAccountCommand(String accountType, final Long
return this;
}

public CommandWrapperBuilder createTaxComponent() {
this.actionName = ACTION_CREATE;
this.entityName = ENTITY_TAXCOMPONENT;
this.entityId = null;
this.href = "/taxes/component";
return this;
}

public CommandWrapperBuilder updateTaxComponent(final Long taxComponentId) {
this.actionName = ACTION_UPDATE;
this.entityName = ENTITY_TAXCOMPONENT;
this.entityId = taxComponentId;
this.href = "/taxes/component/" + taxComponentId;
return this;
}

public CommandWrapperBuilder createTaxGroup() {
this.actionName = ACTION_CREATE;
this.entityName = ENTITY_TAXGROUP;
this.entityId = null;
this.href = "/taxes/group";
return this;
}

public CommandWrapperBuilder updateTaxGroup(final Long taxGroupId) {
this.actionName = ACTION_UPDATE;
this.entityName = ENTITY_TAXGROUP;
this.entityId = taxGroupId;
this.href = "/taxes/group/" + taxGroupId;
return this;
}

public CommandWrapperBuilder updateWithHoldTax(final Long accountId) {
this.actionName = ACTION_UPDATEWITHHOLDTAX;
this.entityName = ENTITY_SAVINGSACCOUNT;
Expand Down
Loading
Loading