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

# (DEPRECATED) Calculate and return the revenue for a existing or new price plan

> Calculate and return the revenue for a existing or new price plan



## OpenAPI

````yaml post /revenue_calculator
openapi: 3.0.3
info:
  version: '1.0'
  title: Togai Apis
  contact:
    email: engg@togai.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: APIs for Togai App
servers:
  - description: Api endpoint
    url: https://api.togai.com/
  - description: Sandbox api endpoint
    url: https://sandbox-api.togai.com/
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: Customer level calls
  - name: Accounts
    description: Account level calls
  - name: Event Schemas
    description: Event Schema level calls
  - name: Usage Meters
    description: Usage Meter level calls
  - name: Price Plans
    description: (DEPRECATED) Price Plan level calls
  - name: PricePlanV2
    description: Price Plan V2 level calls
  - name: Schedules
    description: Account Schedule level calls
  - name: Pricing Rules
    description: Pricing Rules level calls
  - name: Settings
    description: Settings
  - name: Price Experimentation
    description: Price Experimentation apis
  - name: InvoiceGroups
    description: Invoice Group level calls
  - name: Organization
    description: Organization level calls
  - name: FileStorage
    description: File Storage level calls
  - name: Aliases
    description: Alias level calls
  - name: Reports
    description: Report level calls
  - name: ReportTemplates
    description: Report Template level calls
  - name: Customer Portal
    description: Portal level calls
  - name: Alerts
    description: Alert level calls
  - name: Event Management
    description: APIs for getting events ingested in Togai
    externalDocs:
      description: docs
      url: https://togai.com/docs/billing/events
  - name: Metrics
    description: APIs for getting Togai metrics
    externalDocs:
      description: docs
      url: https://togai.com/docs/metrics
  - name: Licenses
    description: APIs for getting or updating license records in Togai
  - name: Entitlements
    description: APIs related to entitlements
  - name: Invoices
    description: Invoices API
  - name: Credits
    description: Credits API
  - name: Wallet
    description: Wallet API
  - name: InvoiceTemplates
    description: InvoiceTemplates API
  - name: InvoiceSequence
    description: InvoiceSequence API
  - name: Payments
    description: Payments API
  - name: Authentication
    description: Authentication API
externalDocs:
  description: Find out more about Togai
  url: https://docs.togai.com/docs
