差旅报销单发票日期和行程期间校验

This commit is contained in:
zhangzhiguo 2025-09-29 13:48:46 +08:00
parent 144947a518
commit a87f8845cf
1 changed files with 16 additions and 7 deletions

View File

@ -3,13 +3,14 @@ package zcgj.zcdev.zcdev.fs.plugin.operate;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
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.dataentity.utils.StringUtils;
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;
import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator; import kd.bos.entity.validate.AbstractValidator;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper;
import kd.bos.util.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
@ -35,6 +36,7 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
e.getFieldKeys().add("enddate");//行程结束时间 e.getFieldKeys().add("enddate");//行程结束时间
e.getFieldKeys().add("invoiceentry");//发票信息 e.getFieldKeys().add("invoiceentry");//发票信息
e.getFieldKeys().add("writeoffapply");//关联申请 e.getFieldKeys().add("writeoffapply");//关联申请
e.getFieldKeys().add("zcgjInvoiceremark");//特殊说明
} }
@Override @Override
@ -68,6 +70,7 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
String number = costcompany.getString("number"); String number = costcompany.getString("number");
if(OrgCheckUtils.isKS(costcompanyId) && !number.equals("10006476")){ if(OrgCheckUtils.isKS(costcompanyId) && !number.equals("10006476")){
List<String> errorList = new ArrayList<>(); List<String> errorList = new ArrayList<>();
String zcgjInvoiceremark = dataEntity.getString("zcgj_invoiceremark");//特殊说明
//行程明细会有多个明细 //行程明细会有多个明细
DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("tripentry"); DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("tripentry");
//发票明细 //发票明细
@ -75,8 +78,12 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
DynamicObjectCollection writeoffapply = dataEntity.getDynamicObjectCollection("writeoffapply");//关联的出差申请 DynamicObjectCollection writeoffapply = dataEntity.getDynamicObjectCollection("writeoffapply");//关联的出差申请
Date earliestAuditDate = null; Date earliestAuditDate = null;
for (DynamicObject dynamicObject : writeoffapply) { for (DynamicObject dynamicObject : writeoffapply) {
//er_tripreqbill
long sourceapplybillid = dynamicObject.getLong("sourceapplybillid");
DynamicObject tripreqbill = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "er_tripreqbill");
boolean ischange = tripreqbill.getBoolean("ischange");//出差申请单发生过变更后不进行校验
Date auditDate = dynamicObject.getDate("zcgj_glsq_auditdate"); Date auditDate = dynamicObject.getDate("zcgj_glsq_auditdate");
if (auditDate != null) { if (auditDate != null && !ischange) {
if (earliestAuditDate == null || auditDate.before(earliestAuditDate)) { if (earliestAuditDate == null || auditDate.before(earliestAuditDate)) {
earliestAuditDate = auditDate; // 保留最小审批日期 earliestAuditDate = auditDate; // 保留最小审批日期
} }
@ -103,15 +110,15 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
} }
} }
if (!inTripRange) { if (!inTripRange && StringUtils.isEmpty(zcgjInvoiceremark)) {
//throw new RuntimeException("乘车日期【" + carrierDate + "】不在任何行程时间范围内!"); //throw new RuntimeException("乘车日期【" + carrierDate + "】不在任何行程时间范围内!");
this.addFatalErrorMessage(extendedDataEntity, String.format("发票信息中的第%d行乘车/机日期不在任何行程时间范围内",i)); this.addFatalErrorMessage(extendedDataEntity, String.format("发票信息中的第%d行乘车/机日期不在任何行程时间范围内,请填写特殊说明",i));
} }
// 校验2: 必须在最早审批日期之后 // 校验2: 必须在最早审批日期之后
if (earliestAuditDate != null && carrierDate != null) { if (earliestAuditDate != null && carrierDate != null && StringUtils.isEmpty(zcgjInvoiceremark)) {
if (carrierDate.before(earliestAuditDate)) { if (carrierDate.compareTo(earliestAuditDate) != 0 && carrierDate.before(earliestAuditDate)) {
this.addFatalErrorMessage(extendedDataEntity, String.format("发票信息中的第%d行乘车/机日期早于关联申请最早审批日期",i)); this.addFatalErrorMessage(extendedDataEntity, String.format("发票信息中的第%d行乘车/机日期早于关联申请最早审批日期,请填写特殊说明",i));
//throw new RuntimeException("乘车日期【" + carrierDate + "】早于出差申请最早审批日期【" + earliestAuditDate + "】!"); //throw new RuntimeException("乘车日期【" + carrierDate + "】早于出差申请最早审批日期【" + earliestAuditDate + "】!");
} }
} }
@ -133,4 +140,6 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.systemDefault())
.toLocalDate(); .toLocalDate();
} }
} }