{
  "info": {
    "_postman_id": "visit-report-approval-system",
    "name": "Maintenance Visit Report Approval System API",
    "description": "Complete API collection for visit report approval workflow\n\nThis collection includes:\n- Report Management (CRUD operations)\n- Report Approval/Rejection\n- Comments and Notes\n- Automatic Supply Request Creation\n- Batch Invoice Generation\n- Dashboard Statistics",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "10000001"
  },
  "item": [
    {
      "name": "Report Statistics & Dashboard",
      "item": [
        {
          "name": "Get Approval Statistics",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/statistics",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                "statistics"
              ]
            },
            "description": "Get dashboard statistics:\n- Pending reports count\n- Approved reports count\n- Rejected reports count\n- Reports needing procurement\n- Total reports"
          },
          "response": []
        }
      ]
    },
    {
      "name": "Report Management",
      "item": [
        {
          "name": "List All Reports",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports"
              ]
            },
            "description": "Retrieve all maintenance visit reports"
          },
          "response": []
        },
        {
          "name": "Get Report by ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Get details of a specific report"
          },
          "response": []
        },
        {
          "name": "Get Reports by Visit Request",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/request/:requestId",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                "request",
                ":requestId"
              ],
              "variable": [
                {
                  "key": "requestId",
                  "value": "1"
                }
              ]
            },
            "description": "Get all reports related to a specific maintenance request"
          },
          "response": []
        },
        {
          "name": "Get Reports by Asset",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/asset/:assetId",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                "asset",
                ":assetId"
              ],
              "variable": [
                {
                  "key": "assetId",
                  "value": "1"
                }
              ]
            },
            "description": "Get all reports for a specific asset"
          },
          "response": []
        },
        {
          "name": "Get Reports by Date Range",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/by-date-range?start_date=2024-01-01&end_date=2024-12-31",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                "by-date-range"
              ],
              "query": [
                {
                  "key": "start_date",
                  "value": "2024-01-01"
                },
                {
                  "key": "end_date",
                  "value": "2024-12-31"
                }
              ]
            },
            "description": "Get reports within a specific date range"
          },
          "response": []
        },
        {
          "name": "Create New Report",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"visit_id\": 1,\n  \"technician_id\": 1,\n  \"report_type\": \"preventive\",\n  \"findings\": \"Equipment is functioning normally. Minor lubrication needed.\",\n  \"recommendations\": \"Schedule next maintenance in 3 months.\",\n  \"work_performed\": \"Equipment inspection and lubrication completed.\",\n  \"total_hours\": 2.5,\n  \"spare_parts_used\": [],\n  \"cost_items\": []\n}"
            },
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports"
              ]
            },
            "description": "Create a new visit report"
          },
          "response": []
        },
        {
          "name": "Update Report",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"findings\": \"Equipment needs urgent replacement of bearing.\",\n  \"recommendations\": \"Replace bearing within 24 hours.\",\n  \"total_hours\": 3.0\n}"
            },
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Update an existing report"
          },
          "response": []
        },
        {
          "name": "Get Report with Attachments",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id/with-attachments",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id",
                "with-attachments"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Get report with all attached documents and media"
          },
          "response": []
        }
      ]
    },
    {
      "name": "Report Approval Workflow",
      "item": [
        {
          "name": "Approve Report",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"notes\": \"Report reviewed and approved. Work quality is satisfactory. Proceed with billing.\"\n}"
            },
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id/approve",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id",
                "approve"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Approve a visit report\n\n**Notes:**\n- Changes status to 'approved'\n- Records approval timestamp\n- Logs activity for audit trail\n- Stores optional approval notes"
          },
          "response": []
        },
        {
          "name": "Reject Report",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"reason\": \"Report lacks detailed findings. Technician needs to provide more comprehensive documentation of equipment condition and recommended maintenance items.\"\n}"
            },
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id/reject",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id",
                "reject"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Reject a visit report with reason\n\n**Notes:**\n- Changes status to 'rejected'\n- Records rejection timestamp and reason\n- Logs activity for audit trail\n- Reason is required (max 500 characters)"
          },
          "response": []
        }
      ]
    },
    {
      "name": "Comments & Notes",
      "item": [
        {
          "name": "Add Comment to Report",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"comment\": \"Need to verify the spare parts inventory before creating the supply request. Also, customer needs to approve the estimated cost of 5,000 SAR.\"\n}"
            },
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id/comment",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id",
                "comment"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Add a comment or note to a report\n\n**Notes:**\n- Comment is required (max 1000 characters)\n- Stores user ID of who created the comment\n- Timestamps automatically recorded"
          },
          "response": []
        }
      ]
    },
    {
      "name": "Supply Request Management",
      "item": [
        {
          "name": "Create Automatic Supply Request",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/:id/supply-request",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                ":id",
                "supply-request"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Create automatic supply request from approved report\n\n**Features:**\n- Extracts items from visit report\n- Matches contract conditions\n- Allocates costs (company vs customer)\n- Automatically generates supply order number\n- Creates draft supply order ready for processing\n\n**Returns:**\n- Supply order details\n- Auto-generated order number\n- Item list with cost allocation\n- Procurement status"
          },
          "response": []
        }
      ]
    },
    {
      "name": "Invoice Management",
      "item": [
        {
          "name": "Create Batch Invoice from Reports",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"report_ids\": [1, 2, 3],\n  \"invoice_date\": \"2024-01-15\",\n  \"due_date\": \"2024-02-15\"\n}"
            },
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports/invoice",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports",
                "invoice"
              ]
            },
            "description": "Create batch invoice for multiple approved reports\n\n**Features:**\n- Consolidates multiple reports into single invoice\n- Calculates total amount from all reports\n- Sets invoice and due dates\n- Supports batch operations for efficiency\n\n**Parameters:**\n- report_ids (required): Array of report IDs to invoice\n- invoice_date (optional): Invoice date (defaults to today)\n- due_date (optional): Payment due date (defaults to 30 days from invoice date)"
          },
          "response": []
        }
      ]
    },
    {
      "name": "Report Status Filters",
      "item": [
        {
          "name": "Get Pending Reports",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports?status=pending",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports"
              ],
              "query": [
                {
                  "key": "status",
                  "value": "pending"
                }
              ]
            },
            "description": "Get all reports waiting for approval"
          },
          "response": []
        },
        {
          "name": "Get Approved Reports",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports?status=approved",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports"
              ],
              "query": [
                {
                  "key": "status",
                  "value": "approved"
                }
              ]
            },
            "description": "Get all approved reports ready for invoicing or supply requests"
          },
          "response": []
        },
        {
          "name": "Get Rejected Reports",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{BASE_URL}}/maintenance/reports?status=rejected",
              "host": [
                "{{BASE_URL}}"
              ],
              "path": [
                
                "maintenance",
                "reports"
              ],
              "query": [
                {
                  "key": "status",
                  "value": "rejected"
                }
              ]
            },
            "description": "Get all rejected reports requiring revision"
          },
          "response": []
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost:8000",
      "type": "string"
    },
    {
      "key": "token",
      "value": "your_api_token_here",
      "type": "string"
    }
  ]
}
