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;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.OutputVATInvoiceMapper">
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID" />
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType" />
<result column="ClassCode" jdbcType="VARCHAR" property="classCode" />
<result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber" />
<result column="BuyerName" jdbcType="VARCHAR" property="buyerName" />
<result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber" />
<result column="BankAccount" jdbcType="VARCHAR" property="bankAccount" />
<result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum" />
<result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate" />
<result column="SeqNo" jdbcType="INTEGER" property="seqNo" />
<result column="PeriodID" jdbcType="INTEGER" property="periodID" />
<result column="Status" jdbcType="INTEGER" property="status" />
<result column="CreatorID" jdbcType="VARCHAR" property="creatorID" />
<result column="CreateTime" jdbcType="TIMESTAMP" property="createTime" />
<result column="PartAccntedPeriod" jdbcType="INTEGER" property="partAccntedPeriod" />
<result column="AccntedPeriod" jdbcType="INTEGER" property="accntedPeriod" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID"/>
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
<result column="ClassCode" jdbcType="VARCHAR" property="classCode"/>
<result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber"/>
<result column="BuyerName" jdbcType="VARCHAR" property="buyerName"/>
<result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber"/>
<result column="BankAccount" jdbcType="VARCHAR" property="bankAccount"/>
<result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum"/>
<result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate"/>
<result column="SeqNo" jdbcType="INTEGER" property="seqNo"/>
<result column="PeriodID" jdbcType="INTEGER" property="periodID"/>
<result column="Status" jdbcType="INTEGER" property="status"/>
<result column="CreatorID" jdbcType="VARCHAR" property="creatorID"/>
<result column="CreateTime" jdbcType="TIMESTAMP" property="createTime"/>
<result column="PartAccntedPeriod" jdbcType="INTEGER" property="partAccntedPeriod"/>
<result column="AccntedPeriod" jdbcType="INTEGER" property="accntedPeriod"/>
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
InvoiceID, InvoiceType, ClassCode, InvoiceNumber, BuyerName, BuyerTaxNumber, BankAccount,
PhoneNum, InvoiceDate, SeqNo, PeriodID, `Status`, CreatorID, CreateTime, PartAccntedPeriod,
AccntedPeriod
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample"
resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
InvoiceID, InvoiceType, ClassCode, InvoiceNumber, BuyerName, BuyerTaxNumber, BankAccount,
PhoneNum, InvoiceDate, SeqNo, PeriodID, `Status`, CreatorID, CreateTime, PartAccntedPeriod,
AccntedPeriod
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from OutputVATInvoice
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from OutputVATInvoice
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into OutputVATInvoice (InvoiceID, InvoiceType, ClassCode,
InvoiceNumber, BuyerName, BuyerTaxNumber,
BankAccount, PhoneNum, InvoiceDate,
SeqNo, PeriodID, `Status`,
CreatorID, CreateTime, PartAccntedPeriod,
AccntedPeriod)
values (#{invoiceID,jdbcType=VARCHAR}, #{invoiceType,jdbcType=INTEGER}, #{classCode,jdbcType=VARCHAR},
#{invoiceNumber,jdbcType=VARCHAR}, #{buyerName,jdbcType=VARCHAR}, #{buyerTaxNumber,jdbcType=VARCHAR},
#{bankAccount,jdbcType=VARCHAR}, #{phoneNum,jdbcType=VARCHAR}, #{invoiceDate,jdbcType=TIMESTAMP},
#{seqNo,jdbcType=INTEGER}, #{periodID,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{creatorID,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{partAccntedPeriod,jdbcType=INTEGER},
#{accntedPeriod,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into OutputVATInvoice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="invoiceID != null">
InvoiceID,
</if>
<if test="invoiceType != null">
InvoiceType,
</if>
<if test="classCode != null">
ClassCode,
</if>
<if test="invoiceNumber != null">
InvoiceNumber,
</if>
<if test="buyerName != null">
BuyerName,
</if>
<if test="buyerTaxNumber != null">
BuyerTaxNumber,
</if>
<if test="bankAccount != null">
BankAccount,
</if>
<if test="phoneNum != null">
PhoneNum,
</if>
<if test="invoiceDate != null">
InvoiceDate,
</if>
<if test="seqNo != null">
SeqNo,
</if>
<if test="periodID != null">
PeriodID,
</if>
<if test="status != null">
`Status`,
</if>
<if test="creatorID != null">
CreatorID,
</if>
<if test="createTime != null">
CreateTime,
</if>
<if test="partAccntedPeriod != null">
PartAccntedPeriod,
</if>
<if test="accntedPeriod != null">
AccntedPeriod,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="invoiceID != null">
#{invoiceID,jdbcType=VARCHAR},
</if>
<if test="invoiceType != null">
#{invoiceType,jdbcType=INTEGER},
</if>
<if test="classCode != null">
#{classCode,jdbcType=VARCHAR},
</if>
<if test="invoiceNumber != null">
#{invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="buyerName != null">
#{buyerName,jdbcType=VARCHAR},
</if>
<if test="buyerTaxNumber != null">
#{buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
#{bankAccount,jdbcType=VARCHAR},
</if>
<if test="phoneNum != null">
#{phoneNum,jdbcType=VARCHAR},
</if>
<if test="invoiceDate != null">
#{invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="seqNo != null">
#{seqNo,jdbcType=INTEGER},
</if>
<if test="periodID != null">
#{periodID,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="creatorID != null">
#{creatorID,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="partAccntedPeriod != null">
#{partAccntedPeriod,jdbcType=INTEGER},
</if>
<if test="accntedPeriod != null">
#{accntedPeriod,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
<set>
<if test="record.invoiceID != null">
InvoiceID = #{record.invoiceID,jdbcType=VARCHAR},
</if>
<if test="record.invoiceType != null">
<include refid="Base_Column_List"/>
from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List"/>
from OutputVATInvoice
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from OutputVATInvoice
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into OutputVATInvoice (InvoiceID, InvoiceType, ClassCode,
InvoiceNumber, BuyerName, BuyerTaxNumber,
BankAccount, PhoneNum, InvoiceDate,
SeqNo, PeriodID, `Status`,
CreatorID, CreateTime, PartAccntedPeriod,
AccntedPeriod)
values (#{invoiceID,jdbcType=VARCHAR}, #{invoiceType,jdbcType=INTEGER}, #{classCode,jdbcType=VARCHAR},
#{invoiceNumber,jdbcType=VARCHAR}, #{buyerName,jdbcType=VARCHAR}, #{buyerTaxNumber,jdbcType=VARCHAR},
#{bankAccount,jdbcType=VARCHAR}, #{phoneNum,jdbcType=VARCHAR}, #{invoiceDate,jdbcType=TIMESTAMP},
#{seqNo,jdbcType=INTEGER}, #{periodID,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{creatorID,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{partAccntedPeriod,jdbcType=INTEGER},
#{accntedPeriod,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into OutputVATInvoice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="invoiceID != null">
InvoiceID,
</if>
<if test="invoiceType != null">
InvoiceType,
</if>
<if test="classCode != null">
ClassCode,
</if>
<if test="invoiceNumber != null">
InvoiceNumber,
</if>
<if test="buyerName != null">
BuyerName,
</if>
<if test="buyerTaxNumber != null">
BuyerTaxNumber,
</if>
<if test="bankAccount != null">
BankAccount,
</if>
<if test="phoneNum != null">
PhoneNum,
</if>
<if test="invoiceDate != null">
InvoiceDate,
</if>
<if test="seqNo != null">
SeqNo,
</if>
<if test="periodID != null">
PeriodID,
</if>
<if test="status != null">
`Status`,
</if>
<if test="creatorID != null">
CreatorID,
</if>
<if test="createTime != null">
CreateTime,
</if>
<if test="partAccntedPeriod != null">
PartAccntedPeriod,
</if>
<if test="accntedPeriod != null">
AccntedPeriod,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="invoiceID != null">
#{invoiceID,jdbcType=VARCHAR},
</if>
<if test="invoiceType != null">
#{invoiceType,jdbcType=INTEGER},
</if>
<if test="classCode != null">
#{classCode,jdbcType=VARCHAR},
</if>
<if test="invoiceNumber != null">
#{invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="buyerName != null">
#{buyerName,jdbcType=VARCHAR},
</if>
<if test="buyerTaxNumber != null">
#{buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
#{bankAccount,jdbcType=VARCHAR},
</if>
<if test="phoneNum != null">
#{phoneNum,jdbcType=VARCHAR},
</if>
<if test="invoiceDate != null">
#{invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="seqNo != null">
#{seqNo,jdbcType=INTEGER},
</if>
<if test="periodID != null">
#{periodID,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="creatorID != null">
#{creatorID,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="partAccntedPeriod != null">
#{partAccntedPeriod,jdbcType=INTEGER},
</if>
<if test="accntedPeriod != null">
#{accntedPeriod,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample"
resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
<set>
<if test="record.invoiceID != null">
InvoiceID = #{record.invoiceID,jdbcType=VARCHAR},
</if>
<if test="record.invoiceType != null">
InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
</if>
<if test="record.classCode != null">
ClassCode = #{record.classCode,jdbcType=VARCHAR},
</if>
<if test="record.invoiceNumber != null">
InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="record.buyerName != null">
BuyerName = #{record.buyerName,jdbcType=VARCHAR},
</if>
<if test="record.buyerTaxNumber != null">
BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="record.bankAccount != null">
BankAccount = #{record.bankAccount,jdbcType=VARCHAR},
</if>
<if test="record.phoneNum != null">
PhoneNum = #{record.phoneNum,jdbcType=VARCHAR},
</if>
<if test="record.invoiceDate != null">
InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="record.seqNo != null">
SeqNo = #{record.seqNo,jdbcType=INTEGER},
</if>
<if test="record.periodID != null">
PeriodID = #{record.periodID,jdbcType=INTEGER},
</if>
<if test="record.status != null">
`Status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.creatorID != null">
CreatorID = #{record.creatorID,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
CreateTime = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.partAccntedPeriod != null">
PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER},
</if>
<if test="record.accntedPeriod != null">
AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
set InvoiceID = #{record.invoiceID,jdbcType=VARCHAR},
InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
</if>
<if test="record.classCode != null">
ClassCode = #{record.classCode,jdbcType=VARCHAR},
</if>
<if test="record.invoiceNumber != null">
InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="record.buyerName != null">
BuyerName = #{record.buyerName,jdbcType=VARCHAR},
</if>
<if test="record.buyerTaxNumber != null">
BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="record.bankAccount != null">
BankAccount = #{record.bankAccount,jdbcType=VARCHAR},
</if>
<if test="record.phoneNum != null">
PhoneNum = #{record.phoneNum,jdbcType=VARCHAR},
</if>
<if test="record.invoiceDate != null">
InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="record.seqNo != null">
SeqNo = #{record.seqNo,jdbcType=INTEGER},
</if>
<if test="record.periodID != null">
PeriodID = #{record.periodID,jdbcType=INTEGER},
</if>
<if test="record.status != null">
`Status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.creatorID != null">
CreatorID = #{record.creatorID,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
CreateTime = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.partAccntedPeriod != null">
PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER},
</if>
<if test="record.accntedPeriod != null">
AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
set InvoiceID = #{record.invoiceID,jdbcType=VARCHAR},
InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
ClassCode = #{record.classCode,jdbcType=VARCHAR},
InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
BuyerName = #{record.buyerName,jdbcType=VARCHAR},
BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR},
BankAccount = #{record.bankAccount,jdbcType=VARCHAR},
PhoneNum = #{record.phoneNum,jdbcType=VARCHAR},
InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP},
SeqNo = #{record.seqNo,jdbcType=INTEGER},
PeriodID = #{record.periodID,jdbcType=INTEGER},
`Status` = #{record.status,jdbcType=INTEGER},
CreatorID = #{record.creatorID,jdbcType=VARCHAR},
CreateTime = #{record.createTime,jdbcType=TIMESTAMP},
PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER},
AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
<set>
<if test="invoiceType != null">
InvoiceType = #{invoiceType,jdbcType=INTEGER},
</if>
<if test="classCode != null">
AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
<set>
<if test="invoiceType != null">
InvoiceType = #{invoiceType,jdbcType=INTEGER},
</if>
<if test="classCode != null">
ClassCode = #{classCode,jdbcType=VARCHAR},
</if>
<if test="invoiceNumber != null">
InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="buyerName != null">
BuyerName = #{buyerName,jdbcType=VARCHAR},
</if>
<if test="buyerTaxNumber != null">
BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
BankAccount = #{bankAccount,jdbcType=VARCHAR},
</if>
<if test="phoneNum != null">
PhoneNum = #{phoneNum,jdbcType=VARCHAR},
</if>
<if test="invoiceDate != null">
InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="seqNo != null">
SeqNo = #{seqNo,jdbcType=INTEGER},
</if>
<if test="periodID != null">
PeriodID = #{periodID,jdbcType=INTEGER},
</if>
<if test="status != null">
`Status` = #{status,jdbcType=INTEGER},
</if>
<if test="creatorID != null">
CreatorID = #{creatorID,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
CreateTime = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="partAccntedPeriod != null">
PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER},
</if>
<if test="accntedPeriod != null">
AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER},
</if>
</set>
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
set InvoiceType = #{invoiceType,jdbcType=INTEGER},
ClassCode = #{classCode,jdbcType=VARCHAR},
</if>
<if test="invoiceNumber != null">
InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="buyerName != null">
BuyerName = #{buyerName,jdbcType=VARCHAR},
</if>
<if test="buyerTaxNumber != null">
BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
BankAccount = #{bankAccount,jdbcType=VARCHAR},
</if>
<if test="phoneNum != null">
PhoneNum = #{phoneNum,jdbcType=VARCHAR},
</if>
<if test="invoiceDate != null">
InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="seqNo != null">
SeqNo = #{seqNo,jdbcType=INTEGER},
</if>
<if test="periodID != null">
PeriodID = #{periodID,jdbcType=INTEGER},
</if>
<if test="status != null">
`Status` = #{status,jdbcType=INTEGER},
</if>
<if test="creatorID != null">
CreatorID = #{creatorID,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
CreateTime = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="partAccntedPeriod != null">
PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER},
</if>
<if test="accntedPeriod != null">
AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER},
</if>
</set>
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update OutputVATInvoice
set InvoiceType = #{invoiceType,jdbcType=INTEGER},
ClassCode = #{classCode,jdbcType=VARCHAR},
InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
BuyerName = #{buyerName,jdbcType=VARCHAR},
BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR},
BankAccount = #{bankAccount,jdbcType=VARCHAR},
PhoneNum = #{phoneNum,jdbcType=VARCHAR},
InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
SeqNo = #{seqNo,jdbcType=INTEGER},
PeriodID = #{periodID,jdbcType=INTEGER},
`Status` = #{status,jdbcType=INTEGER},
CreatorID = #{creatorID,jdbcType=VARCHAR},
CreateTime = #{createTime,jdbcType=TIMESTAMP},
PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER},
AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER}
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER}
where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample"
resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from OutputVATInvoice
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<resultMap id="OutputVATInvoiceInfoDto" type="pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto">
<id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID" />
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType" />
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType" />
<result column="InvoiceTypeName" jdbcType="VARCHAR" property="invoiceTypeName" />
<result column="ClassCode" jdbcType="VARCHAR" property="classCode" />
<result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber" />
<result column="BuyerName" jdbcType="VARCHAR" property="buyerName" />
<result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber" />
<result column="BankAccount" jdbcType="VARCHAR" property="bankAccount" />
<result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum" />
<result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate" />
<result column="CodeVersion" jdbcType="VARCHAR" property="codeVersion" />
<result column="ProductName" jdbcType="VARCHAR" property="productName" />
<result column="DocumentNum" jdbcType="VARCHAR" property="documentNum" />
<result column="ProductStandard" jdbcType="VARCHAR" property="productStandard" />
<result column="Unit" jdbcType="VARCHAR" property="unit" />
<result column="Quantity" jdbcType="INTEGER" property="quantity" />
<result column="UnitPrice" jdbcType="DOUBLE" property="unitPrice" />
<result column="Amount" jdbcType="DECIMAL" property="amount" />
<result column="TaxRate" jdbcType="DECIMAL" property="taxRate" />
<result column="TaxAmount" jdbcType="DECIMAL" property="taxAmount" />
<result column="TaxClassCode" jdbcType="VARCHAR" property="taxClassCode" />
<result column="PeriodID" jdbcType="INTEGER" property="periodID" />
<result column="IsDuplicate" jdbcType="INTEGER" property="isDuplicate" />
<result column="AmountDifference" jdbcType="DECIMAL" property="amountDifference" />
<id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID"/>
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
<result column="InvoiceTypeName" jdbcType="VARCHAR" property="invoiceTypeName"/>
<result column="ClassCode" jdbcType="VARCHAR" property="classCode"/>
<result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber"/>
<result column="BuyerName" jdbcType="VARCHAR" property="buyerName"/>
<result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber"/>
<result column="BankAccount" jdbcType="VARCHAR" property="bankAccount"/>
<result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum"/>
<result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate"/>
<result column="CodeVersion" jdbcType="VARCHAR" property="codeVersion"/>
<result column="ProductName" jdbcType="VARCHAR" property="productName"/>
<result column="DocumentNum" jdbcType="VARCHAR" property="documentNum"/>
<result column="ProductStandard" jdbcType="VARCHAR" property="productStandard"/>
<result column="Unit" jdbcType="VARCHAR" property="unit"/>
<result column="Quantity" jdbcType="INTEGER" property="quantity"/>
<result column="UnitPrice" jdbcType="DOUBLE" property="unitPrice"/>
<result column="Amount" jdbcType="DECIMAL" property="amount"/>
<result column="TaxRate" jdbcType="DECIMAL" property="taxRate"/>
<result column="TaxAmount" jdbcType="DECIMAL" property="taxAmount"/>
<result column="TaxClassCode" jdbcType="VARCHAR" property="taxClassCode"/>
<result column="PeriodID" jdbcType="INTEGER" property="periodID"/>
<result column="IsDuplicate" jdbcType="INTEGER" property="isDuplicate"/>
<result column="AmountDifference" jdbcType="DECIMAL" property="amountDifference"/>
</resultMap>
<select id="selectOutputVATInvoiceInfoLeftJoinItem" parameterType="pwc.taxtech.atms.dto.vatdto.QueryOutputDto" resultMap="OutputVATInvoiceInfoDto">
<select id="selectOutputVATInvoiceInfoLeftJoinItem" parameterType="pwc.taxtech.atms.dto.vatdto.QueryOutputDto"
resultMap="OutputVATInvoiceInfoDto">
SELECT
o.InvoiceID,
o.InvoiceType,
o.ClassCode,
o.InvoiceNumber,
o.BuyerName,
o.BuyerTaxNumber,
o.BankAccount,
o.PhoneNum,
o.InvoiceDate,
IFNULL( oi.CodeVersion,'') AS CodeVersion,
IFNULL(oi.ProductName,'') AS ProductName,
IFNULL(oi.DocumentNum,'') AS DocumentNum,
IFNULL(oi.ProductStandard,'') AS ProductStandard,
IFNULL(oi.Unit,'') AS Unit,
IFNULL(oi.Quantity,'') AS Quantity,
IFNULL(oi.UnitPrice,'') AS UnitPrice,
IFNULL(oi.Amount,'') AS Amount,
IFNULL(oi.TaxAmount,'') AS TaxAmount,
IFNULL(oi.TaxClassCode,'') AS TaxClassCode,
o.PeriodID
o.InvoiceID,
o.InvoiceType,
o.ClassCode,
o.InvoiceNumber,
o.BuyerName,
o.BuyerTaxNumber,
o.BankAccount,
o.PhoneNum,
o.InvoiceDate,
IFNULL( oi.CodeVersion,'') AS CodeVersion,
IFNULL(oi.ProductName,'') AS ProductName,
IFNULL(oi.DocumentNum,'') AS DocumentNum,
IFNULL(oi.ProductStandard,'') AS ProductStandard,
IFNULL(oi.Unit,'') AS Unit,
IFNULL(oi.Quantity,'') AS Quantity,
IFNULL(oi.UnitPrice,'') AS UnitPrice,
IFNULL(oi.Amount,'') AS Amount,
IFNULL(oi.TaxAmount,'') AS TaxAmount,
IFNULL(oi.TaxClassCode,'') AS TaxClassCode,
o.PeriodID
FROM OutputVATInvoice o
LEFT JOIN OutputVATInvoiceItem oi
ON o.InvoiceID = oi.InvoiceID
......@@ -524,4 +530,84 @@
AND ProductName LIKE concat('%',#{query.productName,jdbcType=VARCHAR,'%'})
</if>
</select>
<resultMap id="outputVATInvoiceDto" type="pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceDto">
<id property="invoiceID" column="invoice_id"/>
<association property="invoice" javaType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<id column="InvoiceID" property="invoiceID"/>
<result column="InvoiceType" property="invoiceType"/>
<result column="ClassCode" property="classCode"/>
<result column="InvoiceNumber" property="invoiceNumber"/>
<result column="BuyerName" property="buyerName"/>
<result column="BuyerTaxNumber" property="buyerTaxNumber"/>
<result column="BankAccount" property="bankAccount"/>
<result column="PhoneNum" property="phoneNum"/>
<result column="InvoiceDate" property="invoiceDate"/>
<result column="SeqNo" property="seqNo"/>
<result column="PeriodID" property="periodID"/>
<result column="STATUS" property="status"/>
<result column="CreatorID" property="creatorID"/>
<result column="CreateTime" property="createTime"/>
<result column="PartAccntedPeriod" property="partAccntedPeriod"/>
<result column="AccntedPeriod" property="accntedPeriod"/>
</association>
<association property="invoiceItem" javaType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceItem">
<id column="ItemID" property="itemID"/>
<result column="InvoiceID" property="invoiceID"/>
<result column="CodeVersion" property="codeVersion"/>
<result column="ProductName" property="productName"/>
<result column="DocumentNum" property="documentNum"/>
<result column="ProductStandard" property="productStandard"/>
<result column="Unit" property="unit"/>
<result column="Quantity" property="quantity"/>
<result column="UnitPrice" property="unitPrice"/>
<result column="Amount" property="amount"/>
<result column="TaxRate" property="taxRate"/>
<result column="TaxAmount" property="taxAmount"/>
<result column="SeqNo" property="seqNo"/>
<result column="TaxClassCode" property="taxClassCode"/>
<result column="CreatorID" property="creatorID"/>
<result column="CreateTime" property="createTime"/>
<result column="PeriodID" property="periodID"/>
</association>
</resultMap>
<select id="getVatInvoiceWithItems" resultMap="outputVATInvoiceDto" parameterType="java.lang.String">
SELECT
invoice.InvoiceID,
invoice.InvoiceType,
invoice.ClassCode,
invoice.InvoiceNumber,
invoice.BuyerName,
invoice.BuyerTaxNumber,
invoice.BankAccount,
invoice.PhoneNum,
invoice.InvoiceDate,
invoice.SeqNo,
invoice.PeriodID,
invoice.`STATUS`,
invoice.CreatorID,
invoice.CreateTime,
invoice.PartAccntedPeriod,
invoice.AccntedPeriod,
invoiceItem.ItemID,
invoiceItem.InvoiceID,
invoiceItem.CodeVersion,
invoiceItem.ProductName,
invoiceItem.DocumentNum,
invoiceItem.ProductStandard,
invoiceItem.Unit,
invoiceItem.Quantity,
invoiceItem.UnitPrice,
invoiceItem.Amount,
invoiceItem.TaxRate,
invoiceItem.TaxAmount,
invoiceItem.SeqNo,
invoiceItem.TaxClassCode,
invoiceItem.CreatorID,
invoiceItem.CreateTime,
invoiceItem.PeriodID
FROM ${dbName}.OutputVATInvoice invoice
JOIN ${dbName}.OutputVATInvoiceItem invoiceItem
ON invoice.InvoiceID = invoiceItem.InvoiceID
ORDER BY invoice.PeriodID,invoice.ClassCode,invoice.InvoiceNumber,invoiceItem.SeqNo
</select>
</mapper>
\ No newline at end of file
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