Commit 3ba9ce87 authored by frank.xa.zhang's avatar frank.xa.zhang

add code for data preview module

parent 2aaba395
......@@ -8,59 +8,53 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.vatdto.TrialBalanceDto;
import pwc.taxtech.atms.dto.vatdto.TrialBalanceFilter;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.vat.service.TBDataImportService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@RequestMapping(value = "api/v1/DataImport")
@RestController
public class TBDataImportController {
private final String CIT_CATEGORY = "CIT";
@Autowired
TBDataImportService tbDataImportService;
@RequestMapping(value = "GetBalanceDataForDisplay", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public String GetBalanceDataForDisplay(@RequestBody JSONObject param) {
public String getBalanceDataForDisplay(@RequestBody JSONObject param) {
String category = param.get("category").toString();
int fromPeriod = Integer.parseInt(param.get("fromPeriod").toString());
int toPeriod = Integer.parseInt(param.get("toPeriod").toString());
String criteria = param.get("criteria").toString();
TrialBalanceFilter filter = new TrialBalanceFilter();
if (StringUtils.isBlank(criteria) && !criteria.equals("null")) {
if (StringUtils.isBlank(criteria) && !"null".equals(criteria)) {
JSONObject jsonObject = new JSONObject();
filter = jsonObject.getObject(criteria, TrialBalanceFilter.class);
} else {
filter = null;
}
// String passResponse =
return "";
return convertBalanceDataToUiGridTree(fromPeriod, toPeriod, filter, category);
}
private String ConvertBalanceDataToUiGridTree(int fromPeriod, int toPeriod, TrialBalanceFilter filter, String category) {
private String convertBalanceDataToUiGridTree(int fromPeriod, int toPeriod, TrialBalanceFilter filter, String category) {
String result = "";
List<TrialBalanceDto> balanceList = new ArrayList<>();
if (category.equals(CIT_CATEGORY)) {
String citCategory = "CIT";
if (category.equals(citCategory)) {
balanceList = tbDataImportService.getTrialBalanceData(fromPeriod, toPeriod);
} else {
balanceList = tbDataImportService.getTrialBalanceStdData(fromPeriod, toPeriod);
}
if (filter != null && !balanceList.isEmpty()) {
balanceList = filterTrialBalanceList(filter, balanceList);
}
if (!balanceList.isEmpty()) {
......@@ -96,7 +90,7 @@ public class TBDataImportController {
|| filter.getDebitClosingBalanceFrom() != null)) {
isFilterEmpty = false;
List<String> primaryList = subTotalList.stream().filter(x -> x.getParentCode().equals("0")).map(TrialBalanceDto::getAcctCode).collect(Collectors.toList());
List<String> primaryList = subTotalList.stream().filter(x -> "0".equals(x.getParentCode())).map(TrialBalanceDto::getAcctCode).collect(Collectors.toList());
if (!primaryList.isEmpty()) {
......@@ -109,35 +103,259 @@ public class TBDataImportController {
}
if (!subTotalList.isEmpty()) {
subTotalBegCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getBegCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalBegDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getBegDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalEndCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getEndCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalEndDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getEndDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalBegCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getBegCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalBegDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getBegDebitBal()).doubleValue()).summaryStatistics().getSum());
subTotalEndCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getEndCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalEndDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getEndDebitBal()).doubleValue()).summaryStatistics().getSum());
subTotalCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getDebitBal()).doubleValue()).summaryStatistics().getSum());
}
} else {
subTotalBegCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getBegCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalBegDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getBegDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalEndCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getEndCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalEndDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getEndDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> y.getDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalBegCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getBegCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalBegDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getBegDebitBal()).doubleValue()).summaryStatistics().getSum());
subTotalEndCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getEndCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalEndDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getEndDebitBal()).doubleValue()).summaryStatistics().getSum());
subTotalCreditBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalDebitBal = BigDecimal.valueOf(subTotalList.stream().mapToDouble(y -> Objects.requireNonNull(y.getDebitBal()).doubleValue()).summaryStatistics().getSum());
}
} else {
isFilterEmpty = true;
subTotalBegCreditBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> x.getParentCode().equals("0")).mapToDouble(y -> y.getBegCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalBegDebitBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> x.getParentCode().equals("0")).mapToDouble(y -> y.getBegDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalEndCreditBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> x.getParentCode().equals("0")).mapToDouble(y -> y.getEndCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalEndDebitBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> x.getParentCode().equals("0")).mapToDouble(y -> y.getEndDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalCreditBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> x.getParentCode().equals("0")).mapToDouble(y -> y.getCreditBal().doubleValue()).summaryStatistics().getSum());
subTotalDebitBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> x.getParentCode().equals("0")).mapToDouble(y -> y.getDebitBal().doubleValue()).summaryStatistics().getSum());
subTotalBegCreditBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> "0".equals(x.getParentCode()))
.mapToDouble(y -> Objects.requireNonNull(y.getBegCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalBegDebitBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> "0".equals(x.getParentCode()))
.mapToDouble(y -> Objects.requireNonNull(y.getBegDebitBal()).doubleValue()).summaryStatistics().getSum());
subTotalEndCreditBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> "0".equals(x.getParentCode()))
.mapToDouble(y -> Objects.requireNonNull(y.getEndCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalEndDebitBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> "0".equals(x.getParentCode()))
.mapToDouble(y -> Objects.requireNonNull(y.getEndDebitBal()).doubleValue()).summaryStatistics().getSum());
subTotalCreditBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> "0".equals(x.getParentCode()))
.mapToDouble(y -> Objects.requireNonNull(y.getCreditBal()).doubleValue()).summaryStatistics().getSum());
subTotalDebitBal = BigDecimal.valueOf(subTotalList.stream().filter(x -> "0".equals(x.getParentCode()))
.mapToDouble(y -> Objects.requireNonNull(y.getDebitBal()).doubleValue()).summaryStatistics().getSum());
}
//todo: add the code below here
List<JsonTrialBalanceTreeNode> tree = new ArrayList<>();
List<JsonTrialBalanceTreeNode> balanceTree = new ArrayList<>();
JsonTrialBalanceTreeNode note;
for (TrialBalanceDto item : balanceList) {
note = new JsonTrialBalanceTreeNode();
note.setAcctCode(item.getAcctCode());
note.setAccountName(item.getAccountName());
note.setBalanceId(item.getBalanceId());
note.setBegCreditBal(Objects.requireNonNull(item.getBegCreditBal()).toString());
note.setBegDebitBal(Objects.requireNonNull(item.getBegDebitBal()).toString());
note.setEndCreditBal(Objects.requireNonNull(item.getEndCreditBal()).toString());
note.setEndDebitBal(Objects.requireNonNull(item.getEndDebitBal()).toString());
note.setParentCode(item.getParentCode());
note.setCreditBal(Objects.requireNonNull(item.getCreditBal()).toString());
note.setDebitBal(Objects.requireNonNull(item.getDebitBal()).toString());
note.setAcctProp(item.getAcctProp() != null ? item.getAcctProp().toString() : "7"); // 7 means "Other" category
note.setDirection(Integer.toString(item.getDirection()));
balanceTree.add(note);
}
BalanceWithSubTotalsResultDto<JsonTrialBalanceTreeNode> balanceWithSubTotalsInfo = new BalanceWithSubTotalsResultDto<>();
BalanceSubTotalDto subtotalsInfo = new BalanceSubTotalDto();
subtotalsInfo.setBegCreditBal(subTotalBegCreditBal.toString());
subtotalsInfo.setBegDebitBal(subTotalBegDebitBal.toString());
subtotalsInfo.setEndCreditBal(subTotalEndCreditBal.toString());
subtotalsInfo.setEndDebitBal(subTotalEndDebitBal.toString());
subtotalsInfo.setCreditBal(subTotalCreditBal.toString());
subtotalsInfo.setDebitBal(subTotalDebitBal.toString());
if (isFilterEmpty) {
initTree(tree, "0", balanceTree);
} else {
JsonTrialBalanceTreeNode tempNode;
if (!balanceTree.isEmpty()) {
for (JsonTrialBalanceTreeNode row : balanceTree) {
tempNode = new JsonTrialBalanceTreeNode();
CommonUtils.copyProperties(row, tempNode);
tempNode.setAccountName(StringUtils.removeStart(row.getAccountName(), "@"));
tempNode.setChildren(new ArrayList<>());
tree.add(tempNode);
}
}
}
balanceWithSubTotalsInfo.setList(tree.stream()
.sorted(Comparator.comparing(JsonTrialBalanceTreeNode::getAcctCode)
.thenComparing(JsonTrialBalanceTreeNode::getAcctCodeLength))
.collect(Collectors.toList()));
balanceWithSubTotalsInfo.setSubTotals(subtotalsInfo);
result = JSONObject.toJSONString(balanceWithSubTotalsInfo);
return result;
}
private void initTree(List<JsonTrialBalanceTreeNode> nodes, String parentCode, List<JsonTrialBalanceTreeNode> sources) {
JsonTrialBalanceTreeNode tempNode;
//递归寻找子节点
List<JsonTrialBalanceTreeNode> tempTree = sources.stream().filter(item -> item.getParentCode().equals(parentCode)).collect(Collectors.toList());
for (JsonTrialBalanceTreeNode row : tempTree) {
tempNode = new JsonTrialBalanceTreeNode();
CommonUtils.copyProperties(row, tempNode);
tempNode.setChildren(new ArrayList<>());
nodes.add(tempNode);
initTree(tempNode.getChildren(), row.getAcctCode(), sources);
}
}
private static List<TrialBalanceDto> filterTrialBalanceList(TrialBalanceFilter filter, List<TrialBalanceDto> balanceList) {
// Account Code: support multiple codes seperated by space:
if (StringUtils.isNotBlank(filter.getAccountCode())) {
List<String> codes = new ArrayList<>(Arrays.asList(filter.getAccountCode().split(" ")));
balanceList = balanceList.stream().filter(x -> codes.contains(x.getAcctCode())).collect(Collectors.toList());
}
// Account Name: support multiple codes seperated by space:
if (StringUtils.isNotBlank(filter.getAccountName())) {
List<String> names = new ArrayList<>(Arrays.asList(filter.getAccountName().split(" ")));
List<TrialBalanceDto> ds = new ArrayList<>();
for (String name : names) {
ds.addAll(balanceList.stream().filter(x -> x.getAccountName().contains(name)).collect(Collectors.toList()));
}
balanceList = ds;
}
// Debit Opening Balance:
if (filter.getDebitOpeningBalanceFrom() != null || filter.getDebitOpeningBalanceTo() != null) {
if (filter.getDebitOpeningBalanceFrom() != null && filter.getDebitOpeningBalanceTo() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getDebitOpeningBalanceFrom().doubleValue()
&& x.getBegDebitBal().doubleValue() <= filter.getDebitOpeningBalanceTo().doubleValue())
.collect(Collectors.toList());
} else if (filter.getDebitOpeningBalanceFrom() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getDebitOpeningBalanceFrom().doubleValue())
.collect(Collectors.toList());
} else {
balanceList = balanceList.stream().filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() <= filter.getDebitOpeningBalanceTo().doubleValue())
.collect(Collectors.toList());
}
}
// Credit Opening Balance:
if (filter.getCreditOpeningBalanceFrom() != null || filter.getCreditOpeningBalanceTo() != null) {
if (filter.getCreditOpeningBalanceFrom() != null && filter.getCreditOpeningBalanceTo() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getCreditOpeningBalanceFrom().doubleValue()
&& x.getBegDebitBal().doubleValue() <= filter.getCreditOpeningBalanceTo().doubleValue())
.collect(Collectors.toList());
} else if (filter.getCreditOpeningBalanceFrom() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getCreditOpeningBalanceFrom().doubleValue())
.collect(Collectors.toList());
} else {
balanceList = balanceList.stream().filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() <= filter.getCreditOpeningBalanceTo().doubleValue())
.collect(Collectors.toList());
}
}
// Accumulated Debit Balance:
if (filter.getAccumulatedDebitAmountFrom() != null || filter.getAccumulatedDebitAmountTo() != null) {
if (filter.getAccumulatedDebitAmountFrom() != null && filter.getAccumulatedDebitAmountTo() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getAccumulatedDebitAmountFrom().doubleValue()
&& x.getBegDebitBal().doubleValue() <= filter.getAccumulatedDebitAmountTo().doubleValue())
.collect(Collectors.toList());
} else if (filter.getAccumulatedDebitAmountFrom() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getAccumulatedDebitAmountFrom().doubleValue())
.collect(Collectors.toList());
} else {
balanceList = balanceList.stream().filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() <= filter.getAccumulatedDebitAmountTo().doubleValue())
.collect(Collectors.toList());
}
}
// Accumulated Credit Balance:
if (filter.getAccumulatedCreditAmountFrom() != null || filter.getAccumulatedCreditAmountTo() != null) {
if (filter.getAccumulatedCreditAmountFrom() != null && filter.getAccumulatedCreditAmountTo() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getAccumulatedCreditAmountFrom().doubleValue()
&& x.getBegDebitBal().doubleValue() <= filter.getAccumulatedCreditAmountTo().doubleValue())
.collect(Collectors.toList());
} else if (filter.getAccumulatedCreditAmountFrom() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getAccumulatedCreditAmountFrom().doubleValue())
.collect(Collectors.toList());
} else {
balanceList = balanceList.stream().filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() <= filter.getAccumulatedCreditAmountTo().doubleValue())
.collect(Collectors.toList());
}
}
// Closing Debit Balance:
if (filter.getDebitClosingBalanceFrom() != null || filter.getDebitClosingBalanceTo() != null) {
if (filter.getDebitClosingBalanceFrom() != null && filter.getDebitClosingBalanceTo() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getDebitClosingBalanceFrom().doubleValue()
&& x.getBegDebitBal().doubleValue() <= filter.getDebitClosingBalanceTo().doubleValue())
.collect(Collectors.toList());
} else if (filter.getDebitClosingBalanceFrom() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getAccumulatedCreditAmountFrom().doubleValue())
.collect(Collectors.toList());
} else {
balanceList = balanceList.stream().filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() <= filter.getDebitClosingBalanceTo().doubleValue())
.collect(Collectors.toList());
}
}
// Closing Credit Balance:
if (filter.getCreditClosingBalanceFrom() != null || filter.getCreditClosingBalanceTo() != null) {
if (filter.getCreditClosingBalanceFrom() != null && filter.getCreditClosingBalanceTo() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getCreditClosingBalanceFrom().doubleValue()
&& x.getBegDebitBal().doubleValue() <= filter.getCreditClosingBalanceTo().doubleValue())
.collect(Collectors.toList());
} else if (filter.getDebitClosingBalanceFrom() != null) {
balanceList = balanceList.stream()
.filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() >= filter.getCreditClosingBalanceFrom().doubleValue())
.collect(Collectors.toList());
} else {
balanceList = balanceList.stream().filter(x -> x.getBegDebitBal() != null
&& x.getBegDebitBal().doubleValue() <= filter.getCreditClosingBalanceTo().doubleValue())
.collect(Collectors.toList());
}
}
assert filter.isHideAllZeroRecords() != null;
if (filter.isHideAllZeroRecords()) {
balanceList = balanceList.stream()
.filter(x -> ((x.getBegCreditBal() != null && x.getBegCreditBal().doubleValue() != 0)
|| (x.getEndDebitBal() != null && x.getEndDebitBal().doubleValue() != 0)
|| (x.getBegDebitBal() != null && x.getBegDebitBal().doubleValue() != 0)
|| (x.getEndDebitBal() != null && x.getEndDebitBal().doubleValue() != 0)
|| (x.getCreditBal() != null && x.getCreditBal().doubleValue() != 0)
|| (x.getDebitBal() != null && x.getDebitBal().doubleValue() != 0)))
.collect(Collectors.toList());
}
return balanceList;
}
}
package pwc.taxtech.atms.dto.vatdto;
import java.util.Collection;
public class BalanceSubTotalDto {
private String begCreditBal ;
private String begDebitBal ;
private String endCreditBal ;
private String endDebitBal ;
private String yearCreditBal ;
private String yearDebitBal ;
private String debitBal ;
private String creditBal ;
public String getBegCreditBal() {
return begCreditBal;
}
public void setBegCreditBal(String begCreditBal) {
this.begCreditBal = begCreditBal;
}
public String getBegDebitBal() {
return begDebitBal;
}
public void setBegDebitBal(String begDebitBal) {
this.begDebitBal = begDebitBal;
}
public String getEndCreditBal() {
return endCreditBal;
}
public void setEndCreditBal(String endCreditBal) {
this.endCreditBal = endCreditBal;
}
public String getEndDebitBal() {
return endDebitBal;
}
public void setEndDebitBal(String endDebitBal) {
this.endDebitBal = endDebitBal;
}
public String getYearCreditBal() {
return yearCreditBal;
}
public void setYearCreditBal(String yearCreditBal) {
this.yearCreditBal = yearCreditBal;
}
public String getYearDebitBal() {
return yearDebitBal;
}
public void setYearDebitBal(String yearDebitBal) {
this.yearDebitBal = yearDebitBal;
}
public String getDebitBal() {
return debitBal;
}
public void setDebitBal(String debitBal) {
this.debitBal = debitBal;
}
public String getCreditBal() {
return creditBal;
}
public void setCreditBal(String creditBal) {
this.creditBal = creditBal;
}
}
package pwc.taxtech.atms.dto.vatdto;
import java.util.Collection;
public class BalanceWithSubTotalsResultDto<T> {
private Collection<T> list;
private BalanceSubTotalDto subTotals;
public Collection<T> getList() {
return list;
}
public void setList(Collection<T> list) {
this.list = list;
}
public BalanceSubTotalDto getSubTotals() {
return subTotals;
}
public void setSubTotals(BalanceSubTotalDto subTotals) {
this.subTotals = subTotals;
}
}
package pwc.taxtech.atms.dto.vatdto;
import java.util.List;
public class JsonTrialBalanceTreeNode {
private String balanceId;
private Integer periodId;
private String direction;
private String customerCode;
private String begDebitBal;
private String begCreditBal;
private String begBal;
private String endBal;
private String endDebitBal;
private String endCreditBal;
private Integer monthID;
private String debitBal;
private String creditBal;
private String accountName;
private String acctProp;
private String acctCode;
private String parentCode;
private List<JsonTrialBalanceTreeNode> children;
public String getBalanceId() {
return balanceId;
}
public void setBalanceId(String balanceId) {
this.balanceId = balanceId;
}
public Integer getPeriodId() {
return periodId;
}
public void setPeriodId(Integer periodId) {
this.periodId = periodId;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getCustomerCode() {
return customerCode;
}
public void setCustomerCode(String customerCode) {
this.customerCode = customerCode;
}
public String getBegDebitBal() {
return begDebitBal;
}
public void setBegDebitBal(String begDebitBal) {
this.begDebitBal = begDebitBal;
}
public String getBegCreditBal() {
return begCreditBal;
}
public void setBegCreditBal(String begCreditBal) {
this.begCreditBal = begCreditBal;
}
public String getBegBal() {
return begBal;
}
public void setBegBal(String begBal) {
this.begBal = begBal;
}
public String getEndBal() {
return endBal;
}
public void setEndBal(String endBal) {
this.endBal = endBal;
}
public String getEndDebitBal() {
return endDebitBal;
}
public void setEndDebitBal(String endDebitBal) {
this.endDebitBal = endDebitBal;
}
public String getEndCreditBal() {
return endCreditBal;
}
public void setEndCreditBal(String endCreditBal) {
this.endCreditBal = endCreditBal;
}
public Integer getMonthID() {
return monthID;
}
public void setMonthID(Integer monthID) {
this.monthID = monthID;
}
public String getDebitBal() {
return debitBal;
}
public void setDebitBal(String debitBal) {
this.debitBal = debitBal;
}
public String getCreditBal() {
return creditBal;
}
public void setCreditBal(String creditBal) {
this.creditBal = creditBal;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getAcctProp() {
return acctProp;
}
public void setAcctProp(String acctProp) {
this.acctProp = acctProp;
}
public String getAcctCode() {
return acctCode;
}
public int getAcctCodeLength() {
return acctCode.length();
}
public void setAcctCode(String acctCode) {
this.acctCode = acctCode;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public List<JsonTrialBalanceTreeNode> getChildren() {
return children;
}
public void setChildren(List<JsonTrialBalanceTreeNode> children) {
this.children = children;
}
}
......@@ -31,7 +31,7 @@ public class TrialBalanceFilter {
@Nullable
private BigDecimal creditClosingBalanceTo ;
@Nullable
private boolean hideAllZeroRecords ;
private Boolean hideAllZeroRecords ;
public String getAccountCode() {
return accountCode;
......@@ -158,11 +158,11 @@ public class TrialBalanceFilter {
}
@Nullable
public boolean isHideAllZeroRecords() {
public Boolean isHideAllZeroRecords() {
return hideAllZeroRecords;
}
public void setHideAllZeroRecords(@Nullable boolean hideAllZeroRecords) {
public void setHideAllZeroRecords(@Nullable Boolean hideAllZeroRecords) {
this.hideAllZeroRecords = hideAllZeroRecords;
}
}
......@@ -27,15 +27,15 @@ public class TBDataImportServiceImpl extends VatAbstractService implements TBDat
TrialBalanceDto trialBalanceDto = new TrialBalanceDto();
trialBalanceDto.setAcctCode(item.getAcctCode());
trialBalanceDto.setCustomerCode(item.getCustomerCode());
trialBalanceDto.setBegDebitBal(item.getPeriodId().intValue() == fromPeriod ? item.getBegDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setBegCreditBal(item.getPeriodId().intValue() == fromPeriod ? item.getBegCreditBal() : BigDecimal.ZERO);
trialBalanceDto.setBegBal(item.getPeriodId().intValue() == fromPeriod ? item.getBegBal() : BigDecimal.ZERO);
trialBalanceDto.setEndBal(item.getPeriodId().intValue() == toPeriod ? item.getEndBal() : BigDecimal.ZERO);
trialBalanceDto.setEndDebitBal(item.getPeriodId().intValue() == toPeriod ? item.getEndDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setEndCreditBal(item.getPeriodId().intValue() == toPeriod ? item.getEndCreditBal() : BigDecimal.ZERO);
double summaryA = b.stream().mapToDouble(c -> c.getDebitBal().doubleValue()).summaryStatistics().getSum();
trialBalanceDto.setBegDebitBal(item.getPeriodId() == fromPeriod ? item.getBegDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setBegCreditBal(item.getPeriodId() == fromPeriod ? item.getBegCreditBal() : BigDecimal.ZERO);
trialBalanceDto.setBegBal(item.getPeriodId() == fromPeriod ? item.getBegBal() : BigDecimal.ZERO);
trialBalanceDto.setEndBal(item.getPeriodId() == toPeriod ? item.getEndBal() : BigDecimal.ZERO);
trialBalanceDto.setEndDebitBal(item.getPeriodId() == toPeriod ? item.getEndDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setEndCreditBal(item.getPeriodId() == toPeriod ? item.getEndCreditBal() : BigDecimal.ZERO);
double summaryA = b.stream().mapToDouble(c -> Objects.requireNonNull(c.getDebitBal()).doubleValue()).summaryStatistics().getSum();
trialBalanceDto.setDebitBal(BigDecimal.valueOf(summaryA));
double summaryB = b.stream().mapToDouble(c -> c.getCreditBal().doubleValue()).summaryStatistics().getSum();
double summaryB = b.stream().mapToDouble(c -> Objects.requireNonNull(c.getCreditBal()).doubleValue()).summaryStatistics().getSum();
trialBalanceDto.setCreditBal(BigDecimal.valueOf(summaryB));
trialBalanceDto.setParentCode(item.getParentCode());
trialBalanceDto.setAccountName(item.getAccountName());
......@@ -60,15 +60,15 @@ public class TBDataImportServiceImpl extends VatAbstractService implements TBDat
TrialBalanceDto trialBalanceDto = new TrialBalanceDto();
trialBalanceDto.setAcctCode(item.getAcctCode());
trialBalanceDto.setCustomerCode(item.getCustomerCode());
trialBalanceDto.setBegDebitBal(item.getPeriodId().intValue() == fromPeriod ? item.getBegDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setBegCreditBal(item.getPeriodId().intValue() == fromPeriod ? item.getBegCreditBal() : BigDecimal.ZERO);
trialBalanceDto.setBegBal(item.getPeriodId().intValue() == fromPeriod ? item.getBegBal() : BigDecimal.ZERO);
trialBalanceDto.setEndBal(item.getPeriodId().intValue() == toPeriod ? item.getEndBal() : BigDecimal.ZERO);
trialBalanceDto.setEndDebitBal(item.getPeriodId().intValue() == toPeriod ? item.getEndDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setEndCreditBal(item.getPeriodId().intValue() == toPeriod ? item.getEndCreditBal() : BigDecimal.ZERO);
double summaryA = b.stream().mapToDouble(c -> c.getDebitBal().doubleValue()).summaryStatistics().getSum();
trialBalanceDto.setBegDebitBal(item.getPeriodId() == fromPeriod ? item.getBegDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setBegCreditBal(item.getPeriodId() == fromPeriod ? item.getBegCreditBal() : BigDecimal.ZERO);
trialBalanceDto.setBegBal(item.getPeriodId() == fromPeriod ? item.getBegBal() : BigDecimal.ZERO);
trialBalanceDto.setEndBal(item.getPeriodId() == toPeriod ? item.getEndBal() : BigDecimal.ZERO);
trialBalanceDto.setEndDebitBal(item.getPeriodId() == toPeriod ? item.getEndDebitBal() : BigDecimal.ZERO);
trialBalanceDto.setEndCreditBal(item.getPeriodId() == toPeriod ? item.getEndCreditBal() : BigDecimal.ZERO);
double summaryA = b.stream().mapToDouble(c -> Objects.requireNonNull(c.getDebitBal()).doubleValue()).summaryStatistics().getSum();
trialBalanceDto.setDebitBal(BigDecimal.valueOf(summaryA));
double summaryB = b.stream().mapToDouble(c -> c.getCreditBal().doubleValue()).summaryStatistics().getSum();
double summaryB = b.stream().mapToDouble(c -> Objects.requireNonNull(c.getCreditBal()).doubleValue()).summaryStatistics().getSum();
trialBalanceDto.setCreditBal(BigDecimal.valueOf(summaryB));
trialBalanceDto.setParentCode(item.getParentCode());
trialBalanceDto.setAccountName(item.getAccountName());
......@@ -79,80 +79,81 @@ public class TBDataImportServiceImpl extends VatAbstractService implements TBDat
return result;
}
@Deprecated
private List<TrialBalanceDto> dealNullValue(List<TrialBalanceDto> dataList) {
int BegDebitBal = 0, BegCreditBal = 0, BegBal = 0, EndBal = 0;
int EndDebitBal = 0, EndCreditBal = 0, DebitBal = 0, CreditBal = 0, MonthId = 0, CustomerCode = 0;
int begDebitBal = 0, begCreditBal = 0, begBal = 0, endBal = 0;
int endDebitBal = 0, endCreditBal = 0, debitBal = 0, creditBal = 0, monthId = 0, customerCode = 0;
if (dataList != null && !dataList.isEmpty()) {
if (dataList.stream().anyMatch(a -> a.getMonthId() != null)) {
MonthId = 1;
monthId = 1;
}
if (dataList.stream().anyMatch(a -> StringUtils.isNotBlank(a.getCustomerCode()))) {
CustomerCode = 1;
customerCode = 1;
}
if (dataList.stream().anyMatch(p -> p.getBegDebitBal() != null)) {
BegDebitBal = 1;
begDebitBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getBegCreditBal() != null)) {
BegCreditBal = 1;
begCreditBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getBegBal() != null)) {
BegBal = 1;
begBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getEndBal() != null)) {
EndBal = 1;
endBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getEndDebitBal() != null)) {
EndDebitBal = 1;
endDebitBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getEndCreditBal() != null)) {
EndCreditBal = 1;
endCreditBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getDebitBal() != null)) {
DebitBal = 1;
debitBal = 1;
}
if (dataList.stream().anyMatch(p -> p.getCreditBal() != null)) {
CreditBal = 1;
creditBal = 1;
}
for (TrialBalanceDto compbalance : dataList) {
if (compbalance.getMonthId() == null && MonthId == 1) {
if (compbalance.getMonthId() == null && monthId == 1) {
compbalance.setMonthId(0);
}
if (CustomerCode == 0) {
if (customerCode == 0) {
compbalance.setCustomerCode(null);
}
if (compbalance.getBegDebitBal() == null && BegDebitBal == 1) {
if (compbalance.getBegDebitBal() == null && begDebitBal == 1) {
compbalance.setBegDebitBal(BigDecimal.ZERO);
}
if (compbalance.getBegCreditBal() == null && BegCreditBal == 1) {
if (compbalance.getBegCreditBal() == null && begCreditBal == 1) {
compbalance.setBegCreditBal(BigDecimal.ZERO);
}
if (compbalance.getBegBal() == null && BegBal == 1) {
if (compbalance.getBegBal() == null && begBal == 1) {
compbalance.setBegBal(BigDecimal.ZERO);
}
if (compbalance.getEndBal() == null && EndBal == 1) {
if (compbalance.getEndBal() == null && endBal == 1) {
compbalance.setEndBal(BigDecimal.ZERO);
}
if (compbalance.getEndDebitBal() == null && EndDebitBal == 1) {
if (compbalance.getEndDebitBal() == null && endDebitBal == 1) {
compbalance.setEndDebitBal(BigDecimal.ZERO);
}
if (compbalance.getEndCreditBal() == null && EndCreditBal == 1) {
if (compbalance.getEndCreditBal() == null && endCreditBal == 1) {
compbalance.setEndCreditBal(BigDecimal.ZERO);
}
if (compbalance.getDebitBal() == null && DebitBal == 1) {
if (compbalance.getDebitBal() == null && debitBal == 1) {
compbalance.setDebitBal(BigDecimal.ZERO);
}
if (compbalance.getCreditBal() == null && CreditBal == 1) {
if (compbalance.getCreditBal() == null && creditBal == 1) {
compbalance.setCreditBal(BigDecimal.ZERO);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment