Commit 26994390 authored by chase's avatar chase

税金计算表功能开发

parent 018ee398
...@@ -10,7 +10,6 @@ import pwc.taxtech.atms.invoice.OutputInvoiceDetailMapper; ...@@ -10,7 +10,6 @@ import pwc.taxtech.atms.invoice.OutputInvoiceDetailMapper;
import pwc.taxtech.atms.invoice.OutputInvoiceMapper; import pwc.taxtech.atms.invoice.OutputInvoiceMapper;
import pwc.taxtech.atms.service.impl.DistributedIdService; import pwc.taxtech.atms.service.impl.DistributedIdService;
import pwc.taxtech.atms.vat.dao.*; import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.entity.BalanceSheet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -60,7 +59,8 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -60,7 +59,8 @@ public class SpringContextUtil implements ApplicationContextAware {
public static AdjustmentTableMapper adjustmentTableMapper; public static AdjustmentTableMapper adjustmentTableMapper;
public static TrialBalanceFinalMapper trialBalanceFinalMapper; public static TrialBalanceFinalMapper trialBalanceFinalMapper;
public static ProfitLossStatementMapper profitLossStatementMapper; public static ProfitLossStatementMapper profitLossStatementMapper;
public static RevenueTypeMappingMapper revenueTypeMappingMapper;
public static BillDetailMapper billDetailMapper;
...@@ -144,8 +144,8 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -144,8 +144,8 @@ public class SpringContextUtil implements ApplicationContextAware {
citProfitPrcAdjustMapper = webApplicationContext.getBean(CitProfitPrcAdjustMapper.class); citProfitPrcAdjustMapper = webApplicationContext.getBean(CitProfitPrcAdjustMapper.class);
balanceSheetMapper = webApplicationContext.getBean(BalanceSheetMapper.class); balanceSheetMapper = webApplicationContext.getBean(BalanceSheetMapper.class);
revenueTypeMappingMapper = webApplicationContext.getBean(RevenueTypeMappingMapper.class);
billDetailMapper = webApplicationContext.getBean(BillDetailMapper.class);
/* map.put("balance_sheet", balanceMapper); /* map.put("balance_sheet", balanceMapper);
map.put("profit_loss_statement",profitLossStatementMapper); map.put("profit_loss_statement",profitLossStatementMapper);
......
...@@ -48,7 +48,6 @@ public final class Constant { ...@@ -48,7 +48,6 @@ 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 final String DateTimeFormate = "%d年%d月"; public static final String DateTimeFormate = "%d年%d月";
public static final String DateTimeFormate1 = "%d-%d";
public static final String INPUT_RZJG_SUCCESS="1"; public static final String INPUT_RZJG_SUCCESS="1";
public static final String INPUT_RZJG_FAILED="2"; public static final String INPUT_RZJG_FAILED="2";
......
package pwc.taxtech.atms.constant.enums;
import java.util.HashMap;
import java.util.Map;
public class BillDetailEnum {
/**
* 发票类型
*/
public enum BillType {
ORDINARY(1, "增值税普票"),
SPECIAL(2, "增值税专票");
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
BillType(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
static {
for (BillDetailEnum.BillType billType : BillDetailEnum.BillType.values()) {
MAPPING.put(billType.getCode(), billType.getName());
}
}
}
}
...@@ -530,7 +530,8 @@ public class ReportGeneratorImpl { ...@@ -530,7 +530,8 @@ public class ReportGeneratorImpl {
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 XXFP(formulaContext), new GZSD(formulaContext), new PC(formulaContext) new BB(formulaContext), new XXFP(formulaContext), new GZSD(formulaContext), new PC(formulaContext)
, new JXFPMX(formulaContext), new JXFP(formulaContext), new PSUM(formulaContext), new DFFS(formulaContext), , new JXFPMX(formulaContext), new JXFP(formulaContext), new PSUM(formulaContext), new DFFS(formulaContext),
new JFFS(formulaContext), new WPSR(formulaContext), new WPNAME(formulaContext), new WPTYPE(formulaContext), new SUM2(formulaContext), new RSUMIF(formulaContext), new SUM(formulaContext)}; new JFFS(formulaContext), new WPSR(formulaContext), new WPNAME(formulaContext), new WPTYPE(formulaContext),
new SUM2(formulaContext), new RSUMIF(formulaContext), new SUM(formulaContext),new KPSR(formulaContext)};
UDFFinder udfs = new DefaultUDFFinder(functions, functionImpls); UDFFinder udfs = new DefaultUDFFinder(functions, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs); UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack); workbook.addToolPack(udfToolpack);
......
...@@ -64,7 +64,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -64,7 +64,7 @@ public class ReportServiceImpl extends BaseService {
private final static Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class); private final static Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class);
private BlockingQueue<PeriodJob> queue = new LinkedBlockingQueue<>(); private BlockingQueue<PeriodJob> queue = new LinkedBlockingQueue<>();
private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "PC", "JXFPMX", private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "PC", "JXFPMX",
"JXFP", "PSUM", "DFFS", "JFFS", "WPSR", "WPNAME", "WPTYPE", "SUM2", "RSUMIF", "SUM"}; "JXFP", "PSUM", "DFFS", "JFFS", "WPSR", "WPNAME", "WPTYPE", "SUM2", "RSUMIF", "SUM", "KPSR"};
@Autowired @Autowired
private ReportGeneratorImpl reportGenerator; private ReportGeneratorImpl reportGenerator;
...@@ -727,7 +727,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -727,7 +727,7 @@ public class ReportServiceImpl extends BaseService {
RevenueConfigExample example = new RevenueConfigExample(); RevenueConfigExample example = new RevenueConfigExample();
String queryDate = project.getYear()+"-"+(period>=10?period:("0"+period)); String queryDate = project.getYear()+"-"+(period>=10?period:("0"+period));
example.createCriteria().andOrgIdEqualTo(project.getOrganizationId()). example.createCriteria().andOrgIdEqualTo(project.getOrganizationId()).
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).andStatusEqualTo(1); andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).andStatusEqualTo(0);
List<RevenueConfig> dataList = revenueConfigMapper.selectByExample(example); List<RevenueConfig> dataList = revenueConfigMapper.selectByExample(example);
//合计项map //合计项map
Map<Integer,List<String>> sumMap = new HashMap<>(); Map<Integer,List<String>> sumMap = new HashMap<>();
...@@ -759,8 +759,8 @@ public class ReportServiceImpl extends BaseService { ...@@ -759,8 +759,8 @@ public class ReportServiceImpl extends BaseService {
} else { } else {
row.getCell(TaxesCalculateReportEnum.Column.Column_5.getIndex()).setCellValue(""); row.getCell(TaxesCalculateReportEnum.Column.Column_5.getIndex()).setCellValue("");
} }
row.getCell(TaxesCalculateReportEnum.Column.Column_6.getIndex()).setCellValue(""); row.getCell(TaxesCalculateReportEnum.Column.Column_6.getIndex()).setCellValue("KPSR(\""+config.getName()+"\",2)");
row.getCell(TaxesCalculateReportEnum.Column.Column_7.getIndex()).setCellValue(""); row.getCell(TaxesCalculateReportEnum.Column.Column_7.getIndex()).setCellValue("KPSR(\""+config.getName()+"\",1)");
if (1 == config.getTaxBase()) {//账载 if (1 == config.getTaxBase()) {//账载
row.getCell(TaxesCalculateReportEnum.Column.Column_8.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"E\")"); row.getCell(TaxesCalculateReportEnum.Column.Column_8.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"E\")");
} else if (2 == config.getTaxBase()) {//开票收入 } else if (2 == config.getTaxBase()) {//开票收入
......
...@@ -36,11 +36,11 @@ public class JFFS extends FunctionBase implements FreeRefFunction { ...@@ -36,11 +36,11 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
int year = getIntParam(args[1], ec); int year = getIntParam(args[1], ec);
int period = getIntParam(args[2], ec); int period = getIntParam(args[2], ec);
int sourceDataType = getIntParam(args[3], ec);//取值数据源 int sourceDataType = getIntParam(args[3], ec);//取值数据源
String segment5 = ""; String segment5 = null;
if(!(args[4] instanceof MissingArgEval)){ if(!(args[4] instanceof MissingArgEval)){
segment5 = getStringParam(args[4], ec);//利润中心代码 segment5 = getStringParam(args[4], ec);//利润中心代码
} }
String segment6 = ""; String segment6 = null;
if(!(args[4] instanceof MissingArgEval)){ if(!(args[4] instanceof MissingArgEval)){
segment6 = getStringParam(args[5], ec);//产品代码 segment6 = getStringParam(args[5], ec);//产品代码
} }
......
package pwc.taxtech.atms.vat.service.impl.report.functions;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
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.BillDetailEnum;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceType;
import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.vat.entity.BillDetail;
import pwc.taxtech.atms.vat.entity.BillDetailExample;
import pwc.taxtech.atms.vat.entity.RevenueTypeMapping;
import pwc.taxtech.atms.vat.entity.RevenueTypeMappingExample;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 根据收入类型配置查询开票收入开票金额总计
*/
public class KPSR extends FunctionBase implements FreeRefFunction {
public KPSR(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 2) {
return null;
}
String revenueTypeName = getStringParam(args[0], ec);//收入类型名称
Integer billType = getIntParam(args[1], ec);//发票类型
String formulaExpression = "KPSR(\"" + revenueTypeName + "\","+billType+")";
logger.debug(formulaExpression);
List<ReportCellDataSourceDto> dataSource = Lists.newArrayList();
double result = countForTrialBalance(revenueTypeName,dataSource,billType);
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.FormulaDataSourceDto,
new BigDecimal(result), formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, new BigDecimal(result), dataSoureId, formulaContext.getProjectId());
return new NumberEval(result);
}
private double countForTrialBalance(String revenueTypeName, List<ReportCellDataSourceDto> contain, Integer billType) {
formulaContext.getOrganizationId();
String queryDate = formulaContext.getYear()+(formulaContext.getPeriod()<10?("0"+formulaContext.getPeriod()):(formulaContext.getPeriod()+""));
RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample();
typeMappingExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId())
.andRevenueTypeNameEqualTo(revenueTypeName).andStartDateLessThanOrEqualTo(queryDate)
.andEndDateGreaterThanOrEqualTo(queryDate);
List<RevenueTypeMapping> typeMappingList = SpringContextUtil.revenueTypeMappingMapper.selectByExample(typeMappingExample);
if (CollectionUtils.isEmpty(typeMappingList)) {
return 0.0;
}
List<String> contens = typeMappingList.stream()
.map(o -> o.getContent()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(contens)) {
return 0.0;
}
BillDetailExample billDetailExample = new BillDetailExample();
BillDetailExample.Criteria c = billDetailExample.createCriteria().andBillContentIn(contens).andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(formulaContext.getPeriod())
.andBillTypeEqualTo(BillDetailEnum.BillType.MAPPING.get(billType));
List<BillDetail> billDetails = SpringContextUtil.billDetailMapper.selectByExample(billDetailExample);
for (BillDetail billDetail : billDetails) {
ReportCellDataSourceDto dto = new ReportCellDataSourceDto();
dto.setAmount(billDetail.getBillAmount());
dto.setPeriod(formulaContext.getPeriod());
dto.setIsOnlyManualInput(Boolean.FALSE);
dto.setName(Constant.DataSourceName.ReportDataSource);
dto.setType(FormulaDataSourceType.TrialBalanceSource.getCode());
contain.add(dto);
}
return billDetails.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
}
}
...@@ -40,8 +40,8 @@ public class PC extends FunctionBase implements FreeRefFunction { ...@@ -40,8 +40,8 @@ public class PC extends FunctionBase implements FreeRefFunction {
case "FilterDate": case "FilterDate":
return new StringEval(String.format(Constant.DateTimeFormate, formulaContext.getYear(), formulaContext.getPeriod())); return new StringEval(String.format(Constant.DateTimeFormate, formulaContext.getYear(), formulaContext.getPeriod()));
case "FilterDate1": case "FilterDate1":
// String month = formulaContext.getPeriod()<10?"0"+formulaContext.getPeriod():formulaContext.getPeriod()+""; String month = formulaContext.getPeriod()<10?("0"+formulaContext.getPeriod()):(formulaContext.getPeriod()+"");
return new StringEval(String.format(Constant.DateTimeFormate1, formulaContext.getYear(), formulaContext.getPeriod())); return new StringEval(formulaContext.getYear()+"-"+month);
case "TimeInterval": case "TimeInterval":
Date beginOfPeriod = new Date(formulaContext.getYear(), formulaContext.getIsYear() ? 1 : formulaContext.getPeriod(), 1); Date beginOfPeriod = new Date(formulaContext.getYear(), formulaContext.getIsYear() ? 1 : formulaContext.getPeriod(), 1);
calendar.setTime(beginOfPeriod); calendar.setTime(beginOfPeriod);
......
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