openapi: 3.0.3
info:
  title: Repzo API - Full Invoices
  version: 1.0.0
  description: OpenAPI specification for Repzo Full Invoices endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /fullinvoices:
    get:
      summary: Find full invoices
      operationId: findFullInvoices
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              client:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              rep:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              warehouse:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              route:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              status:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              returned_from:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              returned_to:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              partially_returned_from:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              workorder:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              asset:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              asset_unit:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              teams:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              tags:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              return_reason:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: string
              is_void:
                type: boolean
              from_createdAt:
                type: number
              to_createdAt:
                type: number
              from_updatedAt:
                type: number
              to_updatedAt:
                type: number
              from_time:
                type: number
              to_time:
                type: number
              from_total:
                type: number
              to_total:
                type: number
              total:
                oneOf:
                  - type: number
                  - type: array
                    items:
                      type: number
              populatedKeys:
                type: array
                items:
                  type: string
                  enum:
                    - workorder
                    - returned_from
                    - partially_returned_from
                    - returned_to
                    - client
                    - rep
                    - warehouse
                    - route
                    - return_reason
                    - teams
              per_page:
                type: integer
              page:
                type: integer
              sort:
                type: string
              sortPageOrder:
                type: string
                enum: [asc, dsc]
          description: Query parameters for filtering full invoices
      responses:
        "200":
          description: A list of full invoices
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FullInvoiceFindResult"
    post:
      summary: Create a full invoice
      operationId: createFullInvoice
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FullInvoiceCreateBody"
      responses:
        "201":
          description: Full invoice created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FullInvoiceCreateResult"
  /fullinvoices/{id}:
    get:
      summary: Get a full invoice by ID
      operationId: getFullInvoice
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Full invoice details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FullInvoiceGetResult"
    put:
      summary: Update a full invoice
      operationId: updateFullInvoice
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FullInvoiceUpdateBody"
      responses:
        "200":
          description: Full invoice updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FullInvoiceUpdateResult"
components:
  schemas:
    FullInvoiceFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/FullInvoice"
        meta:
          type: object
    FullInvoiceCreateBody:
      type: object
      properties:
        serial:
          type: string
        client:
          type: string
        rep:
          type: string
        warehouse:
          type: string
        route:
          type: string
        items:
          type: array
          items:
            type: object
        total:
          type: number
        status:
          type: string
        dueDate:
          type: string
          format: date-time
        returned_from:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoiceReference"
        returned_to:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoice"
        partially_returned_from:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoiceReference"
        workorder:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/WorkorderReference"
        asset:
          type: string
        asset_unit:
          type: string
        proforma_reference:
          type: string
        exclude_return_items:
          type: boolean
        delivery_fees:
          type: number
        bank_fees:
          type: number
        discount:
          type: number
        prepaid_amount:
          type: number
        return_reason:
          type: string
        comment:
          type: string
        teams:
          type: array
          items:
            type: string
        tags:
          type: array
          items:
            type: string
        skip_promos:
          type: boolean
    FullInvoiceCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/FullInvoice"
    FullInvoiceGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/FullInvoice"
    FullInvoiceUpdateBody:
      type: object
      properties:
        serial:
          type: string
        client:
          type: string
        rep:
          type: string
        warehouse:
          type: string
        route:
          type: string
        items:
          type: array
          items:
            type: object
        total:
          type: number
        status:
          type: string
        dueDate:
          type: string
          format: date-time
        returned_from:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoiceReference"
        returned_to:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoice"
        partially_returned_from:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoiceReference"
        workorder:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/WorkorderReference"
        asset:
          type: string
        asset_unit:
          type: string
        proforma_reference:
          type: string
        exclude_return_items:
          type: boolean
        delivery_fees:
          type: number
        bank_fees:
          type: number
        discount:
          type: number
        prepaid_amount:
          type: number
        return_reason:
          type: string
        comment:
          type: string
        teams:
          type: array
          items:
            type: string
        tags:
          type: array
          items:
            type: string
        skip_promos:
          type: boolean
        is_void:
          type: boolean
    FullInvoiceUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/FullInvoice"
    FullInvoice:
      type: object
      properties:
        _id:
          type: string
        serial:
          type: string
        serial_number:
          $ref: "#/components/schemas/SerialNumber"
        advanced_serial_number:
          $ref: "#/components/schemas/SerialNumber"
        client:
          type: string
        rep:
          type: string
        warehouse:
          type: string
        route:
          type: string
        items:
          type: array
          items:
            type: object
        total:
          type: number
        status:
          type: string
        dueDate:
          type: string
          format: date-time
        returned_from:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoiceReference"
        returned_to:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoice"
        partially_returned_from:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/FullInvoiceReference"
        partially_returned_to:
          type: array
          items:
            type: string
        returned_from_serial_number:
          $ref: "#/components/schemas/SerialNumber"
        returned_to_serial_number:
          $ref: "#/components/schemas/SerialNumber"
        partially_returned_from_serial_number:
          $ref: "#/components/schemas/SerialNumber"
        partially_returned_to_serial_number:
          type: array
          items:
            $ref: "#/components/schemas/SerialNumber"
        workorder:
          oneOf:
            - type: string
            - $ref: "#/components/schemas/WorkorderReference"
        asset:
          type: string
        asset_unit:
          type: string
        signature:
          type: object
        proforma_reference:
          type: string
        converted_at:
          type: number
        exclude_return_items:
          type: boolean
        is_void:
          type: boolean
        skip_promos:
          type: boolean
        skipped_promotions:
          type: array
          items:
            type: object
            properties:
              _id:
                type: string
              name:
                type: string
              ref:
                type: string
        time:
          type: number
        rep_name:
          type: string
        client_name:
          type: string
        client_city:
          type: string
        client_location:
          type: object
          properties:
            lat:
              type: number
            lng:
              type: number
        geo_location:
          type: object
          properties:
            type:
              type: string
              enum: [Point]
            coordinates:
              type: array
              items:
                type: number
              minItems: 2
              maxItems: 2
        delivery_fees:
          type: number
        bank_fees:
          type: number
        discount:
          type: number
        discount_float:
          type: number
        lines_discount_float:
          type: number
        total_word:
          type: string
        total_local_word:
          type: string
        applied_promotions:
          type: array
          items:
            type: object
        prepaid_amount:
          type: number
        is_production_test:
          type: boolean
        return_reason:
          type: string
        comment:
          type: string
        company_namespace:
          type: array
          items:
            type: string
        creator:
          type: object
          properties:
            _id:
              type: string
            type:
              type: string
              enum: [admin, rep]
            name:
              type: string
        teams:
          type: array
          items:
            type: string
        tags:
          type: array
          items:
            type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    SerialNumber:
      type: object
      properties:
        identifier:
          type: string
        formatted:
          type: string
        count:
          type: number
    FullInvoiceReference:
      type: object
      properties:
        _id:
          type: string
        serial_number:
          type: string
        advanced_serial_number:
          type: string
    WorkorderReference:
      type: object
      properties:
        _id:
          type: string
        serial_number:
          type: string
        name:
          type: string
        local_name:
          type: string
