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

fixed null to NumberEval.ZERO

parent 18ffb5bf
...@@ -46,7 +46,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -46,7 +46,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
String accountCode, keyParam; String accountCode, keyParam;
if (args.length < 5) { if (args.length < 5) {
return null; return NumberEval.ZERO;
} }
accountType = this.getIntParam(args[0], ec); accountType = this.getIntParam(args[0], ec);
...@@ -70,7 +70,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -70,7 +70,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
//标准账套 //标准账套
VatStandardAccount vatStandardAccount = SpringContextUtil.vatStandardAccountMapper.selectOneByAccountCode(accountCode); VatStandardAccount vatStandardAccount = SpringContextUtil.vatStandardAccountMapper.selectOneByAccountCode(accountCode);
if (vatStandardAccount == null) { if (vatStandardAccount == null) {
return null; return NumberEval.ZERO;
} }
BalanceStdManual balanceStdManual = null; BalanceStdManual balanceStdManual = null;
...@@ -145,7 +145,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -145,7 +145,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
.getListByAccountCode(accountCode); .getListByAccountCode(accountCode);
if (vatEnterpriseAccountList == null) { if (vatEnterpriseAccountList == null) {
return null; return NumberEval.ZERO;
} }
Balance balance = null; Balance balance = null;
......
...@@ -73,8 +73,8 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -73,8 +73,8 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
if (!matchedRule.isPresent()) { if (!matchedRule.isPresent()) {
matchedRule = Optional.ofNullable(taxRuleSettings.get(0)); matchedRule = Optional.ofNullable(taxRuleSettings.get(0));
if (matchedRule.isPresent()) { if (!matchedRule.isPresent()) {
return null; return NumberEval.ZERO;
} }
} }
...@@ -101,6 +101,6 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -101,6 +101,6 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
//return new NumberEval(matchedRule.get().getTaxBase()); //return new NumberEval(matchedRule.get().getTaxBase());
} }
return null; return NumberEval.ZERO;
} }
} }
...@@ -58,12 +58,12 @@ public class JXFP extends FunctionBase implements FreeRefFunction { ...@@ -58,12 +58,12 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
certificationPeriod = getPeriod(certificationPeriod, yearOffset); certificationPeriod = getPeriod(certificationPeriod, yearOffset);
if (yearOffset[0] < 0) { if (yearOffset[0] < 0) {
return null; return NumberEval.ZERO;
} }
period = getPeriod(period, yearOffset); period = getPeriod(period, yearOffset);
if (yearOffset[0] < 0) { if (yearOffset[0] < 0) {
return null; return NumberEval.ZERO;
} }
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -92,12 +92,12 @@ public class JXFP extends FunctionBase implements FreeRefFunction { ...@@ -92,12 +92,12 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
inputVATInvoices = SpringContextUtil.inputVatInvoiceDao.getInputVATInvoice(period, invoiceType, null, inputVATInvoices = SpringContextUtil.inputVatInvoiceDao.getInputVATInvoice(period, invoiceType, null,
null, Constant.InputInvoiceCertificationResult.NotPass); null, Constant.InputInvoiceCertificationResult.NotPass);
} else { } else {
return null; return NumberEval.ZERO;
} }
if (certificationPeriod != -99 && certificationPeriod != 99 if (certificationPeriod != -99 && certificationPeriod != 99
&& (certificationPeriod < 1 || certificationPeriod > 12)) { && (certificationPeriod < 1 || certificationPeriod > 12)) {
return null; return NumberEval.ZERO;
} else if (!formulaContext.getIsYear()) { } else if (!formulaContext.getIsYear()) {
if (certificationPeriod == -99) { if (certificationPeriod == -99) {
calendar.set(formulaContext.getYear(), formulaContext.getPeriod(), 1); calendar.set(formulaContext.getYear(), formulaContext.getPeriod(), 1);
...@@ -162,6 +162,6 @@ public class JXFP extends FunctionBase implements FreeRefFunction { ...@@ -162,6 +162,6 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId); saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
return new NumberEval(val); return new NumberEval(val);
} }
return null; return NumberEval.ZERO;
} }
} }
package pwc.taxtech.atms.vat.service.impl.report.functions;
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;
/// <summary>
/// 名称:进项发票明细
/// 功能:从发票取数,一般取发票金额或税额汇总数
/// </summary>
/// <param name="taxRate">税率——取值为17%,13%,11%,6%, 5%,3%,1.5%, 其他(其他表示除了17%,13%,11%,6%,5%,3%的税率)</param>
/// <param name="goodsName">货物名称——精确匹配引号中的值,99代表所有值(包括空值)</param>
/// <param name="amountType">取值——两种取值结果“金额” 0 和“税额” 1</param>
/// <param name="period">会计期间——三种取值结果 “-1”指上期,“0”当期,“99”当前累计(从期初到目前)</param>
/// <returns></returns>
public class JXFPMX extends FunctionBase implements FreeRefFunction {
public JXFPMX(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 4) {
return null;
}
String taxRate = getStringParam(args[0], ec);
String goodsName = getStringParam(args[1], ec);
int amountType = getIntParam(args[2], ec);
int period = getIntParam(args[3], ec);
String formulaExpression = "JXFPMX(\"" + taxRate + "\",\"" + goodsName + "\","
+ amountType + "," + period + ")";
logger.debug(formulaExpression);
return NumberEval.ZERO;
}
}
...@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl.report.functions; ...@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext; import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.EvaluationException; import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.OperandResolver; import org.apache.poi.ss.formula.eval.OperandResolver;
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;
...@@ -34,7 +35,7 @@ public class SGSR implements FreeRefFunction { ...@@ -34,7 +35,7 @@ public class SGSR implements FreeRefFunction {
} else if (valueEvals.length == 4) { } else if (valueEvals.length == 4) {
year = 0; year = 0;
} else { } else {
return null; return NumberEval.ZERO;
} }
ValueEval v1 = OperandResolver.getSingleValue(valueEvals[0], ValueEval v1 = OperandResolver.getSingleValue(valueEvals[0],
...@@ -68,7 +69,7 @@ public class SGSR implements FreeRefFunction { ...@@ -68,7 +69,7 @@ public class SGSR implements FreeRefFunction {
curYear = FormulaHelper.getYear(year, formulaContext); curYear = FormulaHelper.getYear(year, formulaContext);
curPeriod = 0; curPeriod = 0;
} else { } else {
return null; return NumberEval.ZERO;
} }
List<CellTemplatePerGroupDto> cellTemplatePerGroupDtoList = SpringContextUtil.periodTemplateMapper List<CellTemplatePerGroupDto> cellTemplatePerGroupDtoList = SpringContextUtil.periodTemplateMapper
...@@ -82,7 +83,7 @@ public class SGSR implements FreeRefFunction { ...@@ -82,7 +83,7 @@ public class SGSR implements FreeRefFunction {
.findFirst(); .findFirst();
if (cellTemplatePerGroupDto == null) { if (cellTemplatePerGroupDto == null) {
return null; return NumberEval.ZERO;
} }
//配置的行号列号都比 DB 中+1 //配置的行号列号都比 DB 中+1
...@@ -93,6 +94,6 @@ public class SGSR implements FreeRefFunction { ...@@ -93,6 +94,6 @@ public class SGSR implements FreeRefFunction {
} catch (EvaluationException e) { } catch (EvaluationException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return NumberEval.ZERO;
} }
} }
...@@ -58,14 +58,14 @@ public class XXFP extends FunctionBase implements FreeRefFunction { ...@@ -58,14 +58,14 @@ public class XXFP extends FunctionBase implements FreeRefFunction {
if (taxRate.equals("99")) { if (taxRate.equals("99")) {
taxRateVal = new BigDecimal("99"); taxRateVal = new BigDecimal("99");
} else { } else {
return null; return NumberEval.ZERO;
} }
} else { } else {
taxRate = StringUtils.removeEnd(taxRate, "%"); taxRate = StringUtils.removeEnd(taxRate, "%");
try { try {
taxRateVal = BigDecimal.valueOf(Double.parseDouble(taxRate)); taxRateVal = BigDecimal.valueOf(Double.parseDouble(taxRate));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
return null; return NumberEval.ZERO;
} }
taxRateVal = taxRateVal.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); //保留两位小数,然后四舍五入 taxRateVal = taxRateVal.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); //保留两位小数,然后四舍五入
} }
...@@ -124,6 +124,6 @@ public class XXFP extends FunctionBase implements FreeRefFunction { ...@@ -124,6 +124,6 @@ public class XXFP extends FunctionBase implements FreeRefFunction {
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId); saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId);
return new NumberEval(val); return new NumberEval(val);
} }
return null; return NumberEval.ZERO;
} }
} }
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