Compare commits

..

No commits in common. "03e947fb722c0e794a8ef7cc639d7d53025e92ff" and "6870eb3602c84d143c3351f362079236b29e8976" have entirely different histories.

1 changed files with 16 additions and 63 deletions

View File

@ -2,9 +2,6 @@ package zcgj.zcdev.zcdev.fs.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.db.ResultSetHandler;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
@ -12,13 +9,8 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.math.BigDecimal;
import java.sql.ResultSet;
/*
对公报销单提交校验插件
说明1校验往来单位与开票公司是否一致不一致需填写特殊说明
2校验往来单位有预付但未冲销时需填写特殊说明
对公报销单提交校验插件校验往来单位与开票公司是否一致不一致需填写特殊说明
*/
public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
@ -30,8 +22,6 @@ public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
e.getFieldKeys().add("zcgj_invoiceremark");
e.getFieldKeys().add("makeoutcompname");
e.getFieldKeys().add("costcompany");
e.getFieldKeys().add("writeoffmoney");
e.getFieldKeys().add("srcbilltype");
//无合同付款相关
e.getFieldKeys().add("zcgj_isec");//工程单据
//e.getFieldKeys().add("zcgj_ecpaytype");//付款方式
@ -50,63 +40,26 @@ public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
DynamicObject costCompany = dataEntity.getDynamicObject("costcompany");//费用承担公司
if (costCompany != null) {
boolean isec = dataEntity.getBoolean("zcgj_isec");
if (costCompany != null && !isec) {
Long companyId = costCompany.getLong("id");
if (OrgCheckUtils.isKS(companyId)) {
//仅针对矿山下组织下的逻辑
boolean isec = dataEntity.getBoolean("zcgj_isec");//是否工程单据
String zcgj_invoiceremark = dataEntity.getString("zcgj_invoiceremark");//特殊说明
DynamicObject billPayerId = dataEntity.getDynamicObject("billpayerid");//往来单位
//1校验往来单位与开票公司是否一致不一致需填写特殊说明
if (!isec) {
DynamicObjectCollection invoiceEntryCollection = dataEntity.getDynamicObjectCollection("invoiceentry");//发票信息
if (invoiceEntryCollection.size() > 0) {
if (billPayerId != null) {
String billPayerIdName = billPayerId.getString("name");
for (DynamicObject invoiceEntry : invoiceEntryCollection) {
String makeOutCompName = invoiceEntry.getString("makeoutcompname");//开票公司
if (!makeOutCompName.equals(billPayerIdName) && "".equals(zcgj_invoiceremark)) {
//开票公司与往来单位名称不一致且特殊说明为空
this.addFatalErrorMessage(extendedDataEntity, "开票公司与往来单位存在不一致!请填写特殊说明!");
}
DynamicObjectCollection invoiceEntryCollection = dataEntity.getDynamicObjectCollection("invoiceentry");//发票信息
if (invoiceEntryCollection.size() > 0) {
DynamicObject billPayerId = dataEntity.getDynamicObject("billpayerid");//往来单位
String zcgj_invoiceremark = dataEntity.getString("zcgj_invoiceremark");//特殊说明
if (billPayerId != null) {
String billPayerIdName = billPayerId.getString("name");
for (DynamicObject invoiceEntry : invoiceEntryCollection) {
String makeOutCompName = invoiceEntry.getString("makeoutcompname");//开票公司
if (!makeOutCompName.equals(billPayerIdName) && "".equals(zcgj_invoiceremark)) {
//开票公司与往来单位名称不一致且特殊说明为空
this.addFatalErrorMessage(extendedDataEntity, "开票公司与往来单位存在不一致!请填写特殊说明!");
}
} else {
this.addFatalErrorMessage(extendedDataEntity, "往来单位为空");
}
}
}
//2校验往来单位有预付但未冲销时需填写特殊说明系统代码类ChangedAccountByPayer
if (billPayerId != null && "".equals(zcgj_invoiceremark)) {
DynamicObjectCollection writeOffMoneyCollection = dataEntity.getDynamicObjectCollection("writeoffmoney");//冲借款
boolean hasPrepayWriteOff = false;
// 检查是否有预付款冲销记录
for (DynamicObject writeOffMoney : writeOffMoneyCollection) {
String srcBillType = writeOffMoney.getString("srcbilltype");//源单类型
if ("er_prepaybill".equals(srcBillType)) {
hasPrepayWriteOff = true;
break;
}
}
// 如果没有预付款冲销记录则检查是否存在未冲销的预付款
if (!hasPrepayWriteOff) {
String sql = "select sum(t.fBalanceAmount) BalanceAmount from t_er_prepaybill t where fbillpayerid = " + (Long) billPayerId.getPkValue() + " and FCostCompanyID=" + companyId;
BigDecimal totalBalanceAmount = (BigDecimal) DB.query(DBRoute.of("er"), sql, (ResultSetHandler) resultSet -> {
BigDecimal balanceamount = BigDecimal.ZERO;
while (resultSet.next()) {
if (resultSet.getBigDecimal("BalanceAmount") != null) {
balanceamount = balanceamount.add(resultSet.getBigDecimal("BalanceAmount"));
}
}
return balanceamount;
});
if (totalBalanceAmount.compareTo(BigDecimal.ZERO) > 0) {
this.addFatalErrorMessage(extendedDataEntity, "往来单位有预付未冲销,不能再提交发起对公付款,请尽快提交冲销发票,才能再次付款,否则需要填写特殊说明!");
}
} else {
this.addFatalErrorMessage(extendedDataEntity, "往来单位为空");
}
}
}