Skip to content

Commit

Permalink
feat(unit-price) add amount_details attribute to Fee object
Browse files Browse the repository at this point in the history
  • Loading branch information
ansmonjol committed Jan 2, 2024
1 parent f7b1cc9 commit 0831c5b
Show file tree
Hide file tree
Showing 7 changed files with 686 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Types
module Fees
module AmountDetails
class GraduatedPercentageRange < Types::BaseObject
graphql_name 'FeeAmountDetailsGraduatedPercentageRange'

field :units, String, null: true
field :from_value, Integer, null: true
field :to_value, Integer, null: true
field :flat_unit_amount, String, null: true
field :rate, String, null: true
field :per_unit_total_amount, String, null: true
field :total_with_flat_amount, String, null: true
end
end
end
end
19 changes: 19 additions & 0 deletions app/graphql/types/fees/amount_details/graduated_range.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Types
module Fees
module AmountDetails
class GraduatedRange < Types::BaseObject
graphql_name 'FeeAmountDetailsGraduatedRange'

field :units, String, null: true
field :from_value, Integer, null: true
field :to_value, Integer, null: true
field :flat_unit_amount, String, null: true
field :per_unit_amount, String, null: true
field :per_unit_total_amount, String, null: true
field :total_with_flat_amount, String, null: true
end
end
end
end
36 changes: 36 additions & 0 deletions app/graphql/types/fees/amount_details/object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

module Types
module Fees
module AmountDetails
class Object < Types::BaseObject
graphql_name 'FeeAmountDetails'

# NOTE: Graduated charge model
field :graduated_ranges, [Types::Fees::AmountDetails::GraduatedRange], null: true

# NOTE: Graduated percentage modle
field :graduated_percentage_ranges, [Types::Fees::AmountDetails::GraduatedPercentageRange], null: true

# NOTE: Package charge model
field :free_units, String, null: true
field :paid_units, String, null: true
field :per_package_size, Integer, null: true
field :per_package_unit_amount, String, null: true

# NOTE: Percentage charge model
field :units, String, null: true
field :free_events, Integer, null: true
field :rate, String, null: true
field :per_unit_total_amount, String, null: true
field :paid_events, Integer, null: true
field :fixed_fee_unit_amount, String, null: true
field :fixed_fee_total_amount, String, null: true
field :min_max_adjustment_total_amount, String, null: true

# NOTE: Volume charge model
field :volume_ranges, [Types::Fees::AmountDetails::VolumeRange], null: true
end
end
end
end
15 changes: 15 additions & 0 deletions app/graphql/types/fees/amount_details/volume_range.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Types
module Fees
module AmountDetails
class VolumeRange < Types::BaseObject
graphql_name 'FeeAmountDetailsVolumeRange'

field :per_unit_amount, String, null: false
field :flat_unit_amount, String, null: false
field :per_unit_total_amount, String, null: false
end
end
end
end
2 changes: 2 additions & 0 deletions app/graphql/types/fees/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Object < Types::BaseObject

field :applied_taxes, [Types::Fees::AppliedTaxes::Object]

field :amount_details, Types::Fees::AmountDetails::Object, null: true

delegate :group_name, to: :object
delegate :invoice_name, to: :object

Expand Down
45 changes: 45 additions & 0 deletions schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0831c5b

Please sign in to comment.