paths:
  /revenue_calculator:
    post:
      tags:
        - Price Experimentation
      summary: >-
        (DEPRECATED) Calculate and return the revenue for a existing or new
        price plan
      description: Calculate and return the revenue for a existing or new price plan
      operationId: calculateRevenue
      requestBody:
        $ref: '#/components/requestBodies/CalculateRevenueRequest'
      responses:
        '200':
          $ref: '#/components/responses/CalculateRevenueResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '403':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '429':
          $ref: '#/components/responses/ErrorResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  requestBodies:
    CalculateRevenueRequest:
      description: Request payload for calculateRevenueAPI
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CalculateRevenueRequest'
          examples:
            FirstCalculateRevenueRequestExample:
              $ref: '#/components/examples/FirstCalculateRevenueRequestExample'
            SecondCalculateRevenueRequestExample:
              $ref: '#/components/examples/SecondCalculateRevenueRequestExample'
            ThirdCalculateRevenueRequestExample:
              $ref: '#/components/examples/ThirdCalculateRevenueRequestExample'
  responses:
    CalculateRevenueResponse:
      description: Response payload for calculateRevenueAPI
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CalculateRevenueResponse'
          examples:
            CalculateRevenueResponse:
              $ref: '#/components/examples/CalculateRevenueResponse'
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            ErrorResponse:
              summary: Error message
              value:
                message: <Reason message>
  schemas:
    CalculateRevenueRequest:
      description: Request to get revenue details
      type: object
      additionalProperties: false
      required:
        - currencyConfig
        - pricePlanDetailsConfig
        - usageConfig
        - licenseEntriesConfig
      properties:
        currencyConfig:
          title: CurrencyConfig
          description: Configuration for getting the currency
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - ACCOUNT_INVOICE
              description: |
                Mode to get the currency
                - CUSTOM: Use the currency provided in the request
                - ACCOUNT_INVOICE: Use the invoice currency of the given account
            currency:
              description: Currency to be used, this will be considered if mode is CUSTOM
              type: string
              minLength: 1
            accountId:
              description: >-
                Id of the account of which invoice currency will be used, this
                will be considered if mode is ACCOUNT_INVOICE
              type: string
        pricePlanDetailsConfig:
          title: PricePlanDetailsConfig
          description: Configuration for getting the usage rate card
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - PRICE_PLAN
                - ACCOUNT
              description: >
                Mode to get the usage rate card

                - CUSTOM: Use the price plan details provided in the request

                - PRICE_PLAN: Use the usage rate cards of the given price plan

                - ACCOUNT: Use the usage rate cards of a associated price plan
                of the given account
            pricePlanDetails:
              $ref: '#/components/schemas/CreatePricePlanDetails'
            pricePlanId:
              description: >-
                Id of the price plan, this will be considered if mode is
                PRICE_PLAN
              type: string
              minLength: 1
            accountId:
              description: Id of the account, this will be considered if mode is ACCOUNT
              type: string
              minLength: 1
            effectiveOn:
              description: >-
                Will be used for getting the usage rate card, only used if mode
                is ACCOUNT or PRICE_PLAN
              type: string
              format: date-time
            pricingCycleOrdinal:
              description: >-
                nth cycle, will be used to calculate revenue for the particular
                cycle, only used if mode is CUSTOM or PRICE_PLAN
              type: integer
        usageConfig:
          title: UsageConfig
          description: Configuration for getting the usage
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - LOOKUP_RANGE
                - LOOKUP_CYCLE
              description: >
                Mode to get the usage for the usage meters

                - CUSTOM: Use the usages provided in the request

                - LOOKUP_RANGE: Use the usage of a given account for the
                specified range

                - LOOKUP_CYCLE: Use the usage of a given account for the
                specified cycle
            usageMap:
              description: >-
                Map of usage meter id and usage, this will be considered if mode
                is CUSTOM
              type: object
              additionalProperties:
                type: number
            lookupRange:
              description: >-
                Range of usage to be looked up, this will be considered if mode
                is LOOKUP_RANGE
              type: object
              required:
                - start
                - end
                - accountId
              properties:
                start:
                  type: string
                  format: date-time
                end:
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
            lookupCycle:
              description: >-
                Cycle of usage to be looked up, this will be considered if mode
                is LOOKUP_CYCLE
              type: object
              required:
                - accountId
              properties:
                cycleEffectiveOn:
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
        licenseEntriesConfig:
          title: LicenseEntriesConfig
          description: Configuration for getting the license entries
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - LOOKUP_RANGE
                - LOOKUP_CYCLE
              description: >
                Mode to get the license entries for the license rate cards

                - CUSTOM: Use the license entries provided in the request

                - LOOKUP_RANGE: Use the license entries of a given account for
                the specified range

                - LOOKUP_CYCLE: Use the license entries of a given account for
                the specified cycle
            custom:
              description: >-
                List of license entries, this will be considered if mode is
                CUSTOM
              type: array
              items:
                type: object
                title: LicenseEntry
                required:
                  - licenseId
                  - quantity
                  - effectiveFrom
                properties:
                  licenseId:
                    type: string
                    minLength: 1
                  quantity:
                    type: integer
                  effectiveFrom:
                    type: string
                    format: date-time
            lookupRange:
              description: >-
                Range of license entries to be looked up, this will be
                considered if mode is LOOKUP_RANGE
              type: object
              required:
                - start
                - end
                - accountId
              properties:
                start:
                  type: string
                  format: date-time
                end:
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
            lookupCycle:
              description: >-
                Cycle of license entries to be looked up, this will be
                considered if mode is LOOKUP_CYCLE
              type: object
              required:
                - accountId
              properties:
                cycleEffectiveOn:
                  description: >-
                    Effective date of the cycle, will be used to get the license
                    entries of the cycle
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
        namedLicenseEntriesConfig:
          title: NamedLicenseEntriesConfig
          description: Configuration for getting the named license entries
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - LOOKUP_RANGE
                - LOOKUP_CYCLE
              description: >
                Mode to get the named license entries for the license rate cards

                - CUSTOM: Use the named license entries provided in the request

                - LOOKUP_RANGE: Use the named license entries of a given account
                for the specified range

                - LOOKUP_CYCLE: Use the named license entries of a given account
                for the specified cycle
            custom:
              description: >-
                List of named license entries, this will be considered if mode
                is CUSTOM
              type: array
              items:
                type: object
                title: NamedLicenseEntry
                required:
                  - licenseId
                  - name
                  - effectiveFrom
                properties:
                  licenseId:
                    type: string
                    minLength: 1
                  name:
                    type: integer
                  effectiveFrom:
                    type: string
                    format: date-time
                  effectiveUntil:
                    type: string
                    format: date-time
            lookupRange:
              description: >-
                Range of named license entries to be looked up, this will be
                considered if mode is LOOKUP_RANGE
              type: object
              required:
                - start
                - end
                - accountId
              properties:
                start:
                  type: string
                  format: date-time
                end:
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
            lookupCycle:
              description: >-
                Cycle of named license entries to be looked up, this will be
                considered if mode is LOOKUP_CYCLE
              type: object
              required:
                - accountId
              properties:
                cycleEffectiveOn:
                  description: >-
                    Effective date of the cycle, will be used to get the named
                    license entries of the cycle
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
        prorationConfig:
          title: ProrationConfig
          description: >-
            Configuration for getting the proration, if not provided no
            proration will be applied
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - LOOKUP_CYCLE
              description: >
                Mode to get the proration

                - CUSTOM: Use the proration provided in the request

                - LOOKUP_CYCLE: Use the proration of a given account for the
                specified cycle
            customConfig:
              description: >-
                Custom proration config, this will be considered if mode is
                CUSTOM
              type: object
              required:
                - cycleStartDate
                - cycleEndDate
                - currentDate
              properties:
                cycleStartDate:
                  type: string
                  format: date-time
                cycleEndDate:
                  type: string
                  format: date-time
                currentDate:
                  type: string
                  format: date-time
            lookupCycleConfig:
              description: >-
                Cycle of proration to be looked up, this will be considered if
                mode is LOOKUP_CYCLE
              type: object
              required:
                - accountId
              properties:
                currentDateTime:
                  description: Defaults to current date time if not provided
                  type: string
                  format: date-time
                cycleEffectiveOn:
                  description: Defaults to current date time if not provided
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
        entitlementOverageConfig:
          title: EntitlementOverageConfig
          description: Configuration for getting the entitlement overages
          type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - CUSTOM
                - LOOKUP_CYCLE
              description: >
                Mode to get the entitlement overages for the entitlement overage
                rate cards

                - CUSTOM: Use the entitlement overages provided in the request

                - LOOKUP_CYCLE: Use the entitlement overages of a given account
                for the specified cycle
            custom:
              description: >-
                Quantity of entitlement overages, this will be considered if
                mode is CUSTOM
              type: array
              items:
                type: object
                title: EntitlementOverageEntry
                required:
                  - featureId
                  - quantity
                properties:
                  featureId:
                    type: string
                    minLength: 1
                  quantity:
                    type: number
            lookupCycle:
              description: >-
                Billing cycle of entitlement overages to be looked up, this will
                be considered if mode is LOOKUP_CYCLE
              type: object
              required:
                - accountId
                - billingCycleEndDate
              properties:
                billingCycleEndDate:
                  description: >-
                    Effective date of the cycle, will be used to get the license
                    entries of the cycle
                  type: string
                  format: date-time
                accountId:
                  type: string
                  minLength: 1
    CalculateRevenueResponse:
      type: object
      additionalProperties: false
      required:
        - revenueInfo
        - pricePlanDetails
        - currency
      properties:
        currency:
          type: string
        usageLookupRange:
          type: object
          title: UsageLookupRange
          description: Start and end dates of usage lookup if usage mode is LOOKUP
          additionalProperties: false
          required:
            - start
            - end
          properties:
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
        pricePlanDetails:
          $ref: '#/components/schemas/PricePlanDetails'
        revenueInfo:
          type: array
          items:
            title: RevenueInfo
            type: object
            additionalProperties: false
            required:
              - usages
            properties:
              usageRateCard:
                $ref: '#/components/schemas/UsageRateCard'
              fixedFeeRateCard:
                $ref: '#/components/schemas/FixedFeeRateCard'
              licenseRateCard:
                $ref: '#/components/schemas/LicenseRateCard'
              billingEntitlementRateCard:
                $ref: '#/components/schemas/BillingEntitlementRateCard'
              creditGrantRateCard:
                $ref: '#/components/schemas/CreditGrantRateCard'
              entitlementOverageRateCard:
                $ref: '#/components/schemas/EntitlementOverageRateCard'
              usages:
                type: object
                additionalProperties:
                  type: number
              fixedFeeRevenueSummary:
                type: object
                title: FixedFeeRevenueSummary
                additionalProperties: false
                required:
                  - revenue
                properties:
                  revenue:
                    type: number
              licenseRevenueSummary:
                type: array
                items:
                  $ref: '#/components/schemas/SlabRevenueSummary'
              billingEntitlementRevenueSummary:
                type: object
                title: BillingEntitlementRevenueSummary
                additionalProperties: false
                required:
                  - revenue
                properties:
                  revenue:
                    type: number
              creditGrantRevenueSummary:
                type: object
                title: CreditGrantRevenueSummary
                additionalProperties: false
                required:
                  - revenue
                properties:
                  revenue:
                    type: number
              entitlementOverageRevenueSummary:
                type: object
                title: EntitlementOverageRevenueSummary
                additionalProperties: false
                required:
                  - revenue
                properties:
                  revenue:
                    type: number
              slabRevenueSummaries:
                type: array
                items:
                  $ref: '#/components/schemas/SlabRevenueSummary'
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: error description
          maxLength: 500
    CreatePricePlanDetails:
      type: object
      additionalProperties: false
      required:
        - supportedCurrencies
      properties:
        pricingCycleConfig:
          $ref: '#/components/schemas/PricingCycleConfig'
        supportedCurrencies:
          description: List of currencies supported by the price plan
          type: array
          uniqueItems: true
          items:
            type: string
        usageRateCards:
          description: List of usage rate cards
          type: array
          items:
            $ref: '#/components/schemas/UsageRateCard'
        fixedFeeRateCards:
          type: array
          items:
            $ref: '#/components/schemas/FixedFeeRateCard'
        licenseRateCards:
          type: array
          items:
            $ref: '#/components/schemas/LicenseRateCard'
        billingEntitlementRateCards:
          type: array
          items:
            $ref: '#/components/schemas/BillingEntitlementRateCard'
        minimumCommitment:
          $ref: '#/components/schemas/MinimumCommitment'
        creditGrantRateCards:
          type: array
          items:
            $ref: '#/components/schemas/CreditGrantRateCard'
        entitlementOverageRateCards:
          type: array
          items:
            $ref: '#/components/schemas/EntitlementOverageRateCard'
        deferredRevenue:
          description: >
            This option can be enabled while creating a price plan to opt for
            deferred revenue finalization.

            i.e, Togai will assume that the price plan may change any time
            during the pricing cycle and 

            thereby does not compute the revenue in near-real time. 

            This gives the flexibility of editing rate cards in price plan from
            beginning of the pricing cycle.

            Enabling this mode comes with the following limitations.

            1. Following rate cards are not supported under a `deferredRevenue`
            plan
                * creditGrantRateCards,
                * billingEntitlementRateCards,
                * entitlementOverageRateCards,
                * IN_ADVANCE fixedFeeRateCards,
                * IN_ADVANCE licenseRateCards
            2. Metrics API return revenue metrics only after the grace period of
            the account's pricing cycle 

            (i.e, only once the invoice becomes DUE)
          type: boolean
        allow_ongoing_cycle_updates:
          description: |
            Allow changes to price plan from the beginning of the ongoing cycle.
          type: boolean
    PricePlanDetails:
      type: object
      required:
        - supportedCurrencies
        - activeCurrencies
      properties:
        supportedCurrencies:
          type: array
          uniqueItems: true
          items:
            type: string
        activeCurrencies:
          type: array
          uniqueItems: true
          readOnly: true
          items:
            type: string
        pricingCycleConfig:
          $ref: '#/components/schemas/PricingCycleConfig'
        usageRateCards:
          type: array
          items:
            $ref: '#/components/schemas/UsageRateCard'
        fixedFeeRateCards:
          type: array
          items:
            $ref: '#/components/schemas/FixedFeeRateCard'
        licenseRateCards:
          type: array
          items:
            $ref: '#/components/schemas/LicenseRateCard'
        billingEntitlementRateCards:
          type: array
          items:
            $ref: '#/components/schemas/BillingEntitlementRateCard'
        entitlementOverageRateCards:
          type: array
          items:
            $ref: '#/components/schemas/EntitlementOverageRateCard'
        minimumCommitment:
          $ref: '#/components/schemas/MinimumCommitment'
        creditGrantRateCards:
          type: array
          items:
            $ref: '#/components/schemas/CreditGrantRateCard'
        type:
          $ref: '#/components/schemas/PricePlanType'
        deferredRevenue:
          type: boolean
        allow_ongoing_cycle_updates:
          description: |
            Allow changes to price plan from the beginning of the ongoing cycle.
            type: boolean
    UsageRateCard:
      type: object
      required:
        - usageMeterId
        - ratePlan
        - rateValues
      properties:
        displayName:
          type: string
          description: Name your rate card, this will be displayed in the Togai App
        name:
          type: string
          description: >-
            Unique identifier for the rate card in a price plan. If left null it
            is auto-generated.
        tag:
          type: string
          description: A tag string to group usageRateCards
        usageMeterId:
          type: string
          example: um.1zYnCiM9Bpg.1zYn
        ratePlan:
          $ref: '#/components/schemas/RatePlan'
        rateValues:
          type: array
          items:
            $ref: '#/components/schemas/RateValue'
    FixedFeeRateCard:
      title: FixedFeeRateCard
      type: object
      required:
        - id
        - rateValues
        - enableProration
      properties:
        id:
          description: Unique Identifier of the attached AddOn
          type: string
          maxLength: 50
        displayName:
          type: string
          description: Name of the attached AddOn
        name:
          type: string
          description: >-
            Unique identifier for the rate card in a price plan. If left null it
            is auto-generated.
        tag:
          type: string
          description: A tag string to group fixedFeeRateCards
        invoiceTiming:
          $ref: '#/components/schemas/InvoiceTiming'
        type:
          $ref: '#/components/schemas/FixedFeeType'
        rateValues:
          type: array
          items:
            $ref: '#/components/schemas/CurrencyRateValue'
        enableProration:
          type: boolean
          example: false
        recurrenceConfig:
          $ref: '#/components/schemas/RecurrenceConfig'
    LicenseRateCard:
      title: LicenseRateCard
      type: object
      required:
        - id
        - rateValues
        - ratePlan
        - enableProration
      properties:
        id:
          description: Unique Identifier of the attached AddOn
          type: string
          maxLength: 50
        type:
          $ref: '#/components/schemas/AddOnType'
        displayName:
          type: string
          description: Name of the attached AddOn
        name:
          type: string
          description: >-
            Unique identifier for the rate card in a price plan. If left null it
            is auto-generated.
        tag:
          type: string
          description: A tag string to group licenseRateCards
        invoiceTiming:
          $ref: '#/components/schemas/InvoiceTiming'
        usageCycle:
          $ref: '#/components/schemas/UsageCycleInterval'
        enableProration:
          type: boolean
          example: false
        config:
          $ref: '#/components/schemas/LicenseRateCardConfig'
        ratePlan:
          $ref: '#/components/schemas/RatePlan'
        rateValues:
          type: array
          items:
            $ref: '#/components/schemas/RateValue'
        proratedRefundMode:
          $ref: '#/components/schemas/ProratedRefundMode'
    BillingEntitlementRateCard:
      description: Billing Entitlement rate card
      type: object
      additionalProperties: false
      required:
        - featureId
        - featureConfigs
        - ratePlan
        - rateValues
        - invoiceTiming
      properties:
        featureId:
          type: string
        featureConfigs:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/FeatureConfig'
        tag:
          type: string
          description: A tag string to group rate cards
        invoiceTiming:
          $ref: '#/components/schemas/InvoiceTiming'
        displayName:
          type: string
          description: Name your rate card, this will be used in invoice
        name:
          type: string
          description: >-
            Unique identifier for the rate card in a price plan. If left null it
            is auto-generated.
        ratePlan:
          $ref: '#/components/schemas/RatePlan'
        rateValues:
          type: array
          items:
            $ref: '#/components/schemas/RateValue'
        recurrenceConfig:
          $ref: '#/components/schemas/RecurrenceConfig'
    CreditGrantRateCard:
      description: Credit grant rate card
      type: object
      additionalProperties: false
      required:
        - id
        - rateDetails
        - grantDetails
      properties:
        id:
          type: string
        displayName:
          type: string
        name:
          type: string
          description: >-
            Unique identifier for the rate card in a price plan. If left null it
            is auto-generated.
        tag:
          type: string
          description: A tag string to group creditGrantRateCard
        grantDetails:
          $ref: '#/components/schemas/GrantDetails'
        rateDetails:
          $ref: '#/components/schemas/CreditRateDetails'
        invoiceTiming:
          $ref: '#/components/schemas/InvoiceTiming'
        type:
          $ref: '#/components/schemas/CreditGrantType'
        recurrenceConfig:
          $ref: '#/components/schemas/RecurrenceConfig'
    EntitlementOverageRateCard:
      type: object
      required:
        - ratePlan
        - rateValues
        - featureId
      properties:
        featureId:
          type: string
          description: Unique Identifier of the attached Feature
          maxLength: 50
        displayName:
          type: string
          description: Name to be displayed during invoice
        name:
          type: string
          description: >-
            Unique identifier for the rate card in a price plan. If left null it
            is auto-generated.
        tag:
          type: string
          description: A tag string to group rate cards
        maxQuantity:
          type: number
          description: >-
            Maximum quantity allowed for the feature, if not specified,
            unlimited quantity is allowed
        ratePlan:
          $ref: '#/components/schemas/RatePlan'
        rateValues:
          type: array
          items:
            $ref: '#/components/schemas/RateValue'
        billingConfig:
          $ref: '#/components/schemas/BillingConfig'
          description: >-
            Represents the billing config of the entitlement overage rate card.
            If not specified interval:1 and startOffset:0 is taken as default
            value
    SlabRevenueSummary:
      type: object
      additionalProperties: false
      required:
        - order
        - usage
        - revenue
      properties:
        order:
          type: integer
        usage:
          type: number
        revenue:
          type: number
        metadata:
          title: SlabRevenueMetadata
          type: object
          additionalProperties: false
          properties:
            minimumRateApplied:
              type: boolean
            maximumRateApplied:
              type: boolean
            packageQuantity:
              type: integer
    PricingCycleConfig:
      type: object
      description: Represents configurations related to pricing cycle
      required:
        - interval
        - gracePeriod
      properties:
        interval:
          $ref: '#/components/schemas/PricingCycleInterval'
        startOffset:
          type: object
          description: >
            Represents the start of pricing cycle in terms of
             - dayOffset - number of days from beginning of week / month and
             - monthOffset - number of months from beginning of interval (quarter, half-year or year)
            Note: If a day with offset doesn't exist for a month, closest
            previous day is considered

            Examples:

            WEEKLY -
              - {dayOffset: 1, monthOffset: NIL} - First day of every week (Monday)
              - {dayOffset: 3, monthOffset: NIL} - 3rd day of every week (Wednesday)
              - {dayOffset: LAST, monthOffset: NIL} - Last day of every week (Sunday)
            MONTHLY -
              - {dayOffset: 1, monthOffset: NIL} - First day of every month
              - {dayOffset: 12, monthOffset: NIL} - 12th of every month
              - {dayOffset: 28, monthOffset: NIL} - 28th of every month. i.e, 28th of Jan, 28th of Feb, ...
              - {dayOffset: 30, monthOffset: NIL} - 30th of every month. i.e, 28th of Jan, 28th of Feb, ...
              - {dayOffset: LAST, monthOffset: NIL} - Last day of every month. i.e, 31st of Jan, 28th of Feb, ...
            QUARTERLY
              - {dayOffset: 15, monthOffset: FIRST} - 15th Jan, 15th Apr, 15th Jul and 15th Oct
              - {dayOffset: 15, monthOffset: 2} - 15th Feb, 15th May, 15th Aug and 15th Nov
              - {dayOffset: 15, monthOffset: LAST} - 15th Mar, 15th Jun, 15th Sep and 15th Dec
              - {dayOffset: LAST, monthOffset: FIRST} - 31st Jan, 30th Apr, 30th Jul and 31th Oct
            HALF_YEARLY
              - {dayOffset: 15, monthOffset: FIRST} - 15th Jan and 15th Jul
              - {dayOffset: 15, monthOffset: 4} - 15th Apr and 15th Oct
              - {dayOffset: 15, monthOffset: LAST} - 15th Jun and 15th Dec
            ANNUALLY
              - {dayOffset: 15, monthOffset: FIRST} - 15th Jan
              - {dayOffset: 15, monthOffset: 1} - 15th Jan
              - {dayOffset: LAST, monthOffset: 2} - 29th Feb on Leap year, 28th otherwise 
              - {dayOffset: 15, monthOffset: 8} - 15th Aug
              - {dayOffset: 15, monthOffset: LAST} - 15th Dec
          required:
            - dayOffset
            - monthOffset
          properties:
            dayOffset:
              type: string
              description: >
                If interval is WEEKLY, min: "1" and max: "7" as strings. Spl.
                string allowed: LAST

                Otherwise, min: "1" and max: "31" as strings. Spl. string
                allowed: LAST
            monthOffset:
              type: string
              description: >
                min: "1" and max: "12". Spl. string allowed: FIRST / LAST.

                For QUARTERLY only 1 - 3 is allowed and for HALF_YEARLY 1 - 6.
                This being an optional field, shouldn't be passed for MONTHLY.
        gracePeriod:
          type: integer
          description: >
            Togai allows you to ingest past dated events that will be processed
            by a pricing cycle till the end grace period. 

            For example: Pricing cycle is Monthly from 1st to 30th and
            gracePeriod is 5 days which next month 1 to 5th date, you can ingest
            past dated events during this grace period.
          format: int32
          example: 3
        anniversaryCycle:
          type: boolean
          description: >
            Togai calculates the startOffsets based on the date of association
            instead of requiring from the user and 

            these offsets will be applied as an override if this flag is
            enabled.

            Examples:

            WEEKLY -
              - 23/10/2023 (Monday) - {dayOffset: 1, monthOffset: NIL} 
              - 25/10/2023 (Wednesday) - {dayOffset: 3, monthOffset: NIL} 
              - 29/10/2023 (Sunday) - {dayOffset: 7, monthOffset: NIL}
            MONTHLY -
              - 1st Oct - {dayOffset: 1, monthOffset: NIL}
              - 12th Oct - {dayOffset: 12, monthOffset: NIL}
              - 28th Oct - {dayOffset: 28, monthOffset: NIL}
              - 30th Oct - {dayOffset: 30, monthOffset: NIL}
              - 31th Oct - {dayOffset: LAST, monthOffset: NIL}
            QUARTERLY
              - 15th Jan, 15th Apr, 15th Jul and 15th Oct - {dayOffset: 15, monthOffset: 1}
              - 15th Feb, 15th May, 15th Aug and 15th Nov - {dayOffset: 15, monthOffset: 2} 
              - 15th Mar, 15th Jun, 15th Sep and 15th Dec - {dayOffset: 15, monthOffset: 3}
            HALF_YEARLY
              - 15th Jan and 15th Jul - {dayOffset: 15, monthOffset: 1} 
              - 15th Apr and 15th Oct - {dayOffset: 15, monthOffset: 4} 
              - 15th Jun and 15th Dec - {dayOffset: 15, monthOffset: 6}
            ANNUALLY
              - 15th Jan - {dayOffset: 15, monthOffset: 1}
              - 29th Feb on Leap year  - {dayOffset: LAST, monthOffset: 2}
              - 28th Feb  - {dayOffset: LAST, monthOffset: 2}
              - 15th Aug - {dayOffset: 15, monthOffset: 8}
              - 15th Dec - {dayOffset: 15, monthOffset: 12}
    MinimumCommitment:
      title: MinimumCommitment
      type: object
      required:
        - displayName
        - rateValues
      properties:
        displayName:
          type: string
        rateValues:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/CurrencyRateValue'
    PricePlanType:
      type: string
      description: Type of price plan
      enum:
        - BILLING
        - PURCHASE
    RatePlan:
      type: object
      description: Contains all rate related configurations
      required:
        - pricingModel
        - slabs
      properties:
        pricingModel:
          $ref: '#/components/schemas/PricingModel'
        slabs:
          description: Rate cards can have single or multiple slab up to 100.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Slab'
    RateValue:
      type: object
      description: Represents a rate
      required:
        - currency
        - slabRates
      properties:
        currency:
          type: string
        slabRates:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/SlabRate'
        rateConfig:
          type: object
          additionalProperties:
            type: string
    InvoiceTiming:
      type: string
      enum:
        - IN_ADVANCE
        - IN_ARREARS
        - PREPAID
      x-enum-varnames:
        - IN_ADVANCE
        - IN_ARREARS
        - PREPAID
      description: >
        If IN_ADVANCE, the rate card will be invoiced in the previous billing
        cycle.

        If IN_ARREARS, the rate card will be invoiced in the current billing
        cycle.

        If PREPAID, credits/entitlements will be granted only after invoice is
        paid
    FixedFeeType:
      type: string
      enum:
        - ONE_TIME
        - RECURRING
      description: Fixed fee applies either for a one-time occurrence or for each cycle.
    CurrencyRateValue:
      type: object
      required:
        - currency
        - rate
      properties:
        currency:
          type: string
        rate:
          type: number
    RecurrenceConfig:
      type: object
      properties:
        interval:
          description: >-
            Represents the number of pricing cycles after which the rate card
            will be charged
          type: integer
          format: int64
          example: 3
        offset:
          description: >-
            Represents the offset for pricing cycles after which the rate card
            will be charged
          type: integer
          format: int64
          example: 5
    AddOnType:
      type: string
      enum:
        - LICENSE
        - FIXED_FEE
        - CREDIT_GRANT
        - NAMED_LICENSE
      description: |
        LICENSE: Addon can be used in license rate cards
        FIXED_FEE: Addon can be used in fixed fee rate cards
        CREDIT_GRANT: Addon can be used in credit grant rate cards
        NAMED_LICENSE: Addon can be used in license rate cards
    UsageCycleInterval:
      type: string
      description: >
        UsageCycleInterval field allows you to treat the billing interval as
        many smaller windows. Revenue is calculated for

        each of the windows (usage cycles) and their sum is considered as the
        billing interval revenue.

        Example: 1 Named License being used across entire billing interval. Rate
        Value: $1/license

        CASE 1: Without usage cycle. $1 is charged for the entire billing cycle.

        CASE 2: Usage cycle is configure to be WEEKLY and the billing interval
        has 4 weeks. In this case $1 is charged 

        for each week totalling to $4 across for the billing interval
      enum:
        - WEEKLY
        - MONTHLY
        - QUARTERLY
        - HALF_YEARLY
        - ANNUALLY
    LicenseRateCardConfig:
      title: LicenseRateCardConfig
      type: object
      properties:
        maxQuantity:
          description: Max allowed quantity for a particular license in a price plan
          type: integer
          format: int64
          example: 100
        maxQuantityBreachAction:
          $ref: '#/components/schemas/MaxQuantityBreachAction'
    ProratedRefundMode:
      type: string
      enum:
        - NONE
        - CREDITS
        - PAYMENT
        - WALLET
    FeatureConfig:
      description: Feature configuration object
      type: object
      additionalProperties: false
      required:
        - effectiveUntil
        - featureCreditLimit
      properties:
        effectiveFrom:
          type: string
          format: duration
        effectiveUntil:
          type: string
          format: duration
        featureCreditLimit:
          type: number
          minimum: 0
    GrantDetails:
      description: Grant details of Credit Grant Rate Card
      type: object
      additionalProperties: false
      required:
        - priority
        - expiryType
      properties:
        priority:
          type: integer
          minimum: 0
        expiryType:
          $ref: '#/components/schemas/ExpiryType'
        expiryDuration:
          type: string
          format: duration
        applicableEntityIds:
          type: array
          items:
            type: string
    CreditRateDetails:
      type: object
      description: Amount to be credited
      additionalProperties: false
      required:
        - pricingModel
        - currencySlabRateDetails
      properties:
        pricingModel:
          $ref: '#/components/schemas/PricingModel'
        currencySlabRateDetails:
          type: array
          items:
            $ref: '#/components/schemas/CurrencySlabRateDetail'
    CreditGrantType:
      type: string
      enum:
        - ONE_TIME
        - RECURRING
      description: Credit grant applies either for a one-time occurrence or for each cycle.
    BillingConfig:
      type: object
      properties:
        interval:
          description: >-
            Represents the number of pricing cycles after which the rate card
            will be billed
          type: integer
          format: int64
          example: 3
        startOffset:
          description: >-
            Represents the offset for pricing cycles after which the rate card
            will be billed
          type: integer
          format: int64
          example: 5
    PricingCycleInterval:
      type: string
      description: >-
        Interval field allow you to define the billing interval you would like
        to set
      enum:
        - WEEKLY
        - MONTHLY
        - QUARTERLY
        - HALF_YEARLY
        - ANNUALLY
    PricingModel:
      type: string
      description: >
        Togai supports two type of pricing model Tiered and Volume. Tiered
        pricing model applies respective slab and its rate to the usage value
        while volume pricing model applies the latest matching slab of the usage
        value and applies respective rate. 

        For more understanding read [Rate
        Cards](https://docs.togai.com/docs/priceplan#setting-up-multiple-rate-cards)
      enum:
        - TIERED
        - VOLUME
    Slab:
      type: object
      description: Represents a pricing priceType (rates + slabs) for usage price plan
      required:
        - order
        - startAfter
        - priceType
      properties:
        order:
          type: integer
          format: int32
          minimum: 1
          maximum: 10
        startAfter:
          type: number
        priceType:
          $ref: '#/components/schemas/PriceType'
        slabConfig:
          type: object
          additionalProperties:
            type: string
    SlabRate:
      type: object
      description: Represents a rate for a slab
      required:
        - order
        - rate
      properties:
        order:
          type: integer
          format: int32
        rate:
          type: number
        slabRateConfig:
          type: object
          additionalProperties:
            type: string
    MaxQuantityBreachAction:
      type: string
      enum:
        - DO_NOTHING
      description: |
        Action to be taken when the license maxQuantity is breached: 
        - `DO_NOTHING`: Refrain from granting any new licenses.
    ExpiryType:
      type: string
      description: Expiry type of grant
      enum:
        - PRICING_CYCLE
        - NO_EXPIRY
        - CUSTOM
    CurrencySlabRateDetail:
      type: object
      description: The association of a currency along with its slab detail
      additionalProperties: false
      required:
        - currency
        - creditAmount
        - slabDetails
      properties:
        currency:
          type: string
        creditAmount:
          type: number
          description: The amount of credit that needs to be credited
          minimum: 0
        slabDetails:
          type: array
          items:
            $ref: '#/components/schemas/SlabDetail'
        rateConfig:
          type: object
          additionalProperties:
            type: string
    PriceType:
      type: string
      enum:
        - FLAT
        - PER_UNIT
        - PACKAGE
    SlabDetail:
      type: object
      description: The details of a slab
      additionalProperties: false
      required:
        - startAfter
        - priceType
        - rate
      properties:
        startAfter:
          type: number
        priceType:
          $ref: '#/components/schemas/PriceType'
        slabConfig:
          type: object
          additionalProperties:
            type: string
        rate:
          type: number
        slabRateConfig:
          type: object
          additionalProperties:
            type: string
  examples:
    FirstCalculateRevenueRequestExample:
      description: >
        Example request for calculate revenue API on a existing price plan with
        custom currency and usage.
      value:
        currencyConfig:
          mode: CUSTOM
          currency: USD
        pricePlanDetailsConfig:
          mode: PRICE_PLAN
          pricePlanId: pp.fdhkf.djf
          effectiveOn: '2020-01-01T00:00:00Z'
          pricingCycleOrdinal: 1
        usageConfig:
          mode: CUSTOM
          usageMap:
            um.1zcgWalbM2y.qaX5j: 100
        licenseEntriesConfig:
          mode: CUSTOM
          custom:
            - licenseId: license.1zcgWalbM2y.qaX5j
              quantity: 10
              effectiveFrom: '2020-01-01T00:00:00Z'
        entitlementOverageConfig:
          mode: CUSTOM
          custom:
            - featureId: feature.1122.ahoiud
              quantity: 5
            - featureId: feature.3452.abcaf2
              quantity: 28
    SecondCalculateRevenueRequestExample:
      description: >
        Example request for calculate revenue API on a custom price plan with
        currency as the invoice currency of a existing account, and existing
        usage of a account over a time period
      value:
        currencyConfig:
          mode: ACCOUNT_INVOICE
          accountId: ACC00001
        pricePlanDetailsConfig:
          mode: CUSTOM
          pricingCycleOrdinal: 1
          pricePlanDetails:
            supportedCurrencies:
              - USD
            pricingCycleConfig:
              interval: MONTHLY
              startOffset:
                dayOffset: '4'
                monthOffset: '1'
              gracePeriod: 3
              anniversaryCycle: false
            usageRateCards:
              - displayName: Local Rides
                usageMeterId: um.1zYnCiM9Bpg.1zYn
                ratePlan:
                  pricingModel: TIERED
                  slabs:
                    - order: 1
                      startAfter: 0
                      priceType: FLAT
                rateValues:
                  - currency: USD
                    slabRates:
                      - rate: 40
                        order: 1
        usageConfig:
          mode: LOOKUP_RANGE
          lookupRange:
            start: '2020-01-01T00:00:00Z'
            end: '2020-01-31T00:00:00Z'
            accountId: ACC00001
        licenseEntriesConfig:
          mode: LOOKUP_RANGE
          lookupRange:
            start: '2020-01-01T00:00:00Z'
            end: '2020-01-31T00:00:00Z'
            accountId: ACC00001
        entitlementOverageConfig:
          mode: LOOKUP_CYCLE
          lookupCycle:
            accountId: ACC0001
            billingCycleEndDate: '2020-01-31T00:00:00Z'
    ThirdCalculateRevenueRequestExample:
      value:
        currencyConfig:
          mode: ACCOUNT_INVOICE
          accountId: ACC00001
        pricePlanDetailsConfig:
          mode: ACCOUNT
          accountId: ACC00001
          effectiveOn: '2020-01-01T00:00:00Z'
        usageConfig:
          mode: LOOKUP_CYCLE
          lookupCycle:
            accountId: ACC00001
            cycleEffectiveOn: '2020-01-01T00:00:00Z'
        licenseEntriesConfig:
          mode: LOOKUP_CYCLE
          lookupCycle:
            accountId: ACC00001
            cycleEffectiveOn: '2020-01-01T00:00:00Z'
      description: >
        Example request for calculate revenue API on a already associated price
        plan of the account  with currency as the invoice currency of an
        existing account, and existing usage of a account over a certain pricing
        cycle
    CalculateRevenueResponse:
      value:
        currency: USD
        pricePlanDetails:
          supportedCurrencies:
            - USD
          activeCurrencies:
            - USD
          pricingCycleConfig:
            interval: MONTHLY
            startOffset:
              dayOffset: '1'
              monthOffset: NIL
            gracePeriod: 1
            anniversaryCycle: false
          usageRateCards:
            - displayName: AfterShip Shipments1
              usageMeterId: um.1zcgWalbM2y.qaX5j
              ratePlan:
                pricingModel: TIERED
                slabs:
                  - priceType: PER_UNIT
                    startAfter: 0
                    order: 1
                  - priceType: PACKAGE
                    startAfter: 2
                    order: 2
                    slabConfig:
                      packageSize: '10'
              rateValues:
                - currency: USD
                  slabRates:
                    - order: 1
                      rate: 10
                      slabRateConfig:
                        minimumRate: '1'
                        maximumRate: '10'
                    - order: 2
                      rate: 20
              tag: '1'
          type: BILLING
        revenueInfo:
          - usages:
              um.fdjal.kdajf: 10
            usageRateCard:
              displayName: AfterShip Shipments1
              usageMeterId: um.1zcgWalbM2y.qaX5j
              ratePlan:
                pricingModel: TIERED
                slabs:
                  - priceType: PER_UNIT
                    startAfter: 0
                    order: 1
                  - priceType: PACKAGE
                    startAfter: 2
                    order: 2
                    slabConfig:
                      packageSize: '10'
              rateValues:
                - currency: USD
                  slabRates:
                    - order: 1
                      rate: 10
                      slabRateConfig:
                        minimumRate: 1
                        maximumRate: 10
                    - order: 2
                      rate: 20
            slabRevenueSummaries:
              - order: 1
                usage: 10
                revenue: 100
              - order: 2
                usage: 0
                revenue: 0
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````