Advertisement
SoniaMilena

public class CalcularDiasColombia.vr02

Aug 26th, 2019
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. public class CalcularDiasColombia {
  2.     public class BusinessDays{
  3.         public BusinessHours bHours;
  4.  
  5.         public BusinessDays(String businessHoursName){
  6.        
  7.         bHours = [SELECT Id FROM BusinessHours WHERE Name =: businessHoursName];
  8.         }
  9.         public BusinessDays(){
  10.        
  11.         bHours = [SELECT Id FROM BusinessHours WHERE IsDefault = true];
  12.         }
  13.         public Datetime addDays(Datetime startDate, Integer days){
  14.             BusinessDays bd = new BusinessDays('BusinessHours');
  15.             bd.addDays (Date.today (), 3);
  16.  
  17.             startDate = BusinessHours.nextStartDate(bHours.Id, startDate);
  18.            
  19.             for (Integer elapsed = 0; elapsed < days; elapsed++){
  20.                
  21.                 startDate = startDate.addDays(1);
  22.                
  23.                 if (!BusinessHours.isWithin(bHours.Id, startDate)){
  24.                    
  25.                     startDate = BusinessHours.nextStartDate(bHours.Id, startDate);
  26.                 }
  27.             }
  28.             return startDate;
  29.         }
  30.     }
  31. }
  32.  
  33. @isTest
  34.     public class CaluclarDiasColombiaTest {
  35.  
  36.         /*Test.startTest();
  37.         Test.stopTest();*/
  38.  
  39.         //System.assertEquals();
  40.  
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement