{
  "info": {
    "name": "Income Statement - قائمة الدخل",
    "_postman_id": "income-statement-collection",
    "description": "جميع APIs الخاصة بإعداد وتقرير قائمة الدخل",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "http://localhost/erp_main/public/api", "type": "string" },
    { "key": "token",    "value": "YOUR_TOKEN_HERE",                       "type": "string" }
  ],
  "item": [

    {
      "name": "📋 Setup — إعداد قائمة الدخل",
      "item": [

        {
          "name": "✅ GET Setup — جلب الإعداد الحالي",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "يرجع الإعداد الحالي للمنشأة:\n- config: cogs_method, purchases_calc_type\n- sections: كل قسم مع الحسابات المرتبطة به"
          }
        },

        {
          "name": "✅ POST Setup — إنشاء إعداد جديد (نظام مباشر)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"direct\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",             \"journal_ids\": [1, 2] },\n    { \"section_type\": \"revenue_deductions\",  \"journal_ids\": [3] },\n    { \"section_type\": \"cogs_direct\",         \"journal_ids\": [5] },\n    { \"section_type\": \"expenses\",            \"journal_ids\": [20, 21] },\n    { \"section_type\": \"other_revenue\",       \"journal_ids\": [30] },\n    { \"section_type\": \"other_expenses\",      \"journal_ids\": [] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "نظام الجرد المباشر:\n- cogs_direct: حسابات تكلفة البضاعة مباشرة\n- revenue_deductions: خصومات ومردودات المبيعات"
          }
        },

        {
          "name": "✅ PUT Setup — تعديل الإعداد (نظام مباشر)",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"direct\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",             \"journal_ids\": [1, 2, 3] },\n    { \"section_type\": \"revenue_deductions\",  \"journal_ids\": [4] },\n    { \"section_type\": \"cogs_direct\",         \"journal_ids\": [5, 6] },\n    { \"section_type\": \"expenses\",            \"journal_ids\": [20, 21, 22] },\n    { \"section_type\": \"other_revenue\",       \"journal_ids\": [30, 31] },\n    { \"section_type\": \"other_expenses\",      \"journal_ids\": [40] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "نفس POST لكن بـ PUT لتعديل إعداد موجود مسبقاً"
          }
        },

        {
          "name": "✅ PUT Setup — نظام جرد دوري + صافي مشتريات",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"periodic\",\n  \"purchases_calc_type\": \"net\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",                   \"journal_ids\": [1, 2] },\n    { \"section_type\": \"revenue_deductions\",         \"journal_ids\": [3] },\n    { \"section_type\": \"cogs_opening_inventory\",     \"journal_ids\": [10] },\n    { \"section_type\": \"cogs_purchases\",             \"journal_ids\": [11, 12] },\n    { \"section_type\": \"cogs_purchase_deductions\",   \"journal_ids\": [13] },\n    { \"section_type\": \"cogs_closing_inventory\",     \"journal_ids\": [14] },\n    { \"section_type\": \"expenses\",                   \"journal_ids\": [20, 21] },\n    { \"section_type\": \"other_revenue\",              \"journal_ids\": [30] },\n    { \"section_type\": \"other_expenses\",             \"journal_ids\": [] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "نظام الجرد الدوري:\n- cogs_opening_inventory: مخزون أول المدة\n- cogs_purchases: المشتريات\n- cogs_purchase_deductions: خصومات ومردودات المشتريات (net فقط)\n- cogs_closing_inventory: مخزون آخر المدة (من القيود)\n\nالمعادلة:\nCOGS = Opening + Purchases - Deductions - Closing"
          }
        },

        {
          "name": "✅ PUT Setup — نظام جرد دوري + إجمالي مشتريات (gross)",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"periodic\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",                  \"journal_ids\": [1, 2] },\n    { \"section_type\": \"revenue_deductions\",        \"journal_ids\": [3] },\n    { \"section_type\": \"cogs_opening_inventory\",    \"journal_ids\": [10] },\n    { \"section_type\": \"cogs_purchases\",            \"journal_ids\": [11, 12] },\n    { \"section_type\": \"cogs_purchase_deductions\",  \"journal_ids\": [] },\n    { \"section_type\": \"cogs_closing_inventory\",    \"journal_ids\": [14] },\n    { \"section_type\": \"expenses\",                  \"journal_ids\": [20, 21] },\n    { \"section_type\": \"other_revenue\",             \"journal_ids\": [30] },\n    { \"section_type\": \"other_expenses\",            \"journal_ids\": [] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "purchases_calc_type = gross: لا خصومات، COGS = Opening + Purchases - Closing"
          }
        },

        {
          "name": "❌ POST Setup — خطأ: cogs_method مش صح",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"invalid_value\",\n  \"sections\": []\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "يرجع 400 - cogs_method must be direct or periodic"
          }
        },

        {
          "name": "❌ POST Setup — خطأ: journal_id غير موجود",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"direct\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\", \"journal_ids\": [99999] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "يرجع 400 - journal_ids.0 does not exist in journals table"
          }
        },

        {
          "name": "❌ POST Setup — خطأ: بدون token",
          "request": {
            "method": "POST",
            "header": [
              { "key": "lang",         "value": "ar" },
              { "key": "Accept",       "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"direct\",\n  \"sections\": []\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "يرجع 401 Unauthenticated"
          }
        }

      ]
    },

    {
      "name": "📊 Report — تقرير قائمة الدخل",
      "item": [

        {
          "name": "✅ GET Report — بتاريخ محدد",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?from_date=2026-01-01&to_date=2026-03-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-03-31" }
              ]
            },
            "description": "يرجع التقرير كاملاً بين تاريخين:\n1. إجمالي المبيعات\n2. خصومات ومردودات\n- صافي المبيعات\n3. COGS\n4. إجمالي الربح\n5. المصروفات\n6. إيرادات أخرى\n7. صافي الربح / الخسارة"
          }
        },

        {
          "name": "✅ GET Report — بفترة مالية",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?financial_period_id=1",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "financial_period_id", "value": "1" }
              ]
            },
            "description": "يجلب التواريخ تلقائياً من الفترة المالية (from/to)"
          }
        },

        {
          "name": "✅ GET Report — بدون تواريخ (الشهر الحالي)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"]
            },
            "description": "بدون أي params: from = أول الشهر الحالي، to = اليوم"
          }
        },

        {
          "name": "✅ GET Report — بالإنجليزية",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "en" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" }
              ]
            },
            "description": "نفس التقرير لكن lang=en — يرجع name_en بدلاً من name_ar في الرسائل"
          }
        },

        {
          "name": "❌ GET Report — خطأ: to_date قبل from_date",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?from_date=2026-12-31&to_date=2026-01-01",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "from_date", "value": "2026-12-31" },
                { "key": "to_date",   "value": "2026-01-01" }
              ]
            },
            "description": "يرجع 400 - to_date must be after or equal to from_date"
          }
        },

        {
          "name": "❌ GET Report — خطأ: financial_period_id غير موجود",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?financial_period_id=99999",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "financial_period_id", "value": "99999" }
              ]
            },
            "description": "يرجع 400 - financial_period_id does not exist"
          }
        },

        {
          "name": "❌ GET Report — خطأ: بدون token",
          "request": {
            "method": "GET",
            "header": [
              { "key": "lang",   "value": "ar" },
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"]
            },
            "description": "يرجع 401 Unauthenticated"
          }
        }

      ]
    },

    {
      "name": "🗒️ Report Header — حالات الـ Header",
      "item": [

        {
          "name": "✅ Report — بـ financial_period_id (header كامل)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?financial_period_id=1",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "financial_period_id", "value": "1" }
              ]
            },
            "description": "الـ header يحتوي على:\n- company_name: اسم الشركة\n- financial_period.from / to: الفترة المالية\n- financial_period.status: نشط / مغلق\n- fiscal_year: السنة المالية\n- currency: العملة (اسم + رمز)\n- is_active: الحالة\n- created_at: تاريخ الإنشاء\n- created_by: تمت بواسطة (اسم الموظف صاحب الفترة)"
          }
        },

        {
          "name": "✅ Report — بتواريخ يدوية (header بدون period)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/income-statement/report?from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" }
              ]
            },
            "description": "الـ header:\n- financial_period.id = null (مش محدد)\n- fiscal_year: 2026 (من from_date تلقائياً)\n- created_by: اسم الموظف اللي عمل الطلب\n- currency: من إعداد المنشأة"
          }
        }

      ]
    },

    {
      "name": "📊 Balance Sheet — تقرير الميزانية العمومية",
      "item": [

        {
          "name": "✅ GET Report — بتاريخ محدد",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-03-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-03-31" }
              ]
            },
            "description": "يرجع تقرير الميزانية العمومية كاملاً بين تاريخين:\n- الأصول (Assets): debit - credit\n- الالتزامات (Liabilities): credit - debit\n- حقوق الملكية (Equity): credit - debit\n- إجمالي الالتزامات وحقوق الملكية\n- is_balanced: هل الأصول = الالتزامات + حقوق الملكية"
          }
        },

        {
          "name": "✅ GET Report — بفترة مالية (يزامن مع قائمة الدخل)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?financial_period_id=1",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "financial_period_id", "value": "1" }
              ]
            },
            "description": "يجلب التواريخ تلقائياً من الفترة المالية — نفس financial_period_id المستخدم في قائمة الدخل يُنتج نفس الفترة الزمنية (مزامنة التقريرين)"
          }
        },

        {
          "name": "✅ GET Report — بدون تواريخ (السنة المالية الحالية)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"]
            },
            "description": "بدون أي params:\n- from_date = أول يناير من السنة الحالية\n- to_date = اليوم\n\n(الفرق عن قائمة الدخل التي تبدأ من أول الشهر — الميزانية تبدأ من أول السنة)"
          }
        },

        {
          "name": "✅ GET Report — بالإنجليزية",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "en" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" }
              ]
            },
            "description": "lang=en — رسائل الاستجابة بالإنجليزية"
          }
        },

        {
          "name": "✅ GET Report — فلتر Level 1 (إجمالي عام)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&level=1",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" },
                { "key": "level",     "value": "1" }
              ]
            },
            "description": "Level 1: يظهر الحسابات الرئيسية فقط (مثال: الأصول، الالتزامات)\nالحسابات على مستوى 1 فقط\n\nScenario: Apply account level filter — Given the user selects level 1, then only level 1 accounts shall be displayed"
          }
        },

        {
          "name": "✅ GET Report — فلتر Level 2 (الحسابات الفرعية)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&level=2",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" },
                { "key": "level",     "value": "2" }
              ]
            },
            "description": "Level 2: يظهر الحسابات حتى المستوى الثاني (مثال: الأصول المتداولة، الأصول غير المتداولة)\nحسابات level <= 2"
          }
        },

        {
          "name": "✅ GET Report — فلتر Level 3 (الحسابات التفصيلية)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&level=3",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" },
                { "key": "level",     "value": "3" }
              ]
            },
            "description": "Level 3: يظهر الحسابات حتى المستوى الثالث (مثال: النقد، البنك)\nحسابات level <= 3"
          }
        },

        {
          "name": "✅ GET Report — إظهار الحسابات الصفرية (show_zero_accounts=true)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&show_zero_accounts=true",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date",          "value": "2026-01-01" },
                { "key": "to_date",            "value": "2026-12-31" },
                { "key": "show_zero_accounts", "value": "true" }
              ]
            },
            "description": "Scenario: Include zero balance accounts\nGiven the user chooses to include zero balance accounts\nThen accounts with zero balances shall be included in the report\n\nيُدرج جميع الحسابات حتى لو رصيدها صفر"
          }
        },

        {
          "name": "✅ GET Report — إخفاء الحسابات الصفرية (show_zero_accounts=false)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&show_zero_accounts=false",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date",          "value": "2026-01-01" },
                { "key": "to_date",            "value": "2026-12-31" },
                { "key": "show_zero_accounts", "value": "false" }
              ]
            },
            "description": "Scenario: Exclude zero balance accounts\nGiven the user chooses to exclude zero balance accounts\nThen accounts with zero balances shall be excluded\n\nالقيمة الافتراضية — يحذف أي حساب رصيده 0"
          }
        },

        {
          "name": "✅ GET Report — الحسابات الرئيسية فقط (show_only_parent_accounts=true)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&show_only_parent_accounts=true",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date",                 "value": "2026-01-01" },
                { "key": "to_date",                   "value": "2026-12-31" },
                { "key": "show_only_parent_accounts", "value": "true" }
              ]
            },
            "description": "Scenario: Show only parent accounts\nGiven the user selects to show parent accounts only\nThen only parent-level accounts shall be displayed\n\nيعرض فقط الحسابات التي is_parent = true"
          }
        },

        {
          "name": "✅ GET Report — الحسابات ذات الحركة فقط (show_activity_only=true)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&show_activity_only=true",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date",          "value": "2026-01-01" },
                { "key": "to_date",            "value": "2026-12-31" },
                { "key": "show_activity_only", "value": "true" }
              ]
            },
            "description": "Scenario: Show accounts with activity only\nGiven the user selects to display only accounts with activity\nThen only accounts with balance activity shall be shown\n\nيعرض فقط الحسابات التي لها قيود في الفترة المحددة (debit أو credit > 0)"
          }
        },

        {
          "name": "✅ GET Report — كل الفلاتر مجتمعة",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&level=2&show_zero_accounts=false&show_only_parent_accounts=false&show_activity_only=true",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date",                 "value": "2026-01-01" },
                { "key": "to_date",                   "value": "2026-12-31" },
                { "key": "level",                     "value": "2" },
                { "key": "show_zero_accounts",        "value": "false" },
                { "key": "show_only_parent_accounts", "value": "false" },
                { "key": "show_activity_only",        "value": "true" }
              ]
            },
            "description": "مثال جامع لجميع الفلاتر:\n- level=2: حتى المستوى الثاني\n- show_zero_accounts=false: استبعاد الصفرية\n- show_only_parent_accounts=false: كل الحسابات\n- show_activity_only=true: ذات الحركة فقط"
          }
        },

        {
          "name": "✅ GET Report — مزامنة مع قائمة الدخل (نفس financial_period_id)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?financial_period_id=1",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "financial_period_id", "value": "1" }
              ]
            },
            "description": "Scenario: Synchronize reporting period\nGiven: financial_period_id=1 مرسل لقائمة الدخل\nWhen: نفس financial_period_id=1 مرسل للميزانية العمومية\nThen: كلا التقريرين يُولَّدان على نفس الفترة الزمنية تلقائياً\n\n✅ أرسل نفس financial_period_id لـ /income-statement/report و /balance-sheet/report للحصول على تقريرين متزامنين"
          }
        },

        {
          "name": "✅ GET Report — header كامل مع فترة مالية",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?financial_period_id=1",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "financial_period_id", "value": "1" }
              ]
            },
            "description": "الـ header يحتوي على:\n- company_name: اسم الشركة\n- financial_period.id / name / from / to / status\n- fiscal_year: السنة المالية\n- currency: id, name_ar, name_en, symbol, code\n- is_active: حالة الفترة\n- created_at: تاريخ توليد التقرير\n- created_by: اسم الموظف"
          }
        },

        {
          "name": "❌ GET Report — خطأ: to_date قبل from_date",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-12-31&to_date=2026-01-01",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-12-31" },
                { "key": "to_date",   "value": "2026-01-01" }
              ]
            },
            "description": "يرجع 400 — to_date must be a date after or equal to from_date"
          }
        },

        {
          "name": "❌ GET Report — خطأ: financial_period_id غير موجود",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?financial_period_id=99999",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "financial_period_id", "value": "99999" }
              ]
            },
            "description": "يرجع 400 — financial_period_id does not exist in financial_periods table"
          }
        },

        {
          "name": "❌ GET Report — خطأ: level قيمة غير صالحة",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31&level=0",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" },
                { "key": "level",     "value": "0" }
              ]
            },
            "description": "يرجع 400 — level must be at least 1 (min:1)"
          }
        },

        {
          "name": "❌ GET Report — خطأ: تاريخ بتنسيق غير صحيح",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=01-2026-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "01-2026-01" },
                { "key": "to_date",   "value": "2026-12-31" }
              ]
            },
            "description": "يرجع 400 — from_date is not a valid date (يجب أن يكون YYYY-MM-DD)"
          }
        },

        {
          "name": "❌ GET Report — خطأ: بدون token",
          "request": {
            "method": "GET",
            "header": [
              { "key": "lang",   "value": "ar" },
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/balance-sheet/report?from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "balance-sheet", "report"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" }
              ]
            },
            "description": "يرجع 401 Unauthenticated — لا يوجد Authorization header"
          }
        }

      ]
    },

    {
      "name": "🔄 COGS Scenarios — حالات COGS",
      "item": [

        {
          "name": "🟢 COGS Direct — مثال كامل",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"direct\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",        \"journal_ids\": [1] },\n    { \"section_type\": \"revenue_deductions\", \"journal_ids\": [] },\n    { \"section_type\": \"cogs_direct\",    \"journal_ids\": [5] },\n    { \"section_type\": \"expenses\",       \"journal_ids\": [20] },\n    { \"section_type\": \"other_revenue\",  \"journal_ids\": [] },\n    { \"section_type\": \"other_expenses\", \"journal_ids\": [] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "COGS مباشر:\nCOGS = SUM(debit - credit) من حسابات cogs_direct"
          }
        },

        {
          "name": "🔵 COGS Periodic + Gross — بدون خصومات",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"periodic\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",                  \"journal_ids\": [1] },\n    { \"section_type\": \"revenue_deductions\",        \"journal_ids\": [] },\n    { \"section_type\": \"cogs_opening_inventory\",    \"journal_ids\": [10] },\n    { \"section_type\": \"cogs_purchases\",            \"journal_ids\": [11] },\n    { \"section_type\": \"cogs_purchase_deductions\",  \"journal_ids\": [] },\n    { \"section_type\": \"cogs_closing_inventory\",    \"journal_ids\": [14] },\n    { \"section_type\": \"expenses\",                  \"journal_ids\": [20] },\n    { \"section_type\": \"other_revenue\",             \"journal_ids\": [] },\n    { \"section_type\": \"other_expenses\",            \"journal_ids\": [] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "COGS = Opening + Purchases - Closing\nمثال: 2000 + 8000 - 3000 = 7000"
          }
        },

        {
          "name": "🟣 COGS Periodic + Net — مع خصومات",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" },
              { "key": "Content-Type",  "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"cogs_method\": \"periodic\",\n  \"purchases_calc_type\": \"net\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",                  \"journal_ids\": [1] },\n    { \"section_type\": \"revenue_deductions\",        \"journal_ids\": [3] },\n    { \"section_type\": \"cogs_opening_inventory\",    \"journal_ids\": [10] },\n    { \"section_type\": \"cogs_purchases\",            \"journal_ids\": [11] },\n    { \"section_type\": \"cogs_purchase_deductions\",  \"journal_ids\": [13] },\n    { \"section_type\": \"cogs_closing_inventory\",    \"journal_ids\": [14] },\n    { \"section_type\": \"expenses\",                  \"journal_ids\": [20] },\n    { \"section_type\": \"other_revenue\",             \"journal_ids\": [30] },\n    { \"section_type\": \"other_expenses\",            \"journal_ids\": [] }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/finance/income-statement/setup",
              "host": ["{{base_url}}"],
              "path": ["finance", "income-statement", "setup"]
            },
            "description": "COGS = Opening + (Purchases - Deductions) - Closing\nمثال: 2000 + (8000 - 500) - 3000 = 6500"
          }
        }

      ]
    },

    {
      "name": "🆕 Income Statement V2 — مخزون آخر المدة من جدول مستقل",
      "description": "V2: الفرق الوحيد عن V1 — cogs_closing_inventory يُجلب من جدول closing_inventories (قيمة مُدخَلة يدوياً) بدلاً من القيود اليومية.\n\nFlow:\n1. احفظ قيمة المخزون أولاً عبر POST /closing-inventory\n2. ثم اطلب التقرير عبر GET /report — ستُستخدم القيمة تلقائياً",
      "item": [

        {
          "name": "📋 V2 Setup",
          "item": [

            {
              "name": "✅ GET V2 Setup — جلب الإعداد الحالي",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/setup",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "setup"]
                },
                "description": "نفس استجابة V1 — الإعداد مشترك بين V1 و V2"
              }
            },

            {
              "name": "✅ POST V2 Setup — إنشاء (نظام مباشر)",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"cogs_method\": \"direct\",\n  \"purchases_calc_type\": \"gross\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",            \"journal_ids\": [1, 2] },\n    { \"section_type\": \"revenue_deductions\", \"journal_ids\": [3] },\n    { \"section_type\": \"cogs_direct\",        \"journal_ids\": [5] },\n    { \"section_type\": \"expenses\",           \"journal_ids\": [20, 21] },\n    { \"section_type\": \"other_revenue\",      \"journal_ids\": [30] },\n    { \"section_type\": \"other_expenses\",     \"journal_ids\": [] }\n  ]\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/setup",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "setup"]
                }
              }
            },

            {
              "name": "✅ PUT V2 Setup — نظام جرد دوري (closing من الجدول)",
              "request": {
                "method": "PUT",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"cogs_method\": \"periodic\",\n  \"purchases_calc_type\": \"net\",\n  \"sections\": [\n    { \"section_type\": \"revenue\",                  \"journal_ids\": [1, 2] },\n    { \"section_type\": \"revenue_deductions\",        \"journal_ids\": [3] },\n    { \"section_type\": \"cogs_opening_inventory\",    \"journal_ids\": [10] },\n    { \"section_type\": \"cogs_purchases\",            \"journal_ids\": [11] },\n    { \"section_type\": \"cogs_purchase_deductions\",  \"journal_ids\": [13] },\n    { \"section_type\": \"cogs_closing_inventory\",    \"journal_ids\": [] },\n    { \"section_type\": \"expenses\",                  \"journal_ids\": [20] },\n    { \"section_type\": \"other_revenue\",             \"journal_ids\": [30] },\n    { \"section_type\": \"other_expenses\",            \"journal_ids\": [] }\n  ]\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/setup",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "setup"]
                },
                "description": "في V2 مع periodic:\n- cogs_closing_inventory journal_ids يمكن تركه فارغاً [] لأن القيمة ستُجلب من closing_inventories table مباشرةً"
              }
            },

            {
              "name": "❌ V2 Setup — خطأ: بدون token",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "lang",   "value": "ar" },
                  { "key": "Accept", "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/setup",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "setup"]
                },
                "description": "يرجع 401 Unauthenticated"
              }
            }

          ]
        },

        {
          "name": "📦 V2 Closing Inventory",
          "item": [

            {
              "name": "✅ GET Closing Inventory — قيمة موجودة",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory?period_start=2026-01-01&period_end=2026-03-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"],
                  "query": [
                    { "key": "period_start", "value": "2026-01-01" },
                    { "key": "period_end",   "value": "2026-03-31" }
                  ]
                },
                "description": "يرجع القيمة المحفوظة للفترة إذا وُجدت، وإلا يرجع value=0"
              }
            },

            {
              "name": "✅ GET Closing Inventory — فترة غير موجودة (ترجع 0)",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory?period_start=2025-01-01&period_end=2025-12-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"],
                  "query": [
                    { "key": "period_start", "value": "2025-01-01" },
                    { "key": "period_end",   "value": "2025-12-31" }
                  ]
                },
                "description": "فترة مالية لم يُحفظ لها مخزون بعد — يرجع value=0 وvalue_local=0"
              }
            },

            {
              "name": "✅ POST Closing Inventory — حفظ قيمة جديدة",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"period_start\": \"2026-01-01\",\n  \"period_end\":   \"2026-03-31\",\n  \"value\":        15000.00,\n  \"value_local\":  75000.00,\n  \"notes\":        \"مخزون مستودع أ - ربع أول 2026\"\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"]
                },
                "description": "يحفظ قيمة مخزون آخر المدة للفترة المحددة.\nإذا كانت الفترة موجودة مسبقاً سيتم تحديثها (upsert).\n\nالحقول:\n- period_start / period_end: نطاق الفترة\n- value: بالعملة الأجنبية\n- value_local: بالعملة المحلية (اختياري، يساوي value إذا لم يُرسَل)\n- notes: ملاحظات (اختياري)"
              }
            },

            {
              "name": "✅ POST Closing Inventory — بدون value_local (يأخذ نفس value)",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"period_start\": \"2026-04-01\",\n  \"period_end\":   \"2026-06-30\",\n  \"value\":        20000.00\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"]
                },
                "description": "value_local غير مرسل — يأخذ نفس قيمة value تلقائياً"
              }
            },

            {
              "name": "✅ PUT Closing Inventory — تعديل قيمة موجودة",
              "request": {
                "method": "PUT",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"period_start\": \"2026-01-01\",\n  \"period_end\":   \"2026-03-31\",\n  \"value\":        18000.00,\n  \"value_local\":  90000.00,\n  \"notes\":        \"تعديل بعد الجرد الفعلي\"\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"]
                },
                "description": "يُحدِّث القيمة المحفوظة مسبقاً لنفس الفترة (upsert)"
              }
            },

            {
              "name": "❌ POST Closing Inventory — خطأ: period_end قبل period_start",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"period_start\": \"2026-06-30\",\n  \"period_end\":   \"2026-01-01\",\n  \"value\":        5000\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"]
                },
                "description": "يرجع 400 — period_end must be after or equal to period_start"
              }
            },

            {
              "name": "❌ POST Closing Inventory — خطأ: value سالب",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" },
                  { "key": "Content-Type",  "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"period_start\": \"2026-01-01\",\n  \"period_end\":   \"2026-03-31\",\n  \"value\":        -500\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"]
                },
                "description": "يرجع 400 — value must be at least 0 (min:0)"
              }
            },

            {
              "name": "❌ POST Closing Inventory — خطأ: بدون token",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "lang",         "value": "ar" },
                  { "key": "Accept",       "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"period_start\": \"2026-01-01\",\n  \"period_end\":   \"2026-03-31\",\n  \"value\":        5000\n}"
                },
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/closing-inventory",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "closing-inventory"]
                },
                "description": "يرجع 401 Unauthenticated"
              }
            }

          ]
        },

        {
          "name": "📊 V2 Report",
          "item": [

            {
              "name": "✅ GET V2 Report — periodic + closing من الجدول",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report?from_date=2026-01-01&to_date=2026-03-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"],
                  "query": [
                    { "key": "from_date", "value": "2026-01-01" },
                    { "key": "to_date",   "value": "2026-03-31" }
                  ]
                },
                "description": "في الـ response:\n- cogs.breakdown.closing_inventory.source = \"closing_inventories_table\"\n- القيمة تُجلب من closing_inventories تلقائياً بناءً على from_date/to_date\n\nيجب حفظ القيمة أولاً عبر POST /closing-inventory قبل طلب التقرير"
              }
            },

            {
              "name": "✅ GET V2 Report — بفترة مالية",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report?financial_period_id=1",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"],
                  "query": [
                    { "key": "financial_period_id", "value": "1" }
                  ]
                },
                "description": "يستخدم period.from و period.to للبحث في closing_inventories"
              }
            },

            {
              "name": "✅ GET V2 Report — periodic + closing = 0 (لم يُحفظ بعد)",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report?from_date=2025-01-01&to_date=2025-12-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"],
                  "query": [
                    { "key": "from_date", "value": "2025-01-01" },
                    { "key": "to_date",   "value": "2025-12-31" }
                  ]
                },
                "description": "لا توجد قيمة محفوظة لهذه الفترة في closing_inventories — cogs_closing_inventory ستكون 0\nCOGS = Opening + Purchases - 0"
              }
            },

            {
              "name": "✅ GET V2 Report — direct (لا يستخدم closing_inventories)",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report?from_date=2026-01-01&to_date=2026-12-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"],
                  "query": [
                    { "key": "from_date", "value": "2026-01-01" },
                    { "key": "to_date",   "value": "2026-12-31" }
                  ]
                },
                "description": "إذا cogs_method = direct:\n- جدول closing_inventories لا يُستخدم إطلاقاً\n- COGS يُحسب مباشرةً من cogs_direct حسابات"
              }
            },

            {
              "name": "✅ GET V2 Report — بدون تواريخ (الشهر الحالي)",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"]
                },
                "description": "from = أول الشهر الحالي، to = اليوم"
              }
            },

            {
              "name": "✅ GET V2 Report — مع فلتر level + show_zero_accounts",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report?from_date=2026-01-01&to_date=2026-03-31&level=2&show_zero_accounts=false",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"],
                  "query": [
                    { "key": "from_date",         "value": "2026-01-01" },
                    { "key": "to_date",           "value": "2026-03-31" },
                    { "key": "level",             "value": "2" },
                    { "key": "show_zero_accounts","value": "false" }
                  ]
                }
              }
            },

            {
              "name": "❌ GET V2 Report — خطأ: to_date قبل from_date",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report?from_date=2026-12-31&to_date=2026-01-01",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"],
                  "query": [
                    { "key": "from_date", "value": "2026-12-31" },
                    { "key": "to_date",   "value": "2026-01-01" }
                  ]
                },
                "description": "يرجع 400 — to_date must be after or equal to from_date"
              }
            },

            {
              "name": "❌ GET V2 Report — خطأ: بدون token",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "lang",   "value": "ar" },
                  { "key": "Accept", "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/v2/income-statement/report",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "v2", "income-statement", "report"]
                },
                "description": "يرجع 401 Unauthenticated"
              }
            }

          ]
        }

      ]
    },

    {
      "name": "📈 Finance Reports — تقارير مالية إضافية",
      "description": "تقرير مراكز التكلفة وتقرير العملات — مُضاف من finance_reports.postman_collection",
      "item": [

        {
          "name": "📌 Cost Center Report — تقرير مركز التكلفة",
          "item": [

            {
              "name": "✅ GET Cost Center Report — بكل الفلاتر",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/cost-centers/report?cost_center_id=12&from_date=2026-04-01&to_date=2026-04-30&journal_id=5&journal_entry_numner=12132&ledger_number=50001&search=rent&per_page=20&page=1",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "cost-centers", "report"],
                  "query": [
                    { "key": "cost_center_id",       "value": "12" },
                    { "key": "from_date",             "value": "2026-04-01" },
                    { "key": "to_date",               "value": "2026-04-30" },
                    { "key": "journal_id",            "value": "5" },
                    { "key": "journal_entry_numner",  "value": "12132" },
                    { "key": "ledger_number",         "value": "50001" },
                    { "key": "search",                "value": "rent" },
                    { "key": "per_page",              "value": "20" },
                    { "key": "page",                  "value": "1" }
                  ]
                },
                "description": "جميع الفلاتر المتاحة:\n- cost_center_id: تصفية بمركز تكلفة محدد\n- from_date / to_date: نطاق التاريخ\n- journal_id: تصفية بحساب معين\n- journal_entry_numner: رقم قيد محدد\n- ledger_number: رقم أستاذ\n- search: بحث نصي\n- per_page / page: pagination"
              }
            },

            {
              "name": "✅ GET Cost Center Report — فلاتر أساسية فقط",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/cost-centers/report?cost_center_id=12&from_date=2026-04-01&to_date=2026-04-30&per_page=20&page=1",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "cost-centers", "report"],
                  "query": [
                    { "key": "cost_center_id", "value": "12" },
                    { "key": "from_date",       "value": "2026-04-01" },
                    { "key": "to_date",         "value": "2026-04-30" },
                    { "key": "per_page",        "value": "20" },
                    { "key": "page",            "value": "1" }
                  ]
                },
                "description": "طلب بسيط: مركز تكلفة + نطاق تاريخ + pagination فقط"
              }
            },

            {
              "name": "✅ GET Cost Center Report — بدون pagination (الصفحة الأولى)",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/cost-centers/report?cost_center_id=12&from_date=2026-01-01&to_date=2026-12-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "cost-centers", "report"],
                  "query": [
                    { "key": "cost_center_id", "value": "12" },
                    { "key": "from_date",       "value": "2026-01-01" },
                    { "key": "to_date",         "value": "2026-12-31" }
                  ]
                }
              }
            },

            {
              "name": "✅ GET Cost Center Report — بحث نصي",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/cost-centers/report?cost_center_id=12&from_date=2026-01-01&to_date=2026-12-31&search=rent",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "cost-centers", "report"],
                  "query": [
                    { "key": "cost_center_id", "value": "12" },
                    { "key": "from_date",       "value": "2026-01-01" },
                    { "key": "to_date",         "value": "2026-12-31" },
                    { "key": "search",          "value": "rent" }
                  ]
                }
              }
            },

            {
              "name": "❌ GET Cost Center Report — خطأ: بدون token",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "lang",   "value": "ar" },
                  { "key": "Accept", "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/cost-centers/report?cost_center_id=12&from_date=2026-01-01&to_date=2026-12-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "cost-centers", "report"],
                  "query": [
                    { "key": "cost_center_id", "value": "12" },
                    { "key": "from_date",       "value": "2026-01-01" },
                    { "key": "to_date",         "value": "2026-12-31" }
                  ]
                },
                "description": "يرجع 401 Unauthenticated"
              }
            }

          ]
        },

        {
          "name": "💱 Currency Report — تقرير العملات",
          "item": [

            {
              "name": "✅ GET Currency Report — بكل الفلاتر",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/currencies/report?currency_id=2&from_date=2026-04-01&to_date=2026-04-30&journal_id=5&journal_entry_numner=12132&ledger_number=50001&search=usd&per_page=20&page=1",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "currencies", "report"],
                  "query": [
                    { "key": "currency_id",          "value": "2" },
                    { "key": "from_date",             "value": "2026-04-01" },
                    { "key": "to_date",               "value": "2026-04-30" },
                    { "key": "journal_id",            "value": "5" },
                    { "key": "journal_entry_numner",  "value": "12132" },
                    { "key": "ledger_number",         "value": "50001" },
                    { "key": "search",                "value": "usd" },
                    { "key": "per_page",              "value": "20" },
                    { "key": "page",                  "value": "1" }
                  ]
                },
                "description": "جميع الفلاتر:\n- currency_id: تصفية بعملة محددة\n- from_date / to_date: نطاق التاريخ\n- journal_id / journal_entry_numner / ledger_number: فلاتر القيد\n- search: بحث نصي\n- per_page / page: pagination"
              }
            },

            {
              "name": "✅ GET Currency Report — فلاتر أساسية فقط",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/currencies/report?currency_id=2&from_date=2026-04-01&to_date=2026-04-30&per_page=20&page=1",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "currencies", "report"],
                  "query": [
                    { "key": "currency_id", "value": "2" },
                    { "key": "from_date",   "value": "2026-04-01" },
                    { "key": "to_date",     "value": "2026-04-30" },
                    { "key": "per_page",    "value": "20" },
                    { "key": "page",        "value": "1" }
                  ]
                }
              }
            },

            {
              "name": "✅ GET Currency Report — كل العملات (بدون currency_id)",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/currencies/report?from_date=2026-01-01&to_date=2026-12-31&per_page=50&page=1",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "currencies", "report"],
                  "query": [
                    { "key": "from_date", "value": "2026-01-01" },
                    { "key": "to_date",   "value": "2026-12-31" },
                    { "key": "per_page",  "value": "50" },
                    { "key": "page",      "value": "1" }
                  ]
                },
                "description": "بدون currency_id — يرجع قيود جميع العملات"
              }
            },

            {
              "name": "✅ GET Currency Report — تصفية برقم قيد",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "Authorization", "value": "Bearer {{token}}" },
                  { "key": "lang",          "value": "ar" },
                  { "key": "Accept",        "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/currencies/report?currency_id=2&from_date=2026-01-01&to_date=2026-12-31&journal_entry_numner=12132",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "currencies", "report"],
                  "query": [
                    { "key": "currency_id",         "value": "2" },
                    { "key": "from_date",            "value": "2026-01-01" },
                    { "key": "to_date",              "value": "2026-12-31" },
                    { "key": "journal_entry_numner", "value": "12132" }
                  ]
                }
              }
            },

            {
              "name": "❌ GET Currency Report — خطأ: بدون token",
              "request": {
                "method": "GET",
                "header": [
                  { "key": "lang",   "value": "ar" },
                  { "key": "Accept", "value": "application/json" }
                ],
                "url": {
                  "raw": "{{base_url}}/finance/currencies/report?currency_id=2&from_date=2026-01-01&to_date=2026-12-31",
                  "host": ["{{base_url}}"],
                  "path": ["finance", "currencies", "report"],
                  "query": [
                    { "key": "currency_id", "value": "2" },
                    { "key": "from_date",   "value": "2026-01-01" },
                    { "key": "to_date",     "value": "2026-12-31" }
                  ]
                },
                "description": "يرجع 401 Unauthenticated"
              }
            }

          ]
        }

      ]
    },

    {
      "name": "🏦 Journals Total Balance — مجموع أرصدة الحسابات",
      "item": [

        {
          "name": "✅ GET totalBalance — مجموع أرصدة حسابات محددة",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/journals/totalBalance?account_ids[]=12&account_ids[]=11&from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "journals", "totalBalance"],
              "query": [
                { "key": "account_ids[]", "value": "12" },
                { "key": "account_ids[]", "value": "11" },
                { "key": "from_date",     "value": "2026-01-01" },
                { "key": "to_date",       "value": "2026-12-31" }
              ]
            },
            "description": "يرجع مجموع مديونية وإجمالي الحسابات المحددة من journal_entry_details (قيود posted فقط) في نطاق تاريخ محدد.\n\nالمدخلات:\n- account_ids[]: مصفوفة من معرفات الحسابات (journals.id)\n- from_date: تاريخ البداية\n- to_date: تاريخ النهاية\n\nالناتج:\n- total_debit: مجموع المدين\n- total_credit: مجموع الدائن\n- total_balance: debit - credit"
          }
        },

        {
          "name": "✅ GET totalBalance — حساب واحد فقط",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/journals/totalBalance?account_ids[]=5&from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "journals", "totalBalance"],
              "query": [
                { "key": "account_ids[]", "value": "5" },
                { "key": "from_date",     "value": "2026-01-01" },
                { "key": "to_date",       "value": "2026-12-31" }
              ]
            },
            "description": "مثال بحساب واحد فقط"
          }
        },

        {
          "name": "❌ GET totalBalance — خطأ: بدون account_ids",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/journals/totalBalance?from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "journals", "totalBalance"],
              "query": [
                { "key": "from_date", "value": "2026-01-01" },
                { "key": "to_date",   "value": "2026-12-31" }
              ]
            },
            "description": "يرجع 400 — الحسابات مطلوبة"
          }
        },

        {
          "name": "❌ GET totalBalance — خطأ: بدون from_date/to_date",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/journals/totalBalance?account_ids[]=12",
              "host": ["{{base_url}}"],
              "path": ["finance", "journals", "totalBalance"],
              "query": [
                { "key": "account_ids[]", "value": "12" }
              ]
            },
            "description": "يرجع 400 — تاريخ البداية والنهاية مطلوبان"
          }
        },

        {
          "name": "❌ GET totalBalance — خطأ: account_id غير موجود",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "lang",          "value": "ar" },
              { "key": "Accept",        "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/journals/totalBalance?account_ids[]=99999&from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "journals", "totalBalance"],
              "query": [
                { "key": "account_ids[]", "value": "99999" },
                { "key": "from_date",     "value": "2026-01-01" },
                { "key": "to_date",       "value": "2026-12-31" }
              ]
            },
            "description": "يرجع 400 — أحد الحسابات غير موجود"
          }
        },

        {
          "name": "❌ GET totalBalance — خطأ: بدون token",
          "request": {
            "method": "GET",
            "header": [
              { "key": "lang",   "value": "ar" },
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/finance/journals/totalBalance?account_ids[]=12&account_ids[]=11&from_date=2026-01-01&to_date=2026-12-31",
              "host": ["{{base_url}}"],
              "path": ["finance", "journals", "totalBalance"],
              "query": [
                { "key": "account_ids[]", "value": "12" },
                { "key": "account_ids[]", "value": "11" },
                { "key": "from_date",     "value": "2026-01-01" },
                { "key": "to_date",       "value": "2026-12-31" }
              ]
            },
            "description": "يرجع 401 Unauthenticated"
          }
        }

      ]
    }

  ]
}
