6. Changed Logic for Season Periods in Tariffs Matrix
Date: 2025-07-24
Status
Accepted
Context
Previously, season periods in the tariffs matrix might have allowed or required time specifications along with dates. This led to potential inconsistencies in pricing calculations, as partial days could complicate adjustments. To simplify user input and ensure consistent full-day applications, the logic was updated.
We decided to do this because we currently only offer daily tariffication, and many customers were confused about entering time for selected periods and did not understand how it worked.
Decision
- Users now select only dates for season periods (without time components).
- During pricing calculations (e.g., in lib/calculators.js):
- The ‘from’ date is automatically set to the start of the day (00:00:00).
- The ‘to’ date is set to the end of the day (23:59:59.999).
- This ensures seasons apply to entire days, improving accuracy in per-day pricing adjustments.
- Key implementation in getMillisFromSeasonTariffMatrix function, which adjusts timestamps to full-day boundaries.
- Infinite ranges are handled by setting null dates to minimum (0) or maximum (a far-future date) milliseconds.
Consequences
- Simplifies user interface by removing time selection, reducing errors.
- Ensures consistent full-day seasonal adjustments, potentially affecting pricing for reservations spanning partial days.
- Improves calculation reliability but requires updates to any existing season entries with time components.
- Enhances maintainability by standardizing date handling in calculations.