openapi: 3.1.0
info:
  title: Api
  version: 0.1.0
  description: KonseySoft API specification
servers:
  - url: /api
    description: Base API path
tags:
  - name: health
    description: Health operations
  - name: auth
    description: Authentication
  - name: dashboard
    description: Dashboard data
  - name: customers
    description: Customer (Cari) management
  - name: products
    description: Product and stock management
  - name: categories
    description: Product categories
  - name: invoices
    description: Invoice management
  - name: cash
    description: Cash transactions
  - name: reports
    description: Reporting

paths:
  /healthz:
    get:
      operationId: healthCheck
      tags: [health]
      summary: Health check
      responses:
        "200":
          description: Healthy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthStatus"

  /auth/login:
    post:
      operationId: login
      tags: [auth]
      summary: Login
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LoginRequest"
      responses:
        "200":
          description: Login successful
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LoginResponse"
        "401":
          description: Invalid credentials
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /auth/me:
    get:
      operationId: getMe
      tags: [auth]
      summary: Get current user
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Current user
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/User"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /dashboard:
    get:
      operationId: getDashboard
      tags: [dashboard]
      summary: Get dashboard summary
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Dashboard data
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DashboardData"

  /customers:
    get:
      operationId: listCustomers
      tags: [customers]
      summary: List customers
      security:
        - bearerAuth: []
      parameters:
        - name: search
          in: query
          schema:
            type: string
        - name: page
          in: query
          schema:
            type: number
            default: 1
        - name: limit
          in: query
          schema:
            type: number
            default: 20
      responses:
        "200":
          description: Customers list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerListResponse"
    post:
      operationId: createCustomer
      tags: [customers]
      summary: Create customer
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomerRequest"
      responses:
        "201":
          description: Customer created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"

  /customers/{id}:
    get:
      operationId: getCustomer
      tags: [customers]
      summary: Get customer
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Customer
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerDetail"
    put:
      operationId: updateCustomer
      tags: [customers]
      summary: Update customer
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomerRequest"
      responses:
        "200":
          description: Customer updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"
    delete:
      operationId: deleteCustomer
      tags: [customers]
      summary: Delete customer
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessResponse"

  /customers/{id}/transactions:
    get:
      operationId: getCustomerTransactions
      tags: [customers]
      summary: Get customer transactions
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
        - name: page
          in: query
          schema:
            type: number
            default: 1
        - name: limit
          in: query
          schema:
            type: number
            default: 20
      responses:
        "200":
          description: Customer transactions
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerTransactionListResponse"

  /categories:
    get:
      operationId: listCategories
      tags: [categories]
      summary: List categories
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Categories list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Category"
    post:
      operationId: createCategory
      tags: [categories]
      summary: Create category
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCategoryRequest"
      responses:
        "201":
          description: Category created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Category"

  /products:
    get:
      operationId: listProducts
      tags: [products]
      summary: List products
      security:
        - bearerAuth: []
      parameters:
        - name: search
          in: query
          schema:
            type: string
        - name: categoryId
          in: query
          schema:
            type: number
        - name: lowStock
          in: query
          schema:
            type: boolean
        - name: page
          in: query
          schema:
            type: number
            default: 1
        - name: limit
          in: query
          schema:
            type: number
            default: 20
      responses:
        "200":
          description: Products list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductListResponse"
    post:
      operationId: createProduct
      tags: [products]
      summary: Create product
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProductRequest"
      responses:
        "201":
          description: Product created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Product"

  /products/{id}:
    get:
      operationId: getProduct
      tags: [products]
      summary: Get product
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Product detail
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductDetail"
    put:
      operationId: updateProduct
      tags: [products]
      summary: Update product
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProductRequest"
      responses:
        "200":
          description: Product updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Product"
    delete:
      operationId: deleteProduct
      tags: [products]
      summary: Delete product
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessResponse"

  /products/{id}/movements:
    get:
      operationId: getProductMovements
      tags: [products]
      summary: Get product stock movements
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
        - name: page
          in: query
          schema:
            type: number
            default: 1
        - name: limit
          in: query
          schema:
            type: number
            default: 20
      responses:
        "200":
          description: Stock movements
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockMovementListResponse"

  /products/{id}/stock-adjustment:
    post:
      operationId: adjustStock
      tags: [products]
      summary: Manual stock adjustment
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StockAdjustmentRequest"
      responses:
        "200":
          description: Stock adjusted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessResponse"

  /invoices:
    get:
      operationId: listInvoices
      tags: [invoices]
      summary: List invoices
      security:
        - bearerAuth: []
      parameters:
        - name: type
          in: query
          schema:
            type: string
            enum: [sales, purchase]
        - name: customerId
          in: query
          schema:
            type: number
        - name: startDate
          in: query
          schema:
            type: string
        - name: endDate
          in: query
          schema:
            type: string
        - name: page
          in: query
          schema:
            type: number
            default: 1
        - name: limit
          in: query
          schema:
            type: number
            default: 20
      responses:
        "200":
          description: Invoices list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InvoiceListResponse"
    post:
      operationId: createInvoice
      tags: [invoices]
      summary: Create invoice
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateInvoiceRequest"
      responses:
        "201":
          description: Invoice created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"

  /invoices/{id}:
    get:
      operationId: getInvoice
      tags: [invoices]
      summary: Get invoice
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Invoice
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InvoiceDetail"
    delete:
      operationId: deleteInvoice
      tags: [invoices]
      summary: Delete invoice
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessResponse"

  /cash:
    get:
      operationId: listCashTransactions
      tags: [cash]
      summary: List cash transactions
      security:
        - bearerAuth: []
      parameters:
        - name: type
          in: query
          schema:
            type: string
            enum: [income, expense]
        - name: startDate
          in: query
          schema:
            type: string
        - name: endDate
          in: query
          schema:
            type: string
        - name: page
          in: query
          schema:
            type: number
            default: 1
        - name: limit
          in: query
          schema:
            type: number
            default: 20
      responses:
        "200":
          description: Cash transactions
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CashTransactionListResponse"
    post:
      operationId: createCashTransaction
      tags: [cash]
      summary: Create cash transaction
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCashTransactionRequest"
      responses:
        "201":
          description: Transaction created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CashTransaction"

  /cash/{id}:
    delete:
      operationId: deleteCashTransaction
      tags: [cash]
      summary: Delete cash transaction
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessResponse"

  /reports/sales:
    get:
      operationId: getSalesReport
      tags: [reports]
      summary: Sales report
      security:
        - bearerAuth: []
      parameters:
        - name: startDate
          in: query
          schema:
            type: string
        - name: endDate
          in: query
          schema:
            type: string
        - name: customerId
          in: query
          schema:
            type: number
      responses:
        "200":
          description: Sales report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReport"

  /reports/purchases:
    get:
      operationId: getPurchasesReport
      tags: [reports]
      summary: Purchases report
      security:
        - bearerAuth: []
      parameters:
        - name: startDate
          in: query
          schema:
            type: string
        - name: endDate
          in: query
          schema:
            type: string
        - name: customerId
          in: query
          schema:
            type: number
      responses:
        "200":
          description: Purchases report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchasesReport"

  /reports/stock:
    get:
      operationId: getStockReport
      tags: [reports]
      summary: Stock report
      security:
        - bearerAuth: []
      parameters:
        - name: categoryId
          in: query
          schema:
            type: number
        - name: lowStock
          in: query
          schema:
            type: boolean
      responses:
        "200":
          description: Stock report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockReport"

  /reports/cash:
    get:
      operationId: getCashReport
      tags: [reports]
      summary: Cash report
      security:
        - bearerAuth: []
      parameters:
        - name: startDate
          in: query
          schema:
            type: string
        - name: endDate
          in: query
          schema:
            type: string
      responses:
        "200":
          description: Cash report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CashReport"

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  schemas:
    HealthStatus:
      type: object
      properties:
        status:
          type: string
      required:
        - status

    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
      required:
        - error

    SuccessResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
      required:
        - success

    LoginRequest:
      type: object
      properties:
        username:
          type: string
        password:
          type: string
      required:
        - username
        - password

    LoginResponse:
      type: object
      properties:
        token:
          type: string
        user:
          $ref: "#/components/schemas/User"
      required:
        - token
        - user

    User:
      type: object
      properties:
        id:
          type: number
        username:
          type: string
        fullName:
          type: string
        role:
          type: string
          enum: [admin, user]
        createdAt:
          type: string
      required:
        - id
        - username
        - fullName
        - role
        - createdAt

    DashboardData:
      type: object
      properties:
        dailySales:
          type: number
        dailyPurchases:
          type: number
        totalStockValue:
          type: number
        totalReceivable:
          type: number
        totalPayable:
          type: number
        criticalStockCount:
          type: number
        recentTransactions:
          type: array
          items:
            $ref: "#/components/schemas/RecentTransaction"
        monthlySalesData:
          type: array
          items:
            $ref: "#/components/schemas/MonthlyData"
      required:
        - dailySales
        - dailyPurchases
        - totalStockValue
        - totalReceivable
        - totalPayable
        - criticalStockCount
        - recentTransactions
        - monthlySalesData

    RecentTransaction:
      type: object
      properties:
        id:
          type: number
        type:
          type: string
        description:
          type: string
        amount:
          type: number
        date:
          type: string
      required:
        - id
        - type
        - description
        - amount
        - date

    MonthlyData:
      type: object
      properties:
        month:
          type: string
        sales:
          type: number
        purchases:
          type: number
      required:
        - month
        - sales
        - purchases

    Customer:
      type: object
      properties:
        id:
          type: number
        code:
          type: string
        name:
          type: string
        companyName:
          type: string
        contactPerson:
          type: string
        phone:
          type: string
        email:
          type: string
        taxOffice:
          type: string
        taxNumber:
          type: string
        address:
          type: string
        notes:
          type: string
        balance:
          type: number
        createdAt:
          type: string
      required:
        - id
        - code
        - name
        - balance
        - createdAt

    CustomerDetail:
      allOf:
        - $ref: "#/components/schemas/Customer"
        - type: object
          properties:
            totalSales:
              type: number
            totalPurchases:
              type: number
            totalPayments:
              type: number
            totalCollections:
              type: number
          required:
            - totalSales
            - totalPurchases
            - totalPayments
            - totalCollections

    CustomerListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Customer"
        total:
          type: number
        page:
          type: number
        limit:
          type: number
      required:
        - data
        - total
        - page
        - limit

    CreateCustomerRequest:
      type: object
      properties:
        code:
          type: string
        name:
          type: string
        companyName:
          type: string
        contactPerson:
          type: string
        phone:
          type: string
        email:
          type: string
        taxOffice:
          type: string
        taxNumber:
          type: string
        address:
          type: string
        notes:
          type: string
      required:
        - code
        - name

    CustomerTransaction:
      type: object
      properties:
        id:
          type: number
        source:
          type: string
          enum: [invoice, cash]
        type:
          type: string
          enum: [sales_invoice, purchase_invoice, collection, payment, cash_income, cash_expense]
        description:
          type: string
        amount:
          type: number
        debit:
          type: number
        credit:
          type: number
        balance:
          type: number
        date:
          type: string
        referenceId:
          type: number
          nullable: true
        referenceType:
          type: string
          nullable: true
      required:
        - id
        - source
        - type
        - description
        - amount
        - debit
        - credit
        - balance
        - date

    CustomerTransactionListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CustomerTransaction"
        total:
          type: number
        page:
          type: number
        limit:
          type: number
        currentBalance:
          type: number
      required:
        - data
        - total
        - page
        - limit
        - currentBalance

    Category:
      type: object
      properties:
        id:
          type: number
        name:
          type: string
        description:
          type: string
        productCount:
          type: number
      required:
        - id
        - name
        - productCount

    CreateCategoryRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
      required:
        - name

    Product:
      type: object
      properties:
        id:
          type: number
        code:
          type: string
        barcode:
          type: string
        name:
          type: string
        categoryId:
          type: number
        categoryName:
          type: string
        unit:
          type: string
        purchasePrice:
          type: number
        salePrice:
          type: number
        currentStock:
          type: number
        minStockLevel:
          type: number
        description:
          type: string
        isLowStock:
          type: boolean
        createdAt:
          type: string
      required:
        - id
        - code
        - name
        - unit
        - purchasePrice
        - salePrice
        - currentStock
        - minStockLevel
        - isLowStock
        - createdAt

    ProductDetail:
      allOf:
        - $ref: "#/components/schemas/Product"
        - type: object
          properties:
            totalPurchased:
              type: number
            totalSold:
              type: number
            recentMovements:
              type: array
              items:
                $ref: "#/components/schemas/StockMovement"
          required:
            - totalPurchased
            - totalSold
            - recentMovements

    ProductListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Product"
        total:
          type: number
        page:
          type: number
        limit:
          type: number
      required:
        - data
        - total
        - page
        - limit

    CreateProductRequest:
      type: object
      properties:
        code:
          type: string
        barcode:
          type: string
        name:
          type: string
        categoryId:
          type: number
        unit:
          type: string
        purchasePrice:
          type: number
        salePrice:
          type: number
        minStockLevel:
          type: number
        description:
          type: string
      required:
        - code
        - name
        - unit
        - purchasePrice
        - salePrice
        - minStockLevel

    StockMovement:
      type: object
      properties:
        id:
          type: number
        productId:
          type: number
        productName:
          type: string
        type:
          type: string
          enum: [purchase_in, sale_out, manual_in, manual_out]
        quantity:
          type: number
        unitPrice:
          type: number
        totalPrice:
          type: number
        description:
          type: string
        date:
          type: string
        referenceId:
          type: number
        referenceType:
          type: string
      required:
        - id
        - productId
        - type
        - quantity
        - date

    StockMovementListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/StockMovement"
        total:
          type: number
        page:
          type: number
        limit:
          type: number
      required:
        - data
        - total
        - page
        - limit

    StockAdjustmentRequest:
      type: object
      properties:
        type:
          type: string
          enum: [manual_in, manual_out]
        quantity:
          type: number
        description:
          type: string
      required:
        - type
        - quantity

    InvoiceItem:
      type: object
      properties:
        productId:
          type: number
        productName:
          type: string
        quantity:
          type: number
        unitPrice:
          type: number
        vatRate:
          type: number
        totalPrice:
          type: number
        vatAmount:
          type: number
        grandTotal:
          type: number
      required:
        - productId
        - quantity
        - unitPrice
        - vatRate
        - totalPrice
        - vatAmount
        - grandTotal

    Invoice:
      type: object
      properties:
        id:
          type: number
        invoiceNumber:
          type: string
        type:
          type: string
          enum: [sales, purchase]
        customerId:
          type: number
        customerName:
          type: string
        subtotal:
          type: number
        vatTotal:
          type: number
        grandTotal:
          type: number
        date:
          type: string
        notes:
          type: string
        createdAt:
          type: string
      required:
        - id
        - invoiceNumber
        - type
        - customerId
        - subtotal
        - vatTotal
        - grandTotal
        - date
        - createdAt

    InvoiceDetail:
      allOf:
        - $ref: "#/components/schemas/Invoice"
        - type: object
          properties:
            items:
              type: array
              items:
                $ref: "#/components/schemas/InvoiceItem"
          required:
            - items

    InvoiceListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Invoice"
        total:
          type: number
        page:
          type: number
        limit:
          type: number
      required:
        - data
        - total
        - page
        - limit

    CreateInvoiceRequest:
      type: object
      properties:
        type:
          type: string
          enum: [sales, purchase]
        customerId:
          type: number
        date:
          type: string
        notes:
          type: string
        items:
          type: array
          items:
            $ref: "#/components/schemas/CreateInvoiceItemRequest"
      required:
        - type
        - customerId
        - date
        - items

    CreateInvoiceItemRequest:
      type: object
      properties:
        productId:
          type: number
        quantity:
          type: number
        unitPrice:
          type: number
        vatRate:
          type: number
      required:
        - productId
        - quantity
        - unitPrice
        - vatRate

    CashTransaction:
      type: object
      properties:
        id:
          type: number
        type:
          type: string
          enum: [income, expense]
        description:
          type: string
        amount:
          type: number
        customerId:
          type: number
        customerName:
          type: string
        paymentMethod:
          type: string
          enum: [nakit, kredi_kart, cek, senet, havale]
        cardHolder:
          type: string
        checkOwner:
          type: string
        checkOwnerCustomerId:
          type: number
        documentNumber:
          type: string
        dueDate:
          type: string
        bankName:
          type: string
        date:
          type: string
        createdAt:
          type: string
      required:
        - id
        - type
        - description
        - amount
        - paymentMethod
        - date
        - createdAt

    CashTransactionListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CashTransaction"
        total:
          type: number
        page:
          type: number
        limit:
          type: number
        balance:
          type: number
      required:
        - data
        - total
        - page
        - limit
        - balance

    CreateCashTransactionRequest:
      type: object
      properties:
        type:
          type: string
          enum: [income, expense]
        description:
          type: string
        amount:
          type: number
        customerId:
          type: number
        paymentMethod:
          type: string
          enum: [nakit, kredi_kart, cek, senet, havale]
          default: nakit
        cardHolder:
          type: string
        checkOwner:
          type: string
        checkOwnerCustomerId:
          type: number
        documentNumber:
          type: string
        dueDate:
          type: string
        bankName:
          type: string
        date:
          type: string
      required:
        - type
        - description
        - amount
        - date

    SalesReport:
      type: object
      properties:
        totalSales:
          type: number
        totalVat:
          type: number
        invoiceCount:
          type: number
        invoices:
          type: array
          items:
            $ref: "#/components/schemas/Invoice"
        topProducts:
          type: array
          items:
            $ref: "#/components/schemas/TopProduct"
        topCustomers:
          type: array
          items:
            $ref: "#/components/schemas/TopCustomer"
      required:
        - totalSales
        - totalVat
        - invoiceCount
        - invoices
        - topProducts
        - topCustomers

    PurchasesReport:
      type: object
      properties:
        totalPurchases:
          type: number
        totalVat:
          type: number
        invoiceCount:
          type: number
        invoices:
          type: array
          items:
            $ref: "#/components/schemas/Invoice"
        topProducts:
          type: array
          items:
            $ref: "#/components/schemas/TopProduct"
        topSuppliers:
          type: array
          items:
            $ref: "#/components/schemas/TopCustomer"
      required:
        - totalPurchases
        - totalVat
        - invoiceCount
        - invoices
        - topProducts
        - topSuppliers

    StockReport:
      type: object
      properties:
        totalProducts:
          type: number
        totalStockValue:
          type: number
        lowStockProducts:
          type: number
        products:
          type: array
          items:
            $ref: "#/components/schemas/Product"
      required:
        - totalProducts
        - totalStockValue
        - lowStockProducts
        - products

    CashReport:
      type: object
      properties:
        totalIncome:
          type: number
        totalExpense:
          type: number
        balance:
          type: number
        transactions:
          type: array
          items:
            $ref: "#/components/schemas/CashTransaction"
      required:
        - totalIncome
        - totalExpense
        - balance
        - transactions

    TopProduct:
      type: object
      properties:
        productId:
          type: number
        productName:
          type: string
        quantity:
          type: number
        total:
          type: number
      required:
        - productId
        - productName
        - quantity
        - total

    TopCustomer:
      type: object
      properties:
        customerId:
          type: number
        customerName:
          type: string
        total:
          type: number
        invoiceCount:
          type: number
      required:
        - customerId
        - customerName
        - total
        - invoiceCount
