Class: NewStoreApi::TaxTotalsDto
- Defined in:
- lib/new_store_api/models/tax_totals_dto.rb
Overview
TaxTotalsDto Model.
Instance Attribute Summary collapse
-
#discount_total ⇒ Float
The total discount amount.
-
#grand_total ⇒ Float
The amount consumer has to pay for the order.
-
#net_total ⇒ Float
The sum of net prices of all the items including shipping and gift wrapping.
-
#shipping_tax_amount ⇒ Float
The shipping tax amount.
-
#shipping_total ⇒ Float
The total shipping amount.
-
#subtotal ⇒ Float
The sum of item prices incl.
-
#tax_rates_summary ⇒ Array[TaxRateDto]
Summary of the tax rates applied on the line items of the transaction grouped by the tax name and tax rate.
-
#tax_strategy ⇒ TaxCalculationStrategyEnum
Summary of the tax rates applied on the line items of the transaction grouped by the tax name and tax rate.
-
#tax_total ⇒ Float
The total tax sum (grand total tax incl. shipping tax).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(discount_total = nil, grand_total = nil, net_total = nil, shipping_tax_amount = nil, shipping_total = nil, subtotal = nil, tax_rates_summary = nil, tax_strategy = nil, tax_total = nil) ⇒ TaxTotalsDto
constructor
A new instance of TaxTotalsDto.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(discount_total = nil, grand_total = nil, net_total = nil, shipping_tax_amount = nil, shipping_total = nil, subtotal = nil, tax_rates_summary = nil, tax_strategy = nil, tax_total = nil) ⇒ TaxTotalsDto
Returns a new instance of TaxTotalsDto.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 76 def initialize(discount_total = nil, grand_total = nil, net_total = nil, shipping_tax_amount = nil, shipping_total = nil, subtotal = nil, tax_rates_summary = nil, tax_strategy = nil, tax_total = nil) @discount_total = discount_total @grand_total = grand_total @net_total = net_total @shipping_tax_amount = shipping_tax_amount @shipping_total = shipping_total @subtotal = subtotal @tax_rates_summary = tax_rates_summary @tax_strategy = tax_strategy @tax_total = tax_total end |
Instance Attribute Details
#discount_total ⇒ Float
The total discount amount.
14 15 16 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 14 def discount_total @discount_total end |
#grand_total ⇒ Float
The amount consumer has to pay for the order.
18 19 20 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 18 def grand_total @grand_total end |
#net_total ⇒ Float
The sum of net prices of all the items including shipping and gift wrapping
23 24 25 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 23 def net_total @net_total end |
#shipping_tax_amount ⇒ Float
The shipping tax amount.
27 28 29 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 27 def shipping_tax_amount @shipping_tax_amount end |
#shipping_total ⇒ Float
The total shipping amount.
31 32 33 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 31 def shipping_total @shipping_total end |
#subtotal ⇒ Float
The sum of item prices incl. or excl. tax (depending on tax method).
35 36 37 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 35 def subtotal @subtotal end |
#tax_rates_summary ⇒ Array[TaxRateDto]
Summary of the tax rates applied on the line items of the transaction grouped by the tax name and tax rate.
40 41 42 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 40 def tax_rates_summary @tax_rates_summary end |
#tax_strategy ⇒ TaxCalculationStrategyEnum
Summary of the tax rates applied on the line items of the transaction grouped by the tax name and tax rate.
45 46 47 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 45 def tax_strategy @tax_strategy end |
#tax_total ⇒ Float
The total tax sum (grand total tax incl. shipping tax).
49 50 51 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 49 def tax_total @tax_total end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 92 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. discount_total = hash.key?('discount_total') ? hash['discount_total'] : nil grand_total = hash.key?('grand_total') ? hash['grand_total'] : nil net_total = hash.key?('net_total') ? hash['net_total'] : nil shipping_tax_amount = hash.key?('shipping_tax_amount') ? hash['shipping_tax_amount'] : nil shipping_total = hash.key?('shipping_total') ? hash['shipping_total'] : nil subtotal = hash.key?('subtotal') ? hash['subtotal'] : nil # Parameter is an array, so we need to iterate through it tax_rates_summary = nil unless hash['tax_rates_summary'].nil? tax_rates_summary = [] hash['tax_rates_summary'].each do |structure| tax_rates_summary << (TaxRateDto.from_hash(structure) if structure) end end tax_rates_summary = nil unless hash.key?('tax_rates_summary') tax_strategy = hash.key?('tax_strategy') ? hash['tax_strategy'] : nil tax_total = hash.key?('tax_total') ? hash['tax_total'] : nil # Create object from extracted values. TaxTotalsDto.new(discount_total, grand_total, net_total, shipping_tax_amount, shipping_total, subtotal, tax_rates_summary, tax_strategy, tax_total) end |
.names ⇒ Object
A mapping from model property names to API property names.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 52 def self.names @_hash = {} if @_hash.nil? @_hash['discount_total'] = 'discount_total' @_hash['grand_total'] = 'grand_total' @_hash['net_total'] = 'net_total' @_hash['shipping_tax_amount'] = 'shipping_tax_amount' @_hash['shipping_total'] = 'shipping_total' @_hash['subtotal'] = 'subtotal' @_hash['tax_rates_summary'] = 'tax_rates_summary' @_hash['tax_strategy'] = 'tax_strategy' @_hash['tax_total'] = 'tax_total' @_hash end |
.nullables ⇒ Object
An array for nullable fields
72 73 74 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 72 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
67 68 69 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 67 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
140 141 142 143 144 145 146 147 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 140 def inspect class_name = self.class.name.split('::').last "<#{class_name} discount_total: #{@discount_total.inspect}, grand_total:"\ " #{@grand_total.inspect}, net_total: #{@net_total.inspect}, shipping_tax_amount:"\ " #{@shipping_tax_amount.inspect}, shipping_total: #{@shipping_total.inspect}, subtotal:"\ " #{@subtotal.inspect}, tax_rates_summary: #{@tax_rates_summary.inspect}, tax_strategy:"\ " #{@tax_strategy.inspect}, tax_total: #{@tax_total.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
131 132 133 134 135 136 137 |
# File 'lib/new_store_api/models/tax_totals_dto.rb', line 131 def to_s class_name = self.class.name.split('::').last "<#{class_name} discount_total: #{@discount_total}, grand_total: #{@grand_total},"\ " net_total: #{@net_total}, shipping_tax_amount: #{@shipping_tax_amount}, shipping_total:"\ " #{@shipping_total}, subtotal: #{@subtotal}, tax_rates_summary: #{@tax_rates_summary},"\ " tax_strategy: #{@tax_strategy}, tax_total: #{@tax_total}>" end |