收款业务变更校验2.0
This commit is contained in:
parent
97623d2597
commit
f367bcadc8
|
|
@ -25,7 +25,7 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin {
|
|||
@Override
|
||||
public void afterBindData(EventObject e) {
|
||||
super.afterBindData(e);
|
||||
this.getView().setVisible(false, RecFieldsInfo.ENTRY_CUSTOMER);
|
||||
//this.getView().setVisible(false, RecFieldsInfo.ENTRY_CUSTOMER);
|
||||
DynamicObjectCollection entry = (DynamicObjectCollection) this.getModel().getValue("entry");
|
||||
if (null != entry && entry.size() != 0) {
|
||||
setClosingStatus(entry);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ public class ClaimSubmitValidator extends AbstractValidator {
|
|||
if (null != receivingType) {
|
||||
String type = receivingType.getString("number");
|
||||
if (null != type) {
|
||||
if (!isAmountInvalid(type, reAmount, receivableAll, refundedAll, repaymentAll)) {
|
||||
//检查是否超额
|
||||
if (isAmountInvalid(type, reAmount, receivableAll, refundedAll, repaymentAll)) {
|
||||
String errorMessage = getErrorMessage(type, reAmount, receivableAll, refundedAll, repaymentAll);
|
||||
this.addErrorMessage(dataEntity, errorMessage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.validators;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.plugin.form.RecBillChangeListExtendPlugin;
|
||||
import shjh.jhzj7.fi.fi.plugin.form.info.RecFieldsInfo;
|
||||
import shjh.jhzj7.fi.fi.utils.SapUtils;
|
||||
|
||||
/**
|
||||
* 动态表单插件
|
||||
* 收款业务变更单提交清账状态校验
|
||||
*/
|
||||
public class ClosingStatusValidator extends AbstractValidator {
|
||||
private final static Log logger = LogFactory.getLog(ClosingStatusValidator.class);
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
if (dataEntities != null && dataEntities.length >= 1) {
|
||||
for (ExtendedDataEntity dataEntity : dataEntities) {
|
||||
if (dataEntity != null) {
|
||||
DynamicObject bill = dataEntity.getDataEntity();
|
||||
////付款方为一次性客户/供应商时,需校验国家、城市必录。
|
||||
String type = bill.getString(RecFieldsInfo.PAYER_TYPE);
|
||||
if ("bd_customer".equals(type)||"bd_supplier".equals(type)){
|
||||
long id = bill.getLong("payer");
|
||||
if (0L!=id){
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(id, type);
|
||||
if (null!=dynamicObject){
|
||||
String name = dynamicObject.getString("group.name");
|
||||
if (null!=name && name.contains("一次性客户")){
|
||||
String country = bill.getString("shjh_country");
|
||||
String city = bill.getString("shjh_city");
|
||||
if (country.isEmpty()||city.isEmpty()){
|
||||
this.addErrorMessage(dataEntity, "付款方为一次性客户/供应商时,国家、城市必录。");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String voucherNum = bill.getString("shjh_vouchernum");
|
||||
//如果收款单凭证号不为空
|
||||
if (!voucherNum.isEmpty()){
|
||||
//则需要调用SAP收款凭证清账状态查询接口
|
||||
String billNumber = bill.getString("billno");
|
||||
String companyCode = bill.getString("org.number");
|
||||
String sapFiscalYear = bill.getString("shjh_sapfiscalyear");
|
||||
String sapLineNumber = bill.getString("shjh_sapline");
|
||||
if (!sapLineNumber.isEmpty()&&!sapFiscalYear.isEmpty()){
|
||||
String response = SapUtils.querySapClearAccountsState(billNumber, companyCode, voucherNum, sapFiscalYear, sapLineNumber);
|
||||
if (response != null) {
|
||||
try {
|
||||
JSONObject json = JSONObject.parseObject(response);
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
JSONArray itItems = data.getJSONArray("IT_ITEMS");
|
||||
if (itItems != null && !itItems.isEmpty()) {
|
||||
JSONObject resultItem = itItems.getJSONObject(0);
|
||||
//如果已清,金蝶系统提示当前经办人不允许提交,需要前往SAP处理反清账后,再做收款变更。
|
||||
if ("y".equalsIgnoreCase(resultItem.getString("ZCLEARED"))) {
|
||||
this.addErrorMessage(dataEntity, "提交失败!所选单据在SAP已清账,需前往SAP处理反清账后,再做收款变更。");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("SAP返回清账状态解析异常:" + e.getMessage(), e);
|
||||
this.addErrorMessage(dataEntity, "SAP清账状态查询失败,无法完成校验。");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue