[#424] Confused around setWorkDayInfo and special days.

Migrated from Redmine #424 | Author: Juan Villegas
Status: New | Priority: High, I’m very impatient | Created: 2019-09-13


In our application we have two calendars, one where the User can mark their availability for each day of the week (not for a particular date, but rather specify their “opening” hours for Monday, tuesday, wednesday, etc), and another where they can choose specific dates they are not available and mark them as “day off”.
For the first calendar we are using setWorkDayInfo with breaktimes, etc, and it works perfectly well when the User hasn’t marked any dates as special.
If the user marks a date as special in the current week, and then tries to alter their weekly schedule using setWorkDayInfo, the API returns a success code but the change is not persisted. Even though we are not specifying a “date” in setWorkDayInfo, the API seems to ignore it because there is a “special” date in the current week.

My question is: has anyone experience this before?
And: is this expected behavior? Does setWorkDayInfo takes the current week as reference and ignores my changes if there are special dates in the current week?

Thanks in advance.
Juan Villegas

Company login: smylen

Our weekly calendar: Dropbox - Error - Simplify your life
Our quarter (to set dates off): Dropbox - Error - Simplify your life

Juan Villegas wrote:

I have also noticed that if I mark a date as “off” using:

{
  "is_day_off": 1,
  "date":schedule.date,
  "unit_group_id":doctor.simplyProviderId,
  "event_id":"1",
  "name": "",
  "index": "",
}

Then in simplyBook the date becomes a “special date”. If I then try to set “is_day_off” to false through the API, it is ignored.

I’m going crazy here. :smiley:

Redmine Admin wrote:

Hi, not sure which params you passed to this method. It is possible to set schedule for company|service|provider for week_day|date with this function.
Please check manual here: Company administration service methods - Company administration service methods - SimplyBook.me

In your example you were passed both event_id and unit_group_id which should never be done as we do not have schedule for service-provider pair. You need to pass event_id or provider_id but not both.

Juan Villegas wrote:

Hi, thanks for your answer. I appreciate it.
So let me try to explain myself again with a concrete example. The provider has marked days 16, 17, 18 and 19 of September as “special”, as she won’t be working those days. The provider now wants to edit her general hours of operation, so she issues the following request:

{
  "is_day_off": 0,
  "start_time": "08:00",
  "end_time": "18:00",
  "breaktime": [{start_time: "12:00", end_time: "13:00"}],
  "unit_group_id":doctor.simplyProviderId,
  "name": "Monday",
  "index": "1"
} 

This request:

  • Returns true but doesn’t alter the Provider’s calendar if current week’s monday is marked as special. It’s as if the API wasn’t able to override that for some reason.
  • Return true and works as expected if current week’s monday is not marked as special.

The issue mentioned in my second message is regarding removing the “special” day tag from a particular date. Assuming DATE_X is a “special” date, then executing the following:

{
  "is_day_off": 0,
  "date": DATE_X,
  "unit_group_id":doctor.simplyProviderId,
}

Returns true but doesn’t alter the calendar.

Note I have removed the event_id as you suggested but the bug/issue/error (not sure how to call it) is still there.

Thanks again for your help.
Juan

Redmine Admin wrote:

Hi, it seems there is some confusion about schedule priority.
Service/Provider special day schedule has highest priority and override week schedule. Company schedule has lowest priority.
E.g. if you have special day for provider and would set his weekly schedule on Monday it will not affect special day schedule because it do not change it.
If there is some special day settings then you need to alter it by passing exact day to this function

Juan Villegas wrote:

mm Yea, well, I kind of knew that. However, it should be possible to alter the general provider schedule even if there are some days marked as special in the current week right?
Let’s say the provider has marked next Friday as special, but also wants to set all Fridays operation hours to 2pm-4pm. It seems like that combination wouldn’t be possible with the API.

The only workaround for above example that I can think of with my (limited) knowledge of how this works is:
-test if the current week’s friday is special.
-if it is, unset the special day (using /deleteSpecialDay)
-change the schedule for all fridays
-set friday as special day again.

Which looks odd.

Redmine Admin wrote:

Hi, well, your workaround is actually correct way to solve this problem. This method should not clear special days if it was set, otherwise it may bring up some big-big problems.

Juan Villegas wrote:

No, but I think it should edit the schedule for days that aren’t marked as special. I’m actually a bit surprised no one stumbled with this before..
I’ll proceed with my solution even if it involves 4 api calls then.