差旅报销单发票日期和行程期间校验
This commit is contained in:
parent
c7ede42470
commit
ad57e7f501
|
@ -76,15 +76,15 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
|
||||||
//发票明细
|
//发票明细
|
||||||
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||||
DynamicObjectCollection writeoffapply = dataEntity.getDynamicObjectCollection("writeoffapply");//关联的出差申请
|
DynamicObjectCollection writeoffapply = dataEntity.getDynamicObjectCollection("writeoffapply");//关联的出差申请
|
||||||
Date earliestAuditDate = null;
|
LocalDate earliestAuditDate = null;
|
||||||
for (DynamicObject dynamicObject : writeoffapply) {
|
for (DynamicObject dynamicObject : writeoffapply) {
|
||||||
//er_tripreqbill
|
//er_tripreqbill
|
||||||
long sourceapplybillid = dynamicObject.getLong("sourceapplybillid");
|
long sourceapplybillid = dynamicObject.getLong("sourceapplybillid");
|
||||||
DynamicObject tripreqbill = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "er_tripreqbill");
|
DynamicObject tripreqbill = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "er_tripreqbill");
|
||||||
boolean ischange = tripreqbill.getBoolean("ischange");//出差申请单发生过变更后,不进行校验
|
boolean ischange = tripreqbill.getBoolean("ischange");//出差申请单发生过变更后,不进行校验
|
||||||
Date auditDate = dynamicObject.getDate("zcgj_glsq_auditdate");
|
LocalDate auditDate = dateToLocalDate(dynamicObject.getDate("zcgj_glsq_auditdate"));
|
||||||
if (auditDate != null && !ischange) {
|
if (auditDate != null && !ischange) {
|
||||||
if (earliestAuditDate == null || auditDate.before(earliestAuditDate)) {
|
if (earliestAuditDate == null || auditDate.isBefore(earliestAuditDate)) {
|
||||||
earliestAuditDate = auditDate; // 保留最小审批日期
|
earliestAuditDate = auditDate; // 保留最小审批日期
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,15 +95,15 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
|
||||||
for (DynamicObject invoice : invoiceentry) {
|
for (DynamicObject invoice : invoiceentry) {
|
||||||
i++;
|
i++;
|
||||||
String invoicetype = invoice.getString("invoicetype");
|
String invoicetype = invoice.getString("invoicetype");
|
||||||
Date carrierDate = invoice.getDate("carrierdate"); // 乘车日期
|
LocalDate carrierDate = dateToLocalDate(invoice.getDate("carrierdate")); // 乘车日期
|
||||||
if(carrierDate != null){
|
if(carrierDate != null){
|
||||||
// 校验1: 是否在行程时间范围内
|
// 校验1: 是否在行程时间范围内
|
||||||
boolean inTripRange = false;
|
boolean inTripRange = false;
|
||||||
for (DynamicObject trip : tripentry) {
|
for (DynamicObject trip : tripentry) {
|
||||||
Date startDate = trip.getDate("startdate");
|
LocalDate startDate = dateToLocalDate(trip.getDate("startdate"));
|
||||||
Date endDate = trip.getDate("enddate");
|
LocalDate endDate = dateToLocalDate(trip.getDate("enddate"));
|
||||||
if (carrierDate != null && startDate != null && endDate != null) {
|
if (carrierDate != null && startDate != null && endDate != null) {
|
||||||
if (!carrierDate.before(startDate) && !carrierDate.after(endDate)) {
|
if (!carrierDate.isBefore(startDate) && !carrierDate.isAfter(endDate)) {
|
||||||
inTripRange = true;
|
inTripRange = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
|
||||||
|
|
||||||
// 校验2: 必须在最早审批日期之后
|
// 校验2: 必须在最早审批日期之后
|
||||||
if (earliestAuditDate != null && carrierDate != null && StringUtils.isEmpty(zcgjInvoiceremark)) {
|
if (earliestAuditDate != null && carrierDate != null && StringUtils.isEmpty(zcgjInvoiceremark)) {
|
||||||
if (carrierDate.compareTo(earliestAuditDate) != 0 && carrierDate.before(earliestAuditDate)) {
|
if (!carrierDate.isEqual(earliestAuditDate) && carrierDate.isBefore(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 + "】!");
|
||||||
}
|
}
|
||||||
|
@ -136,9 +136,14 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ
|
||||||
* @return java.time.LocalDate
|
* @return java.time.LocalDate
|
||||||
*/
|
*/
|
||||||
public static LocalDate dateToLocalDate(Date date) {
|
public static LocalDate dateToLocalDate(Date date) {
|
||||||
return date.toInstant()
|
if(date!=null){
|
||||||
.atZone(ZoneId.systemDefault())
|
return date.toInstant()
|
||||||
.toLocalDate();
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.toLocalDate();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue