Class: DearInventoryRuby::SaleItem

Inherits:
Object
  • Object
show all
Defined in:
lib/dear-inventory-ruby/models/sale_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ SaleItem

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 192

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleItem` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'sale_id')
    self.sale_id = attributes[:'sale_id']
  end

  if attributes.key?(:'order_number')
    self.order_number = attributes[:'order_number']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'order_date')
    self.order_date = attributes[:'order_date']
  end

  if attributes.key?(:'invoice_date')
    self.invoice_date = attributes[:'invoice_date']
  end

  if attributes.key?(:'customer')
    self.customer = attributes[:'customer']
  end

  if attributes.key?(:'customer_id')
    self.customer_id = attributes[:'customer_id']
  end

  if attributes.key?(:'invoice_number')
    self.invoice_number = attributes[:'invoice_number']
  end

  if attributes.key?(:'customer_reference')
    self.customer_reference = attributes[:'customer_reference']
  end

  if attributes.key?(:'invoice_amount')
    self.invoice_amount = attributes[:'invoice_amount']
  end

  if attributes.key?(:'paid_amount')
    self.paid_amount = attributes[:'paid_amount']
  end

  if attributes.key?(:'invoice_due_date')
    self.invoice_due_date = attributes[:'invoice_due_date']
  end

  if attributes.key?(:'ship_by')
    self.ship_by = attributes[:'ship_by']
  end

  if attributes.key?(:'base_currency')
    self.base_currency = attributes[:'base_currency']
  end

  if attributes.key?(:'customer_currency')
    self.customer_currency = attributes[:'customer_currency']
  end

  if attributes.key?(:'credit_note_number')
    self.credit_note_number = attributes[:'credit_note_number']
  end

  if attributes.key?(:'updated')
    self.updated = attributes[:'updated']
  end

  if attributes.key?(:'quote_status')
    self.quote_status = attributes[:'quote_status']
  end

  if attributes.key?(:'order_status')
    self.order_status = attributes[:'order_status']
  end

  if attributes.key?(:'combined_picking_status')
    self.combined_picking_status = attributes[:'combined_picking_status']
  end

  if attributes.key?(:'combined_packing_status')
    self.combined_packing_status = attributes[:'combined_packing_status']
  end

  if attributes.key?(:'combined_shipping_status')
    self.combined_shipping_status = attributes[:'combined_shipping_status']
  end

  if attributes.key?(:'ful_filment_status')
    self.ful_filment_status = attributes[:'ful_filment_status']
  end

  if attributes.key?(:'combined_invoice_status')
    self.combined_invoice_status = attributes[:'combined_invoice_status']
  end

  if attributes.key?(:'credit_note_status')
    self.credit_note_status = attributes[:'credit_note_status']
  end

  if attributes.key?(:'combined_payment_status')
    self.combined_payment_status = attributes[:'combined_payment_status']
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.key?(:'combined_tracking_numbers')
    self.combined_tracking_numbers = attributes[:'combined_tracking_numbers']
  end

  if attributes.key?(:'source_channel')
    self.source_channel = attributes[:'source_channel']
  end

  if attributes.key?(:'external_id')
    self.external_id = attributes[:'external_id']
  end

  if attributes.key?(:'order_location_id')
    self.order_location_id = attributes[:'order_location_id']
  end
end

Instance Attribute Details

#base_currencyObject

3 digit Base currency code (as configured in General Settings)



57
58
59
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 57

def base_currency
  @base_currency
end

#combined_invoice_statusObject

Invoice status. Possible Values are VOIDED, DRAFT, AUTHORISED, NOT AVAILABLE, PAID



87
88
89
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 87

def combined_invoice_status
  @combined_invoice_status
end

#combined_packing_statusObject

Pack status. Possible Values are VOIDED, NOT AVAILABLE, PACKED, PACKING, NOT PACKED, PARTIALLY PACKED



78
79
80
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 78

def combined_packing_status
  @combined_packing_status
end

#combined_payment_statusObject

Payment status. Possible Values are NOT REFUNDED, PREPAID, PARTIALLY PAID, UNPAID, PAID, VOIDED



93
94
95
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 93

def combined_payment_status
  @combined_payment_status
end

#combined_picking_statusObject

Pick status. Possible Values are VOIDED, NOT AVAILABLE, PICKED, PICKING , NOT PICKED , PARTIALLY PICKED



75
76
77
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 75

def combined_picking_status
  @combined_picking_status
end

#combined_shipping_statusObject

Ship status. Possible Values are VOIDED, NOT AVAILABLE, SHIPPED, SHIPPING , NOT SHIPPED , PARTIALLY SHIPPED



81
82
83
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 81

def combined_shipping_status
  @combined_shipping_status
end

#combined_tracking_numbersObject

Tracking Numbers



99
100
101
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 99

def combined_tracking_numbers
  @combined_tracking_numbers
end

#credit_note_numberObject

Credit note number generated by DEAR. Is empty unless credit note is created



63
64
65
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 63

def credit_note_number
  @credit_note_number
end

#credit_note_statusObject

Credit Note status. Possible Values are VOIDED, DRAFT, AUTHORISED, NOT AVAILABLE



90
91
92
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 90

def credit_note_status
  @credit_note_status
end

#customerObject

Name of the customer



33
34
35
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 33

def customer
  @customer
end

#customer_currencyObject

3 digit Customer currency code



60
61
62
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 60

def customer_currency
  @customer_currency
end

#customer_idObject

Customer Identifier



36
37
38
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 36

def customer_id
  @customer_id
end

#customer_referenceObject

Optional Customer Reference (typically customer Purchase order number) supplied by the customer for the sale



42
43
44
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 42

def customer_reference
  @customer_reference
end

#external_idObject

Custom field that is only available in API and allows to set arbitrary value for the sale for later search and any custom logic



105
106
107
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 105

def external_id
  @external_id
end

#ful_filment_statusObject

Fulfilment status. Possible Values are FULFILLED, PARTIALLY FULFILLED, NOT AVAILABLE, NOT FULFILLED, VOIDED



84
85
86
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 84

def ful_filment_status
  @ful_filment_status
end

#invoice_amountObject

Total Invoice amount minus total Credit note amount in customer currency



45
46
47
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 45

def invoice_amount
  @invoice_amount
end

#invoice_dateObject

Date when Invoice was issued



30
31
32
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 30

def invoice_date
  @invoice_date
end

#invoice_due_dateObject

Date when invoice is due according to selected payment terms



51
52
53
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 51

def invoice_due_date
  @invoice_due_date
end

#invoice_numberObject

Invoice number generated by DEAR



39
40
41
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 39

def invoice_number
  @invoice_number
end

#order_dateObject

Date when Sale Order was created



27
28
29
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 27

def order_date
  @order_date
end

#order_location_idObject

Sale Order Location ID



108
109
110
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 108

def order_location_id
  @order_location_id
end

#order_numberObject

Sale Order number generated by DEAR



21
22
23
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 21

def order_number
  @order_number
end

#order_statusObject

Sale Order status. Possible Values are values



72
73
74
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 72

def order_status
  @order_status
end

Total Paid amount minus Refunded amount in customer currency



48
49
50
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 48

def paid_amount
  @paid_amount
end

#quote_statusObject

Sale Quote status. Possible Values are values



69
70
71
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 69

def quote_status
  @quote_status
end

#sale_idObject

Unique DEAR Sale identifier



18
19
20
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 18

def sale_id
  @sale_id
end

#ship_byObject

Date when shipment is due



54
55
56
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 54

def ship_by
  @ship_by
end

#source_channelObject

Source of the sale. read-only field



102
103
104
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 102

def source_channel
  @source_channel
end

#statusObject

Current sale status. Possible values are values



24
25
26
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 24

def status
  @status
end

#typeObject

Type of Sale. Possible Values are Simple Sale, Advanced Sale , Service Sale



96
97
98
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 96

def type
  @type
end

#updatedObject

Date when the sale was last created/updated last time



66
67
68
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 66

def updated
  @updated
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 111

def self.attribute_map
  {
    :'sale_id' => :'SaleID',
    :'order_number' => :'OrderNumber',
    :'status' => :'Status',
    :'order_date' => :'OrderDate',
    :'invoice_date' => :'InvoiceDate',
    :'customer' => :'Customer',
    :'customer_id' => :'CustomerID',
    :'invoice_number' => :'InvoiceNumber',
    :'customer_reference' => :'CustomerReference',
    :'invoice_amount' => :'InvoiceAmount',
    :'paid_amount' => :'PaidAmount',
    :'invoice_due_date' => :'InvoiceDueDate',
    :'ship_by' => :'ShipBy',
    :'base_currency' => :'BaseCurrency',
    :'customer_currency' => :'CustomerCurrency',
    :'credit_note_number' => :'CreditNoteNumber',
    :'updated' => :'Updated',
    :'quote_status' => :'QuoteStatus',
    :'order_status' => :'OrderStatus',
    :'combined_picking_status' => :'CombinedPickingStatus',
    :'combined_packing_status' => :'CombinedPackingStatus',
    :'combined_shipping_status' => :'CombinedShippingStatus',
    :'ful_filment_status' => :'FulFilmentStatus',
    :'combined_invoice_status' => :'CombinedInvoiceStatus',
    :'credit_note_status' => :'CreditNoteStatus',
    :'combined_payment_status' => :'CombinedPaymentStatus',
    :'type' => :'Type',
    :'combined_tracking_numbers' => :'CombinedTrackingNumbers',
    :'source_channel' => :'SourceChannel',
    :'external_id' => :'ExternalID',
    :'order_location_id' => :'OrderLocationID'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



396
397
398
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 396

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



185
186
187
188
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 185

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 148

def self.openapi_types
  {
    :'sale_id' => :'String',
    :'order_number' => :'String',
    :'status' => :'String',
    :'order_date' => :'Date',
    :'invoice_date' => :'Date',
    :'customer' => :'String',
    :'customer_id' => :'String',
    :'invoice_number' => :'String',
    :'customer_reference' => :'String',
    :'invoice_amount' => :'Float',
    :'paid_amount' => :'Float',
    :'invoice_due_date' => :'Date',
    :'ship_by' => :'Date',
    :'base_currency' => :'String',
    :'customer_currency' => :'String',
    :'credit_note_number' => :'String',
    :'updated' => :'Date',
    :'quote_status' => :'String',
    :'order_status' => :'String',
    :'combined_picking_status' => :'String',
    :'combined_packing_status' => :'String',
    :'combined_shipping_status' => :'String',
    :'ful_filment_status' => :'String',
    :'combined_invoice_status' => :'String',
    :'credit_note_status' => :'String',
    :'combined_payment_status' => :'String',
    :'type' => :'String',
    :'combined_tracking_numbers' => :'String',
    :'source_channel' => :'String',
    :'external_id' => :'String',
    :'order_location_id' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 345

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      sale_id == o.sale_id &&
      order_number == o.order_number &&
      status == o.status &&
      order_date == o.order_date &&
      invoice_date == o.invoice_date &&
      customer == o.customer &&
      customer_id == o.customer_id &&
      invoice_number == o.invoice_number &&
      customer_reference == o.customer_reference &&
      invoice_amount == o.invoice_amount &&
      paid_amount == o.paid_amount &&
      invoice_due_date == o.invoice_due_date &&
      ship_by == o.ship_by &&
      base_currency == o.base_currency &&
      customer_currency == o.customer_currency &&
      credit_note_number == o.credit_note_number &&
      updated == o.updated &&
      quote_status == o.quote_status &&
      order_status == o.order_status &&
      combined_picking_status == o.combined_picking_status &&
      combined_packing_status == o.combined_packing_status &&
      combined_shipping_status == o.combined_shipping_status &&
      ful_filment_status == o.ful_filment_status &&
      combined_invoice_status == o.combined_invoice_status &&
      credit_note_status == o.credit_note_status &&
      combined_payment_status == o.combined_payment_status &&
      type == o.type &&
      combined_tracking_numbers == o.combined_tracking_numbers &&
      source_channel == o.source_channel &&
      external_id == o.external_id &&
      order_location_id == o.order_location_id
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 424

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    DearInventoryRuby.const_get(type).build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 493

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 403

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


383
384
385
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 383

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



389
390
391
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 389

def hash
  [sale_id, order_number, status, order_date, invoice_date, customer, customer_id, invoice_number, customer_reference, invoice_amount, paid_amount, invoice_due_date, ship_by, base_currency, customer_currency, credit_note_number, updated, quote_status, order_status, combined_picking_status, combined_packing_status, combined_shipping_status, ful_filment_status, combined_invoice_status, credit_note_status, combined_payment_status, type, combined_tracking_numbers, source_channel, external_id, order_location_id].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



332
333
334
335
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 332

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



469
470
471
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 469

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 475

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end
    
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



463
464
465
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 463

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



339
340
341
# File 'lib/dear-inventory-ruby/models/sale_item.rb', line 339

def valid?
  true
end