• Mahmoud Aglan's avatar
    fix(branch): the catalogue belongs to a branch too, and events belong to none · d3cbd5f1
    Mahmoud Aglan authored
    The first pass put programmes, products, prices, promotions, warehouses and
    receipt templates in the *shared* bucket, where `branch_id IS NULL` means "every
    branch uses this row". The reasoning was that a missing base price is a hard
    failure that stops a sale, so hard-filtering the catalogue risked leaving a
    branch unable to sell anything.
    
    That bought safety with the wrong currency. A branch is meant to read as its own
    installation — its own programmes at its own prices, its own products, its own
    stores — and a programme offered at one branch turning up in another branch's
    dropdown is the same bug as a group doing it. The shared bucket just hid it
    behind a plausible-sounding rule.
    
    The data said the caution was unnecessary. Across the live tenant no group
    points at a programme in another branch, no base price prices a programme in
    another branch, and exactly three catalogue rows had no branch at all. The
    catalogue was already per-branch in practice and merely unlabelled.
    
      - Programmes, base prices, pricing rules, promotions, products, product
        categories, kits, warehouses, receipt templates and wallets move to the
        strict bucket. `kits` and `product_categories` gain the column; the rest
        only needed their nulls resolved, from actual usage where a link existed
        and from the main branch otherwise.
    
      - Events go the other way and lose the trait entirely, with their
        registrations. An event is an academy-wide occasion and is genuinely not
        per branch. The column stays — dropping it would be destructive — but
        nothing reads it.
    
      - Only people and the academy calendar stay shared: employees, trainers,
        guardians, holidays. A coach who works two pitches needs one record visible
        from both, not two that drift. Even there the nulls are narrowed — anyone
        who demonstrably belongs to one branch is pinned to it, which in this tenant
        leaves none shared at all.
    
      - Pricing rules are the one model whose branch is genuinely many-valued: the
        wizard targets a list through `pricing_rule_branches` and deliberately
        leaves the legacy column null. A column scope would have hidden every rule
        it has ever created, so PricingRule supplies its own scope reading the pivot
        — and BelongsToBranch now lets a model do that.
    
      - Forms that let a user save a catalogue row with no branch now require one,
        and the "كل الفروع" option is gone from those pickers: on a strictly scoped
        table that choice does not mean every branch, it means none. The setup
        wizard's seeded prices are filed against their programme's branch rather
        than null, so a new academy does not finish setup unable to sell.
    
      - Comments throughout said "SHARED — branch_id NULL means every branch uses
        this row". They now say what is true.
    
    tests/Feature/PricingSurvivesBranchScopeTest.php is the guard on the original
    worry: it prices every live enrolment inside its own branch on each run. It
    passes, and reports the one programme that has no active base price at all — a
    pre-existing gap, unrelated to scoping. Branch suites: 14 tests / 23,060
    assertions against a restored tenant. Standard suite: 224 tests, no failures.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    d3cbd5f1
