swagger: '2.0'
info:
  title: Planning Module API
  description: ''
  contact:
    email: eomoro@krb.go.ke
  license:
    name: BSD License
  version: v1
host: aprpms.devsgraphics.com
schemes:
- http
basePath: /api/planning
consumes:
- application/json
produces:
- application/json
securityDefinitions:
  Basic:
    type: basic
security:
- Basic: []
paths:
  /aprp-export/lookup/export/:
    post:
      operationId: aprp-export_lookup_export_by_keys
      summary: Download APRP Excel (single agency or consolidated)
      description: POST body can specify consolidated=true to export all agencies
        for the given financial_year (optionally filtered by authority_codes). In
        consolidated mode, funding_source and fund_type are ignored. If consolidated=false,
        authority_code, funding_source, and fund_type are required. Optionally include
        revision_number (single-agency) and vat_rate (fraction as string). If no active
        exists in single-agency mode, latest is exported.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/APRPExportKey'
      responses:
        '200':
          description: XLSX stream
        '404':
          description: Not Found
      tags:
      - Planning • APRP Export
    parameters: []
  /aprp-export/{id}/export/:
    get:
      operationId: aprp-export_export_by_id
      summary: Download APRP Excel (by header ID)
      description: Streams an XLSX with KRB styling. Optional query param vat_rate
        (fraction, e.g., 0.16).
      parameters: []
      responses:
        '200':
          description: XLSX stream
      tags:
      - Planning • APRP Export
    parameters:
    - name: id
      in: path
      required: true
      type: string
  /aprp/lookup/:
    post:
      operationId: aprp_lookup
      summary: APRP listing (by business keys, optional revision_number)
      description: POST body contains authority_code, financial_year, funding_source,
        fund_type. Optionally include revision_number (0=original, 1+=revision) and
        vat_rate (fraction). If revision_number is omitted, the active revision is
        returned.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/APRPKeyLookup'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/APRPListingResponse'
        '404':
          description: Not Found
      tags:
      - Planning • APRP
    parameters: []
  /aprp/{id}/listing/:
    get:
      operationId: aprp_listing
      summary: APRP listing (by header ID)
      description: Return header+rows. Optional query param vat_rate (fraction, e.g.,
        0.16).
      parameters: []
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/APRPListingResponse'
      tags:
      - Planning • APRP
    parameters:
    - name: id
      in: path
      required: true
      type: string
  /planning/activities/:
    get:
      operationId: planning_activities_list
      description: ''
      parameters:
      - name: search
        in: query
        description: A search term.
        required: false
        type: string
      - name: ordering
        in: query
        description: Which field to use when ordering the results.
        required: false
        type: string
      - name: page
        in: query
        description: A page number within the paginated result set.
        required: false
        type: integer
      - name: page_size
        in: query
        description: Number of results to return per page.
        required: false
        type: integer
      responses:
        '200':
          description: ''
          schema:
            required:
            - count
            - results
            type: object
            properties:
              count:
                type: integer
              next:
                type: string
                format: uri
                x-nullable: true
              previous:
                type: string
                format: uri
                x-nullable: true
              results:
                type: array
                items:
                  $ref: '#/definitions/WorkplanActivityList'
      tags:
      - Planning • Workplan Activities
    post:
      operationId: planning_activities_create
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanActivityCreate'
      responses:
        '201':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanActivityCreate'
      tags:
      - Planning • Workplan Activities
    parameters: []
  /planning/activities/{id}/:
    get:
      operationId: planning_activities_read
      description: ''
      parameters: []
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanActivityDetail'
      tags:
      - Planning • Workplan Activities
    put:
      operationId: planning_activities_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanActivityUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanActivityUpdate'
      tags:
      - Planning • Workplan Activities
    patch:
      operationId: planning_activities_partial_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanActivityUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanActivityUpdate'
      tags:
      - Planning • Workplan Activities
    delete:
      operationId: planning_activities_delete
      description: ''
      parameters: []
      responses:
        '204':
          description: ''
      tags:
      - Planning • Workplan Activities
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this Workplan Activity.
      required: true
      type: string
      format: uuid
  /planning/details/:
    get:
      operationId: planning_details_list
      description: ''
      parameters:
      - name: search
        in: query
        description: A search term.
        required: false
        type: string
      - name: ordering
        in: query
        description: Which field to use when ordering the results.
        required: false
        type: string
      - name: page
        in: query
        description: A page number within the paginated result set.
        required: false
        type: integer
      - name: page_size
        in: query
        description: Number of results to return per page.
        required: false
        type: integer
      responses:
        '200':
          description: ''
          schema:
            required:
            - count
            - results
            type: object
            properties:
              count:
                type: integer
              next:
                type: string
                format: uri
                x-nullable: true
              previous:
                type: string
                format: uri
                x-nullable: true
              results:
                type: array
                items:
                  $ref: '#/definitions/WorkplanDetailList'
      tags:
      - Planning • Workplan Details
    post:
      operationId: planning_details_create
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanDetailCreate'
      responses:
        '201':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanDetailCreate'
      tags:
      - Planning • Workplan Details
    parameters: []
  /planning/details/{id}/:
    get:
      operationId: planning_details_read
      description: ''
      parameters: []
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanDetailDetail'
      tags:
      - Planning • Workplan Details
    put:
      operationId: planning_details_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanDetailUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanDetailUpdate'
      tags:
      - Planning • Workplan Details
    patch:
      operationId: planning_details_partial_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanDetailUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanDetailUpdate'
      tags:
      - Planning • Workplan Details
    delete:
      operationId: planning_details_delete
      description: ''
      parameters: []
      responses:
        '204':
          description: ''
      tags:
      - Planning • Workplan Details
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this Workplan Detail.
      required: true
      type: string
      format: uuid
  /planning/headers/:
    get:
      operationId: planning_headers_list
      description: ''
      parameters:
      - name: search
        in: query
        description: A search term.
        required: false
        type: string
      - name: ordering
        in: query
        description: Which field to use when ordering the results.
        required: false
        type: string
      - name: page
        in: query
        description: A page number within the paginated result set.
        required: false
        type: integer
      - name: page_size
        in: query
        description: Number of results to return per page.
        required: false
        type: integer
      responses:
        '200':
          description: ''
          schema:
            required:
            - count
            - results
            type: object
            properties:
              count:
                type: integer
              next:
                type: string
                format: uri
                x-nullable: true
              previous:
                type: string
                format: uri
                x-nullable: true
              results:
                type: array
                items:
                  $ref: '#/definitions/WorkplanHeaderList'
      tags:
      - Planning • Workplan Headers
    post:
      operationId: planning_headers_create
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanHeaderCreate'
      responses:
        '201':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanHeaderCreate'
      tags:
      - Planning • Workplan Headers
    parameters: []
  /planning/headers/{id}/:
    get:
      operationId: planning_headers_read
      description: ''
      parameters: []
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanHeaderDetail'
      tags:
      - Planning • Workplan Headers
    put:
      operationId: planning_headers_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanHeaderUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanHeaderUpdate'
      tags:
      - Planning • Workplan Headers
    patch:
      operationId: planning_headers_partial_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanHeaderUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanHeaderUpdate'
      tags:
      - Planning • Workplan Headers
    delete:
      operationId: planning_headers_delete
      description: ''
      parameters: []
      responses:
        '204':
          description: ''
      tags:
      - Planning • Workplan Headers
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this Workplan Header.
      required: true
      type: string
      format: uuid
  /planning/templates/workplan/:
    get:
      operationId: planning_templates_workplan_list
      summary: Download Workplan Upload Template (Excel)
      description: ''
      parameters:
      - name: authority
        in: query
        description: Tailor the template columns for an authority (optional).
        required: false
        type: string
        enum:
        - KeRRA
        - KURA
        - KWS
        - KeNHA
      responses:
        '200':
          description: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
      tags:
      - Planning • Workplan Templates
    parameters: []
  /planning/uploads/:
    get:
      operationId: planning_uploads_list
      description: ''
      parameters:
      - name: search
        in: query
        description: A search term.
        required: false
        type: string
      - name: ordering
        in: query
        description: Which field to use when ordering the results.
        required: false
        type: string
      - name: page
        in: query
        description: A page number within the paginated result set.
        required: false
        type: integer
      - name: page_size
        in: query
        description: Number of results to return per page.
        required: false
        type: integer
      responses:
        '200':
          description: ''
          schema:
            required:
            - count
            - results
            type: object
            properties:
              count:
                type: integer
              next:
                type: string
                format: uri
                x-nullable: true
              previous:
                type: string
                format: uri
                x-nullable: true
              results:
                type: array
                items:
                  $ref: '#/definitions/WorkplanUploadList'
      tags:
      - Planning • Workplan Uploads
    post:
      operationId: planning_uploads_create
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanUploadCreate'
      responses:
        '201':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanUploadCreate'
      tags:
      - Planning • Workplan Uploads
    parameters: []
  /planning/uploads/{id}/:
    get:
      operationId: planning_uploads_read
      description: ''
      parameters: []
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanUploadDetail'
      tags:
      - Planning • Workplan Uploads
    put:
      operationId: planning_uploads_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanUploadUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanUploadUpdate'
      tags:
      - Planning • Workplan Uploads
    patch:
      operationId: planning_uploads_partial_update
      description: ''
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanUploadUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanUploadUpdate'
      tags:
      - Planning • Workplan Uploads
    delete:
      operationId: planning_uploads_delete
      description: ''
      parameters: []
      responses:
        '204':
          description: ''
      tags:
      - Planning • Workplan Uploads
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this Workplan Upload.
      required: true
      type: string
      format: uuid
  /planning/workplans/export/:
    get:
      operationId: planning_workplans_export_list
      summary: Export ARWP Workplan (by query filters)
      description: |-
        Exports the latest WorkplanHeader (highest revision_number) matching the given filters.

        **Required query params**:
        - financial_year (e.g. `2024/2025`)
        - agency (e.g. `KURA`, `KeRRA`, `KeNHA`)
        - fund_type (e.g. `Development`, `Recurrent`)
        - funding_source (e.g. `RMLF`, `Exchequer`)

        **Example**:
        `/api/planning/workplans/export/?financial_year=2024/2025&agency=KURA&fund_type=Development&funding_source=RMLF`

        Returns an XLSX binary response.
      parameters:
      - name: financial_year
        in: query
        required: true
        type: string
        pattern: ^\d{4}-\d{2}$
        minLength: 1
      - name: agency
        in: query
        required: true
        type: string
        enum:
        - KeRRA
        - KURA
        - KWS
        - KeNHA
      - name: fund_type
        in: query
        required: true
        type: string
        minLength: 1
      - name: funding_source
        in: query
        required: true
        type: string
        minLength: 1
      responses:
        '200':
          description: XLSX file download
          schema:
            type: file
        '404':
          description: No matching header found
          schema:
            required:
            - success
            - message
            - statusCode
            - data
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Workplan header not found.
              statusCode:
                type: integer
                example: 404
              data:
                type: array
                items:
                  type: object
                example: []
      tags:
      - planning
    parameters: []
  /planning/workplans/export/{id}/export/:
    get:
      operationId: planning_workplans_export_export_by_header_id
      summary: Export ARWP Workplan (by header id)
      description: |-
        Exports the WorkplanHeader identified by `{header_id}`.

        **Example**:
        `/api/planning/workplans/<header_id>/export/`

        Returns an XLSX binary response.
      parameters:
      - name: header_id
        in: path
        description: WorkplanHeader primary key (UUID/int depending on your model).
        required: true
        type: string
        example: a1b2c3d4-1111-2222-3333-444455556666
      responses:
        '200':
          description: XLSX file download
          schema:
            type: file
        '404':
          description: Header not found
          schema:
            required:
            - success
            - message
            - statusCode
            - data
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Workplan header not found.
              statusCode:
                type: integer
                example: 404
              data:
                type: array
                items:
                  type: object
                example: []
      tags:
      - planning
    parameters:
    - name: id
      in: path
      required: true
      type: string
  /workplan-compliance-review-items/{id}/:
    patch:
      operationId: workplan-compliance-review-items_partial_update
      summary: Update a compliance checklist response
      description: |-
        PATCH-safe item updates.

        Avoids Postgres error:
          FOR UPDATE cannot be applied to the nullable side of an outer join
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanComplianceReviewItemUpdate'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewItem'
      tags:
      - workplan-compliance-review-items
    parameters:
    - name: id
      in: path
      required: true
      type: string
  /workplan-compliance-reviews/:
    get:
      operationId: workplan-compliance-reviews_list
      description: Compliance review workflow.
      parameters:
      - name: page
        in: query
        description: A page number within the paginated result set.
        required: false
        type: integer
      - name: page_size
        in: query
        description: Number of results to return per page.
        required: false
        type: integer
      responses:
        '200':
          description: ''
          schema:
            required:
            - count
            - results
            type: object
            properties:
              count:
                type: integer
              next:
                type: string
                format: uri
                x-nullable: true
              previous:
                type: string
                format: uri
                x-nullable: true
              results:
                type: array
                items:
                  $ref: '#/definitions/WorkplanComplianceReviewList'
      tags:
      - workplan-compliance-reviews
    post:
      operationId: workplan-compliance-reviews_create
      summary: Create compliance review for a workplan header
      description: |-
        Creates a compliance review for an ACTIVE WorkplanHeader.

        System behavior:
        - Uses active checklist if checklist_id not provided
        - Sets first stage as current
        - Seeds items: inactive -> N/A, active -> Under Review
        - Updates WorkplanHeader compliance summary fields
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/CreateComplianceReview'
      responses:
        '201':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewDetail'
      tags:
      - workplan-compliance-reviews
    parameters: []
  /workplan-compliance-reviews/{id}/:
    get:
      operationId: workplan-compliance-reviews_read
      description: Compliance review workflow.
      parameters: []
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewDetail'
      tags:
      - workplan-compliance-reviews
    put:
      operationId: workplan-compliance-reviews_update
      description: Compliance review workflow.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanComplianceReviewDetail'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewDetail'
      tags:
      - workplan-compliance-reviews
    patch:
      operationId: workplan-compliance-reviews_partial_update
      description: Compliance review workflow.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/WorkplanComplianceReviewDetail'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewDetail'
      tags:
      - workplan-compliance-reviews
    delete:
      operationId: workplan-compliance-reviews_delete
      description: Compliance review workflow.
      parameters: []
      responses:
        '204':
          description: ''
      tags:
      - workplan-compliance-reviews
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this workplan compliance review.
      required: true
      type: string
      format: uuid
  /workplan-compliance-reviews/{id}/advance-stage/:
    post:
      operationId: workplan-compliance-reviews_advance_stage
      summary: Advance stage (approve + move next / close review)
      description: Compliance review workflow.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/ApproveStage'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewDetail'
      tags:
      - workplan-compliance-reviews
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this workplan compliance review.
      required: true
      type: string
      format: uuid
  /workplan-compliance-reviews/{id}/approve-current-stage/:
    post:
      operationId: workplan-compliance-reviews_approve_current_stage
      summary: Approve current stage (quorum-aware)
      description: Compliance review workflow.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/ApproveStage'
      responses:
        '200':
          description: OK
      tags:
      - workplan-compliance-reviews
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this workplan compliance review.
      required: true
      type: string
      format: uuid
  /workplan-compliance-reviews/{id}/assign-stage-users/:
    post:
      operationId: workplan-compliance-reviews_assign_stage_users
      summary: Assign users to a stage (Reviewer 1/2/Approver)
      description: Compliance review workflow.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/AssignStageUsers'
      responses:
        '200':
          description: OK
      tags:
      - workplan-compliance-reviews
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this workplan compliance review.
      required: true
      type: string
      format: uuid
  /workplan-compliance-reviews/{id}/progress/:
    get:
      operationId: workplan-compliance-reviews_progress
      summary: Get progress for current stage
      description: Compliance review workflow.
      parameters: []
      responses:
        '200':
          description: OK
      tags:
      - workplan-compliance-reviews
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this workplan compliance review.
      required: true
      type: string
      format: uuid
  /workplan-compliance-reviews/{id}/submit/:
    post:
      operationId: workplan-compliance-reviews_submit
      summary: Submit review
      description: Compliance review workflow.
      parameters:
      - name: data
        in: body
        required: true
        schema:
          $ref: '#/definitions/SubmitReview'
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanComplianceReviewDetail'
      tags:
      - workplan-compliance-reviews
    parameters:
    - name: id
      in: path
      description: A UUID string identifying this workplan compliance review.
      required: true
      type: string
      format: uuid
  /workplans/import/:
    post:
      operationId: workplans_import_create
      summary: Import ARWP Workplan (validate or commit)
      description: Upload the ARWP Excel. Use dry_run=true to validate without saving;
        dry_run=false to import.
      parameters:
      - name: file
        in: formData
        required: true
        type: file
      - name: dry_run
        in: formData
        required: false
        type: boolean
        default: true
      - name: max_errors
        in: formData
        required: false
        type: integer
        default: 500
        maximum: 10000
        minimum: 10
      - name: row_error_limit
        in: formData
        required: false
        type: integer
        default: 10
        maximum: 100
        minimum: 1
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanImportResponse'
        '422':
          description: ''
          schema:
            $ref: '#/definitions/WorkplanImportResponse'
      consumes:
      - multipart/form-data
      - application/x-www-form-urlencoded
      tags:
      - Planning • Workplan Import
    parameters: []
