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 {
public static OutputVATInvoiceMapper outputVATInvoiceMapper;
public static PeriodTaxRuleSettingMapper periodTaxRuleSettingMapper;
public static InputVatInvoiceDao inputVatInvoiceDao;
public static InputVATInvoiceMapper inputVATInvoiceMapper;
/**
* 获取bean
......@@ -68,7 +68,7 @@ public class SpringContextUtil implements ApplicationContextAware {
projectDao = webApplicationContext.getBean(ProjectDao.class);
balanceMapper = webApplicationContext.getBean(BalanceMapper.class);
dataSourceMapper = webApplicationContext.getBean(DataSourceMapper.class);
dataSourceDetailMapper=webApplicationContext.getBean(DataSourceDetailMapper.class);
dataSourceDetailMapper = webApplicationContext.getBean(DataSourceDetailMapper.class);
periodFormulaBlockMapper = webApplicationContext.getBean(PeriodFormulaBlockMapper.class);
vatEnterpriseAccountDao = webApplicationContext.getBean(VatEnterpriseAccountDao.class);
vatEnterpriseAccountMapper = webApplicationContext.getBean(VatEnterpriseAccountMapper.class);
......@@ -76,5 +76,6 @@ public class SpringContextUtil implements ApplicationContextAware {
outputVATInvoiceMapper = webApplicationContext.getBean(OutputVATInvoiceMapper.class);
periodTaxRuleSettingMapper = webApplicationContext.getBean(PeriodTaxRuleSettingMapper.class);
inputVatInvoiceDao = webApplicationContext.getBean(InputVatInvoiceDao.class);
inputVATInvoiceMapper = webApplicationContext.getBean(InputVATInvoiceMapper.class);
}
}
......@@ -4,19 +4,24 @@ public enum FormulaDataSourceDetailType {
BSPLFormulaDataSourceDto(1, pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto.class),
FormulaDataSourceDto(2, pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto.class),
InputInvoiceDataSourceDto(3, pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto.class),
OutputInvoiceDataSourceDto(4, pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto.class);
InputInvoiceDataSourceDto(3, pwc.taxtech.atms.dto.vatdto.InputInvoiceDataSourceDto.class),
InputInvoiceDetailDataSourceDto(4, pwc.taxtech.atms.dto.vatdto.InputInvoiceDetailDataSourceDto.class),
OutputInvoiceDataSourceDto(5, pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto.class);
private Integer code;
private Class clas;
FormulaDataSourceDetailType(Integer code,Class clas) {
this.code = code;this.clas = clas;
FormulaDataSourceDetailType(Integer code, Class clas) {
this.code = code;
this.clas = clas;
}
public Integer getCode() {
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
.filter(rPermissionDto -> currentNode.getId().equals(rPermissionDto.getParentID())).collect(Collectors.toList());
if(subRolePermissionDtoList!=null && !subRolePermissionDtoList.isEmpty()) {
currentNode.setExpanded(true);
currentNode.setItems(new ArrayList());
currentNode.setItems(new ArrayList<>());
for(RolePermissionDto rolePermissionDto : subRolePermissionDtoList) {
DevTreeDto subNode = new DevTreeDto();
subNode.setId(rolePermissionDto.getPermissionID());
......@@ -210,7 +210,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
}
else {
currentNode.setExpanded(false);
currentNode.setItems(new ArrayList());
currentNode.setItems(new ArrayList<>());
}
}
......@@ -221,7 +221,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
.filter(permission -> currentNode.getId().equals(permission.getParentID())).collect(Collectors.toList());
if(subPermissionList!=null && !subPermissionList.isEmpty()) {
currentNode.setExpanded(true);
currentNode.setItems(new ArrayList());
currentNode.setItems(new ArrayList<>());
for(Permission permission : subPermissionList) {
DevTreeDto subNode = new DevTreeDto();
subNode.setId(permission.getID());
......@@ -235,7 +235,7 @@ public class PermissionServiceImpl extends AbstractService implements Permission
}
else {
currentNode.setExpanded(false);
currentNode.setItems(new ArrayList());
currentNode.setItems(new ArrayList<>());
}
}
}
......@@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
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.InputVATInvoiceExample;
......@@ -110,4 +112,6 @@ public interface InputVATInvoiceMapper extends MyVatMapper {
long getInputVATInvoiceCountByCondition(@Param("paras") InputInvoicePreviewQueryParam param);
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
"`VID`";
}
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
List<VoucherDto> voucherDtos = new ArrayList();
List<VoucherDto> voucherDtos = new ArrayList<>();
queryForList.forEach(a -> {
VoucherDto dto = new VoucherDto();
dto.setVoucherID(a.get("VoucherID").toString());
......
......@@ -20,7 +20,8 @@ import java.util.List;
public class FunctionBase {
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;
final FormulaAgent agent;
......
......@@ -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) {
InputInvoiceDataSourceDto inputInvoiceDataSourceDto = new InputInvoiceDataSourceDto();
inputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getAmount(), KeyValueConfigResultType.Accounting,
......
......@@ -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.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.InputInvoiceDetailDataSourceDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceResultDto;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/// <summary>
......@@ -64,8 +72,67 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
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;
}
......
......@@ -91,7 +91,7 @@ public class XXFP extends FunctionBase implements FreeRefFunction {
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) {
OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto();
outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getInvoiceItem().getAmount(),
......
......@@ -571,43 +571,43 @@
</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
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 AND invoice.PeriodID=invoiceItem.PeriodID
ORDER BY invoice.PeriodID,invoice.ClassCode,invoice.InvoiceNumber,invoiceItem.SeqNo
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment