收款单取消收款校验

This commit is contained in:
李贵强 2025-04-18 15:12:25 +08:00
parent fcc126a4f0
commit 281f6f497e
2 changed files with 58 additions and 18 deletions

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.MainEntityType;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.list.BillList;
@ -37,12 +38,6 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
super.beforeItemClick(evt);
String key = evt.getItemKey();
if (!"tblrecchg".equalsIgnoreCase(key)) {
return;
}
BillList list = (BillList) this.getView().getControl("billlistap");
ListSelectedRowCollection selectedRows = list.getSelectedRows();
if (selectedRows == null || selectedRows.isEmpty()) {
@ -50,12 +45,27 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
evt.setCancel(true);
return;
}
if (selectedRows.size()>1){
this.getView().showTipNotification("请选择单条数据进行变更");
evt.setCancel(true);
return;
}
DynamicObject recBill = BusinessDataServiceHelper.loadSingle(
DynamicObject recBill= BusinessDataServiceHelper.loadSingle(
selectedRows.get(0).getPrimaryKeyValue(),
EntityMetadataCache.getDataEntityType("cas_recbill")
);
EntityMetadataCache.getDataEntityType("cas_recbill"));
String key = evt.getItemKey().toLowerCase();
if ("tblrecchg".equals(key)) {
this.changeBillValidator(evt,recBill);
}else if ("cancelrec".equals(key)){
this.cancelRecValidator(evt,recBill);
}
}
private void changeBillValidator(BeforeItemClickEvent evt,DynamicObject recBill) {
String billStatus = recBill.getString("billstatus");
String sourceBillType = recBill.getString("sourcebilltype");
String voucherNum = recBill.getString("shjh_vouchernum");
@ -63,15 +73,6 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
String qzState = recBill.getString("shjh_qzzt");
BigDecimal actrecamt = recBill.getBigDecimal("actrecamt");
// 状态 + 来源校验-----标品已有
// if (!("C".equals(billStatus) && (
// "cas_claimcenterbill".equals(sourceBillType) ||
// "bei_intelrec".equals(sourceBillType)))) {
// this.getView().showTipNotification("所选单据不满足变更条件,只有状态=“已收款”且源单类型=“收款入账中心/认领通知单”的收款单才允许变更。");
// evt.setCancel(true);
// return;
// }
// 凭证号非空
if (voucherNum == null || voucherNum.trim().isEmpty()) {
this.getView().showTipNotification("所选单据不满足变更条件SAP凭证号≠空。");
@ -162,5 +163,12 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
}
}
private void cancelRecValidator(BeforeItemClickEvent evt,DynamicObject recBill) {
boolean ispushsap = recBill.getBoolean("shjh_ispushsap");
if (ispushsap){
this.getView().showTipNotification("已推送SAP,不允许取消收款!");
evt.setCancel(true);
}
}
}

View File

@ -4,6 +4,8 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
@ -22,6 +24,12 @@ import java.util.EventObject;
public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
this.addItemClickListeners("tbmain");
}
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
@ -82,6 +90,30 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin {
}
}
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
super.beforeItemClick(evt);
String key = evt.getItemKey().toLowerCase();
if ("bar_cancelrec".equals(key)) {
this.cancelRecValidator(evt);
}
}
/**
* 已推送SAP不允许取消收款
* @param evt
*/
private void cancelRecValidator(BeforeItemClickEvent evt) {
String billno = (String)this.getModel().getValue("billno");
DynamicObject recObj = BusinessDataServiceHelper.loadSingle("cas_recbill", "id,billno,isvoucher,billstatus,receivingtype,shjh_ispushsap", new QFilter[]{new QFilter("billno", "=", billno)});
boolean ispushsap = recObj.getBoolean("shjh_ispushsap");
if (ispushsap){
this.getView().showTipNotification("已推送SAP,不允许取消收款!");
evt.setCancel(true);
}
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);