title: Calculation
type: object
x-tags:
  - Models
description: The fixed-value or percentage benefit for vouchers, direct quantity discounts and cashback
  earning. Fields that do not apply are returned as null. Percentage benefits round half up once to minor
  units before applying an optional cap.
required:
  - type
  - fixed_value
  - percentage
  - percentage_cap
properties:
  type:
    type: string
    enum:
      - fixed
      - percentage
  fixed_value:
    oneOf:
      - type: "null"
      - $ref: ./PositiveMoney.yaml
  percentage:
    oneOf:
      - type: "null"
      - &a1
        type: string
        pattern: ^(?:0\.[1-9]|[1-9][0-9]?(?:\.[0-9])?|100)$
        example: "10"
        description: The percentage discount, supplied as a string.
  percentage_cap:
    oneOf:
      - type: "null"
      - $ref: ./PositiveMoney.yaml
oneOf:
  - title: Fixed benefit
    type: object
    required:
      - type
      - fixed_value
    properties:
      type:
        type: string
        enum:
          - fixed
      fixed_value:
        $ref: ./PositiveMoney.yaml
      percentage:
        type: "null"
      percentage_cap:
        type: "null"
  - title: Percentage benefit
    type: object
    required:
      - type
      - percentage
    properties:
      type:
        type: string
        enum:
          - percentage
      fixed_value:
        type: "null"
      percentage: *a1
      percentage_cap:
        oneOf:
          - type: "null"
          - $ref: ./PositiveMoney.yaml
