Commit 181bf10f authored by sherlock's avatar sherlock

JXFPMX

parent 5bf4ee74
......@@ -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.ValueEval;
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.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.InputInvoiceDetailDataSourceDto;
import pwc.taxtech.atms.vat.dpo.InputInvoiceResultDto;
import pwc.taxtech.atms.vat.dpo.InputVATInvoiceResultDto;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
......@@ -84,44 +82,45 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
}
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")) {
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());
}
if (taxRateVal.compareTo(new BigDecimal("-1")) == 0) {
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());
} else if (taxRateVal.compareTo(new BigDecimal("99")) != 0) {
BigDecimal finalTaxRateVal = taxRateVal;
inputInvoice = inputInvoice.stream()
.filter(a -> a.getInputVATInvoiceItem().getTaxRate().equals(finalTaxRateVal))
.filter(a -> new BigDecimal(a.getInputInvoiceDetail().getSLV()).equals(finalTaxRateVal))
.collect(Collectors.toList());
}
if (period != 99) {
int finalPeriod = period;
inputInvoice = inputInvoice.stream()
.filter(a -> a.getInputVATInvoice().getPeriodId() == finalPeriod)
.filter(a -> getPeriodFromDate(a.getInputInvoice().getRZSJ()) == finalPeriod)
.collect(Collectors.toList());
}
List<InputInvoiceDetailDataSourceDto> dataSouce = new ArrayList<>();
for (InputVATInvoiceResultDto x : inputInvoice) {
for (InputInvoiceResultDto x : inputInvoice) {
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.setTaxAmount(FormulaHelper.roundValue(x.getInputVATInvoiceItem().getTaxAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
inputInvoiceDetailDataSourceDto.setTaxRate(x.getInputVATInvoiceItem().getTaxRate());
inputInvoiceDetailDataSourceDto.setInvoiceNumber(x.getInputVATInvoice().getInvoiceNumber());
inputInvoiceDetailDataSourceDto.setInvoiceDate(x.getInputVATInvoice().getInvoiceDate());
inputInvoiceDetailDataSourceDto.setInvoiceCode(x.getInputVATInvoice().getInvoiceCode());
inputInvoiceDetailDataSourceDto.setPeriod(x.getInputVATInvoice().getPeriodId());
inputInvoiceDetailDataSourceDto.setProductionName(x.getInputVATInvoiceItem().getProductionName());
inputInvoiceDetailDataSourceDto.setTaxAmount(FormulaHelper.roundValue(new BigDecimal(x.getInputInvoiceDetail().getSE()), KeyValueConfigResultType.Accounting, null, formulaContext));
inputInvoiceDetailDataSourceDto.setTaxRate(new BigDecimal(x.getInputInvoiceDetail().getSLV()));
inputInvoiceDetailDataSourceDto.setInvoiceNumber(x.getInputInvoice().getFPHM());
inputInvoiceDetailDataSourceDto.setInvoiceDate(DateUtils.strToDate(x.getInputInvoice().getKPRQ()));
inputInvoiceDetailDataSourceDto.setInvoiceCode(x.getInputInvoice().getFPDM());
inputInvoiceDetailDataSourceDto.setPeriod(getPeriodFromDate(x.getInputInvoice().getKPRQ()));
inputInvoiceDetailDataSourceDto.setProductionName(x.getInputInvoiceDetail().getSPMC());
inputInvoiceDetailDataSourceDto.setName(Constant.DataSourceName.InputDetailInvoiceDataSource);
inputInvoiceDetailDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
dataSouce.add(inputInvoiceDetailDataSourceDto);
......@@ -151,4 +150,11 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
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;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.CellInvoiceDto;
//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.InputInvoiceExample;
......@@ -110,5 +111,7 @@ public interface InputInvoiceMapper extends MyVatMapper {
List<CellInvoiceDto> selectInputInvoiceWithItem();
List<InputInvoiceResultDto> getInputInvoiceResultDto();
// InputInvoiceItemExtendDto selectInvoiceExtendDto(@Param("invoiceItemId") String invoiceItemId);
}
\ No newline at end of file
......@@ -136,7 +136,7 @@
</if>
</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"/>
<association property="inputVATInvoice" javaType="pwc.taxtech.atms.vat.entity.InputVatInvoice">
<id column="ID" jdbcType="VARCHAR" property="id"/>
......@@ -180,54 +180,48 @@
</association>
</resultMap>
<select id="getInputVATInvoiceResultDto" resultMap="inputInvoiceResultDto" parameterType="java.lang.String">
<select id="getInputInvoiceResultDto" resultMap="inputInvoiceResultDto">
SELECT
INPUT_INVOICE.ID AS INVOICE_ID,
INPUTINVOICE.ID,
INPUTINVOICE.PERIOD_ID,
INPUTINVOICE.INVOICE_CODE,
INPUTINVOICE.INVOICE_NUMBER,
INPUTINVOICE.INVOICE_DATE,
INPUTINVOICE.SELLER_TAX_NUMBER,
INPUTVATINVOICE.AMOUNT,
INPUTVATINVOICE.TAX_AMOUNT,
INPUTVATINVOICE.INVOICE_TYPE,
INPUTVATINVOICE.CERTIFICATION_RESULT,
INPUTVATINVOICE.CERTIFICATION_DATE,
INPUTVATINVOICE.CREATOR_ID,
INPUTVATINVOICE.CREATE_TIME,
INPUTVATINVOICE.`_S_T_A_T_U_S_`,
INPUTVATINVOICE.PART_ACCNTED_PERIOD,
INPUTVATINVOICE.ACCNTED_PERIOD,
INPUTVATINVOICEITEM.ID,
INPUTVATINVOICEITEM.INPUT_VAT_INVOICE_ID,
INPUTVATINVOICEITEM.PERIOD_ID,
INPUTVATINVOICEITEM.INVOICE_CODE,
INPUTVATINVOICEITEM.INVOICE_NUMBER,
INPUTVATINVOICEITEM.AMOUNT,
INPUTVATINVOICEITEM.TAX_AMOUNT,
INPUTVATINVOICEITEM.TAX_RATE,
INPUTVATINVOICEITEM.PRODUCTION_NAME,
INPUTVATINVOICEITEM.CREATOR_ID,
INPUTVATINVOICEITEM.CREATE_TIME,
INPUTVATINVOICEITEM.PRODUCTION_CODE,
GOODSMAPPING.ID,
GOODSMAPPING.CUST_GOODS_NAME,
GOODSMAPPING.STD_GOODS_NAME,
GOODSMAPPING.CREATOR_ID,
GOODSMAPPING.CREATE_TIME,
GOODSMAPPING.UPDATE_TIME
-- INPUTINVOICE.PERIOD_ID,
INPUTINVOICE.FPDM,
INPUTINVOICE.FPHM,
INPUTINVOICE.KPRQ,
INPUTINVOICE.XFSH,
INPUTVATINVOICE.HJJE,
INPUTVATINVOICE.HJSE,
INPUTVATINVOICE.FPLX,
INPUTVATINVOICE.RZJG,
INPUTVATINVOICE.RJSJ,
-- INPUTVATINVOICE.CREATOR_ID,
INPUTVATINVOICE.CJSJ,
-- INPUTVATINVOICE.`_S_T_A_T_U_S_`,
-- INPUTVATINVOICE.PART_ACCNTED_PERIOD,
-- INPUTVATINVOICE.ACCNTED_PERIOD,
INPUTINVOICEDETAIL.ID,
INPUTINVOICEDETAIL.FPID,
-- INPUTINVOICEDETAIL.PERIOD_ID,
INPUTINVOICEDETAIL.FPDM,
INPUTVATINVOICEITEM.FPHM,
INPUTVATINVOICEITEM.JE,
INPUTVATINVOICEITEM.SE,
INPUTVATINVOICEITEM.SLV,
INPUTVATINVOICEITEM.SPMC,
-- INPUTVATINVOICEITEM.CREATOR_ID,
-- INPUTVATINVOICEITEM.CREATE_TIME,
INPUTVATINVOICEITEM.GGXH
FROM
${dbName}.INPUT_INVOICE INPUTINVOICE
INPUT_INVOICE INPUTINVOICE
JOIN
${dbName}.INPUT_INVOICE_DETAIL INPUTINVOICEDETAIL
INPUT_INVOICE_DETAIL INPUTINVOICEDETAIL
ON
INPUTINVOICE.ID = INPUTINVOICEDETAIL.FPID
AND INPUT_INVOICE.PERIOD_ID = INPUTVATINVOICEITEM.PERIOD_ID
LEFT JOIN
${dbName}.INPUT_MATERIAL_ITEM MATERIALITEM
ON
INPUTVATINVOICEITEM.PRODUCTION_NAME = MATERIALITEM.CUST_GOODS_NAME
-- LEFT JOIN
-- ${dbName}.INPUT_MATERIAL_ITEM MATERIALITEM
-- ON
-- INPUTVATINVOICEITEM.PRODUCTION_NAME = MATERIALITEM.CUST_GOODS_NAME
</select>
<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