Class: NewStoreApi::EnrichedTransactionDto
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::EnrichedTransactionDto
- Defined in:
- lib/new_store_api/models/enriched_transaction_dto.rb
Overview
EnrichedTransactionDto Model.
Instance Attribute Summary collapse
-
#calculation_mode ⇒ CalculationModeEnum
TODO: Write general description for this method.
-
#document_id ⇒ String
The documentId of the created tax transaction.
-
#exemption_class ⇒ ExemptionClassEnum
The documentId of the created tax transaction.
-
#exemption_number ⇒ String
The number of the customer's exemption certificate.
-
#fallback_error ⇒ FallbackErrorDto
The optional error of the original tax provider execution that triggered the execution of the fall-back tax provider.
-
#items ⇒ Array[EnrichedTransactionItemDto]
A list of the items sold/returned in the transaction, enriched with the tax amounts.
-
#order_id ⇒ String
The order ID that will be used as a reference to link the order to the created tax transaction in the tax provider records.
-
#return_id ⇒ String
The return ID that will be used as a reference to link the order to the created tax transaction in the tax provider records.
-
#tax_exempt ⇒ TrueClass | FalseClass
Defines the tax exemption status of the transaction.
-
#totals ⇒ TaxTotalsDto
The transaction total amounts.
-
#transaction_type ⇒ TransactionTypeEnum
The transaction total amounts.
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(document_id = nil, items = nil, totals = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, fallback_error = SKIP, order_id = SKIP, return_id = SKIP, tax_exempt = false, transaction_type = SKIP) ⇒ EnrichedTransactionDto
constructor
A new instance of EnrichedTransactionDto.
-
#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(document_id = nil, items = nil, totals = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, fallback_error = SKIP, order_id = SKIP, return_id = SKIP, tax_exempt = false, transaction_type = SKIP) ⇒ EnrichedTransactionDto
Returns a new instance of EnrichedTransactionDto.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 104 def initialize(document_id = nil, items = nil, totals = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, fallback_error = SKIP, order_id = SKIP, return_id = SKIP, tax_exempt = false, transaction_type = SKIP) @calculation_mode = calculation_mode unless calculation_mode == SKIP @document_id = document_id @exemption_class = exemption_class unless exemption_class == SKIP @exemption_number = exemption_number unless exemption_number == SKIP @fallback_error = fallback_error unless fallback_error == SKIP @items = items @order_id = order_id unless order_id == SKIP @return_id = return_id unless return_id == SKIP @tax_exempt = tax_exempt unless tax_exempt == SKIP @totals = totals @transaction_type = transaction_type unless transaction_type == SKIP end |
Instance Attribute Details
#calculation_mode ⇒ CalculationModeEnum
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 14 def calculation_mode @calculation_mode end |
#document_id ⇒ String
The documentId of the created tax transaction.
18 19 20 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 18 def document_id @document_id end |
#exemption_class ⇒ ExemptionClassEnum
The documentId of the created tax transaction.
22 23 24 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 22 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.
28 29 30 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 28 def exemption_number @exemption_number end |
#fallback_error ⇒ FallbackErrorDto
The optional error of the original tax provider execution that triggered the execution of the fall-back tax provider. Will be returned when the orignal tax provider failure occurs.
34 35 36 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 34 def fallback_error @fallback_error end |
#items ⇒ Array[EnrichedTransactionItemDto]
A list of the items sold/returned in the transaction, enriched with the tax amounts.
39 40 41 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 39 def items @items end |
#order_id ⇒ String
The order ID that will be used as a reference to link the order to the created tax transaction in the tax provider records.
- In case the order ID is not provided then a randomly generated identifier will be used instead.
- The tax transaction will be stored by using the given value.
47 48 49 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 47 def order_id @order_id end |
#return_id ⇒ String
The return ID that will be used as a reference to link the order to the created tax transaction in the tax provider records.
- The tax transaction for returns will be stored by using the given value.
- If the value is not set, the return transaction will not be stored.
54 55 56 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 54 def return_id @return_id end |
#tax_exempt ⇒ TrueClass | FalseClass
Defines the tax exemption status of the transaction.
58 59 60 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 58 def tax_exempt @tax_exempt end |
#totals ⇒ TaxTotalsDto
The transaction total amounts.
62 63 64 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 62 def totals @totals end |
#transaction_type ⇒ TransactionTypeEnum
The transaction total amounts.
66 67 68 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 66 def transaction_type @transaction_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 123 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. document_id = hash.key?('document_id') ? hash['document_id'] : nil # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (EnrichedTransactionItemDto.from_hash(structure) if structure) end end items = nil unless hash.key?('items') totals = TaxTotalsDto.from_hash(hash['totals']) if hash['totals'] 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 fallback_error = FallbackErrorDto.from_hash(hash['fallback_error']) if hash['fallback_error'] order_id = hash.key?('order_id') ? hash['order_id'] : SKIP return_id = hash.key?('return_id') ? hash['return_id'] : SKIP tax_exempt = hash['tax_exempt'] ||= false transaction_type = hash.key?('transaction_type') ? hash['transaction_type'] : SKIP # Create object from extracted values. EnrichedTransactionDto.new(document_id, items, totals, calculation_mode, exemption_class, exemption_number, fallback_error, order_id, return_id, tax_exempt, transaction_type) end |
.names ⇒ Object
A mapping from model property names to API property names.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 69 def self.names @_hash = {} if @_hash.nil? @_hash['calculation_mode'] = 'calculation_mode' @_hash['document_id'] = 'document_id' @_hash['exemption_class'] = 'exemption_class' @_hash['exemption_number'] = 'exemption_number' @_hash['fallback_error'] = 'fallback_error' @_hash['items'] = 'items' @_hash['order_id'] = 'order_id' @_hash['return_id'] = 'return_id' @_hash['tax_exempt'] = 'tax_exempt' @_hash['totals'] = 'totals' @_hash['transaction_type'] = 'transaction_type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
100 101 102 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 100 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 86 def self.optionals %w[ calculation_mode exemption_class exemption_number fallback_error order_id return_id tax_exempt transaction_type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
178 179 180 181 182 183 184 185 186 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 178 def inspect class_name = self.class.name.split('::').last "<#{class_name} calculation_mode: #{@calculation_mode.inspect}, document_id:"\ " #{@document_id.inspect}, exemption_class: #{@exemption_class.inspect}, exemption_number:"\ " #{@exemption_number.inspect}, fallback_error: #{@fallback_error.inspect}, items:"\ " #{@items.inspect}, order_id: #{@order_id.inspect}, return_id: #{@return_id.inspect},"\ " tax_exempt: #{@tax_exempt.inspect}, totals: #{@totals.inspect}, transaction_type:"\ " #{@transaction_type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
168 169 170 171 172 173 174 175 |
# File 'lib/new_store_api/models/enriched_transaction_dto.rb', line 168 def to_s class_name = self.class.name.split('::').last "<#{class_name} calculation_mode: #{@calculation_mode}, document_id: #{@document_id},"\ " exemption_class: #{@exemption_class}, exemption_number: #{@exemption_number},"\ " fallback_error: #{@fallback_error}, items: #{@items}, order_id: #{@order_id}, return_id:"\ " #{@return_id}, tax_exempt: #{@tax_exempt}, totals: #{@totals}, transaction_type:"\ " #{@transaction_type}>" end |