> ## Documentation Index
> Fetch the complete documentation index at: https://docs-beta.layerfi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create P&L comparisons

> Compare Profit & Loss views across time periods and/or tags. This endpoint allows specifying multiple time periods (specified in months, years, or custom date ranges) and tags and will generate a comparison for every combination. Note that this endpoint is retrieval only, but uses a `POST` HTTP verb rather than `GET` because of the complexity of the parameters.



## OpenAPI

````yaml post /v1/businesses/{businessId}/reports/profit-and-loss-comparison
openapi: 3.0.1
info:
  title: API
  version: latest
servers: []
security:
  - BearerAuth: []
tags: []
externalDocs:
  url: /
paths:
  /v1/businesses/{businessId}/reports/profit-and-loss-comparison:
    post:
      tags: []
      summary: Create P&L comparisons
      description: >-
        Compare Profit & Loss views across time periods and/or tags. This
        endpoint allows specifying multiple time periods (specified in months,
        years, or custom date ranges) and tags and will generate a comparison
        for every combination. Note that this endpoint is retrieval only, but
        uses a `POST` HTTP verb rather than `GET` because of the complexity of
        the parameters.
      operationId: business.reports.comparison-profit-and-loss-summaries.post
      parameters:
        - name: businessId
          in: path
          description: The UUID of the business to fetch the profit and loss for
          required: true
          schema:
            type: string
        - name: Content-Type
          in: header
          description: Content-Type must be set to application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProfitAndLossComparisonRequest'
      responses:
        '200':
          description: ''
          headers: {}
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProfitAndLossComparisonResult'
        '400':
          description: >-
            P&L not yet reconciled: one or more of the requested time periods is
            not closed or reconciled and cannot be displayed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: >-
            Business id is not found. This indicates the business id is invalid
            or the business has been archived.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      deprecated: false
components:
  schemas:
    ProfitAndLossComparisonRequest:
      type: object
      properties:
        periods:
          $ref: '#/components/schemas/ProfitAndLossComparisonPeriods'
        tag_filters:
          type: array
          items:
            $ref: '#/components/schemas/TagComparisons'
          nullable: true
        reporting_basis:
          $ref: '#/components/schemas/ReportingBasis'
          nullable: true
        structure:
          $ref: '#/components/schemas/PnlTemplates'
          nullable: true
    ProfitAndLossComparisonResult:
      type: object
      properties:
        pnls:
          type: array
          items:
            $ref: '#/components/schemas/ComparisonPnlEntry'
    ApiError:
      type: object
      properties: {}
      example: ''
      description: ''
    ProfitAndLossComparisonPeriods:
      type: object
      oneOf:
        - $ref: '#/components/schemas/Months'
        - $ref: '#/components/schemas/Years'
        - $ref: '#/components/schemas/DateRanges'
      discriminator:
        propertyName: type
        mapping:
          Comparison_Months: '#/components/schemas/Months'
          Comparison_Years: '#/components/schemas/Years'
          Comparison_DateRanges: '#/components/schemas/DateRanges'
    TagComparisons:
      type: object
      properties:
        required_tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
    ReportingBasis:
      type: string
      enum:
        - ACCRUAL
        - CASH
    PnlTemplates:
      type: string
      enum:
        - DEFAULT
        - TRUCKING
        - MEDSPA
        - MEDSPA_NO_LICENSING
        - CITRUS
        - CITRUS_NO_LICENSING
        - FLORIST
    ComparisonPnlEntry:
      type: object
      properties:
        period:
          $ref: '#/components/schemas/ProfitAndLossComparisonPeriods'
        tag_filter:
          $ref: '#/components/schemas/TagFilter'
        pnl:
          $ref: '#/components/schemas/ProfitAndLoss'
    Months:
      type: object
      properties:
        type:
          type: string
          enum:
            - Comparison_Months
        months:
          type: array
          items:
            $ref: '#/components/schemas/Month'
    Years:
      type: object
      properties:
        type:
          type: string
          enum:
            - Comparison_Years
        years:
          type: array
          items:
            $ref: '#/components/schemas/Year'
    DateRanges:
      type: object
      properties:
        type:
          type: string
          enum:
            - Comparison_Date_Ranges
        date_ranges:
          type: array
          items:
            $ref: '#/components/schemas/DateRange'
    TagKeyValue:
      type: object
      description: >-
        A TagKeyValue holds key=value data related to a tag. This is used when
        creating or updating taggable entities (transactions, invoices, etc.).
      properties:
        key:
          type: string
          description: The tag dimension key (e.g., "department", "project", "location")
          example: department
        dimension_display_name:
          type: string
          nullable: true
          description: >-
            If the TagDimension doesn't exist, providing this value specifies
            the display name upon database insertion. Otherwise, it is left as
            null on the TagDimension.
          example: Department
        value:
          type: string
          description: The tag value (e.g., "sales", "marketing", "engineering")
          example: sales
        value_display_name:
          type: string
          nullable: true
          description: >-
            If the TagValueDefinition doesn't exist, providing this value
            specifies the display name upon database insertion. Otherwise, it is
            left as null on the TagValueDefinition.
          example: Sales Department
      required:
        - key
        - value
    TagFilter:
      type: object
      properties:
        key:
          type: string
        value:
          type: array
          items:
            type: string
    ProfitAndLoss:
      type: object
      properties:
        business_id:
          type: string
          format: uuid
        start_date:
          type: string
          format: date-time
        end_date:
          type: string
          format: date-time
        income:
          $ref: '#/components/schemas/LineItem'
        cost_of_goods_sold:
          $ref: '#/components/schemas/LineItem'
        gross_profit:
          type: integer
          format: int64
        expenses:
          $ref: '#/components/schemas/LineItem'
        profit_before_taxes:
          type: integer
          format: int64
        taxes:
          $ref: '#/components/schemas/LineItem'
        net_profit:
          type: integer
          format: int64
        other_outflows:
          $ref: '#/components/schemas/LineItem'
          nullable: true
        personal_expenses:
          $ref: '#/components/schemas/LineItem'
        fully_categorized:
          type: boolean
    Month:
      type: object
      properties:
        year:
          type: integer
          format: int32
          example: 2024
        month:
          type: integer
          format: int32
          example: 12
    Year:
      type: object
      properties:
        year:
          type: integer
          format: int32
          example: 2024
    DateRange:
      type: object
      properties:
        start_date:
          type: string
          format: date-time
        end_date:
          type: string
          format: date-time
    LineItem:
      type: object
      properties:
        name:
          type: string
        display_name:
          type: string
        value:
          type: integer
          format: int64
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
        is_contra:
          type: boolean
      required:
        - name
        - display_name
        - value
        - is_contra
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````