{
  "info": {
    "name": "AbelBirdnest Mobile Operations API",
    "description": "Collection Postman untuk integrasi mobile Warehouse, QC, Sales, Purchasing, dan Owner. Gunakan Login terlebih dahulu untuk mengisi {{sessionToken}}.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "http://localhost:3000/api/v1" },
    { "key": "sessionToken", "value": "" },
    { "key": "purchaseId", "value": "" },
    { "key": "receiptId", "value": "" },
    { "key": "lotId", "value": "" },
    { "key": "washingId", "value": "" },
    { "key": "regularSaleId", "value": "" },
    { "key": "jitSaleId", "value": "" },
    { "key": "consignmentId", "value": "" },
    { "key": "consignmentLineId", "value": "" },
    { "key": "purchaseAnalysisId", "value": "" },
    { "key": "purchaseRealizationId", "value": "" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      { "key": "token", "value": "{{sessionToken}}", "type": "string" }
    ]
  },
  "item": [
    {
      "name": "1. Auth",
      "item": [
        {
          "name": "Login",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  const token = json?.data?.session_token;",
                  "  const role = json?.data?.user?.role;",
                  "  if (token) pm.collectionVariables.set('sessionToken', token);",
                  "  if (role) pm.collectionVariables.set('userRole', role);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"identity\": \"admin\",\n  \"password\": \"admin123\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/auth/login",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "login"]
            }
          }
        },
        {
          "name": "Session Me",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/auth/me",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "me"]
            }
          }
        }
      ]
    },
    {
      "name": "2. Bootstrap & Dashboard",
      "item": [
        {
          "name": "Mobile Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "bootstrap"]
            }
          }
        },
        {
          "name": "Mobile Dashboard",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/dashboard?locale=id",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "dashboard"],
              "query": [
                { "key": "locale", "value": "id" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "3. Warehouse & QC",
      "item": [
        {
          "name": "Lot List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/lots",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "lots"]
            }
          }
        },
        {
          "name": "Lot Scan",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/lots/scan?code=LOT-EXAMPLE-001",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "lots", "scan"],
              "query": [
                { "key": "code", "value": "LOT-EXAMPLE-001" }
              ]
            }
          }
        },
        {
          "name": "Lot Detail",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/lots/{{lotId}}",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "lots", "{{lotId}}"]
            }
          }
        },
        {
          "name": "Receipt Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/receipts/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "receipts", "bootstrap"]
            }
          }
        },
        {
          "name": "Receipt List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/receipts",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "receipts"]
            }
          }
        },
        {
          "name": "Create Receipt",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"purchase_id\": \"{{purchaseId}}\",\n  \"receipt_date\": \"2026-05-16\",\n  \"notes\": \"Receipt dari mobile\",\n  \"lines\": []\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/receipts",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "receipts"]
            }
          }
        },
        {
          "name": "Generate Lots From Receipt",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/mobile/receipts/{{receiptId}}/generate-lots",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "receipts", "{{receiptId}}", "generate-lots"]
            }
          }
        },
        {
          "name": "Stock Adjustment Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/stock-adjustments/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "stock-adjustments", "bootstrap"]
            }
          }
        },
        {
          "name": "Create Stock Adjustment",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"lot_id\": \"{{lotId}}\",\n  \"adjustment_reason_id\": \"\",\n  \"adjustment_date\": \"2026-05-16\",\n  \"qty_change\": -1,\n  \"notes\": \"Mobile adjustment\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/stock-adjustments",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "stock-adjustments"]
            }
          }
        },
        {
          "name": "Washing Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/washing/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "washing", "bootstrap"]
            }
          }
        },
        {
          "name": "Washing List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/washing",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "washing"]
            }
          }
        },
        {
          "name": "Create Washing",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"lot_id\": \"{{lotId}}\",\n  \"washing_place_id\": \"\",\n  \"washing_cost\": 10000,\n  \"duration_hours\": 24\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/washing",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "washing"]
            }
          }
        },
        {
          "name": "Complete Washing",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"after_qty\": 1,\n  \"grade_id\": \"\",\n  \"warehouse_id\": \"\",\n  \"warehouse_location_id\": \"\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/washing/{{washingId}}/complete",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "washing", "{{washingId}}", "complete"]
            }
          }
        },
        {
          "name": "Transformation List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/lot-transformations",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "lot-transformations"]
            }
          }
        },
        {
          "name": "Create Lot Transformation",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"transformation_type\": \"MIX\",\n  \"transformation_date\": \"2026-05-16\",\n  \"remainder_mode\": \"KEEP_SOURCE_GRADE\",\n  \"processing_loss_mode\": \"SHRINKAGE\",\n  \"notes\": \"Mobile transformation\",\n  \"inputs\": [\n    {\n      \"source_lot_code\": \"LOT-EXAMPLE-001\",\n      \"qty_used\": 1\n    }\n  ],\n  \"outputs\": [\n    {\n      \"grade_id\": \"\",\n      \"warehouse_id\": \"\",\n      \"warehouse_location_id\": \"\",\n      \"qty_produced\": 1\n    }\n  ]\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/lot-transformations",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "lot-transformations"]
            }
          }
        }
      ]
    },
    {
      "name": "4. Sales",
      "item": [
        {
          "name": "Regular Sales Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-regular/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-regular", "bootstrap"]
            }
          }
        },
        {
          "name": "Regular Sales List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-regular",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-regular"]
            }
          }
        },
        {
          "name": "Regular Sale Detail",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-regular/{{regularSaleId}}",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-regular", "{{regularSaleId}}"]
            }
          }
        },
        {
          "name": "Close Regular Sale",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"close_date\": \"2026-05-16\",\n  \"lines\": []\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-regular/{{regularSaleId}}/close",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-regular", "{{regularSaleId}}", "close"]
            }
          }
        },
        {
          "name": "JIT Sales Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-jit/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-jit", "bootstrap"]
            }
          }
        },
        {
          "name": "JIT Sales List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-jit",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-jit"]
            }
          }
        },
        {
          "name": "Close JIT Sale",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"close_date\": \"2026-05-16\",\n  \"lines\": []\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/sales-jit/{{jitSaleId}}/close",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "sales-jit", "{{jitSaleId}}", "close"]
            }
          }
        },
        {
          "name": "Consignments Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/consignments/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "consignments", "bootstrap"]
            }
          }
        },
        {
          "name": "Consignments List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/consignments",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "consignments"]
            }
          }
        },
        {
          "name": "Consignment Detail",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/consignments/{{consignmentId}}",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "consignments", "{{consignmentId}}"]
            }
          }
        },
        {
          "name": "Close Consignment Line",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"close_date\": \"2026-05-16\",\n  \"qty_sold\": 1,\n  \"qty_returned\": 0,\n  \"selling_price\": 100000,\n  \"sales_commission\": 0\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/mobile/consignments/lines/{{consignmentLineId}}/close",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "consignments", "lines", "{{consignmentLineId}}", "close"]
            }
          }
        }
      ]
    },
    {
      "name": "5. Purchasing & Owner",
      "item": [
        {
          "name": "Purchases List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchases",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchases"]
            }
          }
        },
        {
          "name": "Purchase Detail",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchases/{{purchaseId}}",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchases", "{{purchaseId}}"]
            }
          }
        },
        {
          "name": "Submit Purchase",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchases/{{purchaseId}}/submit",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchases", "{{purchaseId}}", "submit"]
            }
          }
        },
        {
          "name": "Fund Requests Bootstrap",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/fund-requests/bootstrap",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "fund-requests", "bootstrap"]
            }
          }
        },
        {
          "name": "Fund Requests List",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/fund-requests",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "fund-requests"]
            }
          }
        },
        {
          "name": "Purchase Analyses",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchase-analyses",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchase-analyses"]
            }
          }
        },
        {
          "name": "Purchase Analysis Detail",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchase-analyses/{{purchaseAnalysisId}}",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchase-analyses", "{{purchaseAnalysisId}}"]
            }
          }
        },
        {
          "name": "Purchase Realizations",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchase-realizations",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchase-realizations"]
            }
          }
        },
        {
          "name": "Purchase Realization Detail",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/mobile/purchase-realizations/{{purchaseRealizationId}}",
              "host": ["{{baseUrl}}"],
              "path": ["mobile", "purchase-realizations", "{{purchaseRealizationId}}"]
            }
          }
        }
      ]
    }
  ]
}
