[#1206] Get schedule REST API returns wrong time

Migrated from Redmine #1206 | Author: Ngoc Phung
Status: Closed | Priority: Immediate, there is BUG! | Created: 2024-03-27


Our account is https://marbodal.secure.simplybook.pro/

Service provider id 202 has special working hour on Mar 29 as Off, and I dont see any other schedule is setup on this date.

However, why trying to get the schedule with require https://user-api-v2.simplybook.pro/admin/schedule?date_from=2024-03-29&date_to=2024-03-29&service_id=20&provider_id[]=202, it returns
[
{
“id”: “2024-03-29”,
“date”: “2024-03-29”,
“time_from”: “00:00:00”,
“time_to”: “24:00:00”,
“is_day_off”: true
}
]

Can you pls advise urgently why is that so?

Mar 29 is Off day for service provider 202, should it be 00:00:00 to 00:00:00 instead?

There is one more case with April 8, that provider 202 is also off, but https://user-api-v2.simplybook.pro/admin/schedule?date_from=2024-04-08&date_to=2024-04-08&service_id=20&provider_id[]=202 is returning
[
{
“id”: “2024-04-08”,
“date”: “2024-04-08”,
“time_from”: “00:00:00”,
“time_to”: “23:45:00”,
“is_day_off”: true
}
]

My guess would that, the Company opening hour used to be 00:00:00 - 24:00:00, and lately it was changed to be 00:00:00- 23:45:00. However, the strange issue is that, the service provider is off for the day, why the api still returns time from/ time to?

Redmine Admin wrote:

please don’t pass any service_id and check results. It could happened if your provider don’t have special schedule but service do

Ngoc Phung wrote:

Hi, I checked and service has no special schedule.

And I also try to not pass any service id, and the data returned is the same.

Dmytro Bondarev wrote:

Hi could you please explain what is exactly not correct?
You have flag

"is_day_off": true 

which shows you that this provider is day off.

Ngoc Phung wrote:

yeah but may I ask why it’s still return time from 00:00:00 and time_to 24:00:00? and then, with Mar 28, it’s also off day, but it returns time from 00:00:00 and time_to 00:00:00?

Dmytro Bondarev wrote:

We do not reset time for schedule if user set it as day off.
You should always check is_day_off flag in your code.

Ngoc Phung wrote:

hmm I see. Can you help to explain this one as well?

We have another account Appointment booking service and free online booking service

when I try set up the same scenario and try with https://user-api-v2.enterpriseappointments.com/admin/schedule?date_from=2024-03-29&date_to=2024-03-29&service_id=3&provider_id[]=3, what returns is time from 00:00:00 and time_to 00:00:00
[
{
“id”: “2024-03-29”,
“date”: “2024-03-29”,
“time_from”: “00:00:00”,
“time_to”: “00:00:00”,
“is_day_off”: true
}
]

So there is difference between enterprise and pro version?

Dmytro Bondarev wrote:

There is no difference, but you have different setup on these companies.
For example you do not have schedule for service on pro server, but you do have on enterprise.

Ngoc Phung wrote:

on both server, I setup company opening hour as 00:00:00- 23:45:00, and there is no specific setup for service schedule, it just follows the company opening hour

Dmytro Bondarev wrote:

Unfortunately it is not true :slight_smile:
Please double check your settings for service with id=3 on enterprise server.

But main thing here is that you should always check flag is_day_off first and then look at the time.

Ngoc Phung wrote:

yeah I understand the point with is_day_off, will try that.

regarding to service id 3 on enterprise, here is how it looks from my sbm admin view Screenshot by Lightshot

but this makes me question, how you define if a service has its own working schedule or not?

With this service, I change its schedule several time before, and only today when trying to reproduce the issue, I change it to be 00:00:00- 23:45:00 which is the same as company hour.

However, seems like, for a service to be considered as not having schedule, it needs to stay untouched since the begining?

Dmytro Bondarev wrote:

You can see it from advanced schedule settings:

If you see “Clear custom schedule” it means that you have set custom schedule for service.

Ngoc Phung wrote:

AHA, that is very nice to know.

And I just realize why we didnt check for is_day_off before.

It was because of this issue Bug #1168: bug in the REST API /admin/schedule - API - Simplybook.me support for developers, that Sunday always has strange data, and is_day_off == false eventho it’s off day. But it was fixed now, so we could safely check this property now.

Thanks a lot Dmytro.

Dmytro Bondarev wrote:

You are welcome!

(Short original content)