openapi: 3.1.0
info:
  title: Filing API
  version: 1.5.0
  license:
    name: Proprietary
    url: https://taxable.ng/terms
  description: >-
    Public Taxable filing API: VAT, PIT, and CIT drafts, calculations, and filing documents.


    ## Hosts


    - Production: `https://api.taxable.ng`

    - Development / sandbox: `https://api.dev.taxable.ng`


    ## Authentication


    - `Authorization: Bearer` (platform JWT).

    - PIT/CIT drafts also accept `X-Resume-Code` for anonymous resume.


    A Partner `x-api-key` does not unlock these routes. E-invoicing is documented in the separate E-invoicing API.
    Credentials typed into Try It are not stored by this page.


    ## Filing types


    VAT uses `/vat/*`. PIT and CIT use `/filings` with `filingType` `pit` or `cit`. There is no published
    withholding-tax return route. WHT appears on e-invoices as tax category `WITHHOLDING_TAX`.
servers:
  - url: https://api.taxable.ng
    description: Production
  - url: https://api.dev.taxable.ng
    description: Test / development (sandbox)
security:
  - bearerAuth: []
tags:
  - name: Calculations
    description: Tax calculation endpoints (PIT, CIT)
  - name: Documents
    description: Document upload and management
  - name: VAT
    description: >-
      Value Added Tax (VAT) filing API. Features: monthly VAT returns, 7.5% standard rate calculation, input/output VAT
      reconciliation, amendment workflow with version history, NIL returns for zero activity periods. Status flow: DRAFT
      → SUBMITTED → AMENDED
  - name: Filings
    description: >-
      Tax filing API with guest support and resume codes. Features: anonymous filing with resumable links, optional JWT
      authentication with claiming workflow, resume code-based access, payment integration via Paystack, and async PDF
      generation. Status flow: draft → calculating → pending_payment → paid → submitted
