Module: Orb::Models::Invoice::LineItem::Adjustment

Extended by:
Internal::Type::Union
Defined in:
lib/orb/models/invoice.rb,
sig/orb/models/invoice.rbs

Defined Under Namespace

Classes: TieredPercentageDiscount

Instance Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type, variants, variants

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Instance Method Details

#initialize(id:, adjusted_subtotal:, adjustments:, amount:, credits_applied:, end_date:, filter:, grouping:, name:, partially_invoiced_amount:, price:, quantity:, start_date:, sub_line_items:, subtotal:, tax_amounts:, usage_customer_ids:) ⇒ Object

Some parameter documentations has been truncated, see Orb::Models::Invoice::LineItem for more details.

Parameters:



893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
# File 'lib/orb/models/invoice.rb', line 893

module Adjustment
  extend Orb::Internal::Type::Union

  discriminator :adjustment_type

  variant :usage_discount, -> { Orb::MonetaryUsageDiscountAdjustment }

  variant :amount_discount, -> { Orb::MonetaryAmountDiscountAdjustment }

  variant :percentage_discount, -> { Orb::MonetaryPercentageDiscountAdjustment }

  variant :tiered_percentage_discount, -> { Orb::Invoice::LineItem::Adjustment::TieredPercentageDiscount }

  variant :minimum, -> { Orb::MonetaryMinimumAdjustment }

  variant :maximum, -> { Orb::MonetaryMaximumAdjustment }

  class TieredPercentageDiscount < Orb::Internal::Type::BaseModel
    # @!attribute id
    #
    #   @return [String]
    required :id, String

    # @!attribute adjustment_type
    #
    #   @return [Symbol, :tiered_percentage_discount]
    required :adjustment_type, const: :tiered_percentage_discount

    # @!attribute amount
    #   The value applied by an adjustment.
    #
    #   @return [String]
    required :amount, String

    # @!attribute applies_to_price_ids
    #   @deprecated
    #
    #   The price IDs that this adjustment applies to.
    #
    #   @return [Array<String>]
    required :applies_to_price_ids, Orb::Internal::Type::ArrayOf[String]

    # @!attribute filters
    #   The filters that determine which prices to apply this adjustment to.
    #
    #   @return [Array<Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter>]
    required :filters,
             -> { Orb::Internal::Type::ArrayOf[Orb::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter] }

    # @!attribute is_invoice_level
    #   True for adjustments that apply to an entire invoice, false for adjustments that
    #   apply to only one price.
    #
    #   @return [Boolean]
    required :is_invoice_level, Orb::Internal::Type::Boolean

    # @!attribute reason
    #   The reason for the adjustment.
    #
    #   @return [String, nil]
    required :reason, String, nil?: true

    # @!attribute replaces_adjustment_id
    #   The adjustment id this adjustment replaces. This adjustment will take the place
    #   of the replaced adjustment in plan version migrations.
    #
    #   @return [String, nil]
    required :replaces_adjustment_id, String, nil?: true

    # @!attribute tiers
    #   The ordered, contiguous bands of cumulative eligible spend, each discounted at
    #   its own percentage (progressive fill-a-tier), applied to the prices this
    #   adjustment covers in a given billing period.
    #
    #   @return [Array<Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Tier>]
    required :tiers,
             -> { Orb::Internal::Type::ArrayOf[Orb::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Tier] }

    # @!method initialize(id:, amount:, applies_to_price_ids:, filters:, is_invoice_level:, reason:, replaces_adjustment_id:, tiers:, adjustment_type: :tiered_percentage_discount)
    #   Some parameter documentations has been truncated, see
    #   {Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount} for more
    #   details.
    #
    #   @param id [String]
    #
    #   @param amount [String] The value applied by an adjustment.
    #
    #   @param applies_to_price_ids [Array<String>] The price IDs that this adjustment applies to.
    #
    #   @param filters [Array<Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter>] The filters that determine which prices to apply this adjustment to.
    #
    #   @param is_invoice_level [Boolean] True for adjustments that apply to an entire invoice, false for adjustments that
    #
    #   @param reason [String, nil] The reason for the adjustment.
    #
    #   @param replaces_adjustment_id [String, nil] The adjustment id this adjustment replaces. This adjustment will take the place
    #
    #   @param tiers [Array<Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Tier>] The ordered, contiguous bands of cumulative eligible spend, each discounted at i
    #
    #   @param adjustment_type [Symbol, :tiered_percentage_discount]

    class Filter < Orb::Internal::Type::BaseModel
      # @!attribute field
      #   The property of the price to filter on.
      #
      #   @return [Symbol, Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter::Field]
      required :field, enum: -> { Orb::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter::Field }

      # @!attribute operator
      #   Should prices that match the filter be included or excluded.
      #
      #   @return [Symbol, Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter::Operator]
      required :operator,
               enum: -> { Orb::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter::Operator }

      # @!attribute values
      #   The IDs or values that match this filter.
      #
      #   @return [Array<String>]
      required :values, Orb::Internal::Type::ArrayOf[String]

      # @!method initialize(field:, operator:, values:)
      #   @param field [Symbol, Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter::Field] The property of the price to filter on.
      #
      #   @param operator [Symbol, Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter::Operator] Should prices that match the filter be included or excluded.
      #
      #   @param values [Array<String>] The IDs or values that match this filter.

      # The property of the price to filter on.
      #
      # @see Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter#field
      module Field
        extend Orb::Internal::Type::Enum

        PRICE_ID = :price_id
        ITEM_ID = :item_id
        PRICE_TYPE = :price_type
        CURRENCY = :currency
        PRICING_UNIT_ID = :pricing_unit_id

        # @!method self.values
        #   @return [Array<Symbol>]
      end

      # Should prices that match the filter be included or excluded.
      #
      # @see Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Filter#operator
      module Operator
        extend Orb::Internal::Type::Enum

        INCLUDES = :includes
        EXCLUDES = :excludes

        # @!method self.values
        #   @return [Array<Symbol>]
      end
    end

    class Tier < Orb::Internal::Type::BaseModel
      # @!attribute lower_bound
      #   Exclusive lower bound of cumulative spend for this tier.
      #
      #   @return [Float]
      required :lower_bound, Float

      # @!attribute percentage
      #   The percentage (between 0 and 1) discounted from spend that falls within this
      #   tier.
      #
      #   @return [Float]
      required :percentage, Float

      # @!attribute upper_bound
      #   Inclusive upper bound of cumulative spend for this tier; null for the final
      #   open-ended tier.
      #
      #   @return [Float, nil]
      optional :upper_bound, Float, nil?: true

      # @!method initialize(lower_bound:, percentage:, upper_bound: nil)
      #   Some parameter documentations has been truncated, see
      #   {Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount::Tier} for
      #   more details.
      #
      #   One band of a tiered percentage discount. Bounds are denominated in the
      #   discount's currency. `lower_bound` is the exclusive start of the band and
      #   `upper_bound` is the inclusive end; `upper_bound` is null only for the
      #   open-ended final tier.
      #
      #   @param lower_bound [Float] Exclusive lower bound of cumulative spend for this tier.
      #
      #   @param percentage [Float] The percentage (between 0 and 1) discounted from spend that falls within this ti
      #
      #   @param upper_bound [Float, nil] Inclusive upper bound of cumulative spend for this tier; null for the final open
    end
  end

  # @!method self.variants
  #   @return [Array(Orb::Models::MonetaryUsageDiscountAdjustment, Orb::Models::MonetaryAmountDiscountAdjustment, Orb::Models::MonetaryPercentageDiscountAdjustment, Orb::Models::Invoice::LineItem::Adjustment::TieredPercentageDiscount, Orb::Models::MonetaryMinimumAdjustment, Orb::Models::MonetaryMaximumAdjustment)]
end

#self?.variants::Array[Orb::Models::Invoice::LineItem::adjustment]

Returns:

  • (::Array[Orb::Models::Invoice::LineItem::adjustment])


656
# File 'sig/orb/models/invoice.rbs', line 656

def self?.variants: -> ::Array[Orb::Models::Invoice::LineItem::adjustment]