红冲发票生成开票申请调试报错处理
This commit is contained in:
parent
677f7f9e56
commit
777419f1a9
|
@ -1,5 +1,6 @@
|
|||
package nccloud.api.so.saleinvoice.operator;
|
||||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.pubapp.pattern.log.Log;
|
||||
|
@ -13,10 +14,8 @@ import nc.vo.so.m32trantype.enumeration.Finvoicetime;
|
|||
import nc.vo.so.pub.enumeration.BillStatus;
|
||||
import nc.vo.so.pub.util.AggVOUtil;
|
||||
import nccloud.framework.core.exception.ExceptionUtils;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
import nccloud.itf.sscivm.ivsale.service.ExchangeToIvAppService;
|
||||
import nccloud.pubitf.so.saleinvoice.service.IM32TransTypeService;
|
||||
import nccloud.web.scmpub.pub.action.group.SysInitGroupQueryNcc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -40,10 +39,6 @@ public class ApplicationRedInvoiceService {
|
|||
public List<Map<String, String>> getData(SaleInvoiceVO[] vos) {
|
||||
Map<String, List<Map<String, String>>> dealMnyMap = new HashMap<String, List<Map<String, String>>>();
|
||||
try {
|
||||
if (!SysInitGroupQueryNcc.isEndable("1058")) {
|
||||
ExceptionUtils.wrapBusinessException(
|
||||
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4006013_0", "04006013-0038")/* @res "ÇëÆôÓ÷¢Æ±¹ÜÀíÄ£¿é£¡" */);
|
||||
}
|
||||
Map<String, Boolean> isCanGenerateMap = this.checkInvoiceStatus(AggVOUtil.getPrimaryKeys(vos));
|
||||
Map<String, M32TranTypeVO> invoicetime = this.qryinvoicetime(vos);
|
||||
|
||||
|
@ -91,10 +86,11 @@ public class ApplicationRedInvoiceService {
|
|||
if (ValueCheckUtil.isNullORZeroLength(billIds)) {
|
||||
return new HashMap<String, Boolean>();
|
||||
}
|
||||
if (!SysInitGroupQueryNcc.isEndable("1058")) {
|
||||
/*if (!SysInitGroupQueryNcc.isEndable("1058")) {
|
||||
return new HashMap<String, Boolean>();
|
||||
}
|
||||
return ServiceLocator.find(ExchangeToIvAppService.class).checkApplicationStatus(billIds);
|
||||
}*/
|
||||
ExchangeToIvAppService exchangeToIvAppService = NCLocator.getInstance().lookup(ExchangeToIvAppService.class);
|
||||
return exchangeToIvAppService.checkApplicationStatus(billIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +109,7 @@ public class ApplicationRedInvoiceService {
|
|||
// ĬÈÏÏÈÉóÅúͨ¹ýºó¿ªÆ±
|
||||
if (null != trantypeids && !trantypeids.isEmpty()) {
|
||||
try {
|
||||
IM32TransTypeService service = ServiceLocator.find(IM32TransTypeService.class);
|
||||
IM32TransTypeService service = NCLocator.getInstance().lookup(IM32TransTypeService.class);
|
||||
tranttypeMap = service.queryM32TranType(trantypeids.toArray(new String[0]));
|
||||
} catch (Exception e) {
|
||||
Log.info(e);
|
||||
|
|
|
@ -30,7 +30,6 @@ import nccloud.api.rest.utils.ResultMessageUtil;
|
|||
import nccloud.commons.lang.StringUtils;
|
||||
import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO;
|
||||
import nccloud.framework.core.exception.ExceptionUtils;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
import nccloud.itf.sscivm.ivsale.service.IVApplicationInvoiceService;
|
||||
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
|
||||
import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService;
|
||||
|
@ -205,7 +204,7 @@ public class IAPISaleInvMaitainImpl {
|
|||
// 查询新生成红冲发票的信息
|
||||
String newPk = returnApproveSaleInvoiceVOs[0].getParentVO().getCsaleinvoiceid();
|
||||
String[] idsNew = {newPk};
|
||||
// String[] idsNew = {"1001A11000000FREYYLE"};
|
||||
// String[] idsNew = {"1001A11000000FSB45YA"};
|
||||
SaleInvoiceVO[] redVos = querySaleInvoiceByIds(idsNew);
|
||||
|
||||
/**
|
||||
|
@ -567,8 +566,113 @@ public class IAPISaleInvMaitainImpl {
|
|||
}
|
||||
}
|
||||
|
||||
public IVApplicationAggVO saveIVApplication(JSONObject bject, SaleInvoiceVO[] redVos) throws Exception {
|
||||
SaleInvoiceHVO redHvo = redVos[0].getParentVO();
|
||||
// 获取 红字发票传开票申请的数据
|
||||
ApplicationRedInvoiceService applicationRedInvoiceService = new ApplicationRedInvoiceService();
|
||||
List<Map<String, String>> jeMap = applicationRedInvoiceService.getData(redVos);
|
||||
|
||||
IVApplicationAggVO applyVo = null;
|
||||
|
||||
String invId = bject.getOrDefault("vdef40", "") + "";
|
||||
|
||||
// 查询蓝字发票号对应的税务云开出的发票号
|
||||
String invCode = getSaleInvCode(invId);
|
||||
if (StringUtils.isBlank(invCode) || "null".equals(invCode)) {
|
||||
ExceptionUtils.wrapBusinessException("税务云的发票号不能为空");
|
||||
}
|
||||
IVApplicationInvoiceService ivService = NCLocator.getInstance().lookup(IVApplicationInvoiceService.class);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
// 构造开票申请的VO
|
||||
IVApplicationAggVO[] applicationAggVOS = ivService.getRedInvoice("", invCode, jsonObject1);
|
||||
Logger.error("saveIVApplication-jsonObject1 = " + jsonObject1);
|
||||
if (applicationAggVOS != null) {
|
||||
String src_billid = redHvo.getCsaleinvoiceid();
|
||||
String src_pk_org = redHvo.getPk_org();
|
||||
String src_billno = redHvo.getVbillcode();
|
||||
// String src_billtypeid = "";
|
||||
String src_tradetypeid = redHvo.getCtrantypeid();
|
||||
applicationAggVOS[0].getParentVO().setSrc_jx_billid(src_billid);
|
||||
applicationAggVOS[0].getParentVO().setSrc_jx_billno(src_billno);
|
||||
applicationAggVOS[0].getParentVO().setSrc_jx_billtypeid("32");
|
||||
applicationAggVOS[0].getParentVO().setSrc_jx_sporg(src_pk_org);
|
||||
// applicationAggVOS[0].getParentVO().setSrc_jx_spr(src_spr);
|
||||
applicationAggVOS[0].getParentVO().setSrc_jx_tradetypeid(src_tradetypeid);
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// ntotalorigmny 价税合计
|
||||
UFDouble ntotalorigmny = redHvo.getNtotalorigmny() == null ? UFDouble.ZERO_DBL : redHvo.getNtotalorigmny();
|
||||
for (IVApplicationAggVO applicationAggVO : applicationAggVOS) {
|
||||
// 在开具红字发票时,如果红冲的发票为增值税专用发票,红字信息申请表不能为空
|
||||
IVApplicationHeadVO headVO = applicationAggVO.getParentVO();
|
||||
// 红字信息申请表-赋值
|
||||
// headVO.setHzxxsqb("红字信息申请表");
|
||||
|
||||
IVApplicationBodyVO[] bodyVOs = applicationAggVO.getBodyVOs();
|
||||
UFDouble ntotalorigmnyDiv = ntotalorigmny.div(new UFDouble(bodyVOs.length)).setScale(2, UFDouble.ROUND_HALF_UP);
|
||||
for (IVApplicationBodyVO bodyVO : bodyVOs) {
|
||||
// bchcje 本次红冲金额的赋值(负数转正数)
|
||||
bodyVO.setBchcje(new UFDouble(ntotalorigmnyDiv).multiply(new UFDouble(-1)));
|
||||
}
|
||||
}
|
||||
// 红字发票生成开票申请动作
|
||||
IVApplicationAggVO[] ivApplicationVOs = ivService.makeRedInvoice(applicationAggVOS, jsonObject, jeMap);
|
||||
if (ivApplicationVOs != null && ivApplicationVOs.length > 0) {
|
||||
applyVo = ivApplicationVOs[0];
|
||||
}
|
||||
Logger.error("saveIVApplication-msg = " + jsonObject);
|
||||
return applyVo;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> getSaleOrderInfo(String csaleorderbid) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," +
|
||||
" sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate," +
|
||||
" nvl(sb.vchangerate, '1/1') vchangerate, bdc.code currencycode" +
|
||||
" from so_saleorder_b sb" +
|
||||
" inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" +
|
||||
" left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" +
|
||||
" where sb.csaleorderbid='" + csaleorderbid + "' ";
|
||||
return (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造红冲开票申请VO
|
||||
* 根据税务云单号查询发票的单号
|
||||
*
|
||||
* @param invId
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
private String getSaleInvCode(String invId) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " select nvl(vdef13, '') vdef13" +
|
||||
" from so_saleinvoice" +
|
||||
" where nvl(dr,0) = 0 and csaleinvoiceid = '" + invId + "' ";
|
||||
Map<String, String> resMap = (Map<String, String>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
return resMap.getOrDefault("vdef13", "");
|
||||
}
|
||||
|
||||
private String getString_TrimAsNull(Object value) {
|
||||
if ((value == null) || (value.toString().trim().isEmpty())) {
|
||||
return "";
|
||||
}
|
||||
return value.toString().trim();
|
||||
}
|
||||
|
||||
private UFDouble getUFDouble_NullAsZero(Object value) {
|
||||
if ((value == null) || (value.toString().trim().isEmpty()) || (value.toString().trim().equals("~")))
|
||||
return UFDouble.ONE_DBL;
|
||||
if ((value instanceof UFDouble))
|
||||
return (UFDouble) value;
|
||||
if ((value instanceof BigDecimal)) {
|
||||
return new UFDouble((BigDecimal) value);
|
||||
}
|
||||
return new UFDouble(value.toString().trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造红冲开票申请VO-废弃
|
||||
*
|
||||
* @param applyHeadVO 原开票申请主实体
|
||||
* @param ivApplicationBodyVOS 原开票申请子实体
|
||||
|
@ -663,80 +767,4 @@ public class IAPISaleInvMaitainImpl {
|
|||
}
|
||||
}
|
||||
|
||||
public IVApplicationAggVO saveIVApplication(JSONObject bject, SaleInvoiceVO[] redVos) throws Exception {
|
||||
// 获取 红字发票传开票申请的数据
|
||||
ApplicationRedInvoiceService applicationRedInvoiceService = new ApplicationRedInvoiceService();
|
||||
List<Map<String, String>> jeMap = applicationRedInvoiceService.getData(redVos);
|
||||
|
||||
IVApplicationAggVO applyVo = null;
|
||||
|
||||
String invId = bject.getOrDefault("vdef40", "") + "";
|
||||
|
||||
// 查询蓝字发票号对应的税务云开出的发票号
|
||||
String invCode = getSaleInvCode(invId);
|
||||
if (StringUtils.isBlank(invCode) || "null".equals(invCode)) {
|
||||
ExceptionUtils.wrapBusinessException("税务云的发票号不能为空");
|
||||
}
|
||||
IVApplicationInvoiceService ivService = ServiceLocator.find(IVApplicationInvoiceService.class);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
// 查询对应的蓝字发票
|
||||
IVApplicationAggVO[] blueVos = ivService.getRedInvoice("", invCode, jsonObject1);
|
||||
Logger.error("saveIVApplication-jsonObject1 = " + jsonObject1);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 红字发票生成开票申请动作
|
||||
IVApplicationAggVO[] ivApplicationVOs = ivService.makeRedInvoice(blueVos, jsonObject, jeMap);
|
||||
if (ivApplicationVOs != null && ivApplicationVOs.length > 0) {
|
||||
applyVo = ivApplicationVOs[0];
|
||||
}
|
||||
Logger.error("saveIVApplication-msg = " + jsonObject);
|
||||
return applyVo;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> getSaleOrderInfo(String csaleorderbid) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," +
|
||||
" sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate," +
|
||||
" nvl(sb.vchangerate, '1/1') vchangerate, bdc.code currencycode" +
|
||||
" from so_saleorder_b sb" +
|
||||
" inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" +
|
||||
" left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" +
|
||||
" where sb.csaleorderbid='" + csaleorderbid + "' ";
|
||||
return (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据税务云单号查询发票的单号
|
||||
*
|
||||
* @param invId
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
private String getSaleInvCode(String invId) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " select nvl(vdef13, '') vdef13" +
|
||||
" from so_saleinvoice" +
|
||||
" where nvl(dr,0) = 0 and csaleinvoiceid = '" + invId + "' ";
|
||||
Map<String, String> resMap = (Map<String, String>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
return resMap.getOrDefault("vbillcode", "");
|
||||
}
|
||||
|
||||
private String getString_TrimAsNull(Object value) {
|
||||
if ((value == null) || (value.toString().trim().isEmpty())) {
|
||||
return "";
|
||||
}
|
||||
return value.toString().trim();
|
||||
}
|
||||
|
||||
private UFDouble getUFDouble_NullAsZero(Object value) {
|
||||
if ((value == null) || (value.toString().trim().isEmpty()) || (value.toString().trim().equals("~")))
|
||||
return UFDouble.ONE_DBL;
|
||||
if ((value instanceof UFDouble))
|
||||
return (UFDouble) value;
|
||||
if ((value instanceof BigDecimal)) {
|
||||
return new UFDouble((BigDecimal) value);
|
||||
}
|
||||
return new UFDouble(value.toString().trim());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue