openapi: 3.0.3
info:
  title: Repzo API - Payment Terms
  version: 1.0.0
  description: OpenAPI specification for Repzo Payment Terms endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /paymentterms:
    get:
      summary: Find payment terms
      operationId: findPaymentTerms
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering payment terms
      responses:
        "200":
          description: A list of payment terms
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentTermFindResult"
    post:
      summary: Create a payment term
      operationId: createPaymentTerm
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentTermCreateBody"
      responses:
        "201":
          description: Payment term created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentTermCreateResult"
  /paymentterms/{id}:
    get:
      summary: Get a payment term by ID
      operationId: getPaymentTerm
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Payment term details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentTermGetResult"
    put:
      summary: Update a payment term
      operationId: updatePaymentTerm
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentTermUpdateBody"
      responses:
        "200":
          description: Payment term updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentTermUpdateResult"
    delete:
      summary: Remove a payment term
      operationId: removePaymentTerm
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Payment term removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentTermRemoveResult"
components:
  schemas:
    PaymentTermFindResult:
      type: object
      properties:
        success:
          type: boolean
        result:
          type: array
          items:
            $ref: "#/components/schemas/PaymentTerm"
        pagination:
          $ref: "#/components/schemas/Pagination"
    PaymentTermCreateBody:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the payment term
        description:
          type: string
          description: Description of the payment term
        days:
          type: integer
          description: Number of days for payment
        discount_percentage:
          type: number
          format: float
          description: Discount percentage if paid early
        discount_days:
          type: integer
          description: Number of days for discount eligibility
        is_active:
          type: boolean
          description: Whether the payment term is active
          default: true
    PaymentTermCreateResult:
      type: object
      properties:
        success:
          type: boolean
        result:
          $ref: "#/components/schemas/PaymentTerm"
    PaymentTermGetResult:
      type: object
      properties:
        success:
          type: boolean
        result:
          $ref: "#/components/schemas/PaymentTerm"
    PaymentTermUpdateBody:
      type: object
      properties:
        name:
          type: string
          description: Name of the payment term
        description:
          type: string
          description: Description of the payment term
        days:
          type: integer
          description: Number of days for payment
        discount_percentage:
          type: number
          format: float
          description: Discount percentage if paid early
        discount_days:
          type: integer
          description: Number of days for discount eligibility
        is_active:
          type: boolean
          description: Whether the payment term is active
    PaymentTermUpdateResult:
      type: object
      properties:
        success:
          type: boolean
        result:
          $ref: "#/components/schemas/PaymentTerm"
    PaymentTermRemoveResult:
      type: object
      properties:
        success:
          type: boolean
        result:
          type: object
    PaymentTerm:
      type: object
      properties:
        _id:
          type: string
          description: Unique identifier
        name:
          type: string
          description: Name of the payment term
        description:
          type: string
          description: Description of the payment term
        days:
          type: integer
          description: Number of days for payment
        discount_percentage:
          type: number
          format: float
          description: Discount percentage if paid early
        discount_days:
          type: integer
          description: Number of days for discount eligibility
        is_active:
          type: boolean
          description: Whether the payment term is active
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp
        company_id:
          type: string
          description: Company identifier
    Pagination:
      type: object
      properties:
        total:
          type: integer
          description: Total number of items
        page:
          type: integer
          description: Current page number
        per_page:
          type: integer
          description: Items per page
        total_pages:
          type: integer
          description: Total number of pages
