Commit c55b5c98 authored by frank.xa.zhang's avatar frank.xa.zhang

add function XXPF code, need debug later

refactor previous code, make some method as base class public method
parent c8b6338d
......@@ -35,6 +35,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static VatEnterpriseAccountDao vatEnterpriseAccountDao;
public static VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
public static BalanceStdManualMapper balanceStdManualMapper;
public static OutputVATInvoiceMapper outputVATInvoiceMapper;
/**
......@@ -69,5 +70,6 @@ public class SpringContextUtil implements ApplicationContextAware {
vatEnterpriseAccountDao = webApplicationContext.getBean(VatEnterpriseAccountDao.class);
vatEnterpriseAccountMapper = webApplicationContext.getBean(VatEnterpriseAccountMapper.class);
balanceStdManualMapper = webApplicationContext.getBean(BalanceStdManualMapper.class);
outputVATInvoiceMapper = webApplicationContext.getBean(OutputVATInvoiceMapper.class);
}
}
......@@ -42,4 +42,20 @@ public final class Constant {
public static final String IMAGE_FORMART_ = "png";
public static final String EMPTY = "";
public static class DataSourceName {
public static final String KeyValueDataSource = "KeyValueDataSource";
public static final String InputInvoiceDataSource = "IncomeDataSource";
public static final String InputDetailInvoiceDataSource = "IncomeDetailDataSource";
public static final String OutputInvoiceDataSource = "OutputInvoiceDataSource";
public static final String VoucherDataSource = "VoucherDataSource";
public static final String ReportDataSource = "ReportDataSource";
public static final String ConditionDataSource = "ConditionDataSource";
public static final String MinConditionDataSource = "MinConditionDataSource";
public static final String MaxConditionDataSource = "MaxConditionDataSource";
public static final String SAPDataSource = "SAPDataSource";
public static final String LandSellDataSource = "LandSellDataSource";
public static final String UnbilledDataSource = "UnbilledDataSource";
public static final String AssetListDataSource = "AssetListDataSource";
}
}
\ No newline at end of file
package pwc.taxtech.atms.constant.enums;
public enum EnumOperationType {
Single(0),
Add(1),
Sub(2),
Mul(3),
Div(4);
private Integer code;
EnumOperationType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
......@@ -2,7 +2,8 @@ package pwc.taxtech.atms.constant.enums;
public enum FormulaDataSourceDetailType {
BSPLFormulaDataSourceDto(1, pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto.class);
BSPLFormulaDataSourceDto(1, pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto.class),
OutputInvoiceDataSourceDto(1, pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto.class);
private Integer code;
......
......@@ -24,7 +24,7 @@ public class DataSourceDto {
// 1: Formula, 2: Voucher, 3: OutputInvoice, 4: InputInvoice, 5: CustomInvoice, 6: KeyIn, 7: RelatedModel, 8: SapDaily
Integer dataSourceType;
BigDecimal amount;
private BigDecimal amount;
String description;
// 1: +, 2: -, 3: *, 4: /
......
package pwc.taxtech.atms.dto.vatdto;
import lombok.Getter;
import lombok.Setter;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceType;
import java.math.BigDecimal;
import java.util.Date;
@Getter
@Setter
public class OutputInvoiceDataSourceDto extends FormulaDataSourceDto {
public OutputInvoiceDataSourceDto() {
super();
this.setType(FormulaDataSourceType.OutputInvoice.getCode());
}
private Long id;
private int period;
private Date invoiceDate;
private String buyerName;
private String invoiceCode;
private String invoiceNumber;
private BigDecimal taxRate;
private BigDecimal taxAmount;
private Integer invoiceType;
private String dataSourceId;
//数据源名称
private String dataSourceName;
}
package pwc.taxtech.atms.dto.vatdto;
import lombok.Getter;
import lombok.Setter;
import pwc.taxtech.atms.vat.entity.OutputVATInvoice;
import pwc.taxtech.atms.vat.entity.OutputVATInvoiceItem;
@Getter
@Setter
public class OutputVATInvoiceDto {
private String invoiceID;
private OutputVATInvoice invoice;
private OutputVATInvoiceItem invoiceItem;
}
......@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
import pwc.taxtech.atms.vat.entity.OutputVATInvoice;
......@@ -181,4 +182,6 @@ public interface OutputVATInvoiceMapper extends MyVatMapper {
" AND o.PeriodID = #{period}" +
" ")
List<OutputVATInvoiceInfoDto> queryOutputDetailWithItem(Integer period);
List<OutputVATInvoiceDto> getVatInvoiceWithItems(String dbName);
}
\ No newline at end of file
......@@ -26,11 +26,7 @@ import pwc.taxtech.atms.dto.vatdto.PeriodCellTemplateConfigExtendDto;
import pwc.taxtech.atms.entitiy.Project;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.ReportGenerator;
import pwc.taxtech.atms.vat.service.impl.report.functions.BB;
import pwc.taxtech.atms.vat.service.impl.report.functions.FSJZ;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import pwc.taxtech.atms.vat.service.impl.report.functions.ND;
import pwc.taxtech.atms.vat.service.impl.report.functions.SGSR;
import pwc.taxtech.atms.vat.service.impl.report.functions.*;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -281,9 +277,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
* @param workbook 工作簿
*/
private void addFunctionsToWorkbook(Workbook workbook, FormulaContext formulaContext) {
String[] functionNames = {"SGSR", "FSJZ", "ND", "BB"};
String[] functionNames = {"SGSR", "FSJZ", "ND", "BB","XXFP"};
FreeRefFunction[] functionImpls = {new SGSR(formulaContext), new FSJZ(formulaContext), new ND(formulaContext),
new BB(formulaContext)};
new BB(formulaContext),new XXFP(formulaContext)};
UDFFinder udfs = new DefaultUDFFinder(functionNames, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack);
......
package pwc.taxtech.atms.vat.service.impl.report.functions;
import com.alibaba.fastjson.JSON;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
......@@ -9,8 +8,10 @@ import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto;
import pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.entity.Balance;
import pwc.taxtech.atms.vat.entity.BalanceStdManual;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import pwc.taxtech.atms.vat.entity.VatStandardAccount;
import java.math.BigDecimal;
import java.util.ArrayList;
......@@ -90,7 +91,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
}
BigDecimal val = new BigDecimal(0);
List<FormulaDataSourceDto> formulaDataSourceDtoList = new ArrayList<>();
List<Object> formulaDataSourceDtoList = new ArrayList<>();
if (balanceStdManual != null) {
List<VatEnterpriseAccount> vatEnterpriseAccountList = SpringContextUtil
.vatEnterpriseAccountMapper
......@@ -132,49 +133,9 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
}
//todo: sava data
//save datasource
DataSource dataSource = new DataSource();
Long dataSourceID = SpringContextUtil.distributedIDService.nextId();
dataSource.setId(dataSourceID);
dataSource.setType(1);
dataSource.setName("ReportDataSource");
dataSource.setAmount(val);
dataSource.setDescription("");
dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin");
dataSource.setCreateTime(creatime);
dataSource.setUpdateTime(creatime);
dataSource.setRowIndex(ec.getRowIndex());
dataSource.setColumnIndex(ec.getColumnIndex());
dataSource.setRowName("");
dataSource.setColumnName("");
SpringContextUtil.dataSourceMapper.insertSelective(dataSource);
for (FormulaDataSourceDto aFormulaDataSourceDtoList : formulaDataSourceDtoList) {
BSPLFormulaDataSourceDto bsplFormulaDataSourceDto = ((BSPLFormulaDataSourceDto) aFormulaDataSourceDtoList);
DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setId(SpringContextUtil.distributedIDService.nextId());
dataSourceDetail.setDataSourceId(dataSourceID);
dataSourceDetail.setDataSourceType(FormulaDataSourceDetailType.BSPLFormulaDataSourceDto.getCode());
dataSourceDetail.setItemValue(JSON.toJSONString(bsplFormulaDataSourceDto));
SpringContextUtil.dataSourceDetailMapper.insertSelective(dataSourceDetail);
}
Long dataSourceID = saveDataSource(ec, formulaDataSourceDtoList, FormulaDataSourceDetailType.BSPLFormulaDataSourceDto, val);
//save formulablock
Long cellTemplateID = getCellTemplateID(period, ec);
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIDService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
periodFormulaBlock.setCellTemplateId(cellTemplateID);
periodFormulaBlock.setFormulaExpression(formulaExpression);
periodFormulaBlock.setData(val.toString());
periodFormulaBlock.setDataSourceId(dataSourceID);
periodFormulaBlock.setCreateBy("Admin");
periodFormulaBlock.setCreateTime(creatime);
periodFormulaBlock.setUpdateBy("Admin");
periodFormulaBlock.setUpdateTime(creatime);
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
saveFormulaBlock(period, ec, formulaExpression, val, dataSourceID);
return new NumberEval(val.doubleValue());
} else {
......@@ -196,7 +157,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
}
BigDecimal val = new BigDecimal(0);
List<FormulaDataSourceDto> dsList = new ArrayList<>();
List<Object> dsList = new ArrayList<>();
if (balance != null) {
if (period == 99) {
val = new BigDecimal(((balance.getYearDebitNet() != null ? balance.getYearDebitNet() : 0).doubleValue()
......@@ -232,51 +193,12 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
? FormulaHelper.roundValue(val, KeyValueConfigResultType.Accounting, null, formulaContext)
: new BigDecimal(0);
}
//todo: sava data
//save datasource
DataSource dataSource = new DataSource();
Long dataSourceID = SpringContextUtil.distributedIDService.nextId();
dataSource.setId(dataSourceID);
dataSource.setType(1);
dataSource.setName("ReportDataSource");
dataSource.setAmount(val);
dataSource.setDescription("");
dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin");
dataSource.setCreateTime(creatime);
dataSource.setUpdateTime(creatime);
dataSource.setRowIndex(ec.getRowIndex());
dataSource.setColumnIndex(ec.getColumnIndex());
dataSource.setRowName("");
dataSource.setColumnName("");
SpringContextUtil.dataSourceMapper.insertSelective(dataSource);
for (FormulaDataSourceDto aFormulaDataSourceDtoList : dsList) {
BSPLFormulaDataSourceDto bsplFormulaDataSourceDto = ((BSPLFormulaDataSourceDto) aFormulaDataSourceDtoList);
DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setId(SpringContextUtil.distributedIDService.nextId());
dataSourceDetail.setDataSourceId(dataSourceID);
dataSourceDetail.setDataSourceType(FormulaDataSourceDetailType.BSPLFormulaDataSourceDto.getCode());
dataSourceDetail.setItemValue(JSON.toJSONString(bsplFormulaDataSourceDto));
SpringContextUtil.dataSourceDetailMapper.insertSelective(dataSourceDetail);
}
Long dataSourceID = saveDataSource(ec, dsList, FormulaDataSourceDetailType.BSPLFormulaDataSourceDto, val);
//save formulablock
Long cellTemplateID = getCellTemplateID(period, ec);
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIDService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);//todo:update reportID when report data generated
periodFormulaBlock.setCellTemplateId(cellTemplateID);
periodFormulaBlock.setFormulaExpression(formulaExpression);
periodFormulaBlock.setData(val.toString());
periodFormulaBlock.setDataSourceId(dataSourceID);
periodFormulaBlock.setCreateBy("Admin");
periodFormulaBlock.setCreateTime(creatime);
periodFormulaBlock.setUpdateBy("Admin");
periodFormulaBlock.setUpdateTime(creatime);
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
saveFormulaBlock(period, ec, formulaExpression, val, dataSourceID);
return new NumberEval(val.doubleValue());
}
}
......
package pwc.taxtech.atms.vat.service.impl.report.functions;
import com.alibaba.fastjson.JSON;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.vat.entity.DataSource;
import pwc.taxtech.atms.vat.entity.DataSourceDetail;
import pwc.taxtech.atms.vat.entity.PeriodFormulaBlock;
import pwc.taxtech.atms.vat.service.impl.FormulaAgent;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class FunctionBase {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected FormulaContext formulaContext;
final FormulaAgent agent;
public FunctionBase(FormulaContext formulaContext){
public FunctionBase(FormulaContext formulaContext) {
this.formulaContext = formulaContext;
this.agent = formulaContext.getFormulaAgent();
}
......@@ -43,9 +53,9 @@ public class FunctionBase {
}
}
public Long getCellTemplateID(int period, OperationEvaluationContext ec){
return FormulaHelper
.getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex(ec.getWorkbook().getSheetName(ec.getSheetIndex()),ec.getColumnIndex(),ec.getRowIndex(),period,formulaContext);
public Long getCellTemplateID(int period, OperationEvaluationContext ec) {
return FormulaHelper
.getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex(ec.getWorkbook().getSheetName(ec.getSheetIndex()), ec.getColumnIndex(), ec.getRowIndex(), period, formulaContext);
}
public int getYear(int parameterYear) {
......@@ -58,4 +68,75 @@ public class FunctionBase {
}
}
public int getPeriod(int parameterPeriod, int[] yearOffset) {
if (yearOffset.length == 0) {
yearOffset = new int[10];
}
yearOffset[0] = 0;
if (parameterPeriod == -99) {
return parameterPeriod;
} else if (parameterPeriod <= -1) {
int period = parameterPeriod + formulaContext.getPeriod();
while (period <= 0) {
yearOffset[0]--;
period += 12;
}
return period;
} else if (parameterPeriod == 0) {
return formulaContext.getPeriod();
} else {
return parameterPeriod;
}
}
public Long saveDataSource(OperationEvaluationContext ec, List<Object> dataSourceList,
FormulaDataSourceDetailType formulaDataSourceDetailType, BigDecimal val) {
Date creatime = new Date();
DataSource dataSource = new DataSource();
Long dataSourceID = SpringContextUtil.distributedIDService.nextId();
dataSource.setId(dataSourceID);
dataSource.setType(1);
dataSource.setName("ReportDataSource");
dataSource.setAmount(val);
dataSource.setDescription("");
dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin");
dataSource.setCreateTime(creatime);
dataSource.setUpdateTime(creatime);
dataSource.setRowIndex(ec.getRowIndex());
dataSource.setColumnIndex(ec.getColumnIndex());
dataSource.setRowName("");
dataSource.setColumnName("");
SpringContextUtil.dataSourceMapper.insertSelective(dataSource);
for (Object obj : dataSourceList) {
DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setId(SpringContextUtil.distributedIDService.nextId());
dataSourceDetail.setDataSourceId(dataSourceID);
dataSourceDetail.setDataSourceType(formulaDataSourceDetailType.getCode());
dataSourceDetail.setItemValue(JSON.toJSONString(obj));
SpringContextUtil.dataSourceDetailMapper.insertSelective(dataSourceDetail);
}
return dataSourceID;
}
public void saveFormulaBlock(int period, OperationEvaluationContext ec,
String formulaExpression, BigDecimal val, Long dataSourceID) {
Long cellTemplateID = getCellTemplateID(period, ec);
Date creatime = new Date();
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIDService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
periodFormulaBlock.setCellTemplateId(cellTemplateID);
periodFormulaBlock.setFormulaExpression(formulaExpression);
periodFormulaBlock.setData(val.toString());
periodFormulaBlock.setDataSourceId(dataSourceID);
periodFormulaBlock.setCreateBy("Admin");
periodFormulaBlock.setCreateTime(creatime);
periodFormulaBlock.setUpdateBy("Admin");
periodFormulaBlock.setUpdateTime(creatime);
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
}
}
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.EnumOperationType;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceDto;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/// <summary>
/// 名称:销项发票
/// 功能:从发票取数,一般取发票金额或税额汇总数
/// </summary>
/// <param name="taxRate">税率取值为17%,13%,11%,6%,5%, 3%,1.5%,若所有税率都取则为99</param>
/// <param name="invoiceType">发票类型——两种取值结果“1”专用发票和“0”除专用发票以外其他发票,若所有发票都取则为99</param>
/// <param name="amountType">取值——两种取值结果“金额”0和“税额”1</param>
/// <param name="period">会计期间(开票日期)——三种取值结果 “-1”指上期,“0”当期,“99”当前累计(从期初到目前)</param>
/// <returns></returns>
public class XXFP extends FunctionBase implements FreeRefFunction {
public XXFP(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 4) {
return null;
}
String taxRate = getStringParam(args[0], ec);
int invoiceType = getIntParam(args[1], ec);
int amountType = getIntParam(args[2], ec);
int period = getIntParam(args[3], ec);
String formulaExpression = "XXFP(\"" + taxRate + "\"," + invoiceType + "," + amountType + "," + period + ")";
logger.debug(formulaExpression);
Integer curYear = formulaContext.getYear();
int[] yearOffset = {};
period = getPeriod(period, yearOffset);
curYear = curYear + yearOffset[0];
BigDecimal taxRateVal = new BigDecimal("-1");
if (!taxRate.endsWith("%")) {
if (taxRate.equals("99")) {
taxRateVal = new BigDecimal("99");
} else {
return null;
}
} else {
taxRate = StringUtils.removeEnd(taxRate, "%");
try {
taxRateVal = BigDecimal.valueOf(Double.parseDouble(taxRate));
} catch (NumberFormatException ex) {
return null;
}
taxRateVal = taxRateVal.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); //保留两位小数,然后四舍五入
}
String dbName = SpringContextUtil.projectDao.getDbNameWithYearAndOrgID(formulaContext.getOrganizationID(), curYear);
List<OutputVATInvoiceDto> outputInvoice = SpringContextUtil.outputVATInvoiceMapper.getVatInvoiceWithItems(dbName);
if (invoiceType != 99) {
outputInvoice = outputInvoice.stream()
.filter(a -> a.getInvoice().getInvoiceType() == invoiceType)
.collect(Collectors.toList());
}
if (taxRateVal.compareTo(new BigDecimal("99")) != 0) {
BigDecimal finalTaxRateVal = taxRateVal;
outputInvoice = outputInvoice.stream()
.filter(a -> a.getInvoiceItem().getTaxRate().compareTo(finalTaxRateVal) == 0)
.collect(Collectors.toList());
}
if (period != 99) {
int finalPeriod = period;
outputInvoice = outputInvoice.stream().filter(a -> a.getInvoice().getPeriodID().equals(finalPeriod)).collect(Collectors.toList());
}
List<OutputInvoiceDataSourceDto> dataSource = new ArrayList();
for (OutputVATInvoiceDto x : outputInvoice) {
OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto();
outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getInvoiceItem().getAmount(),
KeyValueConfigResultType.Accounting, null, formulaContext));
outputInvoiceDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
outputInvoiceDataSourceDto.setTaxAmount(FormulaHelper.roundValue(x.getInvoiceItem().getAmount(),
KeyValueConfigResultType.Accounting, null, formulaContext));
outputInvoiceDataSourceDto.setTaxRate(x.getInvoiceItem().getTaxRate());
outputInvoiceDataSourceDto.setBuyerName(x.getInvoice().getBuyerName());
outputInvoiceDataSourceDto.setInvoiceCode(x.getInvoice().getClassCode());
outputInvoiceDataSourceDto.setInvoiceNumber(x.getInvoice().getInvoiceNumber());
outputInvoiceDataSourceDto.setInvoiceDate(x.getInvoice().getInvoiceDate());
outputInvoiceDataSourceDto.setInvoiceType(x.getInvoice().getInvoiceType());
outputInvoiceDataSourceDto.setPeriod(x.getInvoice().getPeriodID());
outputInvoiceDataSourceDto.setName(Constant.DataSourceName.OutputInvoiceDataSource);
outputInvoiceDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
dataSource.add(outputInvoiceDataSourceDto);
}
if (amountType == 0) {
double val = dataSource.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum();
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.OutputInvoiceDataSourceDto, new BigDecimal(val));
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId);
return new NumberEval(val);
} else if (amountType == 1) {
double val = dataSource.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.OutputInvoiceDataSourceDto, new BigDecimal(val));
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId);
return new NumberEval(val);
}
return null;
}
}
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