paths:
  /calculate/pit:
    post:
      tags:
        - Calculations
      summary: Calculate Personal Income Tax (PIT)
      description: >-
        Calculates PIT based on annual income, allowances, pension, and NHF contributions. Applies progressive tax bands
        and state-specific rates.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PITCalculationRequest'
      responses:
        '200':
          description: Successful calculation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PITCalculationResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /calculate/cit:
    post:
      tags:
        - Calculations
      summary: Calculate Company Income Tax (CIT)
      description: >-
        Calculates CIT based on company revenue, expenses, capital allowances, and reliefs. Includes education tax
        calculation.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CITCalculationRequest'
      responses:
        '200':
          description: Successful calculation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CITCalculationResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/documents/upload-url:
    post:
      tags:
        - Documents
      summary: Generate pre-signed upload URL
      description: >-
        Creates a pre-signed S3 URL for uploading a document to a filing. URL expires in 1 hour. Max file size 10MB.
        Creates document metadata in UPLOADING status.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUploadUrlRequest'
      responses:
        '200':
          description: Upload URL created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateUploadUrlResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /filings/{id}/documents:
    get:
      tags:
        - Documents
      summary: List filing documents
      description: >-
        Retrieves all documents attached to a filing. Returns latest versions only by default. Supports filtering by
        document type and status.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Max items per page
            example: '20'
          required: false
          name: limit
          in: query
        - schema:
            type: string
            description: Pagination cursor
          required: false
          name: nextToken
          in: query
        - schema:
            type: string
            description: Filter by document type
            example: bank_statement
          required: false
          name: documentType
          in: query
        - schema:
            type: string
            description: Filter by status
            example: READY
          required: false
          name: status
          in: query
      responses:
        '200':
          description: Documents retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentListResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /filings/{id}/documents/{documentId}:
    get:
      tags:
        - Documents
      summary: Get a document
      description: Retrieves full details of a single document including version and scan status.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Document ID
            example: DOC-abc123-def456
          required: true
          name: documentId
          in: path
      responses:
        '200':
          description: Document retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDocumentResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Document not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
    delete:
      tags:
        - Documents
      summary: Delete document
      description: >-
        Soft-deletes a document. Transitions status to DELETED. Does not immediately remove from S3 (async cleanup).
        Only READY or SCAN_PENDING documents can be deleted.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Document ID
            example: DOC-abc123-def456
          required: true
          name: documentId
          in: path
      responses:
        '200':
          description: Document deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteDocumentResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Document not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /filings/{id}/documents/{documentId}/confirm:
    post:
      tags:
        - Documents
      summary: Confirm document upload
      description: >-
        Confirms that a file has been uploaded to S3. Transitions document status from UPLOADING to SCAN_PENDING. Should
        be called after the S3 PUT upload completes.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Document ID
            example: DOC-abc123-def456
          required: true
          name: documentId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfirmUploadRequest'
      responses:
        '200':
          description: Upload confirmed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfirmUploadResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Document not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /filings/{id}/documents/{documentId}/download-url:
    get:
      tags:
        - Documents
      summary: Get document download URL
      description: >-
        Returns a pre-signed S3 download URL for a document. Only READY documents can be downloaded. URL expires in 5
        minutes.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Document ID
            example: DOC-abc123-def456
          required: true
          name: documentId
          in: path
      responses:
        '200':
          description: Download URL generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDownloadUrlResponse'
        '400':
          description: Document not in READY status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Document not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /filings/{id}/documents/{documentId}/replace:
    post:
      tags:
        - Documents
      summary: Replace document with new version
      description: >-
        Creates a new version of a document. The previous version is marked as SUPERSEDED. The documentId path parameter
        should be the documentGroupId. Returns a pre-signed upload URL for the new version.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Document group ID (identifies all versions of this document)
            example: DGRP-abc123-def456
          required: true
          name: documentId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplaceDocumentRequest'
      responses:
        '200':
          description: Replacement upload URL created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReplaceDocumentResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Document group not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /vat/draft:
    put:
      tags:
        - VAT
      summary: Create or update VAT draft
      description: >-
        Creates a new VAT draft filing or updates an existing draft for the specified period. Calculates VAT
        automatically based on sales and purchases data. Supports idempotency via idempotencyKey.
      security:
        - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VatDraftRequest'
      responses:
        '200':
          description: Draft created or updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatDraftResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '409':
          description: Cannot create draft for period with submitted filing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /vat/{period}/calculate:
    post:
      tags:
        - VAT
      summary: Calculate VAT
      description: >-
        Performs a stateless VAT calculation without saving. Use to review the result before creating a draft. Returns
        output VAT, allowable input VAT, and net payable/refundable.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing period in YYYY-MM format
            example: 2025-01
          required: true
          name: period
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VatCalculateRequest'
      responses:
        '200':
          description: Calculation result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatCalculateResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
  /vat/{period}:
    get:
      tags:
        - VAT
      summary: Get VAT filing
      description: Retrieves the latest VAT filing for a specific period. Returns the most recent version if amendments exist.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing period in YYYY-MM format
            example: 2025-01
          required: true
          name: period
          in: path
      responses:
        '200':
          description: Filing retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatGetResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: No filing found for period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /vat/{period}/submit:
    post:
      tags:
        - VAT
      summary: Submit VAT filing
      description: >-
        Submits a draft VAT filing to FIRS. Requires declaration acceptance. Changes status from DRAFT to SUBMITTED.
        Cannot be undone.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing period in YYYY-MM format
            example: 2025-01
          required: true
          name: period
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VatSubmitRequest'
      responses:
        '200':
          description: Filing submitted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatSubmitResponse'
        '400':
          description: Declaration not accepted or validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: No draft found for period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /vat/{period}/amend:
    post:
      tags:
        - VAT
      summary: Amend VAT filing
      description: >-
        Creates an amendment to a previously submitted VAT filing. Requires amendment reason. Increments version number.
        Original filing is preserved.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing period in YYYY-MM format
            example: 2025-01
          required: true
          name: period
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VatAmendRequest'
      responses:
        '200':
          description: Amendment created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatAmendResponse'
        '400':
          description: Amendment reason missing or validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: No submitted filing found for period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '409':
          description: Cannot amend filing in current state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /vat/{period}/versions:
    get:
      tags:
        - VAT
      summary: List filing versions
      description: >-
        Returns all versions of a VAT filing for a period, including original submission and any amendments. Ordered by
        version number.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            description: Filing period in YYYY-MM format
            example: 2025-01
          required: true
          name: period
          in: path
      responses:
        '200':
          description: Versions retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatVersionsResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
  /vat/filings:
    get:
      tags:
        - VAT
      summary: List all VAT filings
      description: Returns paginated list of all VAT filings for the authenticated organization. Supports cursor-based pagination.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            description: Maximum number of filings to return
            example: 20
          required: false
          name: limit
          in: query
        - schema:
            type: string
            description: Pagination cursor for next page
            example: eyJQSyI6Ik9SRyMxMjMifQ==
          required: false
          name: lastKey
          in: query
      responses:
        '200':
          description: Filings retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VatListResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
  /filings:
    post:
      tags:
        - Filings
      summary: Create a new filing
      description: Creates a new filing with optional authentication. Returns a filing ID and resume code for anonymous access.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFilingRequest'
      responses:
        '200':
          description: Filing created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateFilingResponse'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}:
    get:
      tags:
        - Filings
      summary: Get a filing by ID
      description: >-
        Retrieves a filing by ID. Requires either JWT authentication (if filing is linked to user) or valid
        X-Resume-Code header (for anonymous filings).
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: 'Resume code for anonymous access (format: TXW-XXXXXX)'
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      responses:
        '200':
          description: Filing retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetFilingResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
    patch:
      tags:
        - Filings
      summary: Update a filing
      description: >-
        Progressive update of filing data. Only allowed in draft, calculating, or pending_payment status. Requires
        either JWT authentication or valid X-Resume-Code header.
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateFilingRequest'
      responses:
        '200':
          description: Filing updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateFilingResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '422':
          description: Validation error or invalid status for editing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/restart:
    post:
      tags:
        - Filings
      summary: Restart a filing
      description: Resets the filing to draft status, clearing all data but keeping identifiers. Cannot restart a submitted filing.
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      responses:
        '200':
          description: Filing restarted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestartFilingResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '422':
          description: Cannot restart submitted filing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/resume/{code}:
    get:
      tags:
        - Filings
      summary: Resume a filing by resume code
      description: Lookup and retrieve a filing using the resume code. Used for anonymous users to continue their filing.
      parameters:
        - schema:
            type: string
            description: Resume code (e.g., TXW-ABC123)
            example: TXW-ABC123
          required: true
          name: code
          in: path
      responses:
        '200':
          description: Filing found and returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResumeFilingResponse'
        '404':
          description: Filing not found or resume code inactive
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '422':
          description: Invalid resume code format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/claim:
    post:
      tags:
        - Filings
      summary: Claim a filing for authenticated user
      description: >-
        Links an anonymous filing to the authenticated user's account. Invalidates the resume code after claiming.
        Requires JWT authentication and valid X-Resume-Code header.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code to verify access to anonymous filing
            example: TXW-ABC123
          required: true
          name: X-Resume-Code
          in: header
      responses:
        '200':
          description: Filing claimed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClaimFilingResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: Filing already claimed by another user or invalid resume code
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
  /filings/{id}/calculate:
    post:
      tags:
        - Filings
      summary: Calculate tax for a filing
      description: >-
        Performs tax calculation based on filing data. Routes to appropriate engine based on filing type (PIT or CIT).
        Updates filing status to pending_payment on success.
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      responses:
        '200':
          description: Calculation completed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalculateFilingResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '422':
          description: Cannot calculate in current status or missing required data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/payment:
    post:
      tags:
        - Filings
      summary: Initialize payment for a filing
      description: >-
        Creates a payment intent for the calculated tax. Supports card, bank_transfer, and USSD payment methods. Returns
        Paystack authorization URL for card payments.
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
        - schema:
            type: string
            format: uuid
            description: Opaque key that makes payment initialization retries idempotent
            example: 7b0d8e8a-13af-4c3f-91f4-9b6af4dc7b2a
          required: false
          name: Idempotency-Key
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitPaymentRequest'
      responses:
        '200':
          description: Payment initialized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitPaymentResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '422':
          description: Filing not ready for payment or no tax payable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/submit:
    post:
      tags:
        - Filings
      summary: Submit a filing
      description: >-
        Final submission of a paid filing. Requires JWT authentication (auto-claims if anonymous). Filing must be in
        paid status with completed calculation. Generates tracking number and queues PDF generation.
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      responses:
        '200':
          description: Filing submitted successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitFilingResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '422':
          description: Filing not ready for submission (not paid or missing calculation)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/send-otp:
    post:
      tags:
        - Filings
      summary: Send OTP for email verification
      description: >-
        Sends a one-time password to the email associated with the filing. Used for email verification before
        submission.
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      responses:
        '200':
          description: OTP sent successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendOTPResponse'
        '400':
          description: No email found for filing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '500':
          description: Failed to send OTP
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /filings/{id}/verify-otp:
    post:
      tags:
        - Filings
      summary: Verify OTP code
      description: Verifies the one-time password for email verification. Marks the email as verified upon successful verification.
      parameters:
        - schema:
            type: string
            format: uuid
            description: Filing ID
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
        - schema:
            type: string
            description: Resume code for anonymous access
            example: TXW-ABC123
          required: false
          name: X-Resume-Code
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VerifyOTPRequest'
      responses:
        '200':
          description: OTP verified successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerifyOTPResponse'
        '400':
          description: Invalid or expired OTP
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Filing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
components:
  schemas:
    PITCalculationRequest:
      type: object
      properties:
        residency:
          type: string
          enum:
            - resident
            - non_resident
          description: Tax residency status
          example: resident
        state:
          type: string
          description: State code for state-specific rates
          example: LA
        period:
          type: string
          enum:
            - annual
            - monthly
          description: Calculation period
          example: annual
        income:
          type: object
          properties:
            employment:
              type: number
            basic:
              type: number
            business:
              type: number
            rental:
              type: number
            digital_assets:
              type: number
            honoraria:
              type: number
            grants:
              type: number
            others:
              type: number
        exemptFlags:
          type: object
          properties:
            interest_govt_securities:
              type: boolean
            dividend_wht_final:
              type: boolean
        deductions:
          type: object
          properties:
            pensionContribution:
              type: number
            nhf:
              type: number
            nhis:
              type: number
            lifeAssurance:
              type: number
            annualRentPaid:
              type: number
        benefits:
          type: object
          properties:
            accommodationProvided:
              type: boolean
            employerAssetCost:
              type: number
        special:
          type: object
          properties:
            lossOfEmploymentComp:
              type: number
            usePresumptiveTax:
              type: boolean
        employerView:
          type: object
          properties:
            enabled:
              type: boolean
            benefits:
              type: array
              items:
                type: object
                properties:
                  label:
                    type: string
                  amount:
                    type: number
                required:
                  - label
                  - amount
            bonus:
              type: number
            overtime:
              type: number
            proRataMonths:
              type: number
        idempotencyKey:
          type: string
      required:
        - residency
        - state
        - period
    PITCalculationResponse:
      type: object
      properties:
        taxPayable:
          type: number
        effectiveRate:
          type: number
        marginalRate:
          type: number
        activeBracket:
          type: object
          properties:
            min:
              type: number
            max:
              type: number
            rate:
              type: number
          required:
            - min
            - max
            - rate
        monthly:
          type: object
          properties:
            grossIncome:
              type: number
            taxPayable:
              type: number
            netIncome:
              type: number
          required:
            - grossIncome
            - taxPayable
            - netIncome
        breakdown:
          type: object
          additionalProperties:
            nullable: true
        rulesVersion:
          type: string
        employerView:
          type: object
          properties:
            totalCost:
              type: number
            benefits:
              type: array
              items:
                type: object
                properties:
                  label:
                    type: string
                  amount:
                    type: number
                required:
                  - label
                  - amount
            breakdown:
              type: object
              additionalProperties:
                type: number
          required:
            - totalCost
            - benefits
            - breakdown
      required:
        - taxPayable
        - effectiveRate
        - marginalRate
        - activeBracket
        - monthly
        - breakdown
        - rulesVersion
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error code
          example: VALIDATION_ERROR
        message:
          type: string
          description: Human-readable error message
          example: Invalid input provided
        details:
          type: object
          additionalProperties:
            nullable: true
          description: Additional error details
      required:
        - error
        - message
    CITCalculationRequest:
      type: object
      properties:
        turnover:
          type: number
          minimum: 0
          description: Total company revenue/turnover in NGN
          example: 50000000
        profit:
          type: number
          description: Company profit before tax in NGN
          example: 15000000
        allowableExpenses:
          type: object
          properties:
            depreciation:
              type: number
              description: Depreciation expense
              example: 2000000
            staff_costs:
              type: number
              description: Staff costs and salaries
              example: 10000000
            rent:
              type: number
              description: Rent and lease expenses
              example: 1500000
            utilities:
              type: number
              description: Utilities expenses
              example: 500000
            marketing:
              type: number
              description: Marketing and advertising expenses
              example: 1000000
            professional_fees:
              type: number
              description: Professional fees and consultancy
              example: 750000
            travel:
              type: number
              description: Travel expenses
              example: 500000
            insurance:
              type: number
              description: Insurance premiums
              example: 250000
            repairs_maintenance:
              type: number
              description: Repairs and maintenance costs
              example: 300000
            others:
              type: number
              description: Other allowable expenses
              example: 200000
          description: Breakdown of allowable expenses by category
        sector:
          type: string
          description: Company business sector
          example: manufacturing
        losses:
          type: object
          properties:
            currentYear:
              type: number
              description: Current year losses
              example: 0
            priorYears:
              type: array
              items:
                type: object
                properties:
                  year:
                    type: integer
                    description: Year of loss
                    example: 2024
                  amount:
                    type: number
                    description: Loss amount
                    example: 1000000
                required:
                  - year
                  - amount
              description: Prior years losses to carry forward
          description: Loss carry-forward information
        incentives:
          type: object
          properties:
            pioneerStatus:
              type: boolean
              description: Has pioneer status
              example: false
            exportProcessingZone:
              type: boolean
              description: Operating in export processing zone
              example: false
            gazetteArea:
              type: boolean
              description: Operating in gazetted area
              example: false
            ruralInvestment:
              type: boolean
              description: Qualified rural investment
              example: false
            researchDevelopment:
              type: number
              description: R&D investment eligible for relief
              example: 0
          description: Tax incentives and reliefs
        idempotencyKey:
          type: string
          description: Client-generated idempotency key for deduplication
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - turnover
        - profit
    CITCalculationResponse:
      type: object
      properties:
        taxPayable:
          type: number
          description: Total tax amount payable
          example: 3750000
        effectiveRate:
          type: number
          description: Effective tax rate percentage
          example: 7.5
        breakdown:
          type: object
          properties:
            assessableProfit:
              type: number
              description: Profit subject to assessment
              example: 15000000
            totalAllowableExpenses:
              type: number
              description: Total allowable expenses
              example: 17000000
            totalCapitalAllowances:
              type: number
              description: Total capital allowances
              example: 2000000
            taxableProfit:
              type: number
              description: Profit subject to tax
              example: 12500000
            educationTax:
              type: number
              description: Education tax (2% of assessable profit)
              example: 250000
            companyIncomeTax:
              type: number
              description: Company income tax
              example: 3750000
            totalTax:
              type: number
              description: Total tax payable (CIT + education tax)
              example: 4000000
            incentivesApplied:
              type: array
              items:
                type: string
              description: List of incentives applied
              example: []
          description: Detailed calculation breakdown
        rulesVersion:
          type: string
          description: Tax rules version used for calculation
          example: v2025.1
        calculatedAt:
          type: string
          format: date-time
          description: Timestamp of calculation
          example: '2025-03-02T10:30:00Z'
      required:
        - taxPayable
        - effectiveRate
        - breakdown
        - rulesVersion
    CreateUploadUrlRequest:
      type: object
      properties:
        document_type:
          type: string
          enum:
            - tenancy_agreement
            - rent_receipt
            - landlord_id
            - payslip
            - employment_letter
            - bank_statement
            - contract
            - pension_certificate
            - insurance_policy
            - medical_receipt
            - cac_certificate
            - business_permit
            - invoice
            - receipt
            - tax_return
            - filing_pack
            - acknowledgment
            - tax_certificate
            - other
          description: Type of document being uploaded
          example: bank_statement
        file_name:
          type: string
          minLength: 1
          description: Original file name with extension
          example: financial_statement_2024.pdf
        file_size:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          maximum: 10485760
          description: File size in bytes (max 10MB)
          example: 2048576
        content_type:
          type: string
          enum:
            - application/pdf
            - image/jpeg
            - image/jpg
            - image/png
            - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            - application/vnd.ms-excel
            - application/msword
            - application/vnd.openxmlformats-officedocument.wordprocessingml.document
          description: MIME type of the file
          example: application/pdf
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Additional metadata to attach to document
          example:
            description: Annual financial statement
            year: '2024'
      required:
        - document_type
        - file_name
        - file_size
        - content_type
    CreateUploadUrlResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            document_id:
              type: string
              description: Unique document identifier
              example: DOC-abc123-def456
            document_group_id:
              type: string
              description: Document group identifier
              example: DGRP-abc123-def456
            upload_url:
              type: string
              format: uri
              description: Pre-signed S3 URL for uploading the document
              example: https://s3.amazonaws.com/bucket/key?signature=...
            storage_key:
              type: string
              description: S3 object key
              example: filings/FIL-123/bank_statement/DGRP-456/v1.pdf
            version:
              type: integer
              description: Version number
              example: 1
          required:
            - document_id
            - document_group_id
            - upload_url
            - storage_key
            - version
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    UnauthorizedError:
      type: object
      properties:
        error:
          type: string
          enum:
            - UNAUTHORIZED
          example: UNAUTHORIZED
        message:
          type: string
          example: Authentication required
      required:
        - error
        - message
    NotFoundError:
      type: object
      properties:
        error:
          type: string
          enum:
            - NOT_FOUND
          example: NOT_FOUND
        message:
          type: string
          example: Resource not found
      required:
        - error
        - message
    DocumentListResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/Document'
              description: List of documents for the filing
            nextToken:
              type: string
              description: Cursor for next page of results
              example: '10'
          required:
            - items
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    GetDocumentResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            document:
              $ref: '#/components/schemas/Document'
          required:
            - document
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    DeleteDocumentResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            message:
              type: string
              description: Deletion confirmation message
              example: Document deleted successfully
          required:
            - message
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    ConfirmUploadRequest:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the upload was successful
          example: true
        checksum:
          type: string
          description: MD5 checksum of uploaded file for verification
          example: d41d8cd98f00b204e9800998ecf8427e
      required:
        - success
    ConfirmUploadResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            document:
              $ref: '#/components/schemas/Document'
          required:
            - document
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    GetDownloadUrlResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            url:
              type: string
              format: uri
              description: Pre-signed download URL (expires in 5 minutes)
              example: https://s3.amazonaws.com/bucket/key?signature=...
            expiresIn:
              type: integer
              description: URL expiration in seconds
              example: 300
          required:
            - url
            - expiresIn
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    ReplaceDocumentRequest:
      type: object
      properties:
        file_name:
          type: string
          minLength: 1
          description: New file name with extension
          example: updated_financial_statement_2024.pdf
        file_size:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          maximum: 10485760
          description: File size in bytes (max 10MB)
          example: 3145728
        content_type:
          type: string
          enum:
            - application/pdf
            - image/jpeg
            - image/jpg
            - image/png
            - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            - application/vnd.ms-excel
            - application/msword
            - application/vnd.openxmlformats-officedocument.wordprocessingml.document
          description: MIME type of the file
          example: application/pdf
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Updated metadata
          example:
            description: Revised financial statement
            year: '2024'
      required:
        - file_name
        - file_size
        - content_type
    ReplaceDocumentResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            document_id:
              type: string
              example: DOC-new123-new456
            document_group_id:
              type: string
              example: DGRP-abc123-def456
            upload_url:
              type: string
              format: uri
              description: Pre-signed S3 URL for uploading the replacement
              example: https://s3.amazonaws.com/bucket/key?signature=...
            storage_key:
              type: string
              example: filings/FIL-123/bank_statement/DGRP-456/v2.pdf
            version:
              type: integer
              example: 2
          required:
            - document_id
            - document_group_id
            - upload_url
            - storage_key
            - version
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    VatDraftRequest:
      type: object
      properties:
        period:
          type: string
          pattern: ^\d{4}-(0[1-9]|1[0-2])$
          description: Filing period in YYYY-MM format
          example: 2025-01
        sales:
          $ref: '#/components/schemas/VatSales'
        purchases:
          $ref: '#/components/schemas/VatPurchases'
        company:
          $ref: '#/components/schemas/VatCompany'
        filer:
          $ref: '#/components/schemas/VatFiler'
        idempotencyKey:
          type: string
          format: uuid
          description: Unique key to prevent duplicate submissions
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - period
        - sales
        - purchases
        - company
        - filer
        - idempotencyKey
    VatDraftResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/VatFiling'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
          required:
            - requestId
            - timestamp
      required:
        - success
        - data
        - meta
    VatCalculateRequest:
      type: object
      properties:
        sales:
          $ref: '#/components/schemas/VatSales'
        purchases:
          $ref: '#/components/schemas/VatPurchases'
      required:
        - sales
        - purchases
    VatCalculateResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/VatSummary'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
          required:
            - requestId
            - timestamp
      required:
        - success
        - data
        - meta
    VatGetResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/VatFiling'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
          required:
            - requestId
            - timestamp
      required:
        - success
        - data
        - meta
    VatSubmitRequest:
      type: object
      properties:
        declarationAccepted:
          type: boolean
          enum:
            - true
          description: Acknowledgement that information is accurate
          example: true
        idempotencyKey:
          type: string
          format: uuid
          description: Unique key to prevent duplicate submissions
          example: 550e8400-e29b-41d4-a716-446655440001
      required:
        - declarationAccepted
        - idempotencyKey
    VatSubmitResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/VatFiling'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
          required:
            - requestId
            - timestamp
      required:
        - success
        - data
        - meta
    VatAmendRequest:
      type: object
      properties:
        sales:
          $ref: '#/components/schemas/VatSales'
        purchases:
          $ref: '#/components/schemas/VatPurchases'
        amendmentReason:
          type: string
          minLength: 1
          maxLength: 500
          description: Required explanation for the amendment
          example: Correcting sales figure after invoice reconciliation
        idempotencyKey:
          type: string
          format: uuid
          description: Unique key to prevent duplicate submissions
          example: 550e8400-e29b-41d4-a716-446655440002
      required:
        - sales
        - purchases
        - amendmentReason
        - idempotencyKey
    VatAmendResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/VatFiling'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
          required:
            - requestId
            - timestamp
      required:
        - success
        - data
        - meta
    VatVersionsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          type: array
          items:
            $ref: '#/components/schemas/VatFiling'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
            count:
              type: number
          required:
            - requestId
            - timestamp
            - count
      required:
        - success
        - data
        - meta
    VatListResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          type: array
          items:
            $ref: '#/components/schemas/VatFiling'
        meta:
          type: object
          properties:
            requestId:
              type: string
            timestamp:
              type: string
              format: date-time
            pagination:
              type: object
              properties:
                limit:
                  type: number
                hasMore:
                  type: boolean
                lastKey:
                  type: string
              required:
                - limit
                - hasMore
          required:
            - requestId
            - timestamp
            - pagination
      required:
        - success
        - data
        - meta
    CreateFilingRequest:
      type: object
      properties:
        filingType:
          type: string
          enum:
            - pit
            - cit
          description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
        taxYear:
          type: integer
          minimum: 2020
          maximum: 2030
          example: 2025
      required:
        - filingType
        - taxYear
    CreateFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              format: uuid
              example: 123e4567-e89b-12d3-a456-426614174000
            resumeCode:
              type: string
              example: TXW-ABC123
            filingType:
              type: string
              enum:
                - pit
                - cit
              description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            currentStep:
              type: string
              example: filingType
            taxYear:
              type: integer
              example: 2025
            createdAt:
              type: string
              format: date-time
              example: '2025-01-15T10:00:00Z'
          required:
            - filingId
            - resumeCode
            - filingType
            - status
            - currentStep
            - taxYear
            - createdAt
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              nullable: true
              example: null
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:00:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    GetFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Filing'
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              nullable: true
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    UpdateFilingRequest:
      type: object
      properties:
        step:
          type: string
          description: Current step identifier
          example: income
        data:
          type: object
          properties:
            core:
              $ref: '#/components/schemas/FilingCoreData'
            pitDetails:
              $ref: '#/components/schemas/PITDetails'
            citDetails:
              $ref: '#/components/schemas/CITDetails'
      required:
        - step
        - data
    UpdateFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            currentStep:
              type: string
              example: income
            updatedAt:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
            version:
              type: integer
              example: 3
          required:
            - filingId
            - status
            - currentStep
            - updatedAt
            - version
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              nullable: true
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    RestartFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            resumeCode:
              type: string
              example: TXW-ABC123
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            currentStep:
              type: string
              example: filingFor
            filingType:
              type: string
              enum:
                - pit
                - cit
              description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
            taxYear:
              type: integer
              example: 2025
            updatedAt:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - filingId
            - resumeCode
            - status
            - currentStep
            - filingType
            - taxYear
            - updatedAt
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              nullable: true
              example: user-abc123
            message:
              type: string
              example: Filing has been restarted
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - message
            - timestamp
      required:
        - success
        - data
        - meta
    ResumeFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            filingType:
              type: string
              enum:
                - pit
                - cit
              description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            currentStep:
              type: string
              example: income
            taxYear:
              type: integer
              example: 2025
            core:
              $ref: '#/components/schemas/FilingCoreData'
            pitDetails:
              $ref: '#/components/schemas/PITDetails'
            citDetails:
              $ref: '#/components/schemas/CITDetails'
            calculation:
              $ref: '#/components/schemas/CalculationResult'
            createdAt:
              type: string
              format: date-time
              example: '2025-01-15T10:00:00Z'
            updatedAt:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - filingId
            - filingType
            - status
            - currentStep
            - taxYear
            - core
            - createdAt
            - updatedAt
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            resumeCode:
              type: string
              example: TXW-ABC123
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - resumeCode
            - timestamp
      required:
        - success
        - data
        - meta
    ClaimFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            userId:
              type: string
              example: user-abc123
            resumeCodeActive:
              type: boolean
              example: false
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            currentStep:
              type: string
              example: income
          required:
            - filingId
            - userId
            - resumeCodeActive
            - status
            - currentStep
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            message:
              type: string
              example: Filing successfully linked to your account. Resume code is no longer active.
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - message
            - timestamp
      required:
        - success
        - data
        - meta
    CalculateFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            filingType:
              type: string
              enum:
                - pit
                - cit
              description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            calculation:
              $ref: '#/components/schemas/CalculationResult'
          required:
            - filingId
            - filingType
            - status
            - calculation
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              nullable: true
              example: user-abc123
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - timestamp
      required:
        - success
        - data
        - meta
    InitPaymentRequest:
      type: object
      properties:
        paymentMethod:
          type: string
          enum:
            - card
            - bank_transfer
            - ussd
          default: card
          example: card
        email:
          type: string
          format: email
          description: Email for payment notification (optional, uses filing email if not provided)
          example: user@example.com
        redirectUrl:
          type: string
          format: uri
          description: URL to redirect after payment
          example: https://filing.taxable.ng/payment/success
    InitPaymentResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            payment:
              type: object
              properties:
                reference:
                  type: string
                  example: TX-ABC12345-X7Z9
                amount:
                  type: number
                  example: 50000
                currency:
                  type: string
                  example: NGN
                gateway:
                  type: string
                  example: paystack
                status:
                  type: string
                  example: pending
                accessCode:
                  type: string
                  example: access_code_xyz
                authorizationUrl:
                  type: string
                  format: uri
                  example: https://checkout.paystack.com/abc123
              required:
                - reference
                - amount
                - currency
                - gateway
                - status
            calculation:
              type: object
              properties:
                taxPayable:
                  type: number
                  example: 50000
                effectiveRate:
                  type: number
                  example: 16.65
              required:
                - taxPayable
                - effectiveRate
          required:
            - filingId
            - payment
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              nullable: true
              example: user-abc123
            message:
              type: string
              example: Payment initialized. Complete payment using your preferred method.
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:30:00Z'
          required:
            - requestId
            - userId
            - message
            - timestamp
      required:
        - success
        - data
        - meta
    SubmitFilingResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            filingId:
              type: string
              example: 123e4567-e89b-12d3-a456-426614174000
            filingType:
              type: string
              enum:
                - pit
                - cit
              description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
            taxYear:
              type: integer
              example: 2025
            status:
              type: string
              enum:
                - draft
                - calculating
                - pending_payment
                - paid
                - submitted
              description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
            trackingNumber:
              type: string
              example: PIT-2025-ABC12345-X7Z9
            submittedAt:
              type: string
              format: date-time
              example: '2025-01-15T10:35:00Z'
            calculation:
              type: object
              properties:
                taxPayable:
                  type: number
                  example: 832500
                effectiveRate:
                  type: number
                  example: 16.65
              required:
                - taxPayable
                - effectiveRate
            payment:
              type: object
              properties:
                reference:
                  type: string
                  example: TX-ABC12345-X7Z9
                amount:
                  type: number
                  example: 50000
                paidAt:
                  type: string
                  format: date-time
                  example: '2025-01-15T10:33:00Z'
              required:
                - reference
                - amount
          required:
            - filingId
            - filingType
            - taxYear
            - status
            - trackingNumber
            - submittedAt
            - calculation
            - payment
        meta:
          type: object
          properties:
            requestId:
              type: string
              example: req-12345
            userId:
              type: string
              example: user-abc123
            message:
              type: string
              example: Your tax filing has been submitted successfully.
            nextSteps:
              type: array
              items:
                type: string
              example:
                - A confirmation email will be sent to your registered email address.
                - Your filing pack (PDF) will be available for download within 24 hours.
                - You can track your submission status using the tracking number.
            jobId:
              type: string
              nullable: true
              example: JOB-abc123
            timestamp:
              type: string
              format: date-time
              example: '2025-01-15T10:35:00Z'
          required:
            - requestId
            - userId
            - message
            - nextSteps
            - jobId
            - timestamp
      required:
        - success
        - data
        - meta
    SendOTPResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            message:
              type: string
              example: Verification code sent to your email
            expiresIn:
              type: integer
              description: OTP expiry in seconds
              example: 300
            emailHint:
              type: string
              description: Masked email address
              example: jo***@example.com
          required:
            - message
            - expiresIn
            - emailHint
      required:
        - success
        - data
    VerifyOTPRequest:
      type: object
      properties:
        code:
          type: string
          description: 6-digit OTP code
          example: '123456'
      required:
        - code
    VerifyOTPResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            verified:
              type: boolean
              example: true
            message:
              type: string
              example: Email verified successfully
          required:
            - verified
            - message
      required:
        - success
        - data
    Document:
      type: object
      properties:
        document_id:
          type: string
          example: DOC-abc123-def456
        document_group_id:
          type: string
          description: Groups all versions of the same logical document
          example: DGRP-abc123-def456
        version:
          type: integer
          description: Version number within the document group
          example: 1
        is_latest:
          type: boolean
          description: Whether this is the latest version in the group
          example: true
        filing_id:
          type: string
          example: FIL-1609459200000-A1B2C3D4
        name:
          type: string
          description: Original file name
          example: financial_statement_2024.pdf
        type:
          type: string
          enum:
            - tenancy_agreement
            - rent_receipt
            - landlord_id
            - payslip
            - employment_letter
            - bank_statement
            - contract
            - pension_certificate
            - insurance_policy
            - medical_receipt
            - cac_certificate
            - business_permit
            - invoice
            - receipt
            - tax_return
            - filing_pack
            - acknowledgment
            - tax_certificate
            - other
          description: Type of document being uploaded
          example: bank_statement
        size:
          type: integer
          description: File size in bytes
          example: 2048576
        content_type:
          type: string
          enum:
            - application/pdf
            - image/jpeg
            - image/jpg
            - image/png
            - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            - application/vnd.ms-excel
            - application/msword
            - application/vnd.openxmlformats-officedocument.wordprocessingml.document
          description: MIME type of the file
          example: application/pdf
        status:
          type: string
          enum:
            - UPLOADING
            - SCAN_PENDING
            - READY
            - SUPERSEDED
            - DELETED
          description: Current status of the document
          example: READY
        storage_key:
          type: string
          description: S3 object key
          example: filings/FIL-123/bank_statement/DGRP-456/v1.pdf
        checksum:
          type: string
          description: MD5 checksum of the file
          example: d41d8cd98f00b204e9800998ecf8427e
        virus_scan_status:
          type: string
          enum:
            - pending
            - clean
            - infected
          description: Result of virus scan
          example: clean
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Custom metadata attached to document
        created_at:
          type: string
          format: date-time
          example: '2024-01-15T10:30:00Z'
        updated_at:
          type: string
          format: date-time
          example: '2024-01-15T10:30:00Z'
      required:
        - document_id
        - document_group_id
        - version
        - is_latest
        - filing_id
        - name
        - type
        - size
        - content_type
        - status
        - storage_key
        - created_at
        - updated_at
    VatSales:
      type: object
      properties:
        standardRated:
          type: number
          minimum: 0
          description: Total value of standard-rated sales (VATable at 7.5%)
          example: 1000000
        zeroRated:
          type: number
          minimum: 0
          description: Total value of zero-rated sales (exports, etc.)
          example: 0
        exempt:
          type: number
          minimum: 0
          description: Total value of exempt sales (medical, education, etc.)
          example: 0
      required:
        - standardRated
        - zeroRated
        - exempt
    VatPurchases:
      type: object
      properties:
        vatableValue:
          type: number
          minimum: 0
          description: Total value of VATable purchases
          example: 400000
        inputVatPaid:
          type: number
          minimum: 0
          description: Total input VAT paid on purchases
          example: 30000
        disallowedInputVat:
          type: number
          minimum: 0
          description: Portion of input VAT that cannot be claimed
          example: 0
      required:
        - vatableValue
        - inputVatPaid
        - disallowedInputVat
    VatCompany:
      type: object
      properties:
        tin:
          type: string
          minLength: 1
          description: Tax Identification Number
          example: 01234567-0001
        businessName:
          type: string
          minLength: 1
          description: Registered business name
          example: Acme Nigeria Limited
        contactEmail:
          type: string
          format: email
          description: Company contact email
          example: finance@acme.ng
        contactPhone:
          type: string
          description: Company contact phone
          example: +234 800 123 4567
      required:
        - tin
        - businessName
        - contactEmail
    VatFiler:
      type: object
      properties:
        fullName:
          type: string
          minLength: 1
          description: Full name of person filing
          example: John Doe
        role:
          type: string
          minLength: 1
          description: Role/position in company
          example: Finance Manager
        email:
          type: string
          format: email
          description: Filer email address
          example: john.doe@acme.ng
        phone:
          type: string
          description: Filer phone number
          example: +234 800 987 6543
      required:
        - fullName
        - role
        - email
    VatFiling:
      type: object
      properties:
        filingId:
          type: string
          format: uuid
          description: Unique filing identifier
          example: 123e4567-e89b-12d3-a456-426614174000
        orgId:
          type: string
          description: Organization identifier
          example: org-123
        period:
          type: string
          pattern: ^\d{4}-(0[1-9]|1[0-2])$
          description: Filing period in YYYY-MM format
          example: 2025-01
        status:
          type: string
          enum:
            - DRAFT
            - SUBMITTED
            - AMENDED
          description: Current filing status
          example: DRAFT
        version:
          type: integer
          minimum: 1
          description: Version number (increments with amendments)
          example: 1
        sales:
          $ref: '#/components/schemas/VatSales'
        purchases:
          $ref: '#/components/schemas/VatPurchases'
        summary:
          $ref: '#/components/schemas/VatSummary'
        company:
          $ref: '#/components/schemas/VatCompany'
        filer:
          $ref: '#/components/schemas/VatFiler'
        amendmentReason:
          type: string
          description: Reason for amendment (required for amended filings)
          example: Correcting sales figure after invoice reconciliation
        submittedAt:
          type: string
          format: date-time
          description: Timestamp when filing was submitted
          example: '2025-01-15T10:30:00Z'
        createdAt:
          type: string
          format: date-time
          description: Timestamp when filing was created
          example: '2025-01-10T09:00:00Z'
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when filing was last updated
          example: '2025-01-15T10:30:00Z'
      required:
        - filingId
        - orgId
        - period
        - status
        - version
        - sales
        - purchases
        - summary
        - company
        - filer
        - createdAt
        - updatedAt
    VatSummary:
      type: object
      properties:
        outputVat:
          type: number
          description: Output VAT on standard-rated sales (7.5%)
          example: 75000
        totalInputVat:
          type: number
          description: Total input VAT claimed
          example: 30000
        allowableInputVat:
          type: number
          description: Input VAT after disallowance
          example: 30000
        openingCredit:
          type: number
          description: Credit carried forward from previous period
          example: 0
        grossVatDue:
          type: number
          description: VAT due before applying opening credit (output - input, if positive)
          example: 45000
        vatPayable:
          type: number
          description: Net VAT payable to FIRS after applying opening credit
          example: 45000
        vatRefundable:
          type: number
          description: Net VAT refundable (if negative balance)
          example: 0
        closingCredit:
          type: number
          description: Credit balance to carry forward to next period
          example: 0
        isNilReturn:
          type: boolean
          description: True if zero sales and purchases with no credit activity
          example: false
      required:
        - outputVat
        - totalInputVat
        - allowableInputVat
        - openingCredit
        - grossVatDue
        - vatPayable
        - vatRefundable
        - closingCredit
        - isNilReturn
    Filing:
      type: object
      properties:
        filingId:
          type: string
          format: uuid
          example: 123e4567-e89b-12d3-a456-426614174000
        resumeCode:
          type: string
          description: 'Resume code for anonymous access (format: TXW-XXXXXX)'
          example: TXW-ABC123
        resumeCodeActive:
          type: boolean
          example: true
        userId:
          type: string
          nullable: true
          example: user-abc123
        filingType:
          type: string
          enum:
            - pit
            - cit
          description: 'Filing type: pit (Personal Income Tax) or cit (Company Income Tax)'
        status:
          type: string
          enum:
            - draft
            - calculating
            - pending_payment
            - paid
            - submitted
          description: 'Filing status: draft → calculating → pending_payment → paid → submitted'
        currentStep:
          type: string
          example: income
        taxYear:
          type: integer
          minimum: 2020
          maximum: 2030
          example: 2025
        regime:
          type: string
          enum:
            - FIRS_2025
            - NRS_2026
          description: Tax regime applicable to this filing (auto-assigned based on tax year)
          example: FIRS_2025
        core:
          $ref: '#/components/schemas/FilingCoreData'
        pitDetails:
          $ref: '#/components/schemas/PITDetails'
        citDetails:
          $ref: '#/components/schemas/CITDetails'
        calculation:
          $ref: '#/components/schemas/CalculationResult'
        payment:
          $ref: '#/components/schemas/PaymentInfo'
        createdAt:
          type: string
          format: date-time
          example: '2025-01-15T10:00:00Z'
        updatedAt:
          type: string
          format: date-time
          example: '2025-01-15T10:30:00Z'
        version:
          type: integer
          example: 3
      required:
        - filingId
        - resumeCode
        - resumeCodeActive
        - userId
        - filingType
        - status
        - currentStep
        - taxYear
        - regime
        - core
        - createdAt
        - updatedAt
        - version
    FilingCoreData:
      type: object
      properties:
        contact:
          $ref: '#/components/schemas/Contact'
        agentDetails:
          $ref: '#/components/schemas/AgentDetails'
        isAgentFlow:
          type: boolean
          default: false
          example: false
    PITDetails:
      type: object
      properties:
        personalDetails:
          type: object
          properties:
            nin:
              type: string
              example: '12345678901'
            state:
              type: string
              example: Lagos
            tin:
              type: string
              example: 12345678-0001
            lga:
              type: string
              example: Ikeja
          required:
            - nin
            - state
        primaryIncomeType:
          type: string
          example: employment
        additionalIncomeTypes:
          type: array
          items:
            type: string
          example:
            - rental
            - investment
        income:
          $ref: '#/components/schemas/PITIncome'
        reliefs:
          type: object
          properties:
            rent:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: true
                amount:
                  type: number
                  minimum: 0
                  example: 500000
                landlordName:
                  type: string
                landlordTin:
                  type: string
                propertyAddress:
                  type: string
              required:
                - enabled
                - amount
            pension:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: true
                amount:
                  type: number
                  minimum: 0
                  example: 400000
              required:
                - enabled
                - amount
            nhf:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: true
                amount:
                  type: number
                  minimum: 0
                  example: 125000
              required:
                - enabled
                - amount
            voluntaryPension:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: false
                amount:
                  type: number
                  minimum: 0
                  example: 0
              required:
                - enabled
                - amount
            lifeInsurance:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: false
                amount:
                  type: number
                  minimum: 0
                  example: 0
              required:
                - enabled
                - amount
    CITDetails:
      type: object
      properties:
        company:
          type: object
          properties:
            name:
              type: string
              example: Acme Corp Ltd
            rcNumber:
              type: string
              example: RC123456
            tin:
              type: string
              example: 12345678-0001
            email:
              type: string
              format: email
              example: info@acmecorp.ng
            address:
              type: string
              example: 123 Business Avenue, Lagos
            state:
              type: string
              example: Lagos
          required:
            - name
            - rcNumber
            - tin
            - email
            - address
            - state
        revenue:
          type: number
          minimum: 0
          example: 50000000
        expenses:
          type: number
          minimum: 0
          example: 35000000
        expenseBreakdown:
          type: object
          properties:
            staffCosts:
              type: number
              minimum: 0
              example: 15000000
            operatingCosts:
              type: number
              minimum: 0
              example: 10000000
            adminCosts:
              type: number
              minimum: 0
              example: 5000000
            other:
              type: number
              minimum: 0
              example: 5000000
          required:
            - staffCosts
            - operatingCosts
            - adminCosts
            - other
        extras:
          type: object
          properties:
            nonAllowableDeductions:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: false
                amount:
                  type: number
                  minimum: 0
                  example: 0
              required:
                - enabled
                - amount
            allowableDeductions:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: true
                amount:
                  type: number
                  minimum: 0
                  example: 2000000
              required:
                - enabled
                - amount
            capitalAssets:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: true
                amount:
                  type: number
                  minimum: 0
                  example: 5000000
              required:
                - enabled
                - amount
            previousLosses:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: false
                amount:
                  type: number
                  minimum: 0
                  example: 0
              required:
                - enabled
                - amount
            foreignIncome:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: false
                amount:
                  type: number
                  minimum: 0
                  example: 0
              required:
                - enabled
                - amount
            incentivesReliefs:
              type: object
              properties:
                enabled:
                  type: boolean
                  example: false
                amount:
                  type: number
                  minimum: 0
                  example: 0
              required:
                - enabled
                - amount
        yearEndPosition:
          type: object
          properties:
            cashAndBank:
              type: number
              minimum: 0
              example: 12500000
            tradeReceivables:
              type: number
              minimum: 0
              example: 8000000
            inventory:
              type: number
              minimum: 0
              example: 6000000
            tradePayables:
              type: number
              minimum: 0
              example: 4500000
            accruals:
              type: number
              minimum: 0
              example: 1200000
            longTermLoans:
              type: number
              minimum: 0
              example: 15000000
            shortTermLoans:
              type: number
              minimum: 0
              example: 3000000
            shareCapital:
              type: number
              minimum: 0
              example: 10000000
            retainedEarningsBroughtForward:
              type: number
              example: 7500000
            updatedAt:
              type: string
              example: '2026-04-30T10:00:00Z'
          description: Year-end balance-sheet inputs (manual CIT path). Required for FRC/CAMA-compliant statements.
        engineSnapshot:
          type: object
          additionalProperties:
            nullable: true
          description: Server-set EngineOutput<CITBreakdown> snapshot from @nta/tax-calc. Read-only for clients.
      required:
        - revenue
        - expenses
    CalculationResult:
      type: object
      properties:
        taxPayable:
          type: number
          example: 832500
        effectiveRate:
          type: number
          example: 16.65
        breakdown:
          type: object
          additionalProperties:
            nullable: true
          description: Detailed calculation breakdown
          example:
            grossIncome: 5000000
            taxableIncome: 4200000
        calculatedAt:
          type: string
          format: date-time
          example: '2025-01-15T10:30:00Z'
      required:
        - taxPayable
        - effectiveRate
        - breakdown
        - calculatedAt
    PaymentInfo:
      type: object
      properties:
        reference:
          type: string
          example: TX-ABC12345-X7Z9
        amount:
          type: number
          example: 50000
        gateway:
          type: string
          enum:
            - paystack
            - flutterwave
            - bank_transfer
          example: paystack
        status:
          type: string
          enum:
            - pending
            - paid
            - failed
          example: pending
        accessCode:
          type: string
          example: access_code_xyz
        authorizationUrl:
          type: string
          format: uri
          example: https://checkout.paystack.com/abc123
        paidAt:
          type: string
          format: date-time
          example: '2025-01-15T10:35:00Z'
        transactionId:
          type: string
          example: TXN-12345
      required:
        - reference
        - amount
        - gateway
        - status
    Contact:
      type: object
      properties:
        firstName:
          type: string
          minLength: 1
          example: John
        lastName:
          type: string
          minLength: 1
          example: Doe
        email:
          type: string
          format: email
          example: john.doe@example.com
        phone:
          type: string
          minLength: 10
          example: '+2348012345678'
      required:
        - firstName
        - lastName
        - email
        - phone
    AgentDetails:
      type: object
      properties:
        firstName:
          type: string
          example: Agent
        lastName:
          type: string
          example: Smith
        email:
          type: string
          format: email
          example: agent@example.com
        phone:
          type: string
          example: '+2348098765432'
        agencyName:
          type: string
          example: Tax Agency Ltd
        agencyTin:
          type: string
          example: 12345678-0001
      required:
        - firstName
        - lastName
        - email
        - phone
    PITIncome:
      type: object
      properties:
        employment:
          type: object
          properties:
            grossSalary:
              type: number
              minimum: 0
              example: 5000000
            pension:
              type: number
              minimum: 0
              example: 400000
            nhf:
              type: number
              minimum: 0
              example: 125000
            nhis:
              type: number
              minimum: 0
              example: 50000
            otherDeductions:
              type: number
              minimum: 0
              example: 0
          required:
            - grossSalary
            - pension
            - nhf
            - nhis
            - otherDeductions
        selfEmployed:
          type: object
          properties:
            revenue:
              type: number
              minimum: 0
              example: 2000000
            expenses:
              type: number
              minimum: 0
              example: 500000
          required:
            - revenue
            - expenses
        business:
          type: object
          properties:
            revenue:
              type: number
              minimum: 0
              example: 3000000
            expenses:
              type: number
              minimum: 0
              example: 1000000
          required:
            - revenue
            - expenses
        rental:
          type: object
          properties:
            income:
              type: number
              minimum: 0
              example: 1200000
            expenses:
              type: number
              minimum: 0
              example: 200000
          required:
            - income
            - expenses
        investment:
          type: object
          properties:
            dividends:
              type: number
              minimum: 0
              example: 100000
            interest:
              type: number
              minimum: 0
              example: 50000
            capitalGains:
              type: number
              minimum: 0
              example: 0
          required:
            - dividends
            - interest
            - capitalGains
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Platform JWT from first-party sign-in.
    resumeCodeAuth:
      type: apiKey
      in: header
      name: X-Resume-Code
      description: Anonymous PIT/CIT draft resume code. Accepted on draft filing routes as an alternative to Bearer.
