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