{
  "info": {
    "name": "Walet Inventory API",
    "description": "Postman collection untuk sistem inventory sarang burung walet berbasis lot, traceability, sorting, dan allocation.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:3000/api/v1"
    },
    {
      "key": "token",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Auth",
      "item": [
        {
          "name": "Login",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/auth/login",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"admin@example.com\",\n  \"password\": \"secret\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Master Data",
      "item": [
        {
          "name": "List Suppliers",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/suppliers"
          }
        },
        {
          "name": "Create Supplier",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/suppliers",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"code\": \"SUP-C\",\n  \"name\": \"Supplier C\",\n  \"phone\": \"081310000003\",\n  \"email\": \"sup-c@walet.local\",\n  \"bank_name\": \"BCA\",\n  \"bank_account_number\": \"333444555666\",\n  \"address\": \"Semarang\"\n}"
            }
          }
        },
        {
          "name": "List Customers",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/customers"
          }
        },
        {
          "name": "Create Customer",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/customers",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"code\": \"CUST-C\",\n  \"name\": \"Customer C\",\n  \"phone\": \"081320000003\",\n  \"email\": \"cust-c@walet.local\",\n  \"bank_name\": \"Mandiri\",\n  \"bank_account_number\": \"777888999000\",\n  \"address\": \"Yogyakarta\"\n}"
            }
          }
        },
        {
          "name": "List Item Types",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/item-types"
          }
        },
        {
          "name": "List Item Grades",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/item-grades"
          }
        }
      ]
    },
    {
      "name": "Purchasing",
      "item": [
        {
          "name": "Create Purchase",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/purchases",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"supplier_id\": 1,\n  \"purchase_date\": \"2026-04-28\",\n  \"supplier_invoice_no\": \"INV-8891\",\n  \"notes\": \"Pembelian campuran\",\n  \"lines\": [\n    {\n      \"item_type_id\": 1,\n      \"item_grade_id\": 1,\n      \"qty_ordered\": 50,\n      \"unit_id\": 1,\n      \"unit_price\": 18000000,\n      \"classification_status\": \"FINAL\"\n    },\n    {\n      \"item_type_id\": 1,\n      \"item_grade_id\": null,\n      \"qty_ordered\": 40,\n      \"unit_id\": 1,\n      \"unit_price\": 17500000,\n      \"classification_status\": \"PROVISIONAL\"\n    }\n  ]\n}"
            }
          }
        },
        {
          "name": "List Purchases",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/purchases"
          }
        }
      ]
    },
    {
      "name": "Receiving",
      "item": [
        {
          "name": "Create Receipt",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/receipts",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"purchase_id\": 1,\n  \"supplier_id\": 1,\n  \"receipt_date\": \"2026-04-28\",\n  \"notes\": \"Barang diterima baik\",\n  \"lines\": [\n    {\n      \"purchase_line_id\": 1,\n      \"item_type_id\": 1,\n      \"item_grade_id\": 1,\n      \"qty_received\": 50,\n      \"qty_accepted\": 50,\n      \"qty_rejected\": 0,\n      \"unit_id\": 1,\n      \"unit_cost\": 18000000,\n      \"warehouse_id\": 1,\n      \"warehouse_location_id\": 1\n    }\n  ]\n}"
            }
          }
        },
        {
          "name": "Generate Lots",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/receipts/1/generate-lots"
          }
        }
      ]
    },
    {
      "name": "Inventory Lots",
      "item": [
        {
          "name": "List Lots",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/lots"
          }
        },
        {
          "name": "Lot Detail",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/lots/1"
          }
        },
        {
          "name": "Lot Trace",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/lots/1/trace"
          }
        }
      ]
    },
    {
      "name": "Sorting & Regrade",
      "item": [
        {
          "name": "Create Sorting Session",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/sorting-sessions",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"source_lot_id\": 10,\n  \"sorting_date\": \"2026-04-28T15:00:00Z\",\n  \"input_qty\": 40,\n  \"shrinkage_qty\": 3,\n  \"notes\": \"Sortasi batch campuran\",\n  \"results\": [\n    {\n      \"item_type_id\": 1,\n      \"item_grade_id\": 1,\n      \"qty_result\": 18,\n      \"unit_cost\": 17500000\n    },\n    {\n      \"item_type_id\": 1,\n      \"item_grade_id\": 2,\n      \"qty_result\": 12,\n      \"unit_cost\": 17500000\n    }\n  ]\n}"
            }
          }
        },
        {
          "name": "Regrade Lot",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/lots/1/regrade",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"target_grade_id\": 2,\n  \"qty\": 5,\n  \"reason_id\": 3,\n  \"notes\": \"Turun grade setelah QC\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Sales",
      "item": [
        {
          "name": "Create Sales Order",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/sales",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"customer_id\": 1,\n  \"sales_date\": \"2026-04-28\",\n  \"notes\": \"Order customer X\",\n  \"lines\": [\n    {\n      \"item_type_id\": 1,\n      \"item_grade_id\": 1,\n      \"qty_sold\": 30,\n      \"unit_id\": 1,\n      \"selling_price\": 22000000\n    }\n  ]\n}"
            }
          }
        },
        {
          "name": "Allocate Sales Lots",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/sales/1/allocate",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"lines\": [\n    {\n      \"sales_line_id\": 1,\n      \"allocations\": [\n        {\n          \"inventory_lot_id\": 1,\n          \"qty_allocated\": 20\n        },\n        {\n          \"inventory_lot_id\": 4,\n          \"qty_allocated\": 10\n        }\n      ]\n    }\n  ]\n}"
            }
          }
        },
        {
          "name": "Auto Allocate Sales",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/sales/1/auto-allocate",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"policy\": \"FIFO\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Adjustment & Returns",
      "item": [
        {
          "name": "Create Stock Adjustment",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/stock-adjustments",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"inventory_lot_id\": 11,\n  \"adjustment_type\": \"SHRINKAGE\",\n  \"reason_id\": 1,\n  \"qty_change\": -1.2,\n  \"notes\": \"Selisih opname\"\n}"
            }
          }
        },
        {
          "name": "Create Sales Return",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": "{{baseUrl}}/sales-returns",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sales_id\": 1,\n  \"customer_id\": 1,\n  \"return_date\": \"2026-04-29\",\n  \"lines\": [\n    {\n      \"sales_line_id\": 1,\n      \"inventory_lot_id\": 1,\n      \"item_type_id\": 1,\n      \"item_grade_id\": 1,\n      \"qty_returned\": 2,\n      \"return_condition\": \"GOOD\",\n      \"resolution\": \"RESTOCK\"\n    }\n  ]\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Barcode & Reports",
      "item": [
        {
          "name": "Barcode Lookup",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/barcode/lookup/LOT-260428-SUPA-001"
          }
        },
        {
          "name": "Stock Summary Report",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/reports/stock-summary"
          }
        },
        {
          "name": "Traceability Report by Sales",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/reports/traceability?sales_id=1"
          }
        }
      ]
    }
  ]
}