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

add code for jxfpmx, need debug later

parent 5ace3d48
...@@ -39,7 +39,7 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -39,7 +39,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static OutputVATInvoiceMapper outputVATInvoiceMapper; public static OutputVATInvoiceMapper outputVATInvoiceMapper;
public static PeriodTaxRuleSettingMapper periodTaxRuleSettingMapper; public static PeriodTaxRuleSettingMapper periodTaxRuleSettingMapper;
public static InputVatInvoiceDao inputVatInvoiceDao; public static InputVatInvoiceDao inputVatInvoiceDao;
public static InputVATInvoiceMapper inputVATInvoiceMapper;
/** /**
* 获取bean * 获取bean
...@@ -68,7 +68,7 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -68,7 +68,7 @@ public class SpringContextUtil implements ApplicationContextAware {
projectDao = webApplicationContext.getBean(ProjectDao.class); projectDao = webApplicationContext.getBean(ProjectDao.class);
balanceMapper = webApplicationContext.getBean(BalanceMapper.class); balanceMapper = webApplicationContext.getBean(BalanceMapper.class);
dataSourceMapper = webApplicationContext.getBean(DataSourceMapper.class); dataSourceMapper = webApplicationContext.getBean(DataSourceMapper.class);
dataSourceDetailMapper=webApplicationContext.getBean(DataSourceDetailMapper.class); dataSourceDetailMapper = webApplicationContext.getBean(DataSourceDetailMapper.class);
periodFormulaBlockMapper = webApplicationContext.getBean(PeriodFormulaBlockMapper.class); periodFormulaBlockMapper = webApplicationContext.getBean(PeriodFormulaBlockMapper.class);
vatEnterpriseAccountDao = webApplicationContext.getBean(VatEnterpriseAccountDao.class); vatEnterpriseAccountDao = webApplicationContext.getBean(VatEnterpriseAccountDao.class);
vatEnterpriseAccountMapper = webApplicationContext.getBean(VatEnterpriseAccountMapper.class); vatEnterpriseAccountMapper = webApplicationContext.getBean(VatEnterpriseAccountMapper.class);
...@@ -76,5 +76,6 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -76,5 +76,6 @@ public class SpringContextUtil implements ApplicationContextAware {
outputVATInvoiceMapper = webApplicationContext.getBean(OutputVATInvoiceMapper.class); outputVATInvoiceMapper = webApplicationContext.getBean(OutputVATInvoiceMapper.class);
periodTaxRuleSettingMapper = webApplicationContext.getBean(PeriodTaxRuleSettingMapper.class); periodTaxRuleSettingMapper = webApplicationContext.getBean(PeriodTaxRuleSettingMapper.class);
inputVatInvoiceDao = webApplicationContext.getBean(InputVatInvoiceDao.class); inputVatInvoiceDao = webApplicationContext.getBean(InputVatInvoiceDao.class);
inputVATInvoiceMapper = webApplicationContext.getBean(InputVATInvoiceMapper.class);
} }
} }
...@@ -4,19 +4,24 @@ public enum FormulaDataSourceDetailType { ...@@ -4,19 +4,24 @@ public enum FormulaDataSourceDetailType {
BSPLFormulaDataSourceDto(1, pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto.class), BSPLFormulaDataSourceDto(1, pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto.class),
FormulaDataSourceDto(2, pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto.class), FormulaDataSourceDto(2, pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto.class),
InputInvoiceDataSourceDto(3, pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto.class), InputInvoiceDataSourceDto(3, pwc.taxtech.atms.dto.vatdto.InputInvoiceDataSourceDto.class),
OutputInvoiceDataSourceDto(4, pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto.class); InputInvoiceDetailDataSourceDto(4, pwc.taxtech.atms.dto.vatdto.InputInvoiceDetailDataSourceDto.class),
OutputInvoiceDataSourceDto(5, pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto.class);
private Integer code; private Integer code;
private Class clas; private Class clas;
FormulaDataSourceDetailType(Integer code,Class clas) { FormulaDataSourceDetailType(Integer code, Class clas) {
this.code = code;this.clas = clas; this.code = code;
this.clas = clas;
} }
public Integer getCode() { public Integer getCode() {
return code; return code;
} }
public Class getClas(){return clas;}
public Class getClas() {
return clas;
}
} }
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;
@Setter
@Getter
public class InputInvoiceDetailDataSourceDto extends FormulaDataSourceDto {
public InputInvoiceDetailDataSourceDto() {
super();
this.setType(FormulaDataSourceType.InputInvoiceDetail.getCode());
}
public int Period;
public Date InvoiceDate;
public String InvoiceCode;
public String InvoiceNumber;
public BigDecimal TaxAmount;
public BigDecimal TaxRate;
public String ProductionName;
}
package pwc.taxtech.atms.dto.vatdto;
import lombok.Getter;
import lombok.Setter;
import pwc.taxtech.atms.vat.entity.GoodsMapping;
import pwc.taxtech.atms.vat.entity.InputVATInvoice;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceItem;
@Setter
@Getter
public class InputVATInvoiceResultDto {
private String invoiceID;
private InputVATInvoice inputVATInvoice;
private InputVATInvoiceItem inputVATInvoiceItem;
private GoodsMapping goodsMapping;
}
...@@ -197,7 +197,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission ...@@ -197,7 +197,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
.filter(rPermissionDto -> currentNode.getId().equals(rPermissionDto.getParentID())).collect(Collectors.toList()); .filter(rPermissionDto -> currentNode.getId().equals(rPermissionDto.getParentID())).collect(Collectors.toList());
if(subRolePermissionDtoList!=null && !subRolePermissionDtoList.isEmpty()) { if(subRolePermissionDtoList!=null && !subRolePermissionDtoList.isEmpty()) {
currentNode.setExpanded(true); currentNode.setExpanded(true);
currentNode.setItems(new ArrayList()); currentNode.setItems(new ArrayList<>());
for(RolePermissionDto rolePermissionDto : subRolePermissionDtoList) { for(RolePermissionDto rolePermissionDto : subRolePermissionDtoList) {
DevTreeDto subNode = new DevTreeDto(); DevTreeDto subNode = new DevTreeDto();
subNode.setId(rolePermissionDto.getPermissionID()); subNode.setId(rolePermissionDto.getPermissionID());
...@@ -210,7 +210,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission ...@@ -210,7 +210,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
} }
else { else {
currentNode.setExpanded(false); currentNode.setExpanded(false);
currentNode.setItems(new ArrayList()); currentNode.setItems(new ArrayList<>());
} }
} }
...@@ -221,7 +221,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission ...@@ -221,7 +221,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
.filter(permission -> currentNode.getId().equals(permission.getParentID())).collect(Collectors.toList()); .filter(permission -> currentNode.getId().equals(permission.getParentID())).collect(Collectors.toList());
if(subPermissionList!=null && !subPermissionList.isEmpty()) { if(subPermissionList!=null && !subPermissionList.isEmpty()) {
currentNode.setExpanded(true); currentNode.setExpanded(true);
currentNode.setItems(new ArrayList()); currentNode.setItems(new ArrayList<>());
for(Permission permission : subPermissionList) { for(Permission permission : subPermissionList) {
DevTreeDto subNode = new DevTreeDto(); DevTreeDto subNode = new DevTreeDto();
subNode.setId(permission.getID()); subNode.setId(permission.getID());
...@@ -235,7 +235,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission ...@@ -235,7 +235,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
} }
else { else {
currentNode.setExpanded(false); currentNode.setExpanded(false);
currentNode.setItems(new ArrayList()); currentNode.setItems(new ArrayList<>());
} }
} }
} }
...@@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Param; ...@@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Param;
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.InputInvoicePreviewQueryParam; import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceResultDto;
import pwc.taxtech.atms.vat.entity.InputVATInvoice; import pwc.taxtech.atms.vat.entity.InputVATInvoice;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceExample; import pwc.taxtech.atms.vat.entity.InputVATInvoiceExample;
...@@ -110,4 +112,6 @@ public interface InputVATInvoiceMapper extends MyVatMapper { ...@@ -110,4 +112,6 @@ public interface InputVATInvoiceMapper extends MyVatMapper {
long getInputVATInvoiceCountByCondition(@Param("paras") InputInvoicePreviewQueryParam param); long getInputVATInvoiceCountByCondition(@Param("paras") InputInvoicePreviewQueryParam param);
List<InputVATInvoice> getInputVATInvoiceCountByConditionWithPaging(@Param("paras") InputInvoicePreviewQueryParam param,@Param("limitFrom") int limitFrom); List<InputVATInvoice> getInputVATInvoiceCountByConditionWithPaging(@Param("paras") InputInvoicePreviewQueryParam param,@Param("limitFrom") int limitFrom);
List<InputVATInvoiceResultDto> getInputVATInvoiceResultDto(String dbName);
} }
\ No newline at end of file
...@@ -263,7 +263,7 @@ public class VoucherServiceImpl extends VatAbstractService implements VoucherSer ...@@ -263,7 +263,7 @@ public class VoucherServiceImpl extends VatAbstractService implements VoucherSer
"`VID`"; "`VID`";
} }
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql); List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
List<VoucherDto> voucherDtos = new ArrayList(); List<VoucherDto> voucherDtos = new ArrayList<>();
queryForList.forEach(a -> { queryForList.forEach(a -> {
VoucherDto dto = new VoucherDto(); VoucherDto dto = new VoucherDto();
dto.setVoucherID(a.get("VoucherID").toString()); dto.setVoucherID(a.get("VoucherID").toString());
......
...@@ -20,7 +20,8 @@ import java.util.List; ...@@ -20,7 +20,8 @@ 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());
public static final BigDecimal[] defaultTaxRates = {new BigDecimal("0.17"), new BigDecimal("0.13")
, new BigDecimal("0.11"), new BigDecimal("0.06"), new BigDecimal(" 0.05"), new BigDecimal("0.03")};
protected FormulaContext formulaContext; protected FormulaContext formulaContext;
final FormulaAgent agent; final FormulaAgent agent;
......
...@@ -121,7 +121,7 @@ public class JXFP extends FunctionBase implements FreeRefFunction { ...@@ -121,7 +121,7 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
} }
} }
List<InputInvoiceDataSourceDto> dataSource = new ArrayList(); List<InputInvoiceDataSourceDto> dataSource = new ArrayList<>();
for (InputVATInvoice x : inputVATInvoices) { for (InputVATInvoice x : inputVATInvoices) {
InputInvoiceDataSourceDto inputInvoiceDataSourceDto = new InputInvoiceDataSourceDto(); InputInvoiceDataSourceDto inputInvoiceDataSourceDto = new InputInvoiceDataSourceDto();
inputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getAmount(), KeyValueConfigResultType.Accounting, inputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getAmount(), KeyValueConfigResultType.Accounting,
......
...@@ -5,9 +5,17 @@ import org.apache.poi.ss.formula.OperationEvaluationContext; ...@@ -5,9 +5,17 @@ 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.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.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.dto.vatdto.InputInvoiceDetailDataSourceDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceResultDto;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/// <summary> /// <summary>
...@@ -64,8 +72,67 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction { ...@@ -64,8 +72,67 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
taxRateVal = taxRateVal.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); taxRateVal = taxRateVal.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
} }
String dbName = SpringContextUtil.projectDao.getDbNameWithYearAndOrgID(formulaContext.getOrganizationID(), curYear);
List<InputVATInvoiceResultDto> inputInvoice = SpringContextUtil.inputVATInvoiceMapper.getInputVATInvoiceResultDto(dbName);
if (!goodsName.equals("99")) {
inputInvoice = inputInvoice.stream()
.filter(a -> a.getGoodsMapping() != null && a.getGoodsMapping().getStdGoodsName().equals(goodsName))
.collect(Collectors.toList());
}
if (taxRateVal.compareTo(new BigDecimal("-1")) == 0) {
inputInvoice = inputInvoice.stream()
.filter(a -> Arrays.asList(FunctionBase.defaultTaxRates).contains(a.getInputVATInvoiceItem().getTaxRate()))
.collect(Collectors.toList());
} else if (taxRateVal.compareTo(new BigDecimal("99")) != 0) {
BigDecimal finalTaxRateVal = taxRateVal;
inputInvoice = inputInvoice.stream()
.filter(a -> a.getInputVATInvoiceItem().getTaxRate().equals(finalTaxRateVal))
.collect(Collectors.toList());
}
if (period != 99) {
int finalPeriod = period;
inputInvoice = inputInvoice.stream()
.filter(a -> a.getInputVATInvoice().getPeriodID() == finalPeriod)
.collect(Collectors.toList());
}
List<InputInvoiceDetailDataSourceDto> dataSouce = new ArrayList<>();
for (InputVATInvoiceResultDto x : inputInvoice) {
InputInvoiceDetailDataSourceDto inputInvoiceDetailDataSourceDto = new InputInvoiceDetailDataSourceDto();
inputInvoiceDetailDataSourceDto.setAmount(FormulaHelper.roundValue(x.getInputVATInvoiceItem().getAmount(), 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.setName(Constant.DataSourceName.InputDetailInvoiceDataSource);
inputInvoiceDetailDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
dataSouce.add(inputInvoiceDetailDataSourceDto);
}
dataSouce = dataSouce.stream()
.sorted(Comparator.comparing(InputInvoiceDetailDataSourceDto::getInvoiceDate)
.thenComparing(InputInvoiceDetailDataSourceDto::getInvoiceCode)
.thenComparing(InputInvoiceDetailDataSourceDto::getInvoiceNumber))
.collect(Collectors.toList());
if (amountType == 0) {
double val = dataSouce.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSouce), FormulaDataSourceDetailType.InputInvoiceDetailDataSourceDto, new BigDecimal(val));
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSourceId);
return new NumberEval(val);
} else if (amountType == 1) {
double val = dataSouce.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSouce), FormulaDataSourceDetailType.InputInvoiceDetailDataSourceDto, new BigDecimal(val));
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSourceId);
return new NumberEval(val);
}
return NumberEval.ZERO; return NumberEval.ZERO;
} }
......
...@@ -91,7 +91,7 @@ public class XXFP extends FunctionBase implements FreeRefFunction { ...@@ -91,7 +91,7 @@ public class XXFP extends FunctionBase implements FreeRefFunction {
outputInvoice = outputInvoice.stream().filter(a -> a.getInvoice().getPeriodID().equals(finalPeriod)).collect(Collectors.toList()); outputInvoice = outputInvoice.stream().filter(a -> a.getInvoice().getPeriodID().equals(finalPeriod)).collect(Collectors.toList());
} }
List<OutputInvoiceDataSourceDto> dataSource = new ArrayList(); List<OutputInvoiceDataSourceDto> dataSource = new ArrayList<>();
for (OutputVATInvoiceDto x : outputInvoice) { for (OutputVATInvoiceDto x : outputInvoice) {
OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto(); OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto();
outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getInvoiceItem().getAmount(), outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getInvoiceItem().getAmount(),
......
...@@ -571,43 +571,43 @@ ...@@ -571,43 +571,43 @@
</association> </association>
</resultMap> </resultMap>
<select id="getVatInvoiceWithItems" resultMap="outputVATInvoiceDto" parameterType="java.lang.String"> <select id="getVatInvoiceWithItems" resultMap="outputVATInvoiceDto" parameterType="java.lang.String">
SELECT SELECT
invoice.InvoiceID, invoice.InvoiceID,
invoice.InvoiceType, invoice.InvoiceType,
invoice.ClassCode, invoice.ClassCode,
invoice.InvoiceNumber, invoice.InvoiceNumber,
invoice.BuyerName, invoice.BuyerName,
invoice.BuyerTaxNumber, invoice.BuyerTaxNumber,
invoice.BankAccount, invoice.BankAccount,
invoice.PhoneNum, invoice.PhoneNum,
invoice.InvoiceDate, invoice.InvoiceDate,
invoice.SeqNo, invoice.SeqNo,
invoice.PeriodID, invoice.PeriodID,
invoice.`STATUS`, invoice.`STATUS`,
invoice.CreatorID, invoice.CreatorID,
invoice.CreateTime, invoice.CreateTime,
invoice.PartAccntedPeriod, invoice.PartAccntedPeriod,
invoice.AccntedPeriod, invoice.AccntedPeriod,
invoiceItem.ItemID, invoiceItem.ItemID,
invoiceItem.InvoiceID, invoiceItem.InvoiceID,
invoiceItem.CodeVersion, invoiceItem.CodeVersion,
invoiceItem.ProductName, invoiceItem.ProductName,
invoiceItem.DocumentNum, invoiceItem.DocumentNum,
invoiceItem.ProductStandard, invoiceItem.ProductStandard,
invoiceItem.Unit, invoiceItem.Unit,
invoiceItem.Quantity, invoiceItem.Quantity,
invoiceItem.UnitPrice, invoiceItem.UnitPrice,
invoiceItem.Amount, invoiceItem.Amount,
invoiceItem.TaxRate, invoiceItem.TaxRate,
invoiceItem.TaxAmount, invoiceItem.TaxAmount,
invoiceItem.SeqNo, invoiceItem.SeqNo,
invoiceItem.TaxClassCode, invoiceItem.TaxClassCode,
invoiceItem.CreatorID, invoiceItem.CreatorID,
invoiceItem.CreateTime, invoiceItem.CreateTime,
invoiceItem.PeriodID invoiceItem.PeriodID
FROM ${dbName}.OutputVATInvoice invoice FROM ${dbName}.OutputVATInvoice invoice
JOIN ${dbName}.OutputVATInvoiceItem invoiceItem JOIN ${dbName}.OutputVATInvoiceItem invoiceItem
ON invoice.InvoiceID = invoiceItem.InvoiceID ON invoice.InvoiceID = invoiceItem.InvoiceID AND invoice.PeriodID=invoiceItem.PeriodID
ORDER BY invoice.PeriodID,invoice.ClassCode,invoice.InvoiceNumber,invoiceItem.SeqNo ORDER BY invoice.PeriodID,invoice.ClassCode,invoice.InvoiceNumber,invoiceItem.SeqNo
</select> </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