Compare commits
2 Commits
6870eb3602
...
03e947fb72
Author | SHA1 | Date |
---|---|---|
|
03e947fb72 | |
|
5407792a4a |
|
@ -2,6 +2,9 @@ package zcgj.zcdev.zcdev.fs.plugin.operate;
|
||||||
|
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
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.ExtendedDataEntity;
|
||||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||||
|
@ -9,8 +12,13 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||||
import kd.bos.entity.validate.AbstractValidator;
|
import kd.bos.entity.validate.AbstractValidator;
|
||||||
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
|
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
对公报销单提交校验插件:校验往来单位与开票公司是否一致,不一致需填写特殊说明
|
对公报销单提交校验插件
|
||||||
|
说明:1:校验往来单位与开票公司是否一致,不一致需填写特殊说明
|
||||||
|
2:校验往来单位有预付但未冲销时,需填写特殊说明
|
||||||
*/
|
*/
|
||||||
public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
|
public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
|
||||||
|
|
||||||
|
@ -22,6 +30,8 @@ public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
|
||||||
e.getFieldKeys().add("zcgj_invoiceremark");
|
e.getFieldKeys().add("zcgj_invoiceremark");
|
||||||
e.getFieldKeys().add("makeoutcompname");
|
e.getFieldKeys().add("makeoutcompname");
|
||||||
e.getFieldKeys().add("costcompany");
|
e.getFieldKeys().add("costcompany");
|
||||||
|
e.getFieldKeys().add("writeoffmoney");
|
||||||
|
e.getFieldKeys().add("srcbilltype");
|
||||||
//无合同付款相关
|
//无合同付款相关
|
||||||
e.getFieldKeys().add("zcgj_isec");//工程单据
|
e.getFieldKeys().add("zcgj_isec");//工程单据
|
||||||
//e.getFieldKeys().add("zcgj_ecpaytype");//付款方式
|
//e.getFieldKeys().add("zcgj_ecpaytype");//付款方式
|
||||||
|
@ -40,15 +50,17 @@ public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
|
||||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||||
DynamicObject costCompany = dataEntity.getDynamicObject("costcompany");//费用承担公司
|
DynamicObject costCompany = dataEntity.getDynamicObject("costcompany");//费用承担公司
|
||||||
boolean isec = dataEntity.getBoolean("zcgj_isec");
|
if (costCompany != null) {
|
||||||
if (costCompany != null && !isec) {
|
|
||||||
Long companyId = costCompany.getLong("id");
|
Long companyId = costCompany.getLong("id");
|
||||||
if (OrgCheckUtils.isKS(companyId)) {
|
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");//发票信息
|
DynamicObjectCollection invoiceEntryCollection = dataEntity.getDynamicObjectCollection("invoiceentry");//发票信息
|
||||||
if (invoiceEntryCollection.size() > 0) {
|
if (invoiceEntryCollection.size() > 0) {
|
||||||
DynamicObject billPayerId = dataEntity.getDynamicObject("billpayerid");//往来单位
|
|
||||||
String zcgj_invoiceremark = dataEntity.getString("zcgj_invoiceremark");//特殊说明
|
|
||||||
if (billPayerId != null) {
|
if (billPayerId != null) {
|
||||||
String billPayerIdName = billPayerId.getString("name");
|
String billPayerIdName = billPayerId.getString("name");
|
||||||
for (DynamicObject invoiceEntry : invoiceEntryCollection) {
|
for (DynamicObject invoiceEntry : invoiceEntryCollection) {
|
||||||
|
@ -63,6 +75,41 @@ public class PublicReimburPayerSubOp extends AbstractOperationServicePlugIn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//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, "往来单位有预付未冲销,不能再提交发起对公付款,请尽快提交冲销发票,才能再次付款,否则需要填写特殊说明!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue