{
  "info": {
    "_postman_id": "a1b2c3d4-panel-bo-fintra",
    "name": "Fintra — Panel BO (child / optional mother)",
    "description": "## Panel BO API\n\n**Base URL** is in collection variable `base_url` (default `http://127.0.0.1:8000/api`).\n\n### Auth\n1. Run **Back-office login** first. The test script saves `access_token` → `{{token}}` and `userdata.users_id` → `{{users_id}}`.\n2. Other requests use **Bearer** `{{token}}` from collection auth.\n\n### Route\n`POST {{base_url}}/panel-bo/create-quick-panel-account`\n\nMiddleware: `jwt.auth`, `check.token`, `dynamic.permission`. Ensure this route is allowed for the logged-in role (submenu/API mapping), or testing will return 403.\n\n### Prerequisites (DB)\n- `{{users_id}}`: back-office user (`fintra_back_users.user_id`) — set automatically after login.\n- `{{user_id}}`: existing `client_user.user_id` for the child panel login.\n- `childPanel[branch_id]`: valid `fintra_branch_info.branch_id`.\n- `childPanel[fintr_customer_id]`: unique in `panel_bo_in_info` when provided.\n\n### Body\nUse **form-data** (multipart). Nested keys use bracket notation, e.g. `contactPersons[0][firstName]`, `authorizedPersons[0][firstName]`, `bankInfo[bankName]`, `childPanel[branch_id]`, `motherBo[mother_bo_name]`.\n\n### Sections\n- **Contact Persons** → stored in `bo_personal_info` (one row per person; `panel_bo_in_id` + `bo_type='P'` + `applicant_status` = 1..N). Also creates `identification`, `present_address`, `permanent_address`, and optional `panel_bo_doc_info`.\n- **Authorized Persons** → stored in `bo_authorized_person_info`. Each row is linked to the **first contact person's** `personal_info_id` (FK requirement) and to the child panel's `user_id`.\n- **Bank Information** → ONE row in `bank_info` for the whole Panel BO. Sent ONCE at the top level under `bankInfo[*]`. Linked to the **first contact person's** `personal_info_id`.\n\n### Files\n- Contact person 0: `contactPersons[0][profilePicture]`, `contactPersons[0][signature]`, `contactPersons[0][nidFront]`, `contactPersons[0][nidBack]` (or `passport` / `birthCertificate` based on `identityVerification`). Optional: `contactPersons[0][boAcknowledgement]`, `contactPersons[0][appointingLetter]`.\n- Bank: `bankInfo[blankBankChequeBook]` (required), `bankInfo[tinCertificate]` (optional).\n- Authorized person 0: `authorizedPersons[0][profileImage]`, `authorizedPersons[0][signature]`, `authorizedPersons[0][nidFront]`, `authorizedPersons[0][nidBack]` (or `passport` / `birthCertificate`).\n\n### Scenarios\n- **Standalone child**: omit `panel_mother_info_id`, `motherBo` → `panel_mother_info_id` on child row is `null`.\n- **Existing mother**: send `panel_mother_info_id` only.\n- **New mother row**: send `motherBo[mother_bo_name]` (no `panel_mother_info_id`).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "http://127.0.0.1:8000/api" },
    { "key": "token", "value": "" },
    { "key": "users_id", "value": "" },
    { "key": "user_id", "value": "1" },
    { "key": "panel_bo_in_id", "value": "1" },
    { "key": "panel_mother_info_id", "value": "" },
    { "key": "branch_id", "value": "1" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Auth — Back-office login",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "try {",
              "  var json = pm.response.json();",
              "  if (json.access_token) { pm.collectionVariables.set('token', json.access_token); }",
              "  if (json.userdata && json.userdata.users_id != null) { pm.collectionVariables.set('users_id', String(json.userdata.users_id)); }",
              "} catch (e) { console.warn(e); }"
            ]
          }
        }
      ],
      "request": {
        "auth": { "type": "noauth" },
        "method": "POST",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"your-backoffice@email.com\",\n  \"password\": \"your-password\"\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": "{{base_url}}/auth/login",
        "description": "Update email/password. On success, `token` and `users_id` collection variables are set for the next requests."
      },
      "response": []
    },
    {
      "name": "Panel BO — Get account detail",
      "request": {
        "method": "GET",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "url": {
          "raw": "{{base_url}}/panel-bo/panel-bo-account-detail?user_id={{user_id}}&panel_bo_in_id={{panel_bo_in_id}}",
          "host": ["{{base_url}}"],
          "path": ["panel-bo", "panel-bo-account-detail"],
          "query": [
            { "key": "user_id", "value": "{{user_id}}" },
            { "key": "panel_bo_in_id", "value": "{{panel_bo_in_id}}" }
          ]
        },
        "description": "Returns full Panel BO detail: general_info, account_pref, mother_panel (optional), bankInfo (single row), contactPersons[], authorizedPersons[]. Image fields are full fi_bo URLs."
      },
      "response": []
    },
    {
      "name": "Panel BO — Standalone child (1 contact + 1 authorized, NID)",
      "request": {
        "method": "POST",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "users_id", "value": "{{users_id}}", "type": "text" },
            { "key": "user_id", "value": "{{user_id}}", "type": "text" },
            { "key": "start_time", "value": "1704067200000", "type": "text", "description": "Unix epoch ms (Asia/Dhaka used in server for approval_log)" },
            { "key": "end_time", "value": "1704067205000", "type": "text" },
            { "key": "total_duration", "value": "5000", "type": "text" },
            { "key": "total_duration_formatted", "value": "0:00:05", "type": "text" },

            { "key": "childPanel[branch_id]", "value": "{{branch_id}}", "type": "text" },
            { "key": "childPanel[child_bo_type]", "value": "AMC", "type": "text", "description": "AMC | MF" },
            { "key": "childPanel[investor_type]", "value": "Institutional", "type": "text" },
            { "key": "childPanel[accountCategory]", "value": "Regular", "type": "text", "description": "Regular | Omnibus | Clearing → bo_category R|O|C" },
            { "key": "childPanel[fintr_customer_id]", "value": "PANEL{{$timestamp}}", "type": "text" },
            { "key": "childPanel[email]", "value": "panel.contact@example.com", "type": "text" },
            { "key": "childPanel[mobile]", "value": "01700000000", "type": "text" },

            { "key": "contactPersons[0][firstName]", "value": "Karim", "type": "text" },
            { "key": "contactPersons[0][middleName]", "value": "", "type": "text" },
            { "key": "contactPersons[0][lastName]", "value": "Ahmed", "type": "text" },
            { "key": "contactPersons[0][dateOfBirth]", "value": "1990-05-10", "type": "text" },
            { "key": "contactPersons[0][gender]", "value": "Male", "type": "text" },
            { "key": "contactPersons[0][fatherorHusbandName]", "value": "Father Name", "type": "text" },
            { "key": "contactPersons[0][motherName]", "value": "Mother Name", "type": "text" },
            { "key": "contactPersons[0][maritalStatus]", "value": "Single", "type": "text" },
            { "key": "contactPersons[0][spouseName]", "value": "", "type": "text", "disabled": true },
            { "key": "contactPersons[0][fullName]", "value": "Karim Ahmed", "type": "text" },
            { "key": "contactPersons[0][nationality]", "value": "BD", "type": "text" },
            { "key": "contactPersons[0][residency]", "value": "Y", "type": "text" },
            { "key": "contactPersons[0][profession]", "value": "Business", "type": "text" },
            { "key": "contactPersons[0][contactNumber]", "value": "01711111111", "type": "text" },
            { "key": "contactPersons[0][email]", "value": "contact0@example.com", "type": "text" },
            { "key": "contactPersons[0][fullAddress]", "value": "House 1 Road 2", "type": "text" },
            { "key": "contactPersons[0][postalCode]", "value": "1200", "type": "text" },
            { "key": "contactPersons[0][city]", "value": "Dhaka", "type": "text" },
            { "key": "contactPersons[0][stateDivision]", "value": "Dhaka", "type": "text" },
            { "key": "contactPersons[0][country]", "value": "Bangladesh", "type": "text" },
            { "key": "contactPersons[0][identityVerification]", "value": "nid", "type": "text" },
            { "key": "contactPersons[0][nidNumber]", "value": "1234567890123", "type": "text" },
            { "key": "contactPersons[0][profilePicture]", "type": "file", "src": "" },
            { "key": "contactPersons[0][signature]", "type": "file", "src": "" },
            { "key": "contactPersons[0][nidFront]", "type": "file", "src": "" },
            { "key": "contactPersons[0][nidBack]", "type": "file", "src": "" },
            { "key": "contactPersons[0][passport]", "type": "file", "src": "", "disabled": true },
            { "key": "contactPersons[0][birthCertificate]", "type": "file", "src": "", "disabled": true },
            { "key": "contactPersons[0][boAcknowledgement]", "type": "file", "src": "", "disabled": true },
            { "key": "contactPersons[0][appointingLetter]", "type": "file", "src": "", "disabled": true },

            { "key": "bankInfo[bankName]", "value": "Dutch Bangla Bank", "type": "text" },
            { "key": "bankInfo[bankBranch]", "value": "Gulshan", "type": "text" },
            { "key": "bankInfo[bankDistrict]", "value": "Dhaka", "type": "text" },
            { "key": "bankInfo[bankRtn]", "value": "090260344", "type": "text" },
            { "key": "bankInfo[bankIdCode]", "value": "DBBL", "type": "text" },
            { "key": "bankInfo[bankAccountNumber]", "value": "1234567890", "type": "text" },
            { "key": "bankInfo[tinNumber]", "value": "", "type": "text", "disabled": true },
            { "key": "bankInfo[TaxId]", "value": "", "type": "text", "disabled": true },
            { "key": "bankInfo[taxExamption]", "value": "N", "type": "text" },
            { "key": "bankInfo[foreignBank]", "value": "false", "type": "text" },
            { "key": "bankInfo[iban]", "value": "", "type": "text", "disabled": true },
            { "key": "bankInfo[swiftCode]", "value": "", "type": "text", "disabled": true },
            { "key": "bankInfo[blankBankChequeBook]", "type": "file", "src": "" },
            { "key": "bankInfo[tinCertificate]", "type": "file", "src": "", "disabled": true },

            { "key": "authorizedPersons[0][firstName]", "value": "Rahim", "type": "text" },
            { "key": "authorizedPersons[0][middleName]", "value": "", "type": "text" },
            { "key": "authorizedPersons[0][lastName]", "value": "Khan", "type": "text" },
            { "key": "authorizedPersons[0][fullName]", "value": "Rahim Khan", "type": "text" },
            { "key": "authorizedPersons[0][mobileNumber]", "value": "01722222222", "type": "text" },
            { "key": "authorizedPersons[0][telephone]", "value": "", "type": "text", "disabled": true },
            { "key": "authorizedPersons[0][email]", "value": "authorized0@example.com", "type": "text" },
            { "key": "authorizedPersons[0][fax]", "value": "", "type": "text", "disabled": true },
            { "key": "authorizedPersons[0][relation]", "value": "Director", "type": "text" },
            { "key": "authorizedPersons[0][fullAddress]", "value": "House 5 Road 7", "type": "text" },
            { "key": "authorizedPersons[0][city]", "value": "Dhaka", "type": "text" },
            { "key": "authorizedPersons[0][postalCode]", "value": "1207", "type": "text" },
            { "key": "authorizedPersons[0][stateDivision]", "value": "Dhaka", "type": "text" },
            { "key": "authorizedPersons[0][country]", "value": "Bangladesh", "type": "text" },
            { "key": "authorizedPersons[0][nationality]", "value": "BD", "type": "text" },
            { "key": "authorizedPersons[0][residency]", "value": "Y", "type": "text" },
            { "key": "authorizedPersons[0][identityVerification]", "value": "nid", "type": "text" },
            { "key": "authorizedPersons[0][nidNumber]", "value": "9876543210987", "type": "text" },
            { "key": "authorizedPersons[0][profileImage]", "type": "file", "src": "", "disabled": true },
            { "key": "authorizedPersons[0][signature]", "type": "file", "src": "", "disabled": true },
            { "key": "authorizedPersons[0][nidFront]", "type": "file", "src": "" },
            { "key": "authorizedPersons[0][nidBack]", "type": "file", "src": "" },
            { "key": "authorizedPersons[0][passport]", "type": "file", "src": "", "disabled": true },
            { "key": "authorizedPersons[0][birthCertificate]", "type": "file", "src": "", "disabled": true }
          ]
        },
        "url": "{{base_url}}/panel-bo/create-quick-panel-account",
        "description": "Standalone child: do NOT send `panel_mother_info_id` or `motherBo[mother_bo_name]`. Enable file fields and pick images before sending."
      },
      "response": []
    },
    {
      "name": "Panel BO — Child under existing mother",
      "request": {
        "method": "POST",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "users_id", "value": "{{users_id}}", "type": "text" },
            { "key": "user_id", "value": "{{user_id}}", "type": "text" },
            { "key": "panel_mother_info_id", "value": "{{panel_mother_info_id}}", "type": "text", "description": "Set collection variable panel_mother_info_id to a real panel_mother_bo_in_id" },
            { "key": "start_time", "value": "1704067200000", "type": "text" },
            { "key": "end_time", "value": "1704067205000", "type": "text" },
            { "key": "total_duration", "value": "5000", "type": "text" },
            { "key": "total_duration_formatted", "value": "0:00:05", "type": "text" },

            { "key": "childPanel[branch_id]", "value": "{{branch_id}}", "type": "text" },
            { "key": "childPanel[child_bo_type]", "value": "AMC", "type": "text" },
            { "key": "childPanel[investor_type]", "value": "Institutional", "type": "text" },
            { "key": "childPanel[accountCategory]", "value": "Regular", "type": "text" },
            { "key": "childPanel[fintr_customer_id]", "value": "PANELM{{$timestamp}}", "type": "text" },
            { "key": "childPanel[email]", "value": "child@example.com", "type": "text" },
            { "key": "childPanel[mobile]", "value": "01722222222", "type": "text" },

            { "key": "contactPersons[0][firstName]", "value": "Karim", "type": "text" },
            { "key": "contactPersons[0][lastName]", "value": "Ahmed", "type": "text" },
            { "key": "contactPersons[0][dateOfBirth]", "value": "1990-05-10", "type": "text" },
            { "key": "contactPersons[0][gender]", "value": "Male", "type": "text" },
            { "key": "contactPersons[0][fatherorHusbandName]", "value": "Father Name", "type": "text" },
            { "key": "contactPersons[0][motherName]", "value": "Mother Name", "type": "text" },
            { "key": "contactPersons[0][maritalStatus]", "value": "Single", "type": "text" },
            { "key": "contactPersons[0][fullName]", "value": "Karim Ahmed", "type": "text" },
            { "key": "contactPersons[0][nationality]", "value": "BD", "type": "text" },
            { "key": "contactPersons[0][residency]", "value": "Y", "type": "text" },
            { "key": "contactPersons[0][profession]", "value": "Business", "type": "text" },
            { "key": "contactPersons[0][contactNumber]", "value": "01711111111", "type": "text" },
            { "key": "contactPersons[0][email]", "value": "contact0@example.com", "type": "text" },
            { "key": "contactPersons[0][fullAddress]", "value": "House 1 Road 2", "type": "text" },
            { "key": "contactPersons[0][postalCode]", "value": "1200", "type": "text" },
            { "key": "contactPersons[0][city]", "value": "Dhaka", "type": "text" },
            { "key": "contactPersons[0][stateDivision]", "value": "Dhaka", "type": "text" },
            { "key": "contactPersons[0][country]", "value": "Bangladesh", "type": "text" },
            { "key": "contactPersons[0][identityVerification]", "value": "nid", "type": "text" },
            { "key": "contactPersons[0][nidNumber]", "value": "1234567890123", "type": "text" },
            { "key": "contactPersons[0][profilePicture]", "type": "file", "src": "" },
            { "key": "contactPersons[0][signature]", "type": "file", "src": "" },
            { "key": "contactPersons[0][nidFront]", "type": "file", "src": "" },
            { "key": "contactPersons[0][nidBack]", "type": "file", "src": "" },

            { "key": "bankInfo[bankName]", "value": "Dutch Bangla Bank", "type": "text" },
            { "key": "bankInfo[bankBranch]", "value": "Gulshan", "type": "text" },
            { "key": "bankInfo[bankAccountNumber]", "value": "1234567890", "type": "text" },
            { "key": "bankInfo[foreignBank]", "value": "false", "type": "text" },
            { "key": "bankInfo[blankBankChequeBook]", "type": "file", "src": "" }
          ]
        },
        "url": "{{base_url}}/panel-bo/create-quick-panel-account"
      },
      "response": []
    },
    {
      "name": "Panel BO — Create new mother + child",
      "request": {
        "method": "POST",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "users_id", "value": "{{users_id}}", "type": "text" },
            { "key": "user_id", "value": "{{user_id}}", "type": "text" },
            { "key": "motherBo[mother_bo_id]", "value": "", "type": "text", "disabled": true },
            { "key": "motherBo[mother_bo_name]", "value": "Mother Panel Demo", "type": "text" },
            { "key": "motherBo[mother_bo_type]", "value": "AMC", "type": "text" },
            { "key": "start_time", "value": "1704067200000", "type": "text" },
            { "key": "end_time", "value": "1704067205000", "type": "text" },
            { "key": "total_duration", "value": "5000", "type": "text" },
            { "key": "total_duration_formatted", "value": "0:00:05", "type": "text" },

            { "key": "childPanel[branch_id]", "value": "{{branch_id}}", "type": "text" },
            { "key": "childPanel[child_bo_type]", "value": "AMC", "type": "text" },
            { "key": "childPanel[investor_type]", "value": "Institutional", "type": "text" },
            { "key": "childPanel[accountCategory]", "value": "Regular", "type": "text" },
            { "key": "childPanel[fintr_customer_id]", "value": "PANELNEW{{$timestamp}}", "type": "text" },
            { "key": "childPanel[email]", "value": "child@example.com", "type": "text" },
            { "key": "childPanel[mobile]", "value": "01733333333", "type": "text" },

            { "key": "contactPersons[0][firstName]", "value": "Karim", "type": "text" },
            { "key": "contactPersons[0][lastName]", "value": "Ahmed", "type": "text" },
            { "key": "contactPersons[0][dateOfBirth]", "value": "1990-05-10", "type": "text" },
            { "key": "contactPersons[0][gender]", "value": "Male", "type": "text" },
            { "key": "contactPersons[0][fatherorHusbandName]", "value": "Father Name", "type": "text" },
            { "key": "contactPersons[0][motherName]", "value": "Mother Name", "type": "text" },
            { "key": "contactPersons[0][maritalStatus]", "value": "Single", "type": "text" },
            { "key": "contactPersons[0][fullName]", "value": "Karim Ahmed", "type": "text" },
            { "key": "contactPersons[0][nationality]", "value": "BD", "type": "text" },
            { "key": "contactPersons[0][residency]", "value": "Y", "type": "text" },
            { "key": "contactPersons[0][profession]", "value": "Business", "type": "text" },
            { "key": "contactPersons[0][contactNumber]", "value": "01711111111", "type": "text" },
            { "key": "contactPersons[0][email]", "value": "contact0@example.com", "type": "text" },
            { "key": "contactPersons[0][fullAddress]", "value": "House 1 Road 2", "type": "text" },
            { "key": "contactPersons[0][postalCode]", "value": "1200", "type": "text" },
            { "key": "contactPersons[0][city]", "value": "Dhaka", "type": "text" },
            { "key": "contactPersons[0][stateDivision]", "value": "Dhaka", "type": "text" },
            { "key": "contactPersons[0][country]", "value": "Bangladesh", "type": "text" },
            { "key": "contactPersons[0][identityVerification]", "value": "nid", "type": "text" },
            { "key": "contactPersons[0][nidNumber]", "value": "1234567890123", "type": "text" },
            { "key": "contactPersons[0][profilePicture]", "type": "file", "src": "" },
            { "key": "contactPersons[0][signature]", "type": "file", "src": "" },
            { "key": "contactPersons[0][nidFront]", "type": "file", "src": "" },
            { "key": "contactPersons[0][nidBack]", "type": "file", "src": "" },

            { "key": "bankInfo[bankName]", "value": "Dutch Bangla Bank", "type": "text" },
            { "key": "bankInfo[bankBranch]", "value": "Gulshan", "type": "text" },
            { "key": "bankInfo[bankAccountNumber]", "value": "1234567890", "type": "text" },
            { "key": "bankInfo[foreignBank]", "value": "false", "type": "text" },
            { "key": "bankInfo[blankBankChequeBook]", "type": "file", "src": "" }
          ]
        },
        "url": "{{base_url}}/panel-bo/create-quick-panel-account",
        "description": "Do NOT send `panel_mother_info_id`. Requires `motherBo[mother_bo_name]` (uses the same `user_id` as the child by default; adjust if your design needs a separate mother login)."
      },
      "response": []
    }
  ]
}
