Days Tariffs Matrix Documentation
Overview
The Days Tariffs Matrix is a feature in the Power Rent system that enables tiered pricing based on the duration of the rental period. It allows rental companies to define different price coefficients, extra kilometer prices, and daily kilometer allowances for varying ranges of rental days. This supports flexible pricing strategies, such as discounts for longer rentals.
Unlike the seasons matrix, which is time-based, the days matrix focuses on the length of the reservation in days. It is configured per vehicle for targeted adjustments.
Key Concepts
-
Tariff Entry: Each entry in the matrix defines:
- From Days: The starting day of the range (inclusive).
- Up To Days: The ending day of the range (inclusive).
- Price Coefficient: Multiplier applied to the base daily price.
- Base Km Day Coefficient: Multiplier for the daily kilometer allowance.
- Extra Km Price: Cost per extra kilometer beyond the allowance (optional override).
- Unlimited Kilometers: Boolean to indicate if kilometers are unlimited for this range.
-
Range Handling: Ranges should be contiguous and non-overlapping. The system selects the appropriate tariff based on the total rental days.
-
Fallback: If no matching range is found, the system uses the vehicle’s base price, extra km price, and base km/day.
Configuration
-
Assigning to Vehicles:
- In vehicle settings, add tariff entries via the Days Matrix interface.
- Specify day ranges, coefficients, and other parameters.
- Ensure ranges cover expected rental durations (e.g., 1-3 days, 4-7 days, 8+ days).
-
Validation:
- Ranges must be logical (fromDays <= upToDays).
- Avoid gaps or overlaps to prevent calculation errors.
Pricing Calculation Workflow
The matrix integrates into the pricing engine (primarily in lib/calculators.js):
- Calculate Rental Days: Determine the total days using
getDaysAmountByISO, considering tariffication variant and buffer time. - Find Actual Tariff: Use
findActualTariffPureorfindActualTariffto select the matching range:- If days exceed the maximum range, use the max range.
- If days are below the minimum, use the min range.
- Otherwise, find the exact matching range.
- Apply Parameters: From the selected tariff, apply:
- Adjusted daily price (base price * coefficient).
- Adjusted km/day (base km/day * coefficient).
- Overridden extra km price if specified.
- Unlimited km flag.
- Compute Total: Multiply adjusted daily price by days, add extras, etc.
Key Functions:
findActualTariffPure: Pure function to find the tariff for a given day count.getDefaultVehicleParametersPure: Retrieves adjusted parameters (price, extraKmPrice, baseKmDay, unlimitedKilometers) based on the selected tariff.- Integrated into
calculateTotalPricePurefor overall pricing.
Usage Examples
- Short-Term Premium: 1-3 days: price coefficient 1.2, base km/day 0.8.
- Long-Term Discount: 8+ days: price coefficient 0.85, unlimited kilometers true.
- Standard Weekly: 4-7 days: extra km price reduced to 0.50.
Best Practices
- Define comprehensive ranges to cover all possible rental lengths.
- Use coefficients to incentivize longer rentals.
- Combine with seasons matrix for multi-dimensional pricing.
- Test for various day counts to ensure correct tariff selection.
Related Documentation
- Seasons Tariffs Matrix
- Tariffs Matrix Architecture Changes
- ADR: Removal of Global Tariff Matrix Fallback
For implementation details, refer to the codebase, particularly lib/calculators.js and vehicle tariff resolvers.