• Mahmoud Aglan's avatar
    feat(pricing): scope a discount to members or to non-members, and let a... · cc9d0d65
    Mahmoud Aglan authored
    feat(pricing): scope a discount to members or to non-members, and let a branch-targeted one save at all
    
    Membership tier decided only which base price was read; it was invisible to
    every rule. A club wanting '10% off, members only' had no way to say it.
    The nearest rule type, membership_duration, is tenure in months, which is a
    different question and happily matches a non-member who has been around a
    while. New membership_type rule type, with the CHECK constraint widened to
    admit it — no existing row changes value, and the new one is unreachable
    until a rule is authored with it.
    
    The tier the rule matches is the same one that chose the base price, so a
    discount and the price it discounts cannot disagree about who this is. An
    unset tier reads as non_member, matching step 1, so a 'members only' rule
    cannot quietly reach someone nobody ever classified.
    
    And the bug the test for it found: NO branch-targeted discount could be
    saved. pricing_rule_branches.academy_id is NOT NULL and the pivot has no
    model, so no BelongsToAcademy hook filled it and a bare sync() died on a
    not-null violation — every rule authored in the wizard with a branch
    ticked. Stamped by hand, the way ProgramForm already does for
    program_products.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    cc9d0d65
CreatePricingRuleWizard.php 19.2 KB