FINERACT-2425: Tax component and Tax Group refactoring

This commit is contained in:
Jose Alberto Hernandez
2026-01-03 01:56:47 +01:00
committed by Adam Saghy
parent cbf8a4f5ab
commit b7306f19d0
33 changed files with 525 additions and 295 deletions
@@ -119,6 +119,10 @@ public enum GLAccountType {
return name();
}
public EnumOptionData toEnumOptionData() {
return new EnumOptionData((long) value, code, code);
}
public boolean isAssetType() {
return this.value.equals(GLAccountType.ASSET.getValue());
}
@@ -20,6 +20,7 @@ package org.apache.fineract.accounting.glaccount.domain;
import java.util.HashMap;
import java.util.Map;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public enum GLAccountUsage {
@@ -81,4 +82,8 @@ public enum GLAccountUsage {
return name().toString();
}
public EnumOptionData toEnumOptionData() {
return new EnumOptionData((long) value, code, code);
}
}
@@ -0,0 +1,69 @@
/**
* 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.glaccount.mapper;
import java.util.List;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
import org.apache.fineract.accounting.glaccount.domain.GLAccountUsage;
import org.apache.fineract.infrastructure.codes.mapper.CodeValueMapper;
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
@Mapper(config = MapstructMapperConfig.class, uses = { CodeValueMapper.class })
public interface GlAccountMapper {
@Mapping(target = "usage", source = "glAccount.usage", qualifiedByName = "glAccountUsage")
@Mapping(target = "type", source = "glAccount.type", qualifiedByName = "glAccountType")
@Mapping(target = "name", source = "glAccount.name")
@Mapping(target = "nameDecorated", source = "glAccount.name")
@Mapping(target = "parentId", source = "glAccount.parent.id")
@Mapping(target = "tagId", source = "glAccount.tagId")
@Mapping(target = "accountTypeOptions", ignore = true)
@Mapping(target = "usageOptions", ignore = true)
@Mapping(target = "assetHeaderAccountOptions", ignore = true)
@Mapping(target = "liabilityHeaderAccountOptions", ignore = true)
@Mapping(target = "equityHeaderAccountOptions", ignore = true)
@Mapping(target = "incomeHeaderAccountOptions", ignore = true)
@Mapping(target = "expenseHeaderAccountOptions", ignore = true)
@Mapping(target = "allowedAssetsTagOptions", ignore = true)
@Mapping(target = "allowedLiabilitiesTagOptions", ignore = true)
@Mapping(target = "allowedEquityTagOptions", ignore = true)
@Mapping(target = "allowedIncomeTagOptions", ignore = true)
@Mapping(target = "allowedExpensesTagOptions", ignore = true)
@Mapping(target = "organizationRunningBalance", ignore = true)
@Mapping(target = "rowIndex", ignore = true)
GLAccountData map(GLAccount glAccount);
List<GLAccountData> map(List<GLAccount> glAccounts);
@Named("glAccountType")
default EnumOptionData glAccountType(Integer typeId) {
return GLAccountType.fromInt(typeId).toEnumOptionData();
}
@Named("glAccountUsage")
default EnumOptionData glAccountUsage(Integer usageId) {
return GLAccountUsage.fromInt(usageId).toEnumOptionData();
}
}
@@ -0,0 +1,35 @@
/**
* 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.glaccount.mapper;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@Mapper(config = MapstructMapperConfig.class)
public interface GlAccountTypeMapper {
@Mapping(target = "id", expression = "java((long) glAccountType.getValue())")
@Mapping(target = "code", source = "glAccountType.code")
@Mapping(target = "description", source = "glAccountType.code")
EnumOptionData map(GLAccountType glAccountType);
}
@@ -0,0 +1,35 @@
/**
* 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.glaccount.mapper;
import org.apache.fineract.accounting.glaccount.domain.GLAccountUsage;
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@Mapper(config = MapstructMapperConfig.class)
public interface GlAccountUsageMapper {
@Mapping(target = "id", expression = "java((long) glAccountUsage.getValue())")
@Mapping(target = "code", source = "glAccountUsage.code")
@Mapping(target = "description", source = "glAccountUsage.code")
EnumOptionData map(GLAccountUsage glAccountUsage);
}
@@ -49,25 +49,25 @@ public final class TaxComponentData implements Serializable {
private final Collection<EnumOptionData> glAccountTypeOptions;
public static TaxComponentData instance(final Long id, final String name, final BigDecimal percentage,
final EnumOptionData debitAccountType, final GLAccountData debitAcount, final EnumOptionData creditAccountType,
final GLAccountData creditAcount, final LocalDate startDate, final Collection<TaxComponentHistoryData> taxComponentHistories) {
final EnumOptionData debitAccountType, final GLAccountData debitAccount, final EnumOptionData creditAccountType,
final GLAccountData creditAccount, final LocalDate startDate, final Collection<TaxComponentHistoryData> taxComponentHistories) {
final Map<String, List<GLAccountData>> glAccountOptions = null;
final Collection<EnumOptionData> glAccountTypeOptions = null;
return new TaxComponentData(id, name, percentage, debitAccountType, debitAcount, creditAccountType, creditAcount, startDate,
return new TaxComponentData(id, name, percentage, debitAccountType, debitAccount, creditAccountType, creditAccount, startDate,
taxComponentHistories, glAccountOptions, glAccountTypeOptions);
}
public static TaxComponentData lookup(final Long id, final String name) {
final BigDecimal percentage = null;
final EnumOptionData debitAccountType = null;
final GLAccountData debitAcount = null;
final GLAccountData debitAccount = null;
final EnumOptionData creditAccountType = null;
final GLAccountData creditAcount = null;
final GLAccountData creditAccount = null;
final LocalDate startDate = null;
final Collection<TaxComponentHistoryData> taxComponentHistories = null;
final Map<String, List<GLAccountData>> glAccountOptions = null;
final Collection<EnumOptionData> glAccountTypeOptions = null;
return new TaxComponentData(id, name, percentage, debitAccountType, debitAcount, creditAccountType, creditAcount, startDate,
return new TaxComponentData(id, name, percentage, debitAccountType, debitAccount, creditAccountType, creditAccount, startDate,
taxComponentHistories, glAccountOptions, glAccountTypeOptions);
}
@@ -77,24 +77,24 @@ public final class TaxComponentData implements Serializable {
final String name = null;
final BigDecimal percentage = null;
final EnumOptionData debitAccountType = null;
final GLAccountData debitAcount = null;
final GLAccountData debitAccount = null;
final EnumOptionData creditAccountType = null;
final GLAccountData creditAcount = null;
final GLAccountData creditAccount = null;
final LocalDate startDate = null;
final Collection<TaxComponentHistoryData> taxComponentHistories = null;
return new TaxComponentData(id, name, percentage, debitAccountType, debitAcount, creditAccountType, creditAcount, startDate,
return new TaxComponentData(id, name, percentage, debitAccountType, debitAccount, creditAccountType, creditAccount, startDate,
taxComponentHistories, glAccountOptions, glAccountTypeOptions);
}
private TaxComponentData(final Long id, final BigDecimal percentage, final GLAccountData debitAcount,
final GLAccountData creditAcount) {
private TaxComponentData(final Long id, final BigDecimal percentage, final GLAccountData debitAccount,
final GLAccountData creditAccount) {
this.id = id;
this.percentage = percentage;
this.name = null;
this.debitAccountType = null;
this.debitAccount = debitAcount;
this.debitAccount = debitAccount;
this.creditAccountType = null;
this.creditAccount = creditAcount;
this.creditAccount = creditAccount;
this.startDate = null;
this.taxComponentHistories = null;
this.glAccountOptions = null;
@@ -40,7 +40,7 @@ public class TaxComponentRequest implements Serializable {
private Integer debitAccountType;
private Long debitAccountId;
private Integer creditAccountType;
private Long creditAcountId;
private Long creditAccountId;
private String startDate;
private String dateFormat;
private String locale;