Admin - Products
What families buy (single lessons by length, trainings) and how it moves
Product mix: orders, hours, money and price per hour of each single-lesson length and each training, per period and in total
A purchase is an order whose money was collected (charged, partial_transfer, full_transfer), dated by lesson_order.created_at, the finance clock. An admin cancellation of the whole order removes it; the refund of single lessons leaves hours_bought and amount_paid unchanged and lowers only revenue_total. Accepts start_date_time, end_date_time, granularity, product_type, competence_school (the order's own), page/page_size (over the series periods) and sort_order; anything else is a 400.
Transition matrix: how the families' purchases moved between single lessons and trainings across a pivot date or a tariff change
Two windows of window_days each, [pivot − N, pivot) and [pivot, pivot + N). Each family with a purchase in either window is profiled per window as none, single_only, training_only or mixed, and counted in the cell of its (before, after) pair with what it bought on each side. Only complete days count: when the after-window reaches today both windows are shortened to the same effective length and `truncated` is true; a pivot today or later is a 400. compare_previous_year adds the same matrix one year earlier (same effective length), to tell the school-year seasonality from the effect of the pivot. Narrowed by competence school, a family is profiled on the purchases made in that competence only (lesson_order.competence_school_id), so a school sees what was bought from it. Accepts pivot_date or price_change_id, window_days, compare_previous_year and competence_school; date range and product_type are a 400.
Conversion cohorts: families whose first purchase was a single lesson, by month, and the share that bought a training within 30, 60 and 90 days
The first purchase is the first collected one over the whole history (narrowed by competence school: the first made in that competence); the date range selects the cohorts by the date of that first purchase. A rate is computed only over the families whose horizon has fully elapsed; the others are counted as not_yet_observable, and a rate over nobody is null. Accepts start_date_time, end_date_time, competence_school and sort_order (of the cohorts); anything else is a 400.