February 3, 20232 yr Trying to calculate the estimated arrival date of a shipment. I believe I am overcomplicating it We ship same day before 3 pm otherwise, it ships on the next business day if it's Friday then Monday unless priority Saturday delivery is elected. Would like to make this more reliable. Grateful for a better approach. Let ( [ id = Method ; shipOn = Case( status = 0 ; Get(CurrentDate) ; INVOICES::Invoice_Date) ; w = DayOfWeek ( shipOn ) ; cutoff = Case ( Hour ( Get(CurrentHostTimestamp )) > 15 and w = 6 ; 2 ; 0 ) ]; shipOn + cutoff + Case ( //3Day id = 118 or id = 119; 3 + Case ( w ≥ 4 ; 2 ) ; //2Day id = 106 ; 2 + Case ( w ≥ 5 ; 2 ) ; //Std Overnight id = 116 ; 1 + Case ( w = 6 ; 1 ) ; //Priority id = 112 ; 1 + Case ( w = 6 ; 2 ) ; //SaturdayPriority id = 114 ; 1 ) )
February 3, 20232 yr I am not sure I follow your business rules. I think (!) it might be easier to calculate the target shipping date first, without considering the weekend. Then, if it falls on a weekend, delay it until Monday, unless it has a higher priority. Edited February 3, 20232 yr by comment
February 3, 20232 yr Author if the invoice is paid in full before 3pm we will ship same date M-F and based on service add 3 day / 2 days / 1 day (morning or afternoon) / and today is Friday they can elect Saturday delivery. Anytime after 3pm we will ship it out the next day plus days in transit. But if it's after 3pm on Friday it won't ship until Monday, almost seems to need to be recorusive a bit?
February 3, 20232 yr I am sorry, I missed the fact that the 1/2/3 days are days in transit, not days until shipment. Still, I think you should start with the day of shipment, then add the days in transit.
Create an account or sign in to comment