收款业务变更校验
This commit is contained in:
parent
323ca77b3f
commit
97623d2597
|
|
@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.EntityMetadataCache;
|
||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||
import kd.bos.form.control.events.BeforeClickEvent;
|
||||
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||
import kd.bos.form.control.events.ItemClickEvent;
|
||||
import kd.bos.list.BillList;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
|
|
@ -33,8 +35,11 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
|
|||
|
||||
private final static Log logger = LogFactory.getLog(RecBillChangeListExtendPlugin.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent evt) {
|
||||
public void beforeItemClick(BeforeItemClickEvent evt) {
|
||||
super.beforeItemClick(evt);
|
||||
|
||||
String key = evt.getItemKey();
|
||||
if (!"tblrecchg".equalsIgnoreCase(key)) {
|
||||
return;
|
||||
|
|
@ -44,6 +49,7 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
|
|||
ListSelectedRowCollection selectedRows = list.getSelectedRows();
|
||||
if (selectedRows == null || selectedRows.isEmpty()) {
|
||||
this.getView().showTipNotification("请选择需要操作的收款单!");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -59,27 +65,30 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
|
|||
String qzState = recBill.getString("shjh_qzzt");
|
||||
BigDecimal actrecamt = recBill.getBigDecimal("actrecamt");
|
||||
|
||||
// 校验:状态为“已收款” 且 来源为“收款入账中心/认领通知单”
|
||||
boolean isStatusC = "C".equals(billStatus);
|
||||
boolean isValidSource = "cas_claimcenterbill".equals(sourceBillType) || "bei_intelrec".equals(sourceBillType);
|
||||
if (!(isStatusC && isValidSource)) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,只有单据状态=“已收款”且源单类型=“收款入账中心/认领通知单”的收款单才允许变更。");
|
||||
// 状态 + 来源校验
|
||||
if (!("C".equals(billStatus) && (
|
||||
"cas_claimcenterbill".equals(sourceBillType) ||
|
||||
"bei_intelrec".equals(sourceBillType)))) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,只有状态=“已收款”且源单类型=“收款入账中心/认领通知单”的收款单才允许变更。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验:SAP凭证号不能为空
|
||||
// 凭证号非空
|
||||
if (voucherNum == null || voucherNum.trim().isEmpty()) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,SAP凭证号≠空。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验:收款类型必须为指定类型
|
||||
// 收款类型校验
|
||||
if (!Arrays.asList("103", "109", "100").contains(typeNumber)) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,只有收款类型=“预付款退回/员工还款/销售回款”的收款单才允许变更。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验清账状态
|
||||
// 清账状态判断
|
||||
boolean isAutoCleared = "A".equals(qzState) || "D".equals(qzState);
|
||||
boolean isToBeCleared = "B".equals(qzState);
|
||||
boolean isClearBillCancelled = false;
|
||||
|
|
@ -92,28 +101,30 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
|
|||
DynamicObject clearBill = BusinessDataServiceHelper.loadSingle(billId, "shjh_clear_account");
|
||||
if (clearBill != null && "D".equals(clearBill.getString("billstatus"))) {
|
||||
isClearBillCancelled = true;
|
||||
break; // 只要存在一个作废的清账单即可
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,下游未关联清账单。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(isAutoCleared || (isToBeCleared && isClearBillCancelled))) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,只有清账状态为“无需金蝶清账/反清账”,或清账状态为“待清账”且清账单已作废的收款单才允许变更。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验收款金额 > 0
|
||||
if (actrecamt == null || actrecamt.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
// 金额校验
|
||||
if (actrecamt.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,只有收款金额>0的收款单才允许变更。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// SAP清账状态校验
|
||||
boolean cleared = false;
|
||||
// SAP 清账状态校验
|
||||
String billNumber = recBill.getString("billno");
|
||||
String companyCode = recBill.getString("org.number");
|
||||
String sapFiscalYear = recBill.getString("shjh_sapfiscalyear");
|
||||
|
|
@ -127,19 +138,21 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
|
|||
JSONArray itItems = data.getJSONArray("IT_ITEMS");
|
||||
if (itItems != null && !itItems.isEmpty()) {
|
||||
JSONObject resultItem = itItems.getJSONObject(0);
|
||||
cleared = "y".equalsIgnoreCase(resultItem.getString("ZCLEARED"));
|
||||
if ("y".equalsIgnoreCase(resultItem.getString("ZCLEARED"))) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,该单据在SAP已清账。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("SAP返回清账状态解析异常:" + e.getMessage(), e);
|
||||
this.getView().showTipNotification("SAP清账状态查询失败,无法完成校验。");
|
||||
evt.setCancel(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cleared) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,该单据在SAP已清账。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验是否有付款申请锁定
|
||||
// 是否存在付款申请
|
||||
QFilter[] filters = new QFilter[]{
|
||||
new QFilter("org.number", QCP.equals, companyCode),
|
||||
new QFilter("shjh_vouchernum", QCP.equals, voucherNum),
|
||||
|
|
@ -149,10 +162,9 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
|
|||
DynamicObject payApply = BusinessDataServiceHelper.loadSingle("ap_payapply", filters);
|
||||
if (payApply != null) {
|
||||
this.getView().showTipNotification("所选单据不满足变更条件,存在SAP关联付款申请:" + payApply.getString("billno") + ",不允许变更。");
|
||||
return;
|
||||
evt.setCancel(true);
|
||||
}
|
||||
|
||||
// 到这里表示全部校验通过,可以继续执行变更逻辑
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue