Commit 181bf10f authored by sherlock's avatar sherlock

JXFPMX

parent 5bf4ee74
...@@ -5,20 +5,18 @@ import org.apache.poi.ss.formula.OperationEvaluationContext; ...@@ -5,20 +5,18 @@ 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;
import org.apache.poi.ss.formula.functions.FreeRefFunction; import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.common.util.SpringContextUtil; import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant; import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.EnumOperationType; import pwc.taxtech.atms.constant.enums.EnumOperationType;
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.InputInvoiceDetailDataSourceDto; import pwc.taxtech.atms.dto.vatdto.InputInvoiceDetailDataSourceDto;
import pwc.taxtech.atms.vat.dpo.InputInvoiceResultDto;
import pwc.taxtech.atms.vat.dpo.InputVATInvoiceResultDto; import pwc.taxtech.atms.vat.dpo.InputVATInvoiceResultDto;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -84,44 +82,45 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction { ...@@ -84,44 +82,45 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
} }
String dbName = SpringContextUtil.projectDao.getDbNameWithYearAndOrgId(formulaContext.getOrganizationId(), curYear); String dbName = SpringContextUtil.projectDao.getDbNameWithYearAndOrgId(formulaContext.getOrganizationId(), curYear);
List<InputVATInvoiceResultDto> inputInvoice = SpringContextUtil.inputVatInvoiceMapper.getInputVATInvoiceResultDto(dbName); // List<InputVATInvoiceResultDto> inputInvoice = SpringContextUtil.inputVatInvoiceMapper.getInputVATInvoiceResultDto(dbName);
List<InputInvoiceResultDto> inputInvoice = SpringContextUtil.inputInvoiceMapper.getInputInvoiceResultDto();
if (!goodsName.equals("99")) { if (!goodsName.equals("99")) {
inputInvoice = inputInvoice.stream() inputInvoice = inputInvoice.stream()
.filter(a -> a.getGoodsMapping() != null && a.getGoodsMapping().getStdGoodsName() != null && a.getGoodsMapping().getStdGoodsName().equals(goodsName)) .filter(a -> a.getInputInvoiceDetail() != null && StringUtils.isNotBlank(goodsName) && goodsName.equals(a.getInputInvoiceDetail().getSPMC()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (taxRateVal.compareTo(new BigDecimal("-1")) == 0) { if (taxRateVal.compareTo(new BigDecimal("-1")) == 0) {
inputInvoice = inputInvoice.stream() inputInvoice = inputInvoice.stream()
.filter(a -> Arrays.asList(FunctionBase.defaultTaxRates).contains(a.getInputVATInvoiceItem().getTaxRate())) .filter(a -> Arrays.asList(FunctionBase.defaultTaxRates).contains(new BigDecimal(a.getInputInvoiceDetail().getSLV())))
.collect(Collectors.toList()); .collect(Collectors.toList());
} else if (taxRateVal.compareTo(new BigDecimal("99")) != 0) { } else if (taxRateVal.compareTo(new BigDecimal("99")) != 0) {
BigDecimal finalTaxRateVal = taxRateVal; BigDecimal finalTaxRateVal = taxRateVal;
inputInvoice = inputInvoice.stream() inputInvoice = inputInvoice.stream()
.filter(a -> a.getInputVATInvoiceItem().getTaxRate().equals(finalTaxRateVal)) .filter(a -> new BigDecimal(a.getInputInvoiceDetail().getSLV()).equals(finalTaxRateVal))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (period != 99) { if (period != 99) {
int finalPeriod = period; int finalPeriod = period;
inputInvoice = inputInvoice.stream() inputInvoice = inputInvoice.stream()
.filter(a -> a.getInputVATInvoice().getPeriodId() == finalPeriod) .filter(a -> getPeriodFromDate(a.getInputInvoice().getRZSJ()) == finalPeriod)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
List<InputInvoiceDetailDataSourceDto> dataSouce = new ArrayList<>(); List<InputInvoiceDetailDataSourceDto> dataSouce = new ArrayList<>();
for (InputVATInvoiceResultDto x : inputInvoice) { for (InputInvoiceResultDto x : inputInvoice) {
InputInvoiceDetailDataSourceDto inputInvoiceDetailDataSourceDto = new InputInvoiceDetailDataSourceDto(); InputInvoiceDetailDataSourceDto inputInvoiceDetailDataSourceDto = new InputInvoiceDetailDataSourceDto();
inputInvoiceDetailDataSourceDto.setAmount(FormulaHelper.roundValue(x.getInputVATInvoiceItem().getAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); inputInvoiceDetailDataSourceDto.setAmount(FormulaHelper.roundValue(new BigDecimal(x.getInputInvoiceDetail().getJE()), KeyValueConfigResultType.Accounting, null, formulaContext));
inputInvoiceDetailDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode()); inputInvoiceDetailDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
inputInvoiceDetailDataSourceDto.setTaxAmount(FormulaHelper.roundValue(x.getInputVATInvoiceItem().getTaxAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); inputInvoiceDetailDataSourceDto.setTaxAmount(FormulaHelper.roundValue(new BigDecimal(x.getInputInvoiceDetail().getSE()), KeyValueConfigResultType.Accounting, null, formulaContext));
inputInvoiceDetailDataSourceDto.setTaxRate(x.getInputVATInvoiceItem().getTaxRate()); inputInvoiceDetailDataSourceDto.setTaxRate(new BigDecimal(x.getInputInvoiceDetail().getSLV()));
inputInvoiceDetailDataSourceDto.setInvoiceNumber(x.getInputVATInvoice().getInvoiceNumber()); inputInvoiceDetailDataSourceDto.setInvoiceNumber(x.getInputInvoice().getFPHM());
inputInvoiceDetailDataSourceDto.setInvoiceDate(x.getInputVATInvoice().getInvoiceDate()); inputInvoiceDetailDataSourceDto.setInvoiceDate(DateUtils.strToDate(x.getInputInvoice().getKPRQ()));
inputInvoiceDetailDataSourceDto.setInvoiceCode(x.getInputVATInvoice().getInvoiceCode()); inputInvoiceDetailDataSourceDto.setInvoiceCode(x.getInputInvoice().getFPDM());
inputInvoiceDetailDataSourceDto.setPeriod(x.getInputVATInvoice().getPeriodId()); inputInvoiceDetailDataSourceDto.setPeriod(getPeriodFromDate(x.getInputInvoice().getKPRQ()));
inputInvoiceDetailDataSourceDto.setProductionName(x.getInputVATInvoiceItem().getProductionName()); inputInvoiceDetailDataSourceDto.setProductionName(x.getInputInvoiceDetail().getSPMC());
inputInvoiceDetailDataSourceDto.setName(Constant.DataSourceName.InputDetailInvoiceDataSource); inputInvoiceDetailDataSourceDto.setName(Constant.DataSourceName.InputDetailInvoiceDataSource);
inputInvoiceDetailDataSourceDto.setOperationType(EnumOperationType.Single.getCode()); inputInvoiceDetailDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
dataSouce.add(inputInvoiceDetailDataSourceDto); dataSouce.add(inputInvoiceDetailDataSourceDto);
...@@ -151,4 +150,11 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction { ...@@ -151,4 +150,11 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
return NumberEval.ZERO; return NumberEval.ZERO;
} }
private int getPeriodFromDate(String dateStr){
Date date = DateUtils.strToDate(dateStr);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.MONTH) + 1;
}
} }
...@@ -7,6 +7,7 @@ import org.apache.ibatis.session.RowBounds; ...@@ -7,6 +7,7 @@ import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.CellInvoiceDto; import pwc.taxtech.atms.vat.dpo.CellInvoiceDto;
//import pwc.taxtech.atms.vat.dpo.InputInvoiceItemExtendDto; //import pwc.taxtech.atms.vat.dpo.InputInvoiceItemExtendDto;
import pwc.taxtech.atms.vat.dpo.InputInvoiceResultDto;
import pwc.taxtech.atms.vat.entity.InputInvoice; import pwc.taxtech.atms.vat.entity.InputInvoice;
import pwc.taxtech.atms.vat.entity.InputInvoiceExample; import pwc.taxtech.atms.vat.entity.InputInvoiceExample;
...@@ -110,5 +111,7 @@ public interface InputInvoiceMapper extends MyVatMapper { ...@@ -110,5 +111,7 @@ public interface InputInvoiceMapper extends MyVatMapper {
List<CellInvoiceDto> selectInputInvoiceWithItem(); List<CellInvoiceDto> selectInputInvoiceWithItem();
List<InputInvoiceResultDto> getInputInvoiceResultDto();
// InputInvoiceItemExtendDto selectInvoiceExtendDto(@Param("invoiceItemId") String invoiceItemId); // InputInvoiceItemExtendDto selectInvoiceExtendDto(@Param("invoiceItemId") String invoiceItemId);
} }
\ No newline at end of file
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
</if> </if>
</select> </select>
<resultMap id="inputInvoiceResultDto" type="pwc.taxtech.atms.dto.vatdto.InputVATInvoiceResultDto"> <resultMap id="inputInvoiceResultDto" type="pwc.taxtech.atms.vat.dpo.InputInvoiceResultDto">
<id property="invoiceID" column="invoice_id"/> <id property="invoiceID" column="invoice_id"/>
<association property="inputVATInvoice" javaType="pwc.taxtech.atms.vat.entity.InputVatInvoice"> <association property="inputVATInvoice" javaType="pwc.taxtech.atms.vat.entity.InputVatInvoice">
<id column="ID" jdbcType="VARCHAR" property="id"/> <id column="ID" jdbcType="VARCHAR" property="id"/>
...@@ -180,54 +180,48 @@ ...@@ -180,54 +180,48 @@
</association> </association>
</resultMap> </resultMap>
<select id="getInputVATInvoiceResultDto" resultMap="inputInvoiceResultDto" parameterType="java.lang.String"> <select id="getInputInvoiceResultDto" resultMap="inputInvoiceResultDto">
SELECT SELECT
INPUT_INVOICE.ID AS INVOICE_ID, INPUT_INVOICE.ID AS INVOICE_ID,
INPUTINVOICE.ID, INPUTINVOICE.ID,
INPUTINVOICE.PERIOD_ID, -- INPUTINVOICE.PERIOD_ID,
INPUTINVOICE.INVOICE_CODE, INPUTINVOICE.FPDM,
INPUTINVOICE.INVOICE_NUMBER, INPUTINVOICE.FPHM,
INPUTINVOICE.INVOICE_DATE, INPUTINVOICE.KPRQ,
INPUTINVOICE.SELLER_TAX_NUMBER, INPUTINVOICE.XFSH,
INPUTVATINVOICE.AMOUNT, INPUTVATINVOICE.HJJE,
INPUTVATINVOICE.TAX_AMOUNT, INPUTVATINVOICE.HJSE,
INPUTVATINVOICE.INVOICE_TYPE, INPUTVATINVOICE.FPLX,
INPUTVATINVOICE.CERTIFICATION_RESULT, INPUTVATINVOICE.RZJG,
INPUTVATINVOICE.CERTIFICATION_DATE, INPUTVATINVOICE.RJSJ,
INPUTVATINVOICE.CREATOR_ID, -- INPUTVATINVOICE.CREATOR_ID,
INPUTVATINVOICE.CREATE_TIME, INPUTVATINVOICE.CJSJ,
INPUTVATINVOICE.`_S_T_A_T_U_S_`, -- INPUTVATINVOICE.`_S_T_A_T_U_S_`,
INPUTVATINVOICE.PART_ACCNTED_PERIOD, -- INPUTVATINVOICE.PART_ACCNTED_PERIOD,
INPUTVATINVOICE.ACCNTED_PERIOD, -- INPUTVATINVOICE.ACCNTED_PERIOD,
INPUTVATINVOICEITEM.ID, INPUTINVOICEDETAIL.ID,
INPUTVATINVOICEITEM.INPUT_VAT_INVOICE_ID, INPUTINVOICEDETAIL.FPID,
INPUTVATINVOICEITEM.PERIOD_ID, -- INPUTINVOICEDETAIL.PERIOD_ID,
INPUTVATINVOICEITEM.INVOICE_CODE, INPUTINVOICEDETAIL.FPDM,
INPUTVATINVOICEITEM.INVOICE_NUMBER, INPUTVATINVOICEITEM.FPHM,
INPUTVATINVOICEITEM.AMOUNT, INPUTVATINVOICEITEM.JE,
INPUTVATINVOICEITEM.TAX_AMOUNT, INPUTVATINVOICEITEM.SE,
INPUTVATINVOICEITEM.TAX_RATE, INPUTVATINVOICEITEM.SLV,
INPUTVATINVOICEITEM.PRODUCTION_NAME, INPUTVATINVOICEITEM.SPMC,
INPUTVATINVOICEITEM.CREATOR_ID, -- INPUTVATINVOICEITEM.CREATOR_ID,
INPUTVATINVOICEITEM.CREATE_TIME, -- INPUTVATINVOICEITEM.CREATE_TIME,
INPUTVATINVOICEITEM.PRODUCTION_CODE, INPUTVATINVOICEITEM.GGXH
GOODSMAPPING.ID,
GOODSMAPPING.CUST_GOODS_NAME,
GOODSMAPPING.STD_GOODS_NAME,
GOODSMAPPING.CREATOR_ID,
GOODSMAPPING.CREATE_TIME,
GOODSMAPPING.UPDATE_TIME
FROM FROM
${dbName}.INPUT_INVOICE INPUTINVOICE INPUT_INVOICE INPUTINVOICE
JOIN JOIN
${dbName}.INPUT_INVOICE_DETAIL INPUTINVOICEDETAIL INPUT_INVOICE_DETAIL INPUTINVOICEDETAIL
ON ON
INPUTINVOICE.ID = INPUTINVOICEDETAIL.FPID INPUTINVOICE.ID = INPUTINVOICEDETAIL.FPID
AND INPUT_INVOICE.PERIOD_ID = INPUTVATINVOICEITEM.PERIOD_ID AND INPUT_INVOICE.PERIOD_ID = INPUTVATINVOICEITEM.PERIOD_ID
LEFT JOIN -- LEFT JOIN
${dbName}.INPUT_MATERIAL_ITEM MATERIALITEM -- ${dbName}.INPUT_MATERIAL_ITEM MATERIALITEM
ON -- ON
INPUTVATINVOICEITEM.PRODUCTION_NAME = MATERIALITEM.CUST_GOODS_NAME -- INPUTVATINVOICEITEM.PRODUCTION_NAME = MATERIALITEM.CUST_GOODS_NAME
</select> </select>
<resultMap id="cellInvoiceDto" type="pwc.taxtech.atms.vat.dpo.CellInvoiceDto"> <resultMap id="cellInvoiceDto" type="pwc.taxtech.atms.vat.dpo.CellInvoiceDto">
......
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