{
  "info": {
    "name": "FIP Tadbeer API v1",
    "description": "منصة FIP — قياس وتحليل الأداء المالي للمنشآت التجارية. كل الـ endpoints تحت `/api/v1/`. الـ Authentication بـ Sanctum Bearer tokens.\n\n## تدفّق الاستخدام:\n1. `POST /auth/request-otp` بإيميل → ييجي OTP في الإيميل\n2. `POST /auth/verify-otp` بالكود → يرجّع Bearer token\n3. استخدم الـ token في `Authorization: Bearer <token>` لكل الـ requests بعد كده\n\n## Variables:\n- `base_url`: عنوان السيرفر (مثلاً http://127.0.0.1:8000)\n- `token`: Bearer token اللي بيرجع من verify-otp",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }]
  },
  "variable": [
    { "key": "base_url", "value": "http://127.0.0.1:8000",   "type": "string" },
    { "key": "email",    "value": "admin@tadbeer.sa",         "type": "string" },
    { "key": "otp",      "value": "",                          "type": "string" },
    { "key": "token",    "value": "",                          "type": "string" }
  ],
  "item": [
    {
      "name": "1. Authentication",
      "description": "تسجيل دخول بـ OTP عبر الإيميل",
      "item": [
        {
          "name": "Request OTP",
          "event": [{
            "listen": "test",
            "script": { "exec": [
              "if (pm.response.code === 200) {",
              "  const json = pm.response.json();",
              "  if (json.dev_otp) {",
              "    pm.collectionVariables.set('otp', json.dev_otp);",
              "    console.log('OTP saved to {{otp}}:', json.dev_otp);",
              "  }",
              "  if (json.email) {",
              "    pm.collectionVariables.set('email', json.email);",
              "  }",
              "}"
            ], "type": "text/javascript" }
          }],
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"{{email}}\"\n}"
            },
            "url": { "raw": "{{base_url}}/api/v1/auth/request-otp", "host": ["{{base_url}}"], "path": ["api","v1","auth","request-otp"] },
            "description": "يرسل OTP بـ 8 أرقام إلى الإيميل. في بيئة التطوير، الـ OTP بيرجع في الـ response في field `dev_otp` ويتم حفظه تلقائياً في `{{otp}}` variable عشان الـ Verify OTP request يستخدمه."
          }
        },
        {
          "name": "Verify OTP (get token)",
          "event": [{
            "listen": "test",
            "script": { "exec": [
              "if (pm.response.code === 200) {",
              "  const json = pm.response.json();",
              "  pm.collectionVariables.set('token', json.token);",
              "  console.log('Token saved:', json.token);",
              "}"
            ], "type": "text/javascript" }
          }],
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"{{email}}\",\n  \"code\": \"{{otp}}\",\n  \"device_name\": \"postman\"\n}"
            },
            "url": { "raw": "{{base_url}}/api/v1/auth/verify-otp", "host": ["{{base_url}}"], "path": ["api","v1","auth","verify-otp"] },
            "description": "يتحقق من الـ OTP ويرجّع Bearer token. بيستخدم `{{email}}` و `{{otp}}` المحفوظين تلقائياً من Request OTP السابق. الـ token المُسلَّم يتم حفظه تلقائياً في `{{token}}`."
          }
        },
        {
          "name": "Me (current user)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/auth/me", "host": ["{{base_url}}"], "path": ["api","v1","auth","me"] },
            "description": "بيانات المستخدم الحالي + الـ roles + current_plan."
          }
        },
        {
          "name": "Logout",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/auth/logout", "host": ["{{base_url}}"], "path": ["api","v1","auth","logout"] },
            "description": "يلغي الـ token الحالي فقط."
          }
        },
        {
          "name": "Logout from all devices",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/auth/logout-all", "host": ["{{base_url}}"], "path": ["api","v1","auth","logout-all"] },
            "description": "يلغي كل الـ tokens للمستخدم."
          }
        }
      ]
    },
    {
      "name": "2. Lookups (Public)",
      "description": "البيانات الثابتة (dropdowns) — لا تحتاج auth",
      "item": [
        {
          "name": "All lookups",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/lookups", "host": ["{{base_url}}"], "path": ["api","v1","lookups"] },
            "description": "كل الـ dropdowns في request واحد: data_entries, main_activities, sub_activities, cities, facility_sizes, facility_ages, filter_by_outlets, products."
          }
        },
        {
          "name": "Sub-activities by main",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/lookups/sub-activities?main_activity_id=1",
              "host": ["{{base_url}}"], "path": ["api","v1","lookups","sub-activities"],
              "query": [{ "key": "main_activity_id", "value": "1" }]
            },
            "description": "الأنشطة الفرعية حسب النشاط الرئيسي (للـ cascading dropdown)."
          }
        },
        {
          "name": "Products list",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/lookups/products", "host": ["{{base_url}}"], "path": ["api","v1","lookups","products"] },
            "description": "قائمة المنتجات الـ 26 — تظهر للأنشطة الصناعية والتجارية فقط."
          }
        }
      ]
    },
    {
      "name": "3. Plans (Public)",
      "item": [
        {
          "name": "List active plans",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/plans", "host": ["{{base_url}}"], "path": ["api","v1","plans"] },
            "description": "كل الخطط النشطة (مجاني / أساسي 13 مؤشر / Premium 21 / محفظة)."
          }
        },
        {
          "name": "Plan details",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/plans/1", "host": ["{{base_url}}"], "path": ["api","v1","plans","1"] }
          }
        }
      ]
    },
    {
      "name": "4. Company",
      "description": "كل مستخدم له منشأة واحدة فقط",
      "item": [
        {
          "name": "Get my company",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/companies", "host": ["{{base_url}}"], "path": ["api","v1","companies"] },
            "description": "ترجّع منشأة المستخدم الحالي مع كل الـ relations + accounts."
          }
        },
        {
          "name": "Create company",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"شركتي التجارية\",\n  \"data_entry_id\": 1,\n  \"main_activity_id\": 9,\n  \"sub_activity_id\": 10,\n  \"facility_size_id\": null,\n  \"city_id\": null,\n  \"facility_age_id\": null,\n  \"filter_by_outlet_id\": null,\n  \"portfolio_code\": null,\n  \"excerpt\": \"نبذة عن المنشأة\",\n  \"agreement\": true,\n  \"product_ids\": []\n}"
            },
            "url": { "raw": "{{base_url}}/api/v1/companies", "host": ["{{base_url}}"], "path": ["api","v1","companies"] },
            "description": "تسجيل منشأة جديدة (مرة واحدة فقط لكل مستخدم). `agreement: true` إلزامي. `product_ids` array من ids المنتجات (للأنشطة الصناعية والتجارية)."
          }
        },
        {
          "name": "Update company",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"الاسم الجديد\",\n  \"excerpt\": \"نبذة محدّثة\"\n}"
            },
            "url": { "raw": "{{base_url}}/api/v1/companies", "host": ["{{base_url}}"], "path": ["api","v1","companies"] },
            "description": "تحديث جزئي — كل الحقول `sometimes`."
          }
        }
      ]
    },
    {
      "name": "5. Accounts (Yearly Financials)",
      "description": "البيانات المالية السنوية — كل entry لسنة مختلفة",
      "item": [
        {
          "name": "List all years",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/accounts", "host": ["{{base_url}}"], "path": ["api","v1","accounts"] },
            "description": "كل البيانات المالية مرتبة بالأحدث. كل entry فيه `computed` بالمؤشرات المحسوبة."
          }
        },
        {
          "name": "Get specific year",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/accounts/2024", "host": ["{{base_url}}"], "path": ["api","v1","accounts","2024"] }
          }
        },
        {
          "name": "Create/Update year entry",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"fiscal_year\": 2024,\n\n  \"revenue\": 1000000,\n  \"purchases\": 600000,\n\n  \"cost\": 500000,\n  \"cost_goods_sold\": 300000,\n  \"cost_direct_salaries\": 150000,\n  \"cost_other_direct\": 50000,\n\n  \"general_expenses\": 200000,\n  \"gen_emp_expenses\": 100000,\n  \"gen_rent_expenses\": 50000,\n  \"gen_admin_expenses\": 30000,\n  \"gen_training_expenses\": 20000,\n\n  \"marketing_expenses\": 100000,\n  \"mkt_salaries_commissions\": 60000,\n  \"mkt_ads_campaigns\": 40000,\n\n  \"fixed_assets\": 300000,\n\n  \"customers_balance\": 100000,\n  \"inventory_balance\": 200000,\n  \"suppliers_balance\": 150000,\n  \"accrued_expenses\": 50000,\n  \"loans_balance\": 200000,\n  \"property_rights\": 500000,\n\n  \"loans_increase\": 50000,\n  \"capital_increase\": 100000\n}"
            },
            "url": { "raw": "{{base_url}}/api/v1/accounts", "host": ["{{base_url}}"], "path": ["api","v1","accounts"] },
            "description": "إدخالات Sheet 5 من Excel — 24 حقل. الإلزاميين: revenue, cost, general_expenses, marketing_expenses, fixed_assets, customers_balance, inventory_balance, suppliers_balance, accrued_expenses, loans_balance, property_rights, loans_increase, capital_increase. الاختيارية تتعبأ تلقائياً بـ 0.\n\nلو السنة موجودة بالفعل، يتم update بدل create."
          }
        },
        {
          "name": "Upload financial statements (multipart)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "body": {
              "mode": "formdata",
              "formdata": [
                { "key": "fiscal_year",       "value": "2024",    "type": "text" },
                { "key": "revenue",           "value": "1000000", "type": "text" },
                { "key": "cost",              "value": "500000",  "type": "text" },
                { "key": "general_expenses",  "value": "200000",  "type": "text" },
                { "key": "marketing_expenses","value": "100000",  "type": "text" },
                { "key": "fixed_assets",      "value": "300000",  "type": "text" },
                { "key": "customers_balance", "value": "100000",  "type": "text" },
                { "key": "inventory_balance", "value": "200000",  "type": "text" },
                { "key": "suppliers_balance", "value": "150000",  "type": "text" },
                { "key": "accrued_expenses",  "value": "50000",   "type": "text" },
                { "key": "loans_balance",     "value": "200000",  "type": "text" },
                { "key": "property_rights",   "value": "500000",  "type": "text" },
                { "key": "loans_increase",    "value": "50000",   "type": "text" },
                { "key": "capital_increase",  "value": "100000",  "type": "text" },
                { "key": "financial_statements_file", "type": "file", "src": [] }
              ]
            },
            "url": { "raw": "{{base_url}}/api/v1/accounts", "host": ["{{base_url}}"], "path": ["api","v1","accounts"] },
            "description": "لرفع مرفقات (PDF/Excel) لازم تستخدم `multipart/form-data` بدل JSON. حجم أقصى 5MB."
          }
        },
        {
          "name": "Delete year entry",
          "request": {
            "method": "DELETE",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/accounts/2024", "host": ["{{base_url}}"], "path": ["api","v1","accounts","2024"] }
          }
        }
      ]
    },
    {
      "name": "6. Reports",
      "description": "التقارير الـ 3 من Excel (sheets 7, 8, 9)",
      "item": [
        {
          "name": "Facility report (Sheet 7)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/reports/facility?year=2024",
              "host": ["{{base_url}}"], "path": ["api","v1","reports","facility"],
              "query": [{ "key": "year", "value": "2024", "description": "اختياري — لو ما اتبعتش يقارن كل السنين" }]
            },
            "description": "تقرير المنشأة (13 مؤشر): my-company vs avg vs benchmark. **يحتاج plan: basic أو أعلى**."
          }
        },
        {
          "name": "Portfolio report (Sheet 8)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/reports/portfolio/1?year=2024",
              "host": ["{{base_url}}"], "path": ["api","v1","reports","portfolio","1"],
              "query": [{ "key": "year", "value": "2024" }]
            },
            "description": "تقرير المحفظة: my-portfolio vs avg vs benchmark. **يحتاج plan: portfolio**."
          }
        },
        {
          "name": "Market report (Sheet 9) — Public",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/reports/market?main_activity_id=9&fiscal_year=2024",
              "host": ["{{base_url}}"], "path": ["api","v1","reports","market"],
              "query": [
                { "key": "main_activity_id",    "value": "9" },
                { "key": "sub_activity_id",     "value": null, "disabled": true },
                { "key": "facility_size_id",    "value": null, "disabled": true },
                { "key": "city_id",             "value": null, "disabled": true },
                { "key": "facility_age_id",     "value": null, "disabled": true },
                { "key": "filter_by_outlet_id", "value": null, "disabled": true },
                { "key": "fiscal_year",         "value": "2024" }
              ]
            },
            "description": "تقرير السوق: avg vs pioneer. **متاح للجميع بدون auth**."
          }
        }
      ]
    },
    {
      "name": "7. Portfolios (Portfolio plan only)",
      "item": [
        {
          "name": "List my portfolios",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/portfolios", "host": ["{{base_url}}"], "path": ["api","v1","portfolios"] }
          }
        },
        {
          "name": "Create portfolio",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": { "mode": "raw", "raw": "{\n  \"name\": \"محفظتي الاستثمارية\"\n}" },
            "url": { "raw": "{{base_url}}/api/v1/portfolios", "host": ["{{base_url}}"], "path": ["api","v1","portfolios"] }
          }
        },
        {
          "name": "Show portfolio + companies",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/portfolios/1", "host": ["{{base_url}}"], "path": ["api","v1","portfolios","1"] }
          }
        },
        {
          "name": "Attach company to portfolio",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": { "mode": "raw", "raw": "{ \"company_id\": 1 }" },
            "url": { "raw": "{{base_url}}/api/v1/portfolios/1/companies", "host": ["{{base_url}}"], "path": ["api","v1","portfolios","1","companies"] }
          }
        },
        {
          "name": "Detach company",
          "request": {
            "method": "DELETE",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/portfolios/1/companies/1", "host": ["{{base_url}}"], "path": ["api","v1","portfolios","1","companies","1"] }
          }
        },
        {
          "name": "Delete portfolio",
          "request": {
            "method": "DELETE",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/portfolios/1", "host": ["{{base_url}}"], "path": ["api","v1","portfolios","1"] }
          }
        }
      ]
    },
    {
      "name": "8. Subscriptions (User-side)",
      "item": [
        {
          "name": "My subscriptions",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/subscriptions", "host": ["{{base_url}}"], "path": ["api","v1","subscriptions"] }
          }
        },
        {
          "name": "Request a paid plan",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": { "mode": "raw", "raw": "{\n  \"plan_id\": 3,\n  \"notes\": \"محتاج Premium لاستخدام محاسبي\"\n}" },
            "url": { "raw": "{{base_url}}/api/v1/subscriptions", "host": ["{{base_url}}"], "path": ["api","v1","subscriptions"] },
            "description": "إنشاء طلب اشتراك. لو الخطة مجانية يتفعّل تلقائياً، غير كده يحتاج تفعيل أدمن يدوي."
          }
        }
      ]
    },
    {
      "name": "9. Admin",
      "description": "كل الـ admin endpoints تحتاج role:admin",
      "item": [
        {
          "name": "Dashboard counts",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/admin/dashboard", "host": ["{{base_url}}"], "path": ["api","v1","admin","dashboard"] }
          }
        },
        {
          "name": "Plans CRUD",
          "item": [
            { "name": "List", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/plans", "host": ["{{base_url}}"], "path": ["api","v1","admin","plans"] } } },
            { "name": "Create", "request": { "method": "POST", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"slug\": \"custom\",\n  \"en_title\": \"Custom\",\n  \"ar_title\": \"مخصصة\",\n  \"description\": \"خطة مخصصة\",\n  \"indicators_count\": 13,\n  \"has_portfolio\": false,\n  \"has_year_changes\": false,\n  \"has_financing\": false,\n  \"price\": 150,\n  \"is_active\": true,\n  \"order\": 5\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/plans", "host": ["{{base_url}}"], "path": ["api","v1","admin","plans"] } } },
            { "name": "Show", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/plans/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","plans","1"] } } },
            { "name": "Update", "request": { "method": "PUT", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"slug\": \"basic\",\n  \"en_title\": \"Basic\",\n  \"ar_title\": \"أساسي\",\n  \"indicators_count\": 13,\n  \"price\": 120,\n  \"is_active\": true\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/plans/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","plans","1"] } } },
            { "name": "Delete", "request": { "method": "DELETE", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/plans/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","plans","1"] } } }
          ]
        },
        {
          "name": "Subscriptions Admin",
          "item": [
            { "name": "List (filter by status)", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/subscriptions?status=pending", "host": ["{{base_url}}"], "path": ["api","v1","admin","subscriptions"], "query": [{ "key": "status", "value": "pending", "description": "active أو pending" }] } } },
            { "name": "Create manual subscription", "request": { "method": "POST", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"user_id\": 1,\n  \"plan_id\": 3,\n  \"starts_at\": \"2026-05-19\",\n  \"ends_at\": null,\n  \"is_active\": true,\n  \"notes\": \"تفعيل من أدمن\"\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/subscriptions", "host": ["{{base_url}}"], "path": ["api","v1","admin","subscriptions"] } } },
            { "name": "Toggle activation", "request": { "method": "PATCH", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/subscriptions/1/toggle", "host": ["{{base_url}}"], "path": ["api","v1","admin","subscriptions","1","toggle"] }, "description": "تفعيل/إلغاء تفعيل اشتراك." } },
            { "name": "Show", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/subscriptions/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","subscriptions","1"] } } },
            { "name": "Delete", "request": { "method": "DELETE", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/subscriptions/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","subscriptions","1"] } } }
          ]
        },
        {
          "name": "Products CRUD",
          "item": [
            { "name": "List", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/products", "host": ["{{base_url}}"], "path": ["api","v1","admin","products"] } } },
            { "name": "Create", "request": { "method": "POST", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"ar_title\": \"منتج جديد\",\n  \"en_title\": \"New Product\",\n  \"order\": 27\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/products", "host": ["{{base_url}}"], "path": ["api","v1","admin","products"] } } },
            { "name": "Update", "request": { "method": "PUT", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"ar_title\": \"اسم محدّث\",\n  \"order\": 1\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/products/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","products","1"] } } },
            { "name": "Delete", "request": { "method": "DELETE", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/products/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","products","1"] } } }
          ]
        },
        {
          "name": "Constants CRUD",
          "item": [
            { "name": "List (filter)", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/constants?post_type=main_activities", "host": ["{{base_url}}"], "path": ["api","v1","admin","constants"], "query": [{ "key": "post_type", "value": "main_activities" }, { "key": "parent_id", "value": null, "disabled": true }] } } },
            { "name": "Create", "request": { "method": "POST", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"ar_title\": \"نشاط جديد\",\n  \"en_title\": \"New Activity\",\n  \"post_type\": \"main_activities\",\n  \"parent_id\": null,\n  \"order\": 99\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/constants", "host": ["{{base_url}}"], "path": ["api","v1","admin","constants"] } } },
            { "name": "Update", "request": { "method": "PUT", "header": [{ "key": "Accept", "value": "application/json" },{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", "raw": "{\n  \"ar_title\": \"اسم محدّث\",\n  \"en_title\": \"Updated Name\",\n  \"post_type\": \"main_activities\",\n  \"order\": 1\n}" }, "url": { "raw": "{{base_url}}/api/v1/admin/constants/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","constants","1"] } } },
            { "name": "Delete", "request": { "method": "DELETE", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/constants/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","constants","1"] } } }
          ]
        },
        {
          "name": "Companies Admin",
          "item": [
            { "name": "List (search)", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/companies?search=test", "host": ["{{base_url}}"], "path": ["api","v1","admin","companies"], "query": [{ "key": "search", "value": "test" }] } } },
            { "name": "Show", "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/companies/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","companies","1"] } } },
            { "name": "Delete", "request": { "method": "DELETE", "header": [{ "key": "Accept", "value": "application/json" }], "url": { "raw": "{{base_url}}/api/v1/admin/companies/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","companies","1"] } } }
          ]
        },
        {
          "name": "Accounts Admin (any company)",
          "description": "الأدمن يقدر يشوف البيانات المالية لأي شركة",
          "item": [
            {
              "name": "List all years for a company",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/companies/1/accounts", "host": ["{{base_url}}"], "path": ["api","v1","admin","companies","1","accounts"] },
                "description": "كل السنوات المالية لشركة محددة مع المؤشرات المحسوبة (computed)."
              }
            },
            {
              "name": "Show specific year",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/companies/1/accounts/2024", "host": ["{{base_url}}"], "path": ["api","v1","admin","companies","1","accounts","2024"] },
                "description": "بيانات سنة مالية واحدة لشركة محددة."
              }
            },
            {
              "name": "Delete year entry",
              "request": {
                "method": "DELETE",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/companies/1/accounts/2024", "host": ["{{base_url}}"], "path": ["api","v1","admin","companies","1","accounts","2024"] },
                "description": "حذف بيانات سنة (soft delete)."
              }
            }
          ]
        },
        {
          "name": "Reports Admin (view any)",
          "description": "الأدمن يقدر يشوف تقارير أي شركة/محفظة/مستخدم بدون قيود الـ plan",
          "item": [
            {
              "name": "Facility report (any company)",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/v1/admin/companies/1/report?year=2024",
                  "host": ["{{base_url}}"], "path": ["api","v1","admin","companies","1","report"],
                  "query": [{ "key": "year", "value": "2024", "description": "اختياري" }]
                },
                "description": "تقرير المنشأة (Sheet 7) لأي شركة — 13 مؤشر × 3 أعمدة (my-company / avg / benchmark). Response.meta فيه owner_email."
              }
            },
            {
              "name": "Portfolio report (any portfolio)",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/v1/admin/portfolios/1/report?year=2024",
                  "host": ["{{base_url}}"], "path": ["api","v1","admin","portfolios","1","report"],
                  "query": [{ "key": "year", "value": "2024", "description": "اختياري" }]
                },
                "description": "تقرير المحفظة (Sheet 8) لأي محفظة. Response.meta فيه owner_email."
              }
            },
            {
              "name": "User report (by user id)",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/v1/admin/users/1/report?year=2024",
                  "host": ["{{base_url}}"], "path": ["api","v1","admin","users","1","report"],
                  "query": [{ "key": "year", "value": "2024", "description": "اختياري" }]
                },
                "description": "اختصار: يجيب تقرير المنشأة من user_id مباشرة (بدون ما تجيب company_id الأول)."
              }
            }
          ]
        },
        {
          "name": "Portfolios Admin (view all)",
          "description": "الأدمن يقدر يشوف كل المحافظ عبر كل المستخدمين",
          "item": [
            {
              "name": "List all portfolios",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/v1/admin/portfolios?search=&user_id=",
                  "host": ["{{base_url}}"], "path": ["api","v1","admin","portfolios"],
                  "query": [
                    { "key": "search",  "value": "", "description": "بحث في name أو code" },
                    { "key": "user_id", "value": "", "description": "فلتر بمستخدم معيّن" }
                  ]
                },
                "description": "كل المحافظ paginated + companies_count + owner."
              }
            },
            {
              "name": "Show portfolio (+ owner + companies)",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/portfolios/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","portfolios","1"] },
                "description": "تفاصيل محفظة + بيانات المالك + الشركات بداخلها."
              }
            },
            {
              "name": "Delete portfolio",
              "request": {
                "method": "DELETE",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/portfolios/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","portfolios","1"] },
                "description": "حذف محفظة (الشركات تتفك من المحفظة بدون حذف)."
              }
            }
          ]
        },
        {
          "name": "Users Admin",
          "description": "إدارة المستخدمين — CRUD + roles + جلسات",
          "item": [
            {
              "name": "List users (search + filter role)",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/v1/admin/users?search=&role=",
                  "host": ["{{base_url}}"], "path": ["api","v1","admin","users"],
                  "query": [
                    { "key": "search", "value": "", "description": "بحث في email أو name" },
                    { "key": "role",   "value": "", "description": "admin أو user" }
                  ]
                },
                "description": "قائمة المستخدمين paginated مع roles + company + active subscription."
              }
            },
            {
              "name": "Create user",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Accept",       "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"name\": \"اسم المستخدم\",\n  \"email\": \"new@tadbeer.sa\",\n  \"password\": \"secret-password\",\n  \"roles\": [\"user\"]\n}"
                },
                "url": { "raw": "{{base_url}}/api/v1/admin/users", "host": ["{{base_url}}"], "path": ["api","v1","admin","users"] },
                "description": "إنشاء مستخدم جديد. password اختياري — لو فاضي يتم توليده عشوائياً (المستخدم يستخدم OTP). roles: admin أو user."
              }
            },
            {
              "name": "Show user (with full details)",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/users/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","users","1"] },
                "description": "تفاصيل كاملة: roles, company + activities, subscriptions, portfolios, active tokens."
              }
            },
            {
              "name": "Update user (info / password / roles)",
              "request": {
                "method": "PUT",
                "header": [
                  { "key": "Accept",       "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"name\": \"اسم محدّث\",\n  \"email\": \"updated@tadbeer.sa\",\n  \"roles\": [\"admin\", \"user\"]\n}"
                },
                "url": { "raw": "{{base_url}}/api/v1/admin/users/1", "host": ["{{base_url}}"], "path": ["api","v1","admin","users","1"] },
                "description": "تحديث بيانات المستخدم. كل الحقول sometimes — ابعت اللي عايز تعدّله بس. لو بعتت password يتم hash."
              }
            },
            {
              "name": "Delete user",
              "request": {
                "method": "DELETE",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/users/2", "host": ["{{base_url}}"], "path": ["api","v1","admin","users","2"] },
                "description": "حذف المستخدم + إلغاء كل tokens. الأدمن مش قادر يحذف حسابه."
              }
            },
            {
              "name": "Assign role",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Accept",       "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": { "mode": "raw", "raw": "{\n  \"role\": \"admin\"\n}" },
                "url": { "raw": "{{base_url}}/api/v1/admin/users/1/roles", "host": ["{{base_url}}"], "path": ["api","v1","admin","users","1","roles"] },
                "description": "إضافة دور للمستخدم. الأدوار المتاحة: admin, user."
              }
            },
            {
              "name": "Revoke role",
              "request": {
                "method": "DELETE",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/users/1/roles/admin", "host": ["{{base_url}}"], "path": ["api","v1","admin","users","1","roles","admin"] },
                "description": "إزالة دور من المستخدم."
              }
            },
            {
              "name": "Force logout (revoke all tokens)",
              "request": {
                "method": "POST",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/v1/admin/users/1/revoke-tokens", "host": ["{{base_url}}"], "path": ["api","v1","admin","users","1","revoke-tokens"] },
                "description": "إلغاء كل الـ tokens النشطة للمستخدم — يفرض عليه تسجيل دخول من جديد."
              }
            }
          ]
        }
      ]
    }
  ]
}
