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 { ...@@ -35,6 +35,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static VatEnterpriseAccountDao vatEnterpriseAccountDao; public static VatEnterpriseAccountDao vatEnterpriseAccountDao;
public static VatEnterpriseAccountMapper vatEnterpriseAccountMapper; public static VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
public static BalanceStdManualMapper balanceStdManualMapper; public static BalanceStdManualMapper balanceStdManualMapper;
public static OutputVATInvoiceMapper outputVATInvoiceMapper;
/** /**
...@@ -69,5 +70,6 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -69,5 +70,6 @@ public class SpringContextUtil implements ApplicationContextAware {
vatEnterpriseAccountDao = webApplicationContext.getBean(VatEnterpriseAccountDao.class); vatEnterpriseAccountDao = webApplicationContext.getBean(VatEnterpriseAccountDao.class);
vatEnterpriseAccountMapper = webApplicationContext.getBean(VatEnterpriseAccountMapper.class); vatEnterpriseAccountMapper = webApplicationContext.getBean(VatEnterpriseAccountMapper.class);
balanceStdManualMapper = webApplicationContext.getBean(BalanceStdManualMapper.class); balanceStdManualMapper = webApplicationContext.getBean(BalanceStdManualMapper.class);
outputVATInvoiceMapper = webApplicationContext.getBean(OutputVATInvoiceMapper.class);
} }
} }
...@@ -42,4 +42,20 @@ public final class Constant { ...@@ -42,4 +42,20 @@ public final class Constant {
public static final String IMAGE_FORMART_ = "png"; public static final String IMAGE_FORMART_ = "png";
public static final String EMPTY = ""; 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; ...@@ -2,7 +2,8 @@ package pwc.taxtech.atms.constant.enums;
public enum FormulaDataSourceDetailType { 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; private Integer code;
......
...@@ -24,7 +24,7 @@ public class DataSourceDto { ...@@ -24,7 +24,7 @@ public class DataSourceDto {
// 1: Formula, 2: Voucher, 3: OutputInvoice, 4: InputInvoice, 5: CustomInvoice, 6: KeyIn, 7: RelatedModel, 8: SapDaily // 1: Formula, 2: Voucher, 3: OutputInvoice, 4: InputInvoice, 5: CustomInvoice, 6: KeyIn, 7: RelatedModel, 8: SapDaily
Integer dataSourceType; Integer dataSourceType;
BigDecimal amount; private BigDecimal amount;
String description; String description;
// 1: +, 2: -, 3: *, 4: / // 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; 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 { public class OutputVATInvoiceDto {
private String invoiceID;
private OutputVATInvoice invoice;
private OutputVATInvoiceItem invoiceItem;
} }
...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; 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.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto; import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
import pwc.taxtech.atms.vat.entity.OutputVATInvoice; import pwc.taxtech.atms.vat.entity.OutputVATInvoice;
...@@ -181,4 +182,6 @@ public interface OutputVATInvoiceMapper extends MyVatMapper { ...@@ -181,4 +182,6 @@ public interface OutputVATInvoiceMapper extends MyVatMapper {
" AND o.PeriodID = #{period}" + " AND o.PeriodID = #{period}" +
" ") " ")
List<OutputVATInvoiceInfoDto> queryOutputDetailWithItem(Integer 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; ...@@ -26,11 +26,7 @@ import pwc.taxtech.atms.dto.vatdto.PeriodCellTemplateConfigExtendDto;
import pwc.taxtech.atms.entitiy.Project; import pwc.taxtech.atms.entitiy.Project;
import pwc.taxtech.atms.vat.entity.*; import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.ReportGenerator; 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.*;
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 java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -281,9 +277,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -281,9 +277,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
* @param workbook 工作簿 * @param workbook 工作簿
*/ */
private void addFunctionsToWorkbook(Workbook workbook, FormulaContext formulaContext) { 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), 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 udfs = new DefaultUDFFinder(functionNames, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs); UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack); workbook.addToolPack(udfToolpack);
......
package pwc.taxtech.atms.vat.service.impl.report.functions; 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.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.eval.ValueEval;
...@@ -9,8 +8,10 @@ import pwc.taxtech.atms.common.util.SpringContextUtil; ...@@ -9,8 +8,10 @@ import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType; import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType; import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto; import pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto;
import pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto; import pwc.taxtech.atms.vat.entity.Balance;
import pwc.taxtech.atms.vat.entity.*; 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.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -90,7 +91,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -90,7 +91,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
} }
BigDecimal val = new BigDecimal(0); BigDecimal val = new BigDecimal(0);
List<FormulaDataSourceDto> formulaDataSourceDtoList = new ArrayList<>(); List<Object> formulaDataSourceDtoList = new ArrayList<>();
if (balanceStdManual != null) { if (balanceStdManual != null) {
List<VatEnterpriseAccount> vatEnterpriseAccountList = SpringContextUtil List<VatEnterpriseAccount> vatEnterpriseAccountList = SpringContextUtil
.vatEnterpriseAccountMapper .vatEnterpriseAccountMapper
...@@ -132,49 +133,9 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -132,49 +133,9 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
} }
//todo: sava data //todo: sava data
//save datasource //save datasource
DataSource dataSource = new DataSource(); Long dataSourceID = saveDataSource(ec, formulaDataSourceDtoList, FormulaDataSourceDetailType.BSPLFormulaDataSourceDto, val);
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);
}
//save formulablock //save formulablock
Long cellTemplateID = getCellTemplateID(period, ec); saveFormulaBlock(period, ec, formulaExpression, val, dataSourceID);
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);
return new NumberEval(val.doubleValue()); return new NumberEval(val.doubleValue());
} else { } else {
...@@ -196,7 +157,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -196,7 +157,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
} }
BigDecimal val = new BigDecimal(0); BigDecimal val = new BigDecimal(0);
List<FormulaDataSourceDto> dsList = new ArrayList<>(); List<Object> dsList = new ArrayList<>();
if (balance != null) { if (balance != null) {
if (period == 99) { if (period == 99) {
val = new BigDecimal(((balance.getYearDebitNet() != null ? balance.getYearDebitNet() : 0).doubleValue() val = new BigDecimal(((balance.getYearDebitNet() != null ? balance.getYearDebitNet() : 0).doubleValue()
...@@ -232,51 +193,12 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -232,51 +193,12 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
? FormulaHelper.roundValue(val, KeyValueConfigResultType.Accounting, null, formulaContext) ? FormulaHelper.roundValue(val, KeyValueConfigResultType.Accounting, null, formulaContext)
: new BigDecimal(0); : new BigDecimal(0);
} }
//todo: sava data //todo: sava data
//save datasource //save datasource
DataSource dataSource = new DataSource(); Long dataSourceID = saveDataSource(ec, dsList, FormulaDataSourceDetailType.BSPLFormulaDataSourceDto, val);
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);
}
//save formulablock //save formulablock
Long cellTemplateID = getCellTemplateID(period, ec); saveFormulaBlock(period, ec, formulaExpression, val, dataSourceID);
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);
return new NumberEval(val.doubleValue()); return new NumberEval(val.doubleValue());
} }
} }
......
package pwc.taxtech.atms.vat.service.impl.report.functions; 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.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.EvaluationException; import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver; import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.eval.ValueEval;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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 pwc.taxtech.atms.vat.service.impl.FormulaAgent;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class FunctionBase { public class FunctionBase {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected FormulaContext formulaContext; protected FormulaContext formulaContext;
final FormulaAgent agent; final FormulaAgent agent;
public FunctionBase(FormulaContext formulaContext){ public FunctionBase(FormulaContext formulaContext) {
this.formulaContext = formulaContext; this.formulaContext = formulaContext;
this.agent = formulaContext.getFormulaAgent(); this.agent = formulaContext.getFormulaAgent();
} }
...@@ -43,9 +53,9 @@ public class FunctionBase { ...@@ -43,9 +53,9 @@ public class FunctionBase {
} }
} }
public Long getCellTemplateID(int period, OperationEvaluationContext ec){ public Long getCellTemplateID(int period, OperationEvaluationContext ec) {
return FormulaHelper return FormulaHelper
.getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex(ec.getWorkbook().getSheetName(ec.getSheetIndex()),ec.getColumnIndex(),ec.getRowIndex(),period,formulaContext); .getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex(ec.getWorkbook().getSheetName(ec.getSheetIndex()), ec.getColumnIndex(), ec.getRowIndex(), period, formulaContext);
} }
public int getYear(int parameterYear) { public int getYear(int parameterYear) {
...@@ -58,4 +68,75 @@ public class FunctionBase { ...@@ -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"?> <?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"> <!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"> <mapper namespace="pwc.taxtech.atms.vat.dao.OutputVATInvoiceMapper">
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.OutputVATInvoice"> <resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
<id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID" /> <id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID"/>
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType" /> <result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
<result column="ClassCode" jdbcType="VARCHAR" property="classCode" /> <result column="ClassCode" jdbcType="VARCHAR" property="classCode"/>
<result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber" /> <result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber"/>
<result column="BuyerName" jdbcType="VARCHAR" property="buyerName" /> <result column="BuyerName" jdbcType="VARCHAR" property="buyerName"/>
<result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber" /> <result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber"/>
<result column="BankAccount" jdbcType="VARCHAR" property="bankAccount" /> <result column="BankAccount" jdbcType="VARCHAR" property="bankAccount"/>
<result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum" /> <result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum"/>
<result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate" /> <result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate"/>
<result column="SeqNo" jdbcType="INTEGER" property="seqNo" /> <result column="SeqNo" jdbcType="INTEGER" property="seqNo"/>
<result column="PeriodID" jdbcType="INTEGER" property="periodID" /> <result column="PeriodID" jdbcType="INTEGER" property="periodID"/>
<result column="Status" jdbcType="INTEGER" property="status" /> <result column="Status" jdbcType="INTEGER" property="status"/>
<result column="CreatorID" jdbcType="VARCHAR" property="creatorID" /> <result column="CreatorID" jdbcType="VARCHAR" property="creatorID"/>
<result column="CreateTime" jdbcType="TIMESTAMP" property="createTime" /> <result column="CreateTime" jdbcType="TIMESTAMP" property="createTime"/>
<result column="PartAccntedPeriod" jdbcType="INTEGER" property="partAccntedPeriod" /> <result column="PartAccntedPeriod" jdbcType="INTEGER" property="partAccntedPeriod"/>
<result column="AccntedPeriod" jdbcType="INTEGER" property="accntedPeriod" /> <result column="AccntedPeriod" jdbcType="INTEGER" property="accntedPeriod"/>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
<where> <where>
<foreach collection="oredCriteria" item="criteria" separator="or"> <foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid"> <if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")"> <trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion"> <foreach collection="criteria.criteria" item="criterion">
<choose> <choose>
<when test="criterion.noValue"> <when test="criterion.noValue">
and ${criterion.condition} and ${criterion.condition}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach close=")" collection="criterion.value" item="listItem" open="("
#{listItem} separator=",">
</foreach> #{listItem}
</when> </foreach>
</choose> </when>
</choose>
</foreach>
</trim>
</if>
</foreach> </foreach>
</trim> </where>
</if> </sql>
</foreach> <sql id="Update_By_Example_Where_Clause">
</where> <!--
</sql> WARNING - @mbg.generated
<sql id="Update_By_Example_Where_Clause"> This element is automatically generated by MyBatis Generator, do not modify.
<!-- -->
WARNING - @mbg.generated <where>
This element is automatically generated by MyBatis Generator, do not modify. <foreach collection="example.oredCriteria" item="criteria" separator="or">
--> <if test="criteria.valid">
<where> <trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="example.oredCriteria" item="criteria" separator="or"> <foreach collection="criteria.criteria" item="criterion">
<if test="criteria.valid"> <choose>
<trim prefix="(" prefixOverrides="and" suffix=")"> <when test="criterion.noValue">
<foreach collection="criteria.criteria" item="criterion"> and ${criterion.condition}
<choose> </when>
<when test="criterion.noValue"> <when test="criterion.singleValue">
and ${criterion.condition} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.listValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition}
</when> <foreach close=")" collection="criterion.value" item="listItem" open="("
<when test="criterion.listValue"> separator=",">
and ${criterion.condition} #{listItem}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> </foreach>
#{listItem} </when>
</foreach> </choose>
</when> </foreach>
</choose> </trim>
</if>
</foreach> </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> </if>
</foreach> <include refid="Base_Column_List"/>
</where> from OutputVATInvoice
</sql> <if test="_parameter != null">
<sql id="Base_Column_List"> <include refid="Example_Where_Clause"/>
<!-- </if>
WARNING - @mbg.generated <if test="orderByClause != null">
This element is automatically generated by MyBatis Generator, do not modify. order by ${orderByClause}
--> </if>
InvoiceID, InvoiceType, ClassCode, InvoiceNumber, BuyerName, BuyerTaxNumber, BankAccount, </select>
PhoneNum, InvoiceDate, SeqNo, PeriodID, `Status`, CreatorID, CreateTime, PartAccntedPeriod, <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
AccntedPeriod <!--
</sql> WARNING - @mbg.generated
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample" resultMap="BaseResultMap"> This element is automatically generated by MyBatis Generator, do not modify.
<!-- -->
WARNING - @mbg.generated select
This element is automatically generated by MyBatis Generator, do not modify. <include refid="Base_Column_List"/>
--> from OutputVATInvoice
select where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
<if test="distinct"> </select>
distinct <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
</if> <!--
<include refid="Base_Column_List" /> WARNING - @mbg.generated
from OutputVATInvoice This element is automatically generated by MyBatis Generator, do not modify.
<if test="_parameter != null"> -->
<include refid="Example_Where_Clause" /> delete from OutputVATInvoice
</if> where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
<if test="orderByClause != null"> </delete>
order by ${orderByClause} <delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample">
</if> <!--
</select> WARNING - @mbg.generated
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> This element is automatically generated by MyBatis Generator, do not modify.
<!-- -->
WARNING - @mbg.generated delete from OutputVATInvoice
This element is automatically generated by MyBatis Generator, do not modify. <if test="_parameter != null">
--> <include refid="Example_Where_Clause"/>
select </if>
<include refid="Base_Column_List" /> </delete>
from OutputVATInvoice <insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
where InvoiceID = #{invoiceID,jdbcType=VARCHAR} <!--
</select> WARNING - @mbg.generated
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> This element is automatically generated by MyBatis Generator, do not modify.
<!-- -->
WARNING - @mbg.generated insert into OutputVATInvoice (InvoiceID, InvoiceType, ClassCode,
This element is automatically generated by MyBatis Generator, do not modify. InvoiceNumber, BuyerName, BuyerTaxNumber,
--> BankAccount, PhoneNum, InvoiceDate,
delete from OutputVATInvoice SeqNo, PeriodID, `Status`,
where InvoiceID = #{invoiceID,jdbcType=VARCHAR} CreatorID, CreateTime, PartAccntedPeriod,
</delete> AccntedPeriod)
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample"> values (#{invoiceID,jdbcType=VARCHAR}, #{invoiceType,jdbcType=INTEGER}, #{classCode,jdbcType=VARCHAR},
<!-- #{invoiceNumber,jdbcType=VARCHAR}, #{buyerName,jdbcType=VARCHAR}, #{buyerTaxNumber,jdbcType=VARCHAR},
WARNING - @mbg.generated #{bankAccount,jdbcType=VARCHAR}, #{phoneNum,jdbcType=VARCHAR}, #{invoiceDate,jdbcType=TIMESTAMP},
This element is automatically generated by MyBatis Generator, do not modify. #{seqNo,jdbcType=INTEGER}, #{periodID,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
--> #{creatorID,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{partAccntedPeriod,jdbcType=INTEGER},
delete from OutputVATInvoice #{accntedPeriod,jdbcType=INTEGER})
<if test="_parameter != null"> </insert>
<include refid="Example_Where_Clause" /> <insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
</if> <!--
</delete> WARNING - @mbg.generated
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice"> This element is automatically generated by MyBatis Generator, do not modify.
<!-- -->
WARNING - @mbg.generated insert into OutputVATInvoice
This element is automatically generated by MyBatis Generator, do not modify. <trim prefix="(" suffix=")" suffixOverrides=",">
--> <if test="invoiceID != null">
insert into OutputVATInvoice (InvoiceID, InvoiceType, ClassCode, InvoiceID,
InvoiceNumber, BuyerName, BuyerTaxNumber, </if>
BankAccount, PhoneNum, InvoiceDate, <if test="invoiceType != null">
SeqNo, PeriodID, `Status`, InvoiceType,
CreatorID, CreateTime, PartAccntedPeriod, </if>
AccntedPeriod) <if test="classCode != null">
values (#{invoiceID,jdbcType=VARCHAR}, #{invoiceType,jdbcType=INTEGER}, #{classCode,jdbcType=VARCHAR}, ClassCode,
#{invoiceNumber,jdbcType=VARCHAR}, #{buyerName,jdbcType=VARCHAR}, #{buyerTaxNumber,jdbcType=VARCHAR}, </if>
#{bankAccount,jdbcType=VARCHAR}, #{phoneNum,jdbcType=VARCHAR}, #{invoiceDate,jdbcType=TIMESTAMP}, <if test="invoiceNumber != null">
#{seqNo,jdbcType=INTEGER}, #{periodID,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, InvoiceNumber,
#{creatorID,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{partAccntedPeriod,jdbcType=INTEGER}, </if>
#{accntedPeriod,jdbcType=INTEGER}) <if test="buyerName != null">
</insert> BuyerName,
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice"> </if>
<!-- <if test="buyerTaxNumber != null">
WARNING - @mbg.generated BuyerTaxNumber,
This element is automatically generated by MyBatis Generator, do not modify. </if>
--> <if test="bankAccount != null">
insert into OutputVATInvoice BankAccount,
<trim prefix="(" suffix=")" suffixOverrides=","> </if>
<if test="invoiceID != null"> <if test="phoneNum != null">
InvoiceID, PhoneNum,
</if> </if>
<if test="invoiceType != null"> <if test="invoiceDate != null">
InvoiceType, InvoiceDate,
</if> </if>
<if test="classCode != null"> <if test="seqNo != null">
ClassCode, SeqNo,
</if> </if>
<if test="invoiceNumber != null"> <if test="periodID != null">
InvoiceNumber, PeriodID,
</if> </if>
<if test="buyerName != null"> <if test="status != null">
BuyerName, `Status`,
</if> </if>
<if test="buyerTaxNumber != null"> <if test="creatorID != null">
BuyerTaxNumber, CreatorID,
</if> </if>
<if test="bankAccount != null"> <if test="createTime != null">
BankAccount, CreateTime,
</if> </if>
<if test="phoneNum != null"> <if test="partAccntedPeriod != null">
PhoneNum, PartAccntedPeriod,
</if> </if>
<if test="invoiceDate != null"> <if test="accntedPeriod != null">
InvoiceDate, AccntedPeriod,
</if> </if>
<if test="seqNo != null"> </trim>
SeqNo, <trim prefix="values (" suffix=")" suffixOverrides=",">
</if> <if test="invoiceID != null">
<if test="periodID != null"> #{invoiceID,jdbcType=VARCHAR},
PeriodID, </if>
</if> <if test="invoiceType != null">
<if test="status != null"> #{invoiceType,jdbcType=INTEGER},
`Status`, </if>
</if> <if test="classCode != null">
<if test="creatorID != null"> #{classCode,jdbcType=VARCHAR},
CreatorID, </if>
</if> <if test="invoiceNumber != null">
<if test="createTime != null"> #{invoiceNumber,jdbcType=VARCHAR},
CreateTime, </if>
</if> <if test="buyerName != null">
<if test="partAccntedPeriod != null"> #{buyerName,jdbcType=VARCHAR},
PartAccntedPeriod, </if>
</if> <if test="buyerTaxNumber != null">
<if test="accntedPeriod != null"> #{buyerTaxNumber,jdbcType=VARCHAR},
AccntedPeriod, </if>
</if> <if test="bankAccount != null">
</trim> #{bankAccount,jdbcType=VARCHAR},
<trim prefix="values (" suffix=")" suffixOverrides=","> </if>
<if test="invoiceID != null"> <if test="phoneNum != null">
#{invoiceID,jdbcType=VARCHAR}, #{phoneNum,jdbcType=VARCHAR},
</if> </if>
<if test="invoiceType != null"> <if test="invoiceDate != null">
#{invoiceType,jdbcType=INTEGER}, #{invoiceDate,jdbcType=TIMESTAMP},
</if> </if>
<if test="classCode != null"> <if test="seqNo != null">
#{classCode,jdbcType=VARCHAR}, #{seqNo,jdbcType=INTEGER},
</if> </if>
<if test="invoiceNumber != null"> <if test="periodID != null">
#{invoiceNumber,jdbcType=VARCHAR}, #{periodID,jdbcType=INTEGER},
</if> </if>
<if test="buyerName != null"> <if test="status != null">
#{buyerName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
</if> </if>
<if test="buyerTaxNumber != null"> <if test="creatorID != null">
#{buyerTaxNumber,jdbcType=VARCHAR}, #{creatorID,jdbcType=VARCHAR},
</if> </if>
<if test="bankAccount != null"> <if test="createTime != null">
#{bankAccount,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="phoneNum != null"> <if test="partAccntedPeriod != null">
#{phoneNum,jdbcType=VARCHAR}, #{partAccntedPeriod,jdbcType=INTEGER},
</if> </if>
<if test="invoiceDate != null"> <if test="accntedPeriod != null">
#{invoiceDate,jdbcType=TIMESTAMP}, #{accntedPeriod,jdbcType=INTEGER},
</if> </if>
<if test="seqNo != null"> </trim>
#{seqNo,jdbcType=INTEGER}, </insert>
</if> <select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample"
<if test="periodID != null"> resultType="java.lang.Long">
#{periodID,jdbcType=INTEGER}, <!--
</if> WARNING - @mbg.generated
<if test="status != null"> This element is automatically generated by MyBatis Generator, do not modify.
#{status,jdbcType=INTEGER}, -->
</if> select count(*) from OutputVATInvoice
<if test="creatorID != null"> <if test="_parameter != null">
#{creatorID,jdbcType=VARCHAR}, <include refid="Example_Where_Clause"/>
</if> </if>
<if test="createTime != null"> </select>
#{createTime,jdbcType=TIMESTAMP}, <update id="updateByExampleSelective" parameterType="map">
</if> <!--
<if test="partAccntedPeriod != null"> WARNING - @mbg.generated
#{partAccntedPeriod,jdbcType=INTEGER}, This element is automatically generated by MyBatis Generator, do not modify.
</if> -->
<if test="accntedPeriod != null"> update OutputVATInvoice
#{accntedPeriod,jdbcType=INTEGER}, <set>
</if> <if test="record.invoiceID != null">
</trim> InvoiceID = #{record.invoiceID,jdbcType=VARCHAR},
</insert> </if>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample" resultType="java.lang.Long"> <if test="record.invoiceType != null">
<!-- InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
WARNING - @mbg.generated </if>
This element is automatically generated by MyBatis Generator, do not modify. <if test="record.classCode != null">
--> ClassCode = #{record.classCode,jdbcType=VARCHAR},
select count(*) from OutputVATInvoice </if>
<if test="_parameter != null"> <if test="record.invoiceNumber != null">
<include refid="Example_Where_Clause" /> InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
</if> </if>
</select> <if test="record.buyerName != null">
<update id="updateByExampleSelective" parameterType="map"> BuyerName = #{record.buyerName,jdbcType=VARCHAR},
<!-- </if>
WARNING - @mbg.generated <if test="record.buyerTaxNumber != null">
This element is automatically generated by MyBatis Generator, do not modify. BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR},
--> </if>
update OutputVATInvoice <if test="record.bankAccount != null">
<set> BankAccount = #{record.bankAccount,jdbcType=VARCHAR},
<if test="record.invoiceID != null"> </if>
InvoiceID = #{record.invoiceID,jdbcType=VARCHAR}, <if test="record.phoneNum != null">
</if> PhoneNum = #{record.phoneNum,jdbcType=VARCHAR},
<if test="record.invoiceType != null"> </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}, InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
</if>
<if test="record.classCode != null">
ClassCode = #{record.classCode,jdbcType=VARCHAR}, ClassCode = #{record.classCode,jdbcType=VARCHAR},
</if>
<if test="record.invoiceNumber != null">
InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR}, InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="record.buyerName != null">
BuyerName = #{record.buyerName,jdbcType=VARCHAR}, BuyerName = #{record.buyerName,jdbcType=VARCHAR},
</if>
<if test="record.buyerTaxNumber != null">
BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR}, BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="record.bankAccount != null">
BankAccount = #{record.bankAccount,jdbcType=VARCHAR}, BankAccount = #{record.bankAccount,jdbcType=VARCHAR},
</if>
<if test="record.phoneNum != null">
PhoneNum = #{record.phoneNum,jdbcType=VARCHAR}, PhoneNum = #{record.phoneNum,jdbcType=VARCHAR},
</if>
<if test="record.invoiceDate != null">
InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP}, InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="record.seqNo != null">
SeqNo = #{record.seqNo,jdbcType=INTEGER}, SeqNo = #{record.seqNo,jdbcType=INTEGER},
</if>
<if test="record.periodID != null">
PeriodID = #{record.periodID,jdbcType=INTEGER}, PeriodID = #{record.periodID,jdbcType=INTEGER},
</if>
<if test="record.status != null">
`Status` = #{record.status,jdbcType=INTEGER}, `Status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.creatorID != null">
CreatorID = #{record.creatorID,jdbcType=VARCHAR}, CreatorID = #{record.creatorID,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
CreateTime = #{record.createTime,jdbcType=TIMESTAMP}, CreateTime = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.partAccntedPeriod != null">
PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER}, PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER},
</if> AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER}
<if test="record.accntedPeriod != null"> <if test="_parameter != null">
AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER}, <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</set> </update>
<if test="_parameter != null"> <update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice">
<include refid="Update_By_Example_Where_Clause" /> <!--
</if> WARNING - @mbg.generated
</update> This element is automatically generated by MyBatis Generator, do not modify.
<update id="updateByExample" parameterType="map"> -->
<!-- update OutputVATInvoice
WARNING - @mbg.generated <set>
This element is automatically generated by MyBatis Generator, do not modify. <if test="invoiceType != null">
--> InvoiceType = #{invoiceType,jdbcType=INTEGER},
update OutputVATInvoice </if>
set InvoiceID = #{record.invoiceID,jdbcType=VARCHAR}, <if test="classCode != null">
InvoiceType = #{record.invoiceType,jdbcType=INTEGER}, ClassCode = #{classCode,jdbcType=VARCHAR},
ClassCode = #{record.classCode,jdbcType=VARCHAR}, </if>
InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR}, <if test="invoiceNumber != null">
BuyerName = #{record.buyerName,jdbcType=VARCHAR}, InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
BuyerTaxNumber = #{record.buyerTaxNumber,jdbcType=VARCHAR}, </if>
BankAccount = #{record.bankAccount,jdbcType=VARCHAR}, <if test="buyerName != null">
PhoneNum = #{record.phoneNum,jdbcType=VARCHAR}, BuyerName = #{buyerName,jdbcType=VARCHAR},
InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP}, </if>
SeqNo = #{record.seqNo,jdbcType=INTEGER}, <if test="buyerTaxNumber != null">
PeriodID = #{record.periodID,jdbcType=INTEGER}, BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR},
`Status` = #{record.status,jdbcType=INTEGER}, </if>
CreatorID = #{record.creatorID,jdbcType=VARCHAR}, <if test="bankAccount != null">
CreateTime = #{record.createTime,jdbcType=TIMESTAMP}, BankAccount = #{bankAccount,jdbcType=VARCHAR},
PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER}, </if>
AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER} <if test="phoneNum != null">
<if test="_parameter != null"> PhoneNum = #{phoneNum,jdbcType=VARCHAR},
<include refid="Update_By_Example_Where_Clause" /> </if>
</if> <if test="invoiceDate != null">
</update> InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice"> </if>
<!-- <if test="seqNo != null">
WARNING - @mbg.generated SeqNo = #{seqNo,jdbcType=INTEGER},
This element is automatically generated by MyBatis Generator, do not modify. </if>
--> <if test="periodID != null">
update OutputVATInvoice PeriodID = #{periodID,jdbcType=INTEGER},
<set> </if>
<if test="invoiceType != null"> <if test="status != null">
InvoiceType = #{invoiceType,jdbcType=INTEGER}, `Status` = #{status,jdbcType=INTEGER},
</if> </if>
<if test="classCode != null"> <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}, ClassCode = #{classCode,jdbcType=VARCHAR},
</if>
<if test="invoiceNumber != null">
InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR}, InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
</if>
<if test="buyerName != null">
BuyerName = #{buyerName,jdbcType=VARCHAR}, BuyerName = #{buyerName,jdbcType=VARCHAR},
</if>
<if test="buyerTaxNumber != null">
BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR}, BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
BankAccount = #{bankAccount,jdbcType=VARCHAR}, BankAccount = #{bankAccount,jdbcType=VARCHAR},
</if>
<if test="phoneNum != null">
PhoneNum = #{phoneNum,jdbcType=VARCHAR}, PhoneNum = #{phoneNum,jdbcType=VARCHAR},
</if>
<if test="invoiceDate != null">
InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP}, InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
</if>
<if test="seqNo != null">
SeqNo = #{seqNo,jdbcType=INTEGER}, SeqNo = #{seqNo,jdbcType=INTEGER},
</if>
<if test="periodID != null">
PeriodID = #{periodID,jdbcType=INTEGER}, PeriodID = #{periodID,jdbcType=INTEGER},
</if>
<if test="status != null">
`Status` = #{status,jdbcType=INTEGER}, `Status` = #{status,jdbcType=INTEGER},
</if>
<if test="creatorID != null">
CreatorID = #{creatorID,jdbcType=VARCHAR}, CreatorID = #{creatorID,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
CreateTime = #{createTime,jdbcType=TIMESTAMP}, CreateTime = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="partAccntedPeriod != null">
PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER}, PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER},
</if> AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER}
<if test="accntedPeriod != null"> where InvoiceID = #{invoiceID,jdbcType=VARCHAR}
AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER}, </update>
</if> <select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample"
</set> resultMap="BaseResultMap">
where InvoiceID = #{invoiceID,jdbcType=VARCHAR} <!--
</update> WARNING - @mbg.generated
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.OutputVATInvoice"> This element is automatically generated by MyBatis Generator, do not modify.
<!-- -->
WARNING - @mbg.generated select
This element is automatically generated by MyBatis Generator, do not modify. <if test="distinct">
--> distinct
update OutputVATInvoice </if>
set InvoiceType = #{invoiceType,jdbcType=INTEGER}, <include refid="Base_Column_List"/>
ClassCode = #{classCode,jdbcType=VARCHAR}, from OutputVATInvoice
InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR}, <if test="_parameter != null">
BuyerName = #{buyerName,jdbcType=VARCHAR}, <include refid="Example_Where_Clause"/>
BuyerTaxNumber = #{buyerTaxNumber,jdbcType=VARCHAR}, </if>
BankAccount = #{bankAccount,jdbcType=VARCHAR}, <if test="orderByClause != null">
PhoneNum = #{phoneNum,jdbcType=VARCHAR}, order by ${orderByClause}
InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP}, </if>
SeqNo = #{seqNo,jdbcType=INTEGER}, </select>
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>
<resultMap id="OutputVATInvoiceInfoDto" type="pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto"> <resultMap id="OutputVATInvoiceInfoDto" type="pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto">
<id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID" /> <id column="InvoiceID" jdbcType="VARCHAR" property="invoiceID"/>
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType" /> <result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
<result column="InvoiceType" jdbcType="INTEGER" property="invoiceType" /> <result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
<result column="InvoiceTypeName" jdbcType="VARCHAR" property="invoiceTypeName" /> <result column="InvoiceTypeName" jdbcType="VARCHAR" property="invoiceTypeName"/>
<result column="ClassCode" jdbcType="VARCHAR" property="classCode" /> <result column="ClassCode" jdbcType="VARCHAR" property="classCode"/>
<result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber" /> <result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber"/>
<result column="BuyerName" jdbcType="VARCHAR" property="buyerName" /> <result column="BuyerName" jdbcType="VARCHAR" property="buyerName"/>
<result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber" /> <result column="BuyerTaxNumber" jdbcType="VARCHAR" property="buyerTaxNumber"/>
<result column="BankAccount" jdbcType="VARCHAR" property="bankAccount" /> <result column="BankAccount" jdbcType="VARCHAR" property="bankAccount"/>
<result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum" /> <result column="PhoneNum" jdbcType="VARCHAR" property="phoneNum"/>
<result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate" /> <result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate"/>
<result column="CodeVersion" jdbcType="VARCHAR" property="codeVersion" /> <result column="CodeVersion" jdbcType="VARCHAR" property="codeVersion"/>
<result column="ProductName" jdbcType="VARCHAR" property="productName" /> <result column="ProductName" jdbcType="VARCHAR" property="productName"/>
<result column="DocumentNum" jdbcType="VARCHAR" property="documentNum" /> <result column="DocumentNum" jdbcType="VARCHAR" property="documentNum"/>
<result column="ProductStandard" jdbcType="VARCHAR" property="productStandard" /> <result column="ProductStandard" jdbcType="VARCHAR" property="productStandard"/>
<result column="Unit" jdbcType="VARCHAR" property="unit" /> <result column="Unit" jdbcType="VARCHAR" property="unit"/>
<result column="Quantity" jdbcType="INTEGER" property="quantity" /> <result column="Quantity" jdbcType="INTEGER" property="quantity"/>
<result column="UnitPrice" jdbcType="DOUBLE" property="unitPrice" /> <result column="UnitPrice" jdbcType="DOUBLE" property="unitPrice"/>
<result column="Amount" jdbcType="DECIMAL" property="amount" /> <result column="Amount" jdbcType="DECIMAL" property="amount"/>
<result column="TaxRate" jdbcType="DECIMAL" property="taxRate" /> <result column="TaxRate" jdbcType="DECIMAL" property="taxRate"/>
<result column="TaxAmount" jdbcType="DECIMAL" property="taxAmount" /> <result column="TaxAmount" jdbcType="DECIMAL" property="taxAmount"/>
<result column="TaxClassCode" jdbcType="VARCHAR" property="taxClassCode" /> <result column="TaxClassCode" jdbcType="VARCHAR" property="taxClassCode"/>
<result column="PeriodID" jdbcType="INTEGER" property="periodID" /> <result column="PeriodID" jdbcType="INTEGER" property="periodID"/>
<result column="IsDuplicate" jdbcType="INTEGER" property="isDuplicate" /> <result column="IsDuplicate" jdbcType="INTEGER" property="isDuplicate"/>
<result column="AmountDifference" jdbcType="DECIMAL" property="amountDifference" /> <result column="AmountDifference" jdbcType="DECIMAL" property="amountDifference"/>
</resultMap> </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 SELECT
o.InvoiceID, o.InvoiceID,
o.InvoiceType, o.InvoiceType,
o.ClassCode, o.ClassCode,
o.InvoiceNumber, o.InvoiceNumber,
o.BuyerName, o.BuyerName,
o.BuyerTaxNumber, o.BuyerTaxNumber,
o.BankAccount, o.BankAccount,
o.PhoneNum, o.PhoneNum,
o.InvoiceDate, o.InvoiceDate,
IFNULL( oi.CodeVersion,'') AS CodeVersion, IFNULL( oi.CodeVersion,'') AS CodeVersion,
IFNULL(oi.ProductName,'') AS ProductName, IFNULL(oi.ProductName,'') AS ProductName,
IFNULL(oi.DocumentNum,'') AS DocumentNum, IFNULL(oi.DocumentNum,'') AS DocumentNum,
IFNULL(oi.ProductStandard,'') AS ProductStandard, IFNULL(oi.ProductStandard,'') AS ProductStandard,
IFNULL(oi.Unit,'') AS Unit, IFNULL(oi.Unit,'') AS Unit,
IFNULL(oi.Quantity,'') AS Quantity, IFNULL(oi.Quantity,'') AS Quantity,
IFNULL(oi.UnitPrice,'') AS UnitPrice, IFNULL(oi.UnitPrice,'') AS UnitPrice,
IFNULL(oi.Amount,'') AS Amount, IFNULL(oi.Amount,'') AS Amount,
IFNULL(oi.TaxAmount,'') AS TaxAmount, IFNULL(oi.TaxAmount,'') AS TaxAmount,
IFNULL(oi.TaxClassCode,'') AS TaxClassCode, IFNULL(oi.TaxClassCode,'') AS TaxClassCode,
o.PeriodID o.PeriodID
FROM OutputVATInvoice o FROM OutputVATInvoice o
LEFT JOIN OutputVATInvoiceItem oi LEFT JOIN OutputVATInvoiceItem oi
ON o.InvoiceID = oi.InvoiceID ON o.InvoiceID = oi.InvoiceID
...@@ -524,4 +530,84 @@ ...@@ -524,4 +530,84 @@
AND ProductName LIKE concat('%',#{query.productName,jdbcType=VARCHAR,'%'}) AND ProductName LIKE concat('%',#{query.productName,jdbcType=VARCHAR,'%'})
</if> </if>
</select> </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> </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