Class: NewStoreApi::QuotationDto
- Defined in:
- lib/new_store_api/models/quotation_dto.rb
Overview
QuotationDto Model.
Instance Attribute Summary collapse
-
#calculation_mode ⇒ CalculationModeEnum
TODO: Write general description for this method.
-
#exemption_class ⇒ ExemptionClassEnum
TODO: Write general description for this method.
-
#exemption_number ⇒ String
The number of the customer's exemption certificate.
-
#items ⇒ Array[Object]
A list of the items sold/returned in the quotation.
-
#tax_date ⇒ DateTime
Date of the transaction (in UTC timezone) that'll be used in committing taxes.
-
#tax_exempt ⇒ TrueClass | FalseClass
Defines the tax exemption status of the transaction.
-
#transaction_type ⇒ TransactionTypeEnum
Defines the tax exemption status of the transaction.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(items = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, tax_date = SKIP, tax_exempt = false, transaction_type = SKIP) ⇒ QuotationDto
constructor
A new instance of QuotationDto.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_tax_date ⇒ Object
-
#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(items = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, tax_date = SKIP, tax_exempt = false, transaction_type = SKIP) ⇒ QuotationDto
Returns a new instance of QuotationDto.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 80 def initialize(items = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, tax_date = SKIP, tax_exempt = false, transaction_type = SKIP) @calculation_mode = calculation_mode unless calculation_mode == SKIP @exemption_class = exemption_class unless exemption_class == SKIP @exemption_number = exemption_number unless exemption_number == SKIP @items = items @tax_date = tax_date unless tax_date == SKIP @tax_exempt = tax_exempt unless tax_exempt == SKIP @transaction_type = transaction_type unless transaction_type == SKIP end |
Instance Attribute Details
#calculation_mode ⇒ CalculationModeEnum
TODO: Write general description for this method
15 16 17 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 15 def calculation_mode @calculation_mode end |
#exemption_class ⇒ ExemptionClassEnum
TODO: Write general description for this method
19 20 21 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 19 def exemption_class @exemption_class end |
#exemption_number ⇒ String
The number of the customer's exemption certificate.
- The given value can be verified by the auditors in the event of a tax audit.
25 26 27 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 25 def exemption_number @exemption_number end |
#items ⇒ Array[Object]
A list of the items sold/returned in the quotation. Monetary fields are in
the currency's minor unit. All items must use the same
currency_consumer.
- The type
ReverseCalculationQuotationItemDtoshould be used when thecalculation_modeis set toREVERSE. - The type
QuotationItemDtoshould be used When thecalculation_modeis not sent or set toSTANDARD.
35 36 37 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 35 def items @items end |
#tax_date ⇒ DateTime
Date of the transaction (in UTC timezone) that'll be used in committing taxes.
40 41 42 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 40 def tax_date @tax_date end |
#tax_exempt ⇒ TrueClass | FalseClass
Defines the tax exemption status of the transaction.
44 45 46 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 44 def tax_exempt @tax_exempt end |
#transaction_type ⇒ TransactionTypeEnum
Defines the tax exemption status of the transaction.
48 49 50 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 48 def transaction_type @transaction_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 93 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. items = hash.key?('items') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:QuotationDtoItems), hash['items'] ) : nil calculation_mode = hash.key?('calculation_mode') ? hash['calculation_mode'] : SKIP exemption_class = hash.key?('exemption_class') ? hash['exemption_class'] : SKIP exemption_number = hash.key?('exemption_number') ? hash['exemption_number'] : SKIP tax_date = if hash.key?('tax_date') (DateTimeHelper.from_rfc3339(hash['tax_date']) if hash['tax_date']) else SKIP end tax_exempt = hash['tax_exempt'] ||= false transaction_type = hash.key?('transaction_type') ? hash['transaction_type'] : SKIP # Create object from extracted values. QuotationDto.new(items, calculation_mode, exemption_class, exemption_number, tax_date, tax_exempt, transaction_type) end |
.names ⇒ Object
A mapping from model property names to API property names.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 51 def self.names @_hash = {} if @_hash.nil? @_hash['calculation_mode'] = 'calculation_mode' @_hash['exemption_class'] = 'exemption_class' @_hash['exemption_number'] = 'exemption_number' @_hash['items'] = 'items' @_hash['tax_date'] = 'tax_date' @_hash['tax_exempt'] = 'tax_exempt' @_hash['transaction_type'] = 'transaction_type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
76 77 78 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 76 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 64 def self.optionals %w[ calculation_mode exemption_class exemption_number tax_date tax_exempt transaction_type ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 131 def self.validate(value) if value.instance_of? self return UnionTypeLookUp.get(:QuotationDtoItems) .validate(value.items) end return false unless value.instance_of? Hash UnionTypeLookUp.get(:QuotationDtoItems) .validate(value['items']) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
152 153 154 155 156 157 158 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 152 def inspect class_name = self.class.name.split('::').last "<#{class_name} calculation_mode: #{@calculation_mode.inspect}, exemption_class:"\ " #{@exemption_class.inspect}, exemption_number: #{@exemption_number.inspect}, items:"\ " #{@items.inspect}, tax_date: #{@tax_date.inspect}, tax_exempt: #{@tax_exempt.inspect},"\ " transaction_type: #{@transaction_type.inspect}>" end |
#to_custom_tax_date ⇒ Object
125 126 127 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 125 def to_custom_tax_date DateTimeHelper.to_rfc3339(tax_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
144 145 146 147 148 149 |
# File 'lib/new_store_api/models/quotation_dto.rb', line 144 def to_s class_name = self.class.name.split('::').last "<#{class_name} calculation_mode: #{@calculation_mode}, exemption_class:"\ " #{@exemption_class}, exemption_number: #{@exemption_number}, items: #{@items}, tax_date:"\ " #{@tax_date}, tax_exempt: #{@tax_exempt}, transaction_type: #{@transaction_type}>" end |