发票问题修改
This commit is contained in:
parent
4a2828c944
commit
26d54d61a3
|
@ -1,15 +1,22 @@
|
||||||
package shkd.fi.fi.formplugin;
|
package shkd.fi.fi.formplugin;
|
||||||
|
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
|
import kd.bos.dataentity.OperateOption;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.entity.datamodel.events.AfterDeleteRowEventArgs;
|
||||||
|
import kd.bos.entity.datamodel.events.BeforeDeleteRowEventArgs;
|
||||||
|
import kd.bos.entity.operate.OperateOptionConst;
|
||||||
|
import kd.bos.entity.property.EntryProp;
|
||||||
import kd.bos.form.CloseCallBack;
|
import kd.bos.form.CloseCallBack;
|
||||||
import kd.bos.form.FormShowParameter;
|
import kd.bos.form.FormShowParameter;
|
||||||
import kd.bos.form.ShowType;
|
import kd.bos.form.ShowType;
|
||||||
import kd.bos.form.control.events.ItemClickEvent;
|
import kd.bos.form.control.events.ItemClickEvent;
|
||||||
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||||
import kd.bos.form.events.ClosedCallBackEvent;
|
import kd.bos.form.events.ClosedCallBackEvent;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
|
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ApFinapbillFormPlugin extends AbstractBillPlugIn {
|
public class ApFinapbillFormPlugin extends AbstractBillPlugIn {
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,15 +29,33 @@ public class ApFinapbillFormPlugin extends AbstractBillPlugIn {
|
||||||
public void itemClick(ItemClickEvent evt) {
|
public void itemClick(ItemClickEvent evt) {
|
||||||
super.itemClick(evt);
|
super.itemClick(evt);
|
||||||
String itemKey = evt.getItemKey();
|
String itemKey = evt.getItemKey();
|
||||||
|
|
||||||
|
//发票采集按钮
|
||||||
if ("shkd_fpocr".equals(itemKey)) {
|
if ("shkd_fpocr".equals(itemKey)) {
|
||||||
FormShowParameter parameter = new FormShowParameter();
|
FormShowParameter parameter = new FormShowParameter();
|
||||||
|
parameter.setCustomParam("billno", this.getModel().getValue("billno"));//应付单单据编号
|
||||||
|
DynamicObject asstact = (DynamicObject) this.getModel().getValue("asstact");//往来户
|
||||||
|
DynamicObject org = (DynamicObject) this.getModel().getValue("org");//结算组织
|
||||||
|
String asstactName = "";
|
||||||
|
if (asstact == null) {
|
||||||
|
this.getView().showMessage("请选择结算供应商");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
asstactName = asstact.getLocaleString("name").getLocaleValue_zh_CN();
|
||||||
|
parameter.setCustomParam("asstactName", asstactName);//往来户
|
||||||
|
String orgName = "";
|
||||||
|
if (org == null) {
|
||||||
|
this.getView().showMessage("请选择结算组织");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
orgName = org.getString("name");
|
||||||
|
parameter.setCustomParam("orgName", orgName);//结算组织 org
|
||||||
Object id = this.getModel().getValue("id");
|
Object id = this.getModel().getValue("id");
|
||||||
if (id.equals(0L)) {
|
if (id.equals(0L)) {
|
||||||
this.getView().showMessage("请先保存单据");
|
this.getView().showMessage("请先保存单据");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parameter.setCustomParam("id", id);
|
parameter.setCustomParam("id", id);//应付单id
|
||||||
parameter.setCustomParam("billno", this.getModel().getValue("billno"));
|
|
||||||
parameter.setFormId("shkd_uploadattachments");
|
parameter.setFormId("shkd_uploadattachments");
|
||||||
parameter.setCloseCallBack(new CloseCallBack(this, "shkd_fpocr"));
|
parameter.setCloseCallBack(new CloseCallBack(this, "shkd_fpocr"));
|
||||||
parameter.getOpenStyle().setShowType(ShowType.Modal);
|
parameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||||
|
@ -42,7 +67,42 @@ public class ApFinapbillFormPlugin extends AbstractBillPlugIn {
|
||||||
@Override
|
@Override
|
||||||
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||||
super.closedCallBack(closedCallBackEvent);
|
super.closedCallBack(closedCallBackEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeDeleteRow(BeforeDeleteRowEventArgs e) {
|
||||||
|
super.beforeDeleteRow(e);
|
||||||
|
EntryProp entryProp = e.getEntryProp();
|
||||||
|
String entryPropName = entryProp.getName();
|
||||||
|
OperateOption option = OperateOption.create();
|
||||||
|
option.setVariableValue(OperateOptionConst.ISHASRIGHT, "true");
|
||||||
|
option.setVariableValue(OperateOptionConst.IGNOREWARN, "true");
|
||||||
|
if ("inventry".equals(entryPropName)) {
|
||||||
|
int[] rowIndexs = e.getRowIndexs();
|
||||||
|
if (rowIndexs.length > 0) {
|
||||||
|
int row = rowIndexs[0];
|
||||||
|
DynamicObject shkd_invoicereceipt = (DynamicObject) this.getModel().getValue("shkd_invoicereceipt", row);
|
||||||
|
if (shkd_invoicereceipt != null) {
|
||||||
|
DynamicObject invoicereceipt = BusinessDataServiceHelper.loadSingle(shkd_invoicereceipt.get("id"), "shkd_invoicereceipt");
|
||||||
|
OperationServiceHelper.executeOperate("unaudit", "shkd_invoicereceipt", new DynamicObject[]{invoicereceipt}, option);
|
||||||
|
OperationServiceHelper.executeOperate("delete", "shkd_invoicereceipt", new DynamicObject[]{invoicereceipt}, option);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterDeleteRow(AfterDeleteRowEventArgs e) {
|
||||||
|
super.afterDeleteRow(e);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
|
||||||
|
super.afterDoOperation(afterDoOperationEventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package shkd.fi.fi.formplugin;
|
||||||
import com.alibaba.druid.support.logging.Log;
|
import com.alibaba.druid.support.logging.Log;
|
||||||
import com.alibaba.druid.support.logging.LogFactory;
|
import com.alibaba.druid.support.logging.LogFactory;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import dm.jdbc.util.StringUtil;
|
||||||
import kd.bos.cache.CacheFactory;
|
import kd.bos.cache.CacheFactory;
|
||||||
import kd.bos.cache.DistributeSessionlessCache;
|
import kd.bos.cache.DistributeSessionlessCache;
|
||||||
import kd.bos.cache.TempFileCache;
|
import kd.bos.cache.TempFileCache;
|
||||||
|
@ -53,11 +54,11 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
* OCR发票识别接口url
|
* OCR发票识别接口url
|
||||||
*/
|
*/
|
||||||
// public static final String OCR_INVOICESCANNER_URL = "https://apigw.coscoshipping.com/tax/ocr/v1/invoiceScanner";
|
// public static final String OCR_INVOICESCANNER_URL = "https://apigw.coscoshipping.com/tax/ocr/v1/invoiceScanner";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发票验证接口url
|
* 发票验证接口url
|
||||||
*/
|
*/
|
||||||
// public static final String COMPLIANCECOLLECTZY_URL = "https://apigw.coscoshipping.com/tax/input/v1/compliancecollectZY";
|
// public static final String COMPLIANCECOLLECTZY_URL = "https://apigw.coscoshipping.com/tax/input/v1/compliancecollectZY";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerListener(EventObject e) {
|
public void registerListener(EventObject e) {
|
||||||
super.registerListener(e);
|
super.registerListener(e);
|
||||||
|
@ -88,6 +89,10 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
Object id = formShowParameter.getCustomParam("id");
|
Object id = formShowParameter.getCustomParam("id");
|
||||||
//财务应付单号
|
//财务应付单号
|
||||||
String billno = formShowParameter.getCustomParam("billno");
|
String billno = formShowParameter.getCustomParam("billno");
|
||||||
|
//往来户
|
||||||
|
String asstactName = formShowParameter.getCustomParam("asstactName");
|
||||||
|
//结算组织
|
||||||
|
String orgName = formShowParameter.getCustomParam("orgName");
|
||||||
//财务应付单
|
//财务应付单
|
||||||
DynamicObject ap_finapbill = BusinessDataServiceHelper.loadSingle(id, "ap_finapbill");
|
DynamicObject ap_finapbill = BusinessDataServiceHelper.loadSingle(id, "ap_finapbill");
|
||||||
|
|
||||||
|
@ -198,6 +203,16 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
}
|
}
|
||||||
List<Response> responseList = ocrRetureData.getResponse();
|
List<Response> responseList = ocrRetureData.getResponse();
|
||||||
Response response = responseList.get(0);
|
Response response = responseList.get(0);
|
||||||
|
String saleName = response.getSaleName();//开票公司
|
||||||
|
if (StringUtils.isNotEmpty(saleName) && !StringUtil.equals(asstactName, saleName)) {
|
||||||
|
this.getView().showMessage("发票开票单位和当前单据上结算供应商不一致");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String purchaserName = response.getPurchaserName();//收票公司
|
||||||
|
if (StringUtils.isNotEmpty(purchaserName) && !StringUtil.equals(orgName, purchaserName)) {
|
||||||
|
this.getView().showMessage("发票收票公司和当前应付单结算组织不匹配");
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<DetailList> detailList = response.getDetailList();
|
List<DetailList> detailList = response.getDetailList();
|
||||||
BigDecimal shkd_tax = BigDecimal.ZERO;//税额
|
BigDecimal shkd_tax = BigDecimal.ZERO;//税额
|
||||||
BigDecimal shkd_amount = BigDecimal.ZERO;//金额
|
BigDecimal shkd_amount = BigDecimal.ZERO;//金额
|
||||||
|
@ -246,6 +261,7 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
this.getView().showMessage(message);
|
this.getView().showMessage(message);
|
||||||
}
|
}
|
||||||
|
this.getView().showMessage("发票已识别验真通过,生成发票明细成功");
|
||||||
//2.5.发票合规查验接口调用成功 生成发票识别单据
|
//2.5.发票合规查验接口调用成功 生成发票识别单据
|
||||||
DynamicObject shkd_invoicereceipt = BusinessDataServiceHelper.newDynamicObject("shkd_invoicereceipt");
|
DynamicObject shkd_invoicereceipt = BusinessDataServiceHelper.newDynamicObject("shkd_invoicereceipt");
|
||||||
shkd_invoicereceipt.set("billno", String.valueOf(System.currentTimeMillis()));
|
shkd_invoicereceipt.set("billno", String.valueOf(System.currentTimeMillis()));
|
||||||
|
@ -286,7 +302,7 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
shkd_invoicereceipt.set("shkd_invid", null);//发票id 隐藏字段
|
shkd_invoicereceipt.set("shkd_invid", null);//发票id 隐藏字段
|
||||||
shkd_invoicereceipt.set("shkd_serialno", null);//发票流水号 隐藏字段
|
shkd_invoicereceipt.set("shkd_serialno", null);//发票流水号 隐藏字段
|
||||||
shkd_invoicereceipt.set("shkd_refbill", ap_finapbill);//财务应付单
|
shkd_invoicereceipt.set("shkd_refbill", ap_finapbill);//财务应付单
|
||||||
shkd_invoicereceipt.set("billstatus", "A");
|
shkd_invoicereceipt.set("billstatus", "C");
|
||||||
shkd_invoicereceipt.set("creator", RequestContext.get().getCurrUserId());
|
shkd_invoicereceipt.set("creator", RequestContext.get().getCurrUserId());
|
||||||
|
|
||||||
// option.setVariableValue(OperateOptionConst.ORM_SAVEOP_REMOVECACHE, "true");
|
// option.setVariableValue(OperateOptionConst.ORM_SAVEOP_REMOVECACHE, "true");
|
||||||
|
@ -307,9 +323,9 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
|
|
||||||
//回写发票信息到财务应付单发票明细
|
//回写发票信息到财务应付单发票明细
|
||||||
if (!returnDataList.isEmpty()) {
|
if (!returnDataList.isEmpty()) {
|
||||||
|
ap_finapbill.set("istaxdeduction", false);//进项税抵扣
|
||||||
DynamicObjectCollection inventry = ap_finapbill.getDynamicObjectCollection("inventry");
|
DynamicObjectCollection inventry = ap_finapbill.getDynamicObjectCollection("inventry");
|
||||||
inventry.clear();
|
// inventry.clear();
|
||||||
|
|
||||||
IFormView parentView = this.getView().getParentView();
|
IFormView parentView = this.getView().getParentView();
|
||||||
for (DynamicObject dynamicObject : returnDataList) {
|
for (DynamicObject dynamicObject : returnDataList) {
|
||||||
|
@ -347,7 +363,8 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
try {
|
try {
|
||||||
//current transaction is aborted, commands ignored until end of transaction block
|
//current transaction is aborted, commands ignored until end of transaction block
|
||||||
//保存财务应付单
|
//保存财务应付单
|
||||||
SaveServiceHelper.save(new DynamicObject[]{ap_finapbill}, option);
|
// SaveServiceHelper.save(new DynamicObject[]{ap_finapbill}, option);
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{ap_finapbill});
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
h.markRollback();
|
h.markRollback();
|
||||||
log.info(e.getMessage());
|
log.info(e.getMessage());
|
||||||
|
|
Loading…
Reference in New Issue