Repository navigation
fix(schedule): charge credits for custom-layout reservations - #1879
Open
abu-tahir-0 wants to merge 2 commits into
Open
abu-tahir-0 wants to merge 2 commits into
abu-tahir-0 wants to merge 2 commits into
Conversation
|
Thank you for opening your first pull request in LibreBooking! 🎉 LibreBooking is maintained by volunteers. You will likely get a |
CustomScheduleLayout::GetSlotCount() returned an empty SlotCount, so a reservation on a custom-layout schedule was always charged 0 credits and ReservationSeries::TotalSlots() read properties off an int. Count the reservable periods of the reservation's day that the reservation fully covers, and split them into peak and off-peak slots. Custom layouts never set ScheduleLayout::$layoutTimezone, so the peak times, which were parsed in the server default, are moved to the slot's timezone before the comparison; otherwise peak hours are evaluated against the server clock. This changes billing for sites that use credits together with custom layouts: those reservations are no longer free.
abu-tahir-0
force-pushed
the
fix/1871-custom-layout-credits
branch
from
November 10, 2026 03:23
068f80d to
da6dd6b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Reservations on a custom-layout schedule were always charged 0 credits.
CustomScheduleLayout::GetSlotCount()returned an emptySlotCount, soReservationSeries::TotalSlots()readOffPeak/Peakoff an int (two warnings per instance) and every reservation cost nothing.Peak times were also evaluated in the server's default timezone on custom layouts:
ScheduleLayout::$layoutTimezoneis only set byAppendGenericPeriod(), whichCustomScheduleLayoutoverrides as a no-op. The loaded custom slots carry the schedule timezone, so the peak classification is now done against the slot's timezone.The change counts the reservable periods of the reservation's day that the instance fully covers and splits them into peak and off-peak, following
ScheduleLayout::GetSlotCount(). Custom layouts still useGetLayout()for their slots, and the cache key stays the date.This changes billing: sites that use credits together with custom layouts will start charging for those reservations, which is the intended fix for the issue and worth a release note.
Related issues
Closes: #1871
Checklist
developbranch.Testing
vendor/bin/phpunit --filter 'testCustomScheduleLayout' tests/Application/Schedule/ScheduleLayoutTest.phpdevelop, the four new behaviour tests fail (counts are0,0and the instance is charged0).OK (6 tests, 8 assertions).The tests cover fully covered slots, partially covered slots, a day with no custom slots, the peak/off-peak split when the server timezone differs from the schedule timezone, and
ReservationSeries::CalculateCredits().Full unit suite: 2134 tests, with the same 40 errors and 3 failures as before the change. Those are
Missing config filefailures from this checkout (lib/Config/Configuration.php), unrelated to the change.php-cs-fixerdry-run andphpstan analyse Domain/ScheduleLayout.phpreport no issues.