definitions:
  APRPExportKey:
    required:
    - financial_year
    type: object
    properties:
      consolidated:
        title: Consolidated
        type: boolean
        default: false
      authority_code:
        title: Authority code
        description: e.g. KURA, KERRA, KENHA, KWS
        type: string
        minLength: 1
      authority_codes:
        description: Optional list of authority codes to include when consolidated=True.
        type: array
        items:
          type: string
          minLength: 1
      financial_year:
        title: Financial year
        description: e.g. 2025-26
        type: string
        minLength: 1
      funding_source:
        title: Funding source
        description: e.g. 15% RMLF KURA Portion
        type: string
        minLength: 1
      fund_type:
        title: Fund type
        description: e.g. Current Financial Year Allocation
        type: string
        minLength: 1
      revision_number:
        title: Revision number
        description: Only for single-agency mode. If omitted, active revision is used;
          else latest.
        type: integer
        minimum: 0
      vat_rate:
        title: Vat rate
        description: Fraction as string, e.g. "0.16"
        type: string
        minLength: 1
  APRPKeyLookup:
    required:
    - authority_code
    - financial_year
    - funding_source
    - fund_type
    type: object
    properties:
      authority_code:
        title: Authority code
        description: e.g. KURA
        type: string
        minLength: 1
      financial_year:
        title: Financial year
        description: e.g. 2025-26
        type: string
        minLength: 1
      funding_source:
        title: Funding source
        description: e.g. 15% RMLF KURA Portion
        type: string
        minLength: 1
      fund_type:
        title: Fund type
        description: e.g. Current Financial Year Allocation
        type: string
        minLength: 1
      revision_number:
        title: Revision number
        description: Optional. 0=Original, 1+=Revision. If omitted, active revision
          is used.
        type: integer
        minimum: 0
      vat_rate:
        title: Vat rate
        description: Optional override as a fraction (e.g., 0.16 for 16%). If omitted,
          uses VAT singleton from DB.
        type: string
        format: decimal
  APRPHeader:
    required:
    - authority
    - authorityCode
    - fundingSource
    - fundType
    - financialYear
    - budget
    - totalPlannedSectionLengthKm
    - totalAmountKsh
    - totalAmountKshWithVAT
    type: object
    properties:
      authority:
        title: Authority
        type: string
        minLength: 1
      authorityCode:
        title: Authoritycode
        type: string
        minLength: 1
      fundingSource:
        title: Fundingsource
        type: string
        minLength: 1
      fundType:
        title: Fundtype
        type: string
        minLength: 1
      financialYear:
        title: Financialyear
        type: string
        minLength: 1
      budget:
        title: Budget
        type: number
      totalPlannedSectionLengthKm:
        title: Totalplannedsectionlengthkm
        type: number
      totalAmountKsh:
        title: Totalamountksh
        type: number
      totalAmountKshWithVAT:
        title: Totalamountkshwithvat
        type: number
  APRPRow:
    required:
    - authority
    - authorityCode
    - fundingSource
    - fundType
    - financialYear
    - workplanId
    - regionOrCounty
    - constituency
    - cityOrMunicipality
    - nationalParkOrGameReserve
    - itemNumber
    - roadId
    - sectionId
    - sectionOrRoadName
    - workCategory
    - surfaceType
    - roadConditionStatus
    - plannedSectionLengthKm
    - amountKsh
    - amountKshWithVAT
    type: object
    properties:
      authority:
        title: Authority
        type: string
        minLength: 1
      authorityCode:
        title: Authoritycode
        type: string
        minLength: 1
      fundingSource:
        title: Fundingsource
        type: string
        minLength: 1
      fundType:
        title: Fundtype
        type: string
        minLength: 1
      financialYear:
        title: Financialyear
        type: string
        minLength: 1
      workplanId:
        title: Workplanid
        type: integer
      regionOrCounty:
        title: Regionorcounty
        type: string
        minLength: 1
      constituency:
        title: Constituency
        type: string
        minLength: 1
      cityOrMunicipality:
        title: Cityormunicipality
        type: string
        minLength: 1
      nationalParkOrGameReserve:
        title: Nationalparkorgamereserve
        type: string
        minLength: 1
      itemNumber:
        title: Itemnumber
        type: integer
        x-nullable: true
      roadId:
        title: Roadid
        type: string
        minLength: 1
      sectionId:
        title: Sectionid
        type: string
        minLength: 1
      sectionOrRoadName:
        title: Sectionorroadname
        type: string
        minLength: 1
      workCategory:
        title: Workcategory
        type: string
        minLength: 1
      surfaceType:
        title: Surfacetype
        type: string
        minLength: 1
      roadConditionStatus:
        title: Roadconditionstatus
        type: string
        minLength: 1
      plannedSectionLengthKm:
        title: Plannedsectionlengthkm
        type: number
      amountKsh:
        title: Amountksh
        type: number
      amountKshWithVAT:
        title: Amountkshwithvat
        type: number
  APRPListingResponse:
    required:
    - header
    - rows
    type: object
    properties:
      header:
        $ref: '#/definitions/APRPHeader'
      rows:
        type: array
        items:
          $ref: '#/definitions/APRPRow'
  WorkplanActivityList:
    required:
    - detail
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      detail:
        title: Detail
        type: string
        format: uuid
      activity_code:
        title: Activity code
        type: string
        maxLength: 50
        x-nullable: true
      activity_description:
        title: Activity description
        type: string
        x-nullable: true
      method:
        title: Method
        type: string
        maxLength: 100
        x-nullable: true
      unit_measure:
        title: Unit measure
        type: string
        maxLength: 50
        x-nullable: true
      planned_quantity:
        title: Planned quantity
        type: string
        format: decimal
        x-nullable: true
      planned_rate_ksh:
        title: Planned rate ksh
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
  WorkplanActivityCreate:
    required:
    - detail
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      detail:
        title: Detail
        type: string
        format: uuid
      activity_code:
        title: Activity code
        type: string
        maxLength: 50
        x-nullable: true
      activity_description:
        title: Activity description
        type: string
        x-nullable: true
      method:
        title: Method
        type: string
        maxLength: 100
        x-nullable: true
      unit_measure:
        title: Unit measure
        type: string
        maxLength: 50
        x-nullable: true
      planned_quantity:
        title: Planned quantity
        type: string
        format: decimal
        x-nullable: true
      planned_rate_ksh:
        title: Planned rate ksh
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
  WorkplanActivityDetail:
    required:
    - detail
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      detail:
        title: Detail
        type: string
        format: uuid
      activity_code:
        title: Activity code
        type: string
        maxLength: 50
        x-nullable: true
      activity_description:
        title: Activity description
        type: string
        x-nullable: true
      method:
        title: Method
        type: string
        maxLength: 100
        x-nullable: true
      unit_measure:
        title: Unit measure
        type: string
        maxLength: 50
        x-nullable: true
      planned_quantity:
        title: Planned quantity
        type: string
        format: decimal
        x-nullable: true
      planned_rate_ksh:
        title: Planned rate ksh
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
  WorkplanActivityUpdate:
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      activity_code:
        title: Activity code
        type: string
        maxLength: 50
        x-nullable: true
      activity_description:
        title: Activity description
        type: string
        x-nullable: true
      method:
        title: Method
        type: string
        maxLength: 100
        x-nullable: true
      unit_measure:
        title: Unit measure
        type: string
        maxLength: 50
        x-nullable: true
      planned_quantity:
        title: Planned quantity
        type: string
        format: decimal
        x-nullable: true
      planned_rate_ksh:
        title: Planned rate ksh
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
  WorkplanDetailList:
    required:
    - header
    - region_or_county
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      header:
        title: Header
        type: string
        format: uuid
      region_or_county:
        title: Region or county
        type: string
        minLength: 1
      constituency:
        title: Constituency
        type: string
        x-nullable: true
      city_or_municipality:
        title: City or municipality
        type: string
        x-nullable: true
      national_park_or_game_reserve:
        title: National park or game reserve
        type: string
        x-nullable: true
      road_id:
        title: Road id
        type: string
        x-nullable: true
      section_id:
        title: Section id
        type: string
        x-nullable: true
      section_or_road_name:
        title: Section or road name
        type: string
        x-nullable: true
      work_category:
        title: Work category
        type: string
        x-nullable: true
      surface_type:
        title: Surface type
        type: string
        x-nullable: true
      road_condition_status:
        title: Road condition status
        type: string
        x-nullable: true
      planned_section_length_km:
        title: Planned section length km
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
      activities_count:
        title: Activities count
        type: integer
        readOnly: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
  WorkplanDetailCreate:
    required:
    - header
    - region_or_county
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      header:
        title: Header
        type: string
        format: uuid
      region_or_county:
        title: Region or county
        type: string
        minLength: 1
      constituency:
        title: Constituency
        type: string
        x-nullable: true
      city_or_municipality:
        title: City or municipality
        type: string
        x-nullable: true
      national_park_or_game_reserve:
        title: National park or game reserve
        type: string
        x-nullable: true
      road_id:
        title: Road id
        type: string
        x-nullable: true
      section_id:
        title: Section id
        type: string
        x-nullable: true
      section_or_road_name:
        title: Section or road name
        type: string
        x-nullable: true
      work_category:
        title: Work category
        type: string
        x-nullable: true
      surface_type:
        title: Surface type
        type: string
        x-nullable: true
      road_condition_status:
        title: Road condition status
        type: string
        x-nullable: true
      planned_section_length_km:
        title: Planned section length km
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
      description:
        title: Description
        type: string
        x-nullable: true
  WorkplanDetailDetail:
    required:
    - header
    - region_or_county
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      header:
        title: Header
        type: string
        format: uuid
      region_or_county:
        title: Region or county
        type: string
        minLength: 1
      constituency:
        title: Constituency
        type: string
        x-nullable: true
      city_or_municipality:
        title: City or municipality
        type: string
        x-nullable: true
      national_park_or_game_reserve:
        title: National park or game reserve
        type: string
        x-nullable: true
      road_id:
        title: Road id
        type: string
        x-nullable: true
      section_id:
        title: Section id
        type: string
        x-nullable: true
      section_or_road_name:
        title: Section or road name
        type: string
        x-nullable: true
      work_category:
        title: Work category
        type: string
        x-nullable: true
      surface_type:
        title: Surface type
        type: string
        x-nullable: true
      road_condition_status:
        title: Road condition status
        type: string
        x-nullable: true
      planned_section_length_km:
        title: Planned section length km
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
      description:
        title: Description
        type: string
        x-nullable: true
      activities_count:
        title: Activities count
        type: integer
        readOnly: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
  WorkplanDetailUpdate:
    required:
    - region_or_county
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      region_or_county:
        title: Region or county
        type: string
        minLength: 1
      constituency:
        title: Constituency
        type: string
        x-nullable: true
      city_or_municipality:
        title: City or municipality
        type: string
        x-nullable: true
      national_park_or_game_reserve:
        title: National park or game reserve
        type: string
        x-nullable: true
      road_id:
        title: Road id
        type: string
        x-nullable: true
      section_id:
        title: Section id
        type: string
        x-nullable: true
      section_or_road_name:
        title: Section or road name
        type: string
        x-nullable: true
      work_category:
        title: Work category
        type: string
        x-nullable: true
      surface_type:
        title: Surface type
        type: string
        x-nullable: true
      road_condition_status:
        title: Road condition status
        type: string
        x-nullable: true
      planned_section_length_km:
        title: Planned section length km
        type: string
        format: decimal
        x-nullable: true
      amount_ksh:
        title: Amount ksh
        type: string
        format: decimal
        x-nullable: true
      description:
        title: Description
        type: string
        x-nullable: true
  WorkplanHeaderList:
    required:
    - authority_code
    - financial_year
    - funding_source
    - fund_type
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      authority:
        title: Authority
        description: Road Authority name.
        type: string
        maxLength: 255
      authority_code:
        title: Authority code
        description: Unique code for the Road Authority (alphanumeric, underscore,
          dash, dot).
        type: string
        pattern: ^[A-Za-z0-9_\-\.]+$
        maxLength: 50
        minLength: 1
      financial_year:
        title: Financial year
        description: e.g. 2024-25
        type: string
        pattern: ^\d{4}-\d{2}$
        maxLength: 9
        minLength: 1
      funding_source:
        title: Funding source
        type: string
        maxLength: 255
        minLength: 1
      fund_type:
        title: Fund type
        type: string
        maxLength: 255
        minLength: 1
      budget:
        title: Budget
        type: string
        format: decimal
      approval_status:
        title: Approval status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
      board_approval:
        title: Board approval
        type: boolean
      revision_status:
        title: Revision status
        type: integer
        enum:
        - 0
        - 1
        readOnly: true
      revision_number:
        title: Revision number
        description: 0 for original; 1+ for revisions.
        type: integer
        default: 0
        maximum: 2147483647
        minimum: 0
      is_active:
        title: Is active
        description: 'System-managed: the highest revision is active.'
        type: boolean
        readOnly: true
        default: true
      planned_km:
        title: Planned km
        type: string
        format: decimal
        readOnly: true
      compliance_review_status:
        title: Compliance review status
        description: System-managed summary of compliance review status for this header.
        type: integer
        enum:
        - -1
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        readOnly: true
      compliance_review_started_at:
        title: Compliance review started at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_submitted_at:
        title: Compliance review submitted at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_at:
        title: Compliance review closed at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_by:
        title: Compliance review closed by
        type: string
        readOnly: true
        minLength: 1
        x-nullable: true
      compliance_review_summary_comment:
        title: Compliance review summary comment
        type: string
        readOnly: true
        minLength: 1
      compliance_review_last_review_id:
        title: Compliance review last review id
        description: Pointer to latest WorkplanComplianceReview.id (optional).
        type: string
        format: uuid
        readOnly: true
        x-nullable: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
  WorkplanHeaderCreate:
    required:
    - authority_code
    - financial_year
    - funding_source
    - fund_type
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      authority:
        title: Authority
        description: Road Authority name.
        type: string
        maxLength: 255
      authority_code:
        title: Authority code
        description: Unique code for the Road Authority (alphanumeric, underscore,
          dash, dot).
        type: string
        pattern: ^[A-Za-z0-9_\-\.]+$
        maxLength: 50
        minLength: 1
      financial_year:
        title: Financial year
        description: e.g. 2024-25
        type: string
        pattern: ^\d{4}-\d{2}$
        maxLength: 9
        minLength: 1
      funding_source:
        title: Funding source
        type: string
        maxLength: 255
        minLength: 1
      fund_type:
        title: Fund type
        type: string
        maxLength: 255
        minLength: 1
      budget:
        title: Budget
        type: string
        format: decimal
      approval_status:
        title: Approval status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
      board_approval:
        title: Board approval
        type: boolean
      revision_number:
        title: Revision number
        description: 0 for original; 1+ for revisions.
        type: integer
        default: 0
        maximum: 2147483647
        minimum: 0
      source_upload:
        title: Source upload
        description: Original uploaded Excel that created this header.
        type: string
        format: uuid
        x-nullable: true
      creation_date:
        title: Creation date
        type: string
        format: date-time
        x-nullable: true
      created_by:
        title: Created by
        type: string
        maxLength: 255
        x-nullable: true
      planned_km:
        title: Planned km
        type: string
        format: decimal
        readOnly: true
      compliance_review_status:
        title: Compliance review status
        description: System-managed summary of compliance review status for this header.
        type: integer
        enum:
        - -1
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        readOnly: true
      compliance_review_started_at:
        title: Compliance review started at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_submitted_at:
        title: Compliance review submitted at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_at:
        title: Compliance review closed at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_by:
        title: Compliance review closed by
        type: string
        readOnly: true
        minLength: 1
        x-nullable: true
      compliance_review_summary_comment:
        title: Compliance review summary comment
        type: string
        readOnly: true
        minLength: 1
      compliance_review_last_review_id:
        title: Compliance review last review id
        description: Pointer to latest WorkplanComplianceReview.id (optional).
        type: string
        format: uuid
        readOnly: true
        x-nullable: true
  WorkplanHeaderDetail:
    required:
    - authority_code
    - financial_year
    - funding_source
    - fund_type
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      authority:
        title: Authority
        description: Road Authority name.
        type: string
        maxLength: 255
      authority_code:
        title: Authority code
        description: Unique code for the Road Authority (alphanumeric, underscore,
          dash, dot).
        type: string
        pattern: ^[A-Za-z0-9_\-\.]+$
        maxLength: 50
        minLength: 1
      financial_year:
        title: Financial year
        description: e.g. 2024-25
        type: string
        pattern: ^\d{4}-\d{2}$
        maxLength: 9
        minLength: 1
      funding_source:
        title: Funding source
        type: string
        maxLength: 255
        minLength: 1
      fund_type:
        title: Fund type
        type: string
        maxLength: 255
        minLength: 1
      budget:
        title: Budget
        type: string
        format: decimal
      approval_status:
        title: Approval status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
      board_approval:
        title: Board approval
        type: boolean
      revision_status:
        title: Revision status
        type: integer
        enum:
        - 0
        - 1
        readOnly: true
      revision_number:
        title: Revision number
        description: 0 for original; 1+ for revisions.
        type: integer
        default: 0
        maximum: 2147483647
        minimum: 0
      is_active:
        title: Is active
        description: 'System-managed: the highest revision is active.'
        type: boolean
        readOnly: true
        default: true
      source_upload:
        title: Source upload
        description: Original uploaded Excel that created this header.
        type: string
        format: uuid
        x-nullable: true
      creation_date:
        title: Creation date
        type: string
        format: date-time
        x-nullable: true
      created_by:
        title: Created by
        type: string
        maxLength: 255
        x-nullable: true
      planned_km:
        title: Planned km
        type: string
        format: decimal
        readOnly: true
      compliance_review_status:
        title: Compliance review status
        description: System-managed summary of compliance review status for this header.
        type: integer
        enum:
        - -1
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        readOnly: true
      compliance_review_started_at:
        title: Compliance review started at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_submitted_at:
        title: Compliance review submitted at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_at:
        title: Compliance review closed at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_by:
        title: Compliance review closed by
        type: string
        readOnly: true
        minLength: 1
        x-nullable: true
      compliance_review_summary_comment:
        title: Compliance review summary comment
        type: string
        readOnly: true
        minLength: 1
      compliance_review_last_review_id:
        title: Compliance review last review id
        description: Pointer to latest WorkplanComplianceReview.id (optional).
        type: string
        format: uuid
        readOnly: true
        x-nullable: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      details_count:
        title: Details count
        type: integer
        readOnly: true
  WorkplanHeaderUpdate:
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      budget:
        title: Budget
        type: string
        format: decimal
      approval_status:
        title: Approval status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
      board_approval:
        title: Board approval
        type: boolean
      revision_number:
        title: Revision number
        description: 0 for original; 1+ for revisions.
        type: integer
        maximum: 2147483647
        minimum: 0
      planned_km:
        title: Planned km
        type: string
        format: decimal
        readOnly: true
      compliance_review_status:
        title: Compliance review status
        description: System-managed summary of compliance review status for this header.
        type: integer
        enum:
        - -1
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        readOnly: true
      compliance_review_started_at:
        title: Compliance review started at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_submitted_at:
        title: Compliance review submitted at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_at:
        title: Compliance review closed at
        type: string
        format: date-time
        readOnly: true
        x-nullable: true
      compliance_review_closed_by:
        title: Compliance review closed by
        type: string
        readOnly: true
        minLength: 1
        x-nullable: true
      compliance_review_summary_comment:
        title: Compliance review summary comment
        type: string
        readOnly: true
        minLength: 1
      compliance_review_last_review_id:
        title: Compliance review last review id
        description: Pointer to latest WorkplanComplianceReview.id (optional).
        type: string
        format: uuid
        readOnly: true
        x-nullable: true
  WorkplanUploadList:
    required:
    - original_name
    - sha256
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      original_name:
        title: Original name
        type: string
        maxLength: 255
        minLength: 1
      status:
        title: Status
        type: string
        enum:
        - draft
        - validated
        - imported
        - failed
      uploaded_by:
        title: Uploaded by
        type: string
        maxLength: 255
      uploaded_at:
        title: Uploaded at
        type: string
        format: date-time
        readOnly: true
      size:
        title: Size
        type: integer
        maximum: 9223372036854775807
        minimum: 0
      sha256:
        title: Sha256
        type: string
        maxLength: 64
        minLength: 1
      sha256_short:
        title: Sha256 short
        type: string
        readOnly: true
      file_url:
        title: File url
        type: string
        readOnly: true
        x-nullable: true
      header_id_hint:
        title: Header id hint
        type: string
        format: uuid
        x-nullable: true
  WorkplanUploadCreate:
    required:
    - original_name
    - sha256
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      file:
        title: File
        type: string
        readOnly: true
        format: uri
      original_name:
        title: Original name
        type: string
        maxLength: 255
        minLength: 1
      content_type:
        title: Content type
        type: string
        maxLength: 150
      size:
        title: Size
        type: integer
        maximum: 9223372036854775807
        minimum: 0
      sha256:
        title: Sha256
        type: string
        maxLength: 64
        minLength: 1
      uploaded_by:
        title: Uploaded by
        type: string
        maxLength: 255
      notes:
        title: Notes
        type: string
  WorkplanUploadDetail:
    required:
    - original_name
    - sha256
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      file:
        title: File
        type: string
        readOnly: true
        format: uri
      original_name:
        title: Original name
        type: string
        maxLength: 255
        minLength: 1
      content_type:
        title: Content type
        type: string
        maxLength: 150
      size:
        title: Size
        type: integer
        maximum: 9223372036854775807
        minimum: 0
      sha256:
        title: Sha256
        type: string
        maxLength: 64
        minLength: 1
      sha256_short:
        title: Sha256 short
        type: string
        readOnly: true
      status:
        title: Status
        type: string
        enum:
        - draft
        - validated
        - imported
        - failed
      uploaded_by:
        title: Uploaded by
        type: string
        maxLength: 255
      uploaded_at:
        title: Uploaded at
        type: string
        format: date-time
        readOnly: true
      header_id_hint:
        title: Header id hint
        type: string
        format: uuid
        x-nullable: true
      notes:
        title: Notes
        type: string
      result_json:
        title: Result json
        type: object
        x-nullable: true
      log_json:
        title: Log json
        type: object
      file_url:
        title: File url
        type: string
        readOnly: true
        x-nullable: true
  WorkplanUploadUpdate:
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      status:
        title: Status
        type: string
        enum:
        - draft
        - validated
        - imported
        - failed
      header_id_hint:
        title: Header id hint
        type: string
        format: uuid
        x-nullable: true
      notes:
        title: Notes
        type: string
      result_json:
        title: Result json
        type: object
        x-nullable: true
      log_json:
        title: Log json
        type: object
  WorkplanComplianceReviewItemUpdate:
    required:
    - status
    type: object
    properties:
      status:
        title: Status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
      comment:
        title: Comment
        type: string
        default: ''
  ComplianceReviewStage:
    required:
    - code
    - name
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      code:
        title: Code
        description: e.g. STG1, STG2
        type: string
        maxLength: 50
        minLength: 1
      name:
        title: Name
        type: string
        maxLength: 255
        minLength: 1
      order:
        title: Order
        description: Defines stage order (ascending).
        type: integer
        maximum: 2147483647
        minimum: 0
      is_active:
        title: Is active
        type: boolean
      required_approvals:
        title: Required approvals
        description: How many approvers must approve this stage before advancing.
        type: integer
        maximum: 2147483647
        minimum: 0
      approval_policy:
        title: Approval policy
        description: Who is allowed to approve this stage.
        type: integer
        enum:
        - 0
        - 1
      approval_policy_display:
        title: Approval policy display
        type: string
        readOnly: true
  ComplianceChecklistItem:
    required:
    - code
    - title
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      code:
        title: Code
        description: e.g. C01, C02
        type: string
        maxLength: 50
        minLength: 1
      title:
        title: Title
        type: string
        maxLength: 255
        minLength: 1
      description:
        title: Description
        type: string
      order:
        title: Order
        type: integer
        maximum: 2147483647
        minimum: 0
      is_required:
        title: Is required
        type: boolean
      is_active:
        title: Is active
        description: If false, review status is set to N/A.
        type: boolean
      stage:
        $ref: '#/definitions/ComplianceReviewStage'
  MiniUser:
    required:
    - username
    - email
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      username:
        title: Username
        type: string
        maxLength: 150
        minLength: 1
      email:
        title: Email
        type: string
        format: email
        maxLength: 254
        minLength: 1
  WorkplanComplianceReviewItem:
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      review:
        title: Review
        type: string
        format: uuid
        readOnly: true
      checklist_item:
        $ref: '#/definitions/ComplianceChecklistItem'
      status:
        title: Status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
      status_display:
        title: Status display
        type: string
        readOnly: true
        minLength: 1
      comment:
        title: Comment
        type: string
      updated_by:
        $ref: '#/definitions/MiniUser'
      updated_at:
        title: Updated at
        type: string
        format: date-time
        readOnly: true
  WorkplanHeaderMini:
    required:
    - authority_code
    - financial_year
    - funding_source
    - fund_type
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      authority:
        title: Authority
        description: Road Authority name.
        type: string
        maxLength: 255
      authority_code:
        title: Authority code
        description: Unique code for the Road Authority (alphanumeric, underscore,
          dash, dot).
        type: string
        pattern: ^[A-Za-z0-9_\-\.]+$
        maxLength: 50
        minLength: 1
      financial_year:
        title: Financial year
        description: e.g. 2024-25
        type: string
        pattern: ^\d{4}-\d{2}$
        maxLength: 9
        minLength: 1
      funding_source:
        title: Funding source
        type: string
        maxLength: 255
        minLength: 1
      fund_type:
        title: Fund type
        type: string
        maxLength: 255
        minLength: 1
      revision_number:
        title: Revision number
        description: 0 for original; 1+ for revisions.
        type: integer
        default: 0
        maximum: 2147483647
        minimum: 0
      is_active:
        title: Is active
        description: 'System-managed: the highest revision is active.'
        type: boolean
        default: true
      compliance_review_status:
        title: Compliance review status
        description: System-managed summary of compliance review status for this header.
        type: integer
        enum:
        - -1
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
      compliance_review_status_display:
        title: Compliance review status display
        type: string
        readOnly: true
        minLength: 1
      compliance_review_last_review_id:
        title: Compliance review last review id
        description: Pointer to latest WorkplanComplianceReview.id (optional).
        type: string
        format: uuid
        x-nullable: true
  ComplianceChecklist:
    required:
    - name
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      name:
        title: Name
        type: string
        maxLength: 255
        minLength: 1
      version:
        title: Version
        type: integer
        default: 1
        maximum: 2147483647
        minimum: 0
      description:
        title: Description
        type: string
      is_active:
        title: Is active
        type: boolean
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
  WorkplanComplianceReviewList:
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      header:
        $ref: '#/definitions/WorkplanHeaderMini'
      checklist:
        $ref: '#/definitions/ComplianceChecklist'
      status:
        title: Status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
        default: 0
      status_display:
        title: Status display
        type: string
        readOnly: true
        minLength: 1
      overall_decision:
        title: Overall decision
        type: integer
        enum:
        - 9
        - 0
        - 1
        - 2
      decision_display:
        title: Decision display
        type: string
        readOnly: true
        minLength: 1
      current_stage:
        $ref: '#/definitions/ComplianceReviewStage'
      overall_comment:
        title: Overall comment
        type: string
      created_by:
        $ref: '#/definitions/MiniUser'
      submitted_by:
        $ref: '#/definitions/MiniUser'
      submitted_at:
        title: Submitted at
        type: string
        format: date-time
        x-nullable: true
      closed_by:
        $ref: '#/definitions/MiniUser'
      closed_at:
        title: Closed at
        type: string
        format: date-time
        x-nullable: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
      stage_progress:
        title: Stage progress
        type: object
        readOnly: true
        x-nullable: true
  CreateComplianceReview:
    required:
    - header_id
    type: object
    properties:
      header_id:
        title: Header id
        type: string
        format: uuid
      checklist_id:
        title: Checklist id
        type: string
        format: uuid
        x-nullable: true
  WorkplanComplianceReviewDetail:
    type: object
    properties:
      id:
        title: Id
        type: string
        format: uuid
        readOnly: true
      header:
        $ref: '#/definitions/WorkplanHeaderMini'
      checklist:
        $ref: '#/definitions/ComplianceChecklist'
      status:
        title: Status
        type: integer
        enum:
        - 0
        - 1
        - 2
        - 3
        default: 0
      status_display:
        title: Status display
        type: string
        readOnly: true
        minLength: 1
      overall_decision:
        title: Overall decision
        type: integer
        enum:
        - 9
        - 0
        - 1
        - 2
      decision_display:
        title: Decision display
        type: string
        readOnly: true
        minLength: 1
      current_stage:
        $ref: '#/definitions/ComplianceReviewStage'
      overall_comment:
        title: Overall comment
        type: string
      created_by:
        $ref: '#/definitions/MiniUser'
      submitted_by:
        $ref: '#/definitions/MiniUser'
      submitted_at:
        title: Submitted at
        type: string
        format: date-time
        x-nullable: true
      closed_by:
        $ref: '#/definitions/MiniUser'
      closed_at:
        title: Closed at
        type: string
        format: date-time
        x-nullable: true
      created_at:
        title: Created at
        type: string
        format: date-time
        readOnly: true
      stage_progress:
        title: Stage progress
        type: object
        readOnly: true
        x-nullable: true
      responses:
        type: array
        items:
          $ref: '#/definitions/WorkplanComplianceReviewItem'
        readOnly: true
  ApproveStage:
    type: object
    properties:
      comment:
        title: Comment
        type: string
        default: ''
  AssignStageUsers:
    required:
    - stage_id
    - role
    - user_ids
    type: object
    properties:
      stage_id:
        title: Stage id
        type: string
        format: uuid
      role:
        title: Role
        type: integer
        enum:
        - 0
        - 1
        - 2
      user_ids:
        type: array
        items:
          type: string
          format: uuid
      deactivate_missing:
        title: Deactivate missing
        type: boolean
        default: false
  SubmitReview:
    type: object
    properties: {}
  WorkplanImportResponse:
    required:
    - dry_run
    - upload_id
    - uploaded_file_url
    - created_header_id
    - created_details
    - created_activities
    type: object
    properties:
      dry_run:
        title: Dry run
        type: boolean
      upload_id:
        title: Upload id
        type: string
        format: uuid
        x-nullable: true
      uploaded_file_url:
        title: Uploaded file url
        type: string
        minLength: 1
        x-nullable: true
      errors_csv_url:
        title: Errors csv url
        type: string
        minLength: 1
        x-nullable: true
      created_header_id:
        title: Created header id
        type: string
        format: uuid
        x-nullable: true
      created_details:
        title: Created details
        type: integer
      created_activities:
        title: Created activities
        type: integer
      error_summary:
        title: Error summary
        type: object
        additionalProperties:
          type: string
          x-nullable: true
      errors:
        type: array
        items:
          type: object
          additionalProperties:
            type: string
            x-nullable: true
