-
Mahmoud Aglan authored
A programme can now bundle products it requires (program_products), so the group view can answer "who has not bought their registration card" — which nothing in the system could express before. products.is_essential is global; this is per-programme. Each bundled product gets its own column: bought or not, a progress bar, and the amount settled against the amount billed. Instalments fall out of this for free rather than needing their own column. Reading a payment off a line is not possible here — a subscription and a registration card routinely share one invoice. ParticipantBillingService allocates each payment across the lines it covers, pro rata on subtotal_amount, rounding down so the remainder stays unallocated rather than inventing money. Allocation is capped at the amount billed: a payment settles total_amount, which also carries tax and fees, so paying in full would otherwise allocate over 100% of a line. Verified against production — no invoice over-allocates. The payment column now shows the amount paid rather than a bare "paid", with مجاني for free players and لم يدفع for unpaid, and participants carry their عضو / غير عضو tag. The enrolment-date column is gone. Total collected is shown to users with invoices.list. The bundling migration is conditional: it acts only where an academy has both an active product named قيد and programmes named فريق. Elsewhere it does nothing, which is what makes it safe for every tenant. On oc-sport that is exactly one product across 12 programmes. Co-Authored-By:Claude Opus 5 (1M context) <noreply@anthropic.com>
b6fd3fb7