Files
musadaq-saas/update_annual_plans.sql
2026-05-16 00:33:22 +03:00

48 lines
1.7 KiB
SQL

-- 1. تعطيل الباقات القديمة التي لم نعد نستخدمها
UPDATE subscription_plans SET is_active = 0 WHERE id IN ('office', 'enterprise');
-- 2. تحديث الباقات الحالية إلى باقات سنوية بالأسعار والأرقام الجديدة
UPDATE subscription_plans
SET
name_ar = 'الباقة الأساسية (سنوي)',
name_en = 'Basic Plan (Annual)',
price_jod = 120.00,
max_invoices_month = 12000,
max_companies = 1,
max_users = 1,
is_active = 1
WHERE id = 'basic';
UPDATE subscription_plans
SET
name_ar = 'الباقة الاحترافية (سنوي)',
name_en = 'Pro Plan (Annual)',
price_jod = 250.00,
max_invoices_month = 50000,
max_companies = 9999, -- للشركات غير المحدودة
max_users = 5,
is_active = 1
WHERE id = 'pro';
-- 3. إبقاء الباقة المجانية كما هي
UPDATE subscription_plans
SET
name_ar = 'التجربة المجانية',
name_en = 'Free Trial',
price_jod = 0.00,
max_invoices_month = 15,
max_companies = 1,
max_users = 1,
is_active = 1
WHERE id = 'free';
-- 4. ترحيل وتحديث بيانات العملاء المشتركين حالياً
UPDATE subscriptions s
JOIN subscription_plans sp ON s.plan_id = sp.id
SET
s.max_invoices_per_month = sp.max_invoices_month,
s.max_companies = sp.max_companies,
s.max_users = sp.max_users,
-- تمديد فترة الفوترة للمشتركين المدفوعين لتصبح سنة كاملة من تاريخ بدايتها
s.current_period_end = IF(s.plan_id != 'free', DATE_ADD(s.current_period_start, INTERVAL 1 YEAR), s.current_period_end);