Name
Last commit
Last update
..
2024_01_01_000001_create_academies_table.php Loading commit data...
2024_01_01_000002_create_users_table.php Loading commit data...
2024_01_01_000003_create_cache_and_jobs_tables.php Loading commit data...
2024_01_01_000004_create_branches_table.php Loading commit data...
2024_01_01_000005_create_roles_and_permissions_tables.php Loading commit data...
2024_01_01_000006_create_people_table.php Loading commit data...
2024_01_01_000007_create_guardians_table.php Loading commit data...
2024_01_01_000008_add_phase1_columns_to_users_table.php Loading commit data...
2024_01_01_000009_create_login_history_table.php Loading commit data...
2024_01_01_000010_create_financial_accounts_table.php Loading commit data...
2024_01_01_000011_create_invoices_table.php Loading commit data...
2024_01_01_000012_create_payments_table.php Loading commit data...
2024_01_01_000013_create_transactions_table.php Loading commit data...
2024_01_01_000014_create_wallets_table.php Loading commit data...
2024_01_01_000015_create_payment_plans_table.php Loading commit data...
2024_01_01_000016_create_activities_table.php Loading commit data...
2024_01_01_000017_create_participants_table.php Loading commit data...
2024_01_01_000018_create_guardian_participant_table.php Loading commit data...
2024_01_01_000019_create_training_programs_table.php Loading commit data...
2024_01_01_000020_create_training_groups_table.php Loading commit data...
2024_01_01_000021_create_training_schedules_table.php Loading commit data...
2024_01_01_000022_create_training_sessions_table.php Loading commit data...
2024_01_01_000023_create_enrollments_table.php Loading commit data...
2024_01_01_000024_create_waitlists_table.php Loading commit data...
2024_01_01_000025_create_holidays_table.php Loading commit data...
2024_01_01_000026_create_cash_sessions_table.php Loading commit data...
2024_01_01_000027_create_facilities_table.php Loading commit data...
2024_01_01_000028_create_space_layouts_and_segments_table.php Loading commit data...
2024_01_01_000029_create_space_reservations_table.php Loading commit data...
2024_01_01_000030_create_assignments_table.php Loading commit data...
2024_01_01_000031_create_attendance_records_table.php Loading commit data...
2024_01_01_000032_create_base_prices_table.php Loading commit data...
2024_01_01_000033_create_pricing_rules_table.php Loading commit data...
2024_01_01_000034_create_promotions_and_coupons_table.php Loading commit data...
2024_01_01_000035_create_pos_transactions_table.php Loading commit data...
2024_01_01_000036_create_products_and_categories_table.php Loading commit data...
2024_01_01_000037_create_warehouses_and_inventory_levels_table.php Loading commit data...
2024_01_01_000038_create_inventory_movements_table.php Loading commit data...
2024_01_01_000039_create_purchase_orders_table.php Loading commit data...
2024_01_01_000040_create_kits_table.php Loading commit data...
2024_01_01_000041_create_stock_counts_table.php Loading commit data...
2024_01_01_000042_create_notifications_system_table.php Loading commit data...
2024_01_01_000043_create_audit_logs_table.php Loading commit data...
2024_01_01_000044_create_evaluations_table.php Loading commit data...
2024_01_01_000045_create_system_settings_table.php Loading commit data...
2024_01_01_000046_add_monthly_rental_cost_to_facilities.php Loading commit data...
2024_01_01_000047_create_receipt_templates_and_branch_settings.php Loading commit data...
2024_01_01_000048_add_service_fee_to_transactions_and_invoices.php Loading commit data...
2024_01_01_000049_add_branch_id_to_participants_and_payments.php Loading commit data...
2024_01_01_000050_simplify_membership_type_and_add_membership_id.php Loading commit data...
2024_01_01_000051_add_cash_session_id_to_payments.php Loading commit data...
2024_01_01_000052_rename_program_id_to_training_program_id_on_training_groups.php Loading commit data...
2024_01_01_000053_create_employees_table.php Loading commit data...
2024_01_01_000054_create_trainers_table.php Loading commit data...
2024_01_01_000055_create_trainer_qualifications_table.php Loading commit data...
2024_01_01_000056_create_trainer_availability_table.php Loading commit data...
2024_01_01_000057_create_documents_table.php Loading commit data...
2024_01_01_000060_alter_trainers_make_employee_nullable.php Loading commit data...
2024_01_01_000061_create_trainer_compensations_table.php Loading commit data...
2024_01_01_000062_create_payroll_periods_table.php Loading commit data...
2024_01_01_000063_create_payslips_table.php Loading commit data...
2024_01_01_000064_create_payslip_items_table.php Loading commit data...
2024_01_01_000065_create_trainer_advances_table.php Loading commit data...
2024_01_01_000066_create_trainer_rate_history_table.php Loading commit data...
2024_01_01_000067_add_label_ar_to_system_settings_table.php Loading commit data...
2024_01_01_000070_create_media_table.php Loading commit data...
2024_01_01_000071_add_default_trainer_to_training_programs.php Loading commit data...
2024_01_01_000071_create_website_settings_table.php Loading commit data...
2024_01_01_000072_create_website_sections_table.php Loading commit data...
2024_01_01_000073_create_website_testimonials_table.php Loading commit data...
2024_01_01_000074_create_website_faqs_table.php Loading commit data...
2024_01_01_000075_create_website_news_table.php Loading commit data...
2024_01_01_000076_create_website_partners_table.php Loading commit data...
2024_01_01_000077_create_contact_submissions_table.php Loading commit data...
2024_01_01_000078_create_whatsapp_messages_table.php Loading commit data...
2024_01_01_000079_add_billing_fields_to_programs_and_enrollments.php Loading commit data...
2024_01_01_000080_add_governorate_to_people_table.php Loading commit data...
2026_07_16_162146_add_is_essential_to_products_table.php Loading commit data...
2026_07_16_180000_add_delivery_tracking_to_invoice_items.php Loading commit data...
2026_07_16_200000_add_annual_billing_to_products_table.php Loading commit data...
2026_07_16_210000_add_installment_amounts_to_product_installment_plans.php Loading commit data...
2026_07_17_000001_widen_training_groups_code_column.php Loading commit data...
2026_07_22_000001_create_facility_rent_payments_table.php Loading commit data...
2026_07_22_000002_create_expenses_table.php Loading commit data...
2026_07_22_000003_add_expense_permissions.php Loading commit data...
2026_07_24_000001_create_events_table.php Loading commit data...
2026_07_24_000002_create_event_registrations_table.php Loading commit data...
2026_07_24_000003_add_event_media_collections.php Loading commit data...
2026_07_24_000004_add_event_permissions.php Loading commit data...
2026_07_24_100001_add_locations_to_events.php Loading commit data...
2026_07_24_100002_default_website_published_true.php Loading commit data...
2026_07_25_000001_add_print_count_to_invoices_and_payments.php Loading commit data...
2026_07_25_000001_website_builder_v2_phase_a.php Loading commit data...
2026_07_25_100001_website_builder_v2_phase_b.php Loading commit data...
2026_07_25_200001_website_builder_v2_phase_c.php Loading commit data...
2026_07_26_000001_add_events_section_key.php Loading commit data...
2026_07_27_000001_create_device_tokens_table.php Loading commit data...
2026_07_27_000002_add_channel_push_to_notification_preferences.php Loading commit data...
2026_07_27_000003_create_contact_messages_table.php Loading commit data...
2026_07_27_000004_seed_mobile_app_system_settings.php Loading commit data...
2026_07_27_000005_create_service_requests_table.php Loading commit data...
2026_07_27_100001_create_push_announcements_table.php Loading commit data...
2026_07_27_100002_create_push_analytics_table.php Loading commit data...
2026_07_28_000001_drop_membership_id_unique_index.php Loading commit data...
2026_08_02_000001_add_partial_payment_to_products_table.php Loading commit data...
2026_08_02_000002_add_partially_paid_to_pos_payment_status.php Loading commit data...
2026_08_09_000001_add_external_revenue_to_expenses_category.php Loading commit data...
2026_08_09_000002_add_collected_by_to_invoices.php Loading commit data...
2026_08_10_000001_add_preferred_branch_to_users.php Loading commit data...
2026_08_10_000002_add_status_to_expenses.php Loading commit data...
2026_08_13_000001_enable_partial_payment_all_products.php Loading commit data...
2026_08_14_000001_add_attachment_to_expenses.php Loading commit data...
2026_08_19_000001_add_is_free_to_participants.php Loading commit data...
2026_08_30_000001_pricing_discount_overhaul.php Loading commit data...
2026_08_30_000002_seed_pricing_discount_settings.php Loading commit data...
2026_08_30_000003_facility_activities_and_default_layouts.php Loading commit data...
2026_08_30_000004_normalize_user_credentials.php Loading commit data...
2026_08_31_000001_add_attachment_metadata_to_expenses.php Loading commit data...
2026_08_31_000001_create_website_pages_and_blocks.php Loading commit data...
2026_08_31_000001_trim_stray_whitespace_from_names.php Loading commit data...
2026_08_31_000002_add_subject_to_contact_submissions.php Loading commit data...
2026_08_31_000003_create_website_menus.php Loading commit data...
2026_09_01_000001_add_branches_view_all_permission.php Loading commit data...
2026_09_01_000002_backfill_pos_invoice_item_types.php Loading commit data...
2026_09_01_000003_create_program_products_table.php Loading commit data...
2026_09_01_000004_bundle_registration_product_to_team_programs.php Loading commit data...
2026_09_01_000005_revoke_mobile_api_tokens.php Loading commit data...
2026_09_02_000001_backfill_freetext_product_invoice_items.php Loading commit data...
2026_09_03_000001_seed_financial_accounts_for_every_academy.php Loading commit data...
2026_09_03_000002_branch_attribution_for_money.php Loading commit data...
2026_09_03_000003_tenancy_invariant_repairs.php Loading commit data...
2026_09_03_000004_reconcile_check_vocabularies.php Loading commit data...
2026_09_03_000005_create_invoice_number_counters.php Loading commit data...
2026_09_03_000006_repair_mobile_invoice_item_totals.php Loading commit data...
2026_09_04_000001_branding_single_source_of_truth.php Loading commit data...
2026_09_05_000001_add_player_role_and_portal_permissions.php Loading commit data...
2026_09_05_000002_create_portal_invitations.php Loading commit data...
2026_09_06_000001_add_channel_to_published_content.php Loading commit data...
2026_09_07_000001_create_checkin_infrastructure.php Loading commit data...
2026_09_08_000001_add_instapay_payment_method.php Loading commit data...
2026_09_08_000002_create_payment_proofs.php Loading commit data...
2026_09_09_000001_allow_web_push_device_tokens.php Loading commit data...
2026_09_10_000001_create_consents_and_deletion_requests.php Loading commit data...
2026_09_10_000002_excuses_are_service_requests.php Loading commit data...
2026_09_11_000001_self_registration_infrastructure.php Loading commit data...
2026_09_12_000001_add_branch_presentation_and_season_window.php Loading commit data...
2026_09_12_000002_add_navbar_and_footer_presentation_settings.php Loading commit data...
2026_09_12_000003_allow_glass_navbar_style.php Loading commit data...
2026_09_12_000004_add_english_navbar_cta_text.php Loading commit data...
2026_09_13_000001_branch_isolation_columns_and_backfill.php Loading commit data...
2026_09_13_000002_branch_owns_the_catalogue.php Loading commit data...