Skip to content
Open
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 @@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.tax.data;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collection;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -35,21 +36,28 @@ public final class TaxGroupData implements Serializable {
@SuppressWarnings("unused")
private final Collection<TaxComponentData> taxComponents;

// System business date, exposed so clients can validate a new tax component's start date client-side
private final LocalDate businessDate;

public static TaxGroupData lookup(final Long id, final String name) {
final Collection<TaxComponentData> taxComponents = null;
final Collection<TaxGroupMappingsData> taxAssociations = null;
return new TaxGroupData(id, name, taxAssociations, taxComponents);
return new TaxGroupData(id, name, taxAssociations, taxComponents, null);
}

public static TaxGroupData template(final Collection<TaxComponentData> taxComponents) {
final Long id = null;
final String name = null;
final Collection<TaxGroupMappingsData> taxAssociations = null;
return new TaxGroupData(id, name, taxAssociations, taxComponents);
return new TaxGroupData(id, name, taxAssociations, taxComponents, null);
}

public static TaxGroupData template(final TaxGroupData taxGroupData, final Collection<TaxComponentData> taxComponents) {
return new TaxGroupData(taxGroupData.id, taxGroupData.name, taxGroupData.taxAssociations, taxComponents);
return new TaxGroupData(taxGroupData.id, taxGroupData.name, taxGroupData.taxAssociations, taxComponents, taxGroupData.businessDate);
}

public static TaxGroupData withBusinessDate(final TaxGroupData taxGroupData, final LocalDate businessDate) {
return new TaxGroupData(taxGroupData.id, taxGroupData.name, taxGroupData.taxAssociations, taxGroupData.taxComponents, businessDate);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.tax.data.TaxComponentData;
import org.apache.fineract.portfolio.tax.data.TaxGroupData;
import org.apache.fineract.portfolio.tax.domain.TaxComponentRepository;
Expand Down Expand Up @@ -65,7 +66,8 @@ public List<TaxGroupData> retrieveAllTaxGroups() {

@Override
public TaxGroupData retrieveTaxGroupData(final Long id) {
return taxGroupMapper.map(taxGroupRepositoryWrapper.findOneWithNotFoundDetection(id));
final TaxGroupData taxGroupData = taxGroupMapper.map(taxGroupRepositoryWrapper.findOneWithNotFoundDetection(id));
return TaxGroupData.withBusinessDate(taxGroupData, DateUtils.getBusinessLocalDate());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
Expand Down Expand Up @@ -93,15 +94,17 @@ public Map<String, Object> update(final JsonCommand command, final Set<TaxGroupM
}

public TaxGroupMappings findOneBy(final TaxGroupMappings groupMapping) {
if (groupMapping.getId() != null) {
for (TaxGroupMappings groupMappings : this.taxGroupMappings) {
if (groupMappings.getId().equals(groupMapping.getId())) {
return groupMappings;
}
if (groupMapping.getId() == null) {
return null;
}

for (TaxGroupMappings existing : this.taxGroupMappings) {
if (Objects.equals(existing.getId(), groupMapping.getId())) {
return existing;
}
throw new TaxMappingNotFoundException(groupMapping.getId());
}
return null;

throw new TaxMappingNotFoundException(groupMapping.getId());
}

public Set<TaxGroupMappings> getTaxGroupMappings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface TaxGroupMapper {

@Mapping(target = "taxAssociations", source = "taxGroup.taxGroupMappings")
@Mapping(target = "taxComponents", ignore = true)
@Mapping(target = "businessDate", ignore = true)
TaxGroupData map(TaxGroup taxGroup);

List<TaxGroupData> map(List<TaxGroup> taxGroups);
Expand Down
Loading