title: Calculation
type: object
description: 'Defines the type of calculation that is performed by a discount, surcharge or tax.'
properties:
  type:
    type: string
    enum:
      - fixed
      - percentage
      - price_override
    description: The type of calculation to perform.
  fixed_value:
    description: |-
      The fixed value to apply.

      This property will always be `null` if `type` is `percentage` or `price_override`.
    oneOf:
      - type: 'null'
      - $ref: ./Money.yaml
  percentage:
    type:
      - string
      - 'null'
    example: '7.5'
    pattern: '^((0\.[1-9])|([1-9]([0-9])?(\.[0-9])?)|100)$'
    description: |-
      The percentage to apply.

      This field will always be `null` if `type` is `fixed` or `price_override`.
  percentage_cap:
    description: |-
      Caps the total value of `percentage` when applied.

      This field will always be `null` if `type` is `fixed` or `price_override`.
    oneOf:
      - type: 'null'
      - $ref: ./Money.yaml
  price_override:
    description: |-
      The base unit price that matching items should be reduced to.

      This field will always be `null` if `type` is `fixed` or `percentage`.
    oneOf:
      - type: 'null'
      - $ref: ./Money.yaml
required:
  - type
x-tags:
  - Foundation
