Class: FactPulse::InvoiceLine

Inherits:
ApiModelBase show all
Defined in:
lib/factpulse/models/invoice_line.rb

Overview

Represents an invoice line item (BG-25).

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceLine

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/factpulse/models/invoice_line.rb', line 238

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

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

  if attributes.key?(:'line_number')
    self.line_number = attributes[:'line_number']
  else
    self.line_number = nil
  end

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

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

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

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

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

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

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

  if attributes.key?(:'item_name')
    self.item_name = attributes[:'item_name']
  else
    self.item_name = nil
  end

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

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

  if attributes.key?(:'characteristics')
    if (value = attributes[:'characteristics']).is_a?(Array)
      self.characteristics = value
    end
  end

  if attributes.key?(:'classifications')
    if (value = attributes[:'classifications']).is_a?(Array)
      self.classifications = value
    end
  end

  if attributes.key?(:'quantity')
    self.quantity = attributes[:'quantity']
  else
    self.quantity = nil
  end

  if attributes.key?(:'unit')
    self.unit = attributes[:'unit']
  else
    self.unit = nil
  end

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

  if attributes.key?(:'unit_net_price')
    self.unit_net_price = attributes[:'unit_net_price']
  else
    self.unit_net_price = nil
  end

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

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

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

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

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

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

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

  if attributes.key?(:'allowances_charges')
    if (value = attributes[:'allowances_charges']).is_a?(Array)
      self.allowances_charges = value
    end
  end

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

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

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

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

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

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

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

  if attributes.key?(:'additional_documents')
    if (value = attributes[:'additional_documents']).is_a?(Array)
      self.additional_documents = value
    end
  end

  if attributes.key?(:'line_notes')
    if (value = attributes[:'line_notes']).is_a?(Array)
      self.line_notes = value
    end
  end
end

Instance Attribute Details

#accounting_accountObject

Returns the value of attribute accounting_account.



84
85
86
# File 'lib/factpulse/models/invoice_line.rb', line 84

def 
  @accounting_account
end

#additional_documentsObject

Returns the value of attribute additional_documents.



86
87
88
# File 'lib/factpulse/models/invoice_line.rb', line 86

def additional_documents
  @additional_documents
end

#allowance_amountObject

Returns the value of attribute allowance_amount.



64
65
66
# File 'lib/factpulse/models/invoice_line.rb', line 64

def allowance_amount
  @allowance_amount
end

#allowance_reasonObject

Returns the value of attribute allowance_reason.



68
69
70
# File 'lib/factpulse/models/invoice_line.rb', line 68

def allowance_reason
  @allowance_reason
end

#allowance_reason_codeObject

Returns the value of attribute allowance_reason_code.



66
67
68
# File 'lib/factpulse/models/invoice_line.rb', line 66

def allowance_reason_code
  @allowance_reason_code
end

#allowances_chargesObject

Returns the value of attribute allowances_charges.



70
71
72
# File 'lib/factpulse/models/invoice_line.rb', line 70

def allowances_charges
  @allowances_charges
end

#buyer_assigned_idObject

Returns the value of attribute buyer_assigned_id.



30
31
32
# File 'lib/factpulse/models/invoice_line.rb', line 30

def buyer_assigned_id
  @buyer_assigned_id
end

#characteristicsObject

Returns the value of attribute characteristics.



43
44
45
# File 'lib/factpulse/models/invoice_line.rb', line 43

def characteristics
  @characteristics
end

#classificationsObject

Returns the value of attribute classifications.



45
46
47
# File 'lib/factpulse/models/invoice_line.rb', line 45

def classifications
  @classifications
end

#gross_unit_priceObject

Returns the value of attribute gross_unit_price.



52
53
54
# File 'lib/factpulse/models/invoice_line.rb', line 52

def gross_unit_price
  @gross_unit_price
end

#item_descriptionObject

Returns the value of attribute item_description.



39
40
41
# File 'lib/factpulse/models/invoice_line.rb', line 39

def item_description
  @item_description
end

#item_nameObject

Item name (BT-153).



37
38
39
# File 'lib/factpulse/models/invoice_line.rb', line 37

def item_name
  @item_name
end

#line_net_amountObject

Returns the value of attribute line_net_amount.



62
63
64
# File 'lib/factpulse/models/invoice_line.rb', line 62

def line_net_amount
  @line_net_amount
end

#line_noteObject

Returns the value of attribute line_note.



22
23
24
# File 'lib/factpulse/models/invoice_line.rb', line 22

def line_note
  @line_note
end

#line_notesObject

Returns the value of attribute line_notes.



88
89
90
# File 'lib/factpulse/models/invoice_line.rb', line 88

def line_notes
  @line_notes
end

#line_numberObject

Invoice line identifier (BT-126).



20
21
22
# File 'lib/factpulse/models/invoice_line.rb', line 20

def line_number
  @line_number
end

#line_sub_typeObject

Returns the value of attribute line_sub_type.



26
27
28
# File 'lib/factpulse/models/invoice_line.rb', line 26

def line_sub_type
  @line_sub_type
end

#manual_vat_rateObject

Returns the value of attribute manual_vat_rate.



74
75
76
# File 'lib/factpulse/models/invoice_line.rb', line 74

def manual_vat_rate
  @manual_vat_rate
end

#origin_countryObject

Returns the value of attribute origin_country.



41
42
43
# File 'lib/factpulse/models/invoice_line.rb', line 41

def origin_country
  @origin_country
end

#parent_line_idObject

Returns the value of attribute parent_line_id.



24
25
26
# File 'lib/factpulse/models/invoice_line.rb', line 24

def parent_line_id
  @parent_line_id
end

#period_end_dateObject

Returns the value of attribute period_end_date.



80
81
82
# File 'lib/factpulse/models/invoice_line.rb', line 80

def period_end_date
  @period_end_date
end

#period_start_dateObject

Returns the value of attribute period_start_date.



78
79
80
# File 'lib/factpulse/models/invoice_line.rb', line 78

def period_start_date
  @period_start_date
end

#price_allowance_amountObject

Returns the value of attribute price_allowance_amount.



60
61
62
# File 'lib/factpulse/models/invoice_line.rb', line 60

def price_allowance_amount
  @price_allowance_amount
end

#price_basis_quantityObject

Returns the value of attribute price_basis_quantity.



56
57
58
# File 'lib/factpulse/models/invoice_line.rb', line 56

def price_basis_quantity
  @price_basis_quantity
end

#price_basis_unitObject

Returns the value of attribute price_basis_unit.



58
59
60
# File 'lib/factpulse/models/invoice_line.rb', line 58

def price_basis_unit
  @price_basis_unit
end

#product_global_idObject

Returns the value of attribute product_global_id.



32
33
34
# File 'lib/factpulse/models/invoice_line.rb', line 32

def product_global_id
  @product_global_id
end

#product_global_id_schemeObject

Returns the value of attribute product_global_id_scheme.



34
35
36
# File 'lib/factpulse/models/invoice_line.rb', line 34

def product_global_id_scheme
  @product_global_id_scheme
end

#purchase_order_line_refObject

Returns the value of attribute purchase_order_line_ref.



82
83
84
# File 'lib/factpulse/models/invoice_line.rb', line 82

def purchase_order_line_ref
  @purchase_order_line_ref
end

#quantityObject

Returns the value of attribute quantity.



47
48
49
# File 'lib/factpulse/models/invoice_line.rb', line 47

def quantity
  @quantity
end

#referenceObject

Returns the value of attribute reference.



28
29
30
# File 'lib/factpulse/models/invoice_line.rb', line 28

def reference
  @reference
end

#unitObject

Invoiced quantity unit of measure code (BT-130).



50
51
52
# File 'lib/factpulse/models/invoice_line.rb', line 50

def unit
  @unit
end

#unit_net_priceObject

Returns the value of attribute unit_net_price.



54
55
56
# File 'lib/factpulse/models/invoice_line.rb', line 54

def unit_net_price
  @unit_net_price
end

#vat_categoryObject

Returns the value of attribute vat_category.



76
77
78
# File 'lib/factpulse/models/invoice_line.rb', line 76

def vat_category
  @vat_category
end

#vat_rateObject

Returns the value of attribute vat_rate.



72
73
74
# File 'lib/factpulse/models/invoice_line.rb', line 72

def vat_rate
  @vat_rate
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



153
154
155
# File 'lib/factpulse/models/invoice_line.rb', line 153

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



158
159
160
# File 'lib/factpulse/models/invoice_line.rb', line 158

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



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
146
147
148
149
150
# File 'lib/factpulse/models/invoice_line.rb', line 113

def self.attribute_map
  {
    :'line_number' => :'line_number',
    :'line_note' => :'line_note',
    :'parent_line_id' => :'parent_line_id',
    :'line_sub_type' => :'line_sub_type',
    :'reference' => :'reference',
    :'buyer_assigned_id' => :'buyer_assigned_id',
    :'product_global_id' => :'product_global_id',
    :'product_global_id_scheme' => :'product_global_id_scheme',
    :'item_name' => :'item_name',
    :'item_description' => :'item_description',
    :'origin_country' => :'origin_country',
    :'characteristics' => :'characteristics',
    :'classifications' => :'classifications',
    :'quantity' => :'quantity',
    :'unit' => :'unit',
    :'gross_unit_price' => :'gross_unit_price',
    :'unit_net_price' => :'unit_net_price',
    :'price_basis_quantity' => :'price_basis_quantity',
    :'price_basis_unit' => :'price_basis_unit',
    :'price_allowance_amount' => :'price_allowance_amount',
    :'line_net_amount' => :'lineNetAmount',
    :'allowance_amount' => :'allowanceAmount',
    :'allowance_reason_code' => :'allowanceReasonCode',
    :'allowance_reason' => :'allowanceReason',
    :'allowances_charges' => :'allowances_charges',
    :'vat_rate' => :'vat_rate',
    :'manual_vat_rate' => :'manual_vat_rate',
    :'vat_category' => :'vat_category',
    :'period_start_date' => :'period_start_date',
    :'period_end_date' => :'period_end_date',
    :'purchase_order_line_ref' => :'purchase_order_line_ref',
    :'accounting_account' => :'accounting_account',
    :'additional_documents' => :'additional_documents',
    :'line_notes' => :'line_notes'
  }
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



555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/factpulse/models/invoice_line.rb', line 555

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif 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[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



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
# File 'lib/factpulse/models/invoice_line.rb', line 203

def self.openapi_nullable
  Set.new([
    :'line_note',
    :'parent_line_id',
    :'line_sub_type',
    :'reference',
    :'buyer_assigned_id',
    :'product_global_id',
    :'product_global_id_scheme',
    :'item_description',
    :'origin_country',
    :'characteristics',
    :'classifications',
    :'gross_unit_price',
    :'price_basis_quantity',
    :'price_basis_unit',
    :'price_allowance_amount',
    :'line_net_amount',
    :'allowance_amount',
    :'allowance_reason_code',
    :'allowance_reason',
    :'allowances_charges',
    :'vat_rate',
    :'vat_category',
    :'period_start_date',
    :'period_end_date',
    :'purchase_order_line_ref',
    :'accounting_account',
    :'additional_documents',
    :'line_notes'
  ])
end

.openapi_typesObject

Attribute type mapping.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/factpulse/models/invoice_line.rb', line 163

def self.openapi_types
  {
    :'line_number' => :'Integer',
    :'line_note' => :'String',
    :'parent_line_id' => :'String',
    :'line_sub_type' => :'LineSubType',
    :'reference' => :'String',
    :'buyer_assigned_id' => :'String',
    :'product_global_id' => :'String',
    :'product_global_id_scheme' => :'String',
    :'item_name' => :'String',
    :'item_description' => :'String',
    :'origin_country' => :'String',
    :'characteristics' => :'Array<ProductCharacteristic>',
    :'classifications' => :'Array<ProductClassification>',
    :'quantity' => :'Quantity',
    :'unit' => :'UnitOfMeasure',
    :'gross_unit_price' => :'GrossUnitPrice',
    :'unit_net_price' => :'UnitNetPrice',
    :'price_basis_quantity' => :'PriceBasisQuantity',
    :'price_basis_unit' => :'String',
    :'price_allowance_amount' => :'PriceAllowanceAmount',
    :'line_net_amount' => :'LineNetAmount',
    :'allowance_amount' => :'InvoiceLineAllowanceAmount',
    :'allowance_reason_code' => :'AllowanceReasonCode',
    :'allowance_reason' => :'String',
    :'allowances_charges' => :'Array<AllowanceCharge>',
    :'vat_rate' => :'String',
    :'manual_vat_rate' => :'ManualVatRate',
    :'vat_category' => :'VATCategory',
    :'period_start_date' => :'String',
    :'period_end_date' => :'String',
    :'purchase_order_line_ref' => :'String',
    :'accounting_account' => :'String',
    :'additional_documents' => :'Array<AdditionalDocument>',
    :'line_notes' => :'Array<InvoiceNote>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/factpulse/models/invoice_line.rb', line 501

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      line_number == o.line_number &&
      line_note == o.line_note &&
      parent_line_id == o.parent_line_id &&
      line_sub_type == o.line_sub_type &&
      reference == o.reference &&
      buyer_assigned_id == o.buyer_assigned_id &&
      product_global_id == o.product_global_id &&
      product_global_id_scheme == o.product_global_id_scheme &&
      item_name == o.item_name &&
      item_description == o.item_description &&
      origin_country == o.origin_country &&
      characteristics == o.characteristics &&
      classifications == o.classifications &&
      quantity == o.quantity &&
      unit == o.unit &&
      gross_unit_price == o.gross_unit_price &&
      unit_net_price == o.unit_net_price &&
      price_basis_quantity == o.price_basis_quantity &&
      price_basis_unit == o.price_basis_unit &&
      price_allowance_amount == o.price_allowance_amount &&
      line_net_amount == o.line_net_amount &&
      allowance_amount == o.allowance_amount &&
      allowance_reason_code == o.allowance_reason_code &&
      allowance_reason == o.allowance_reason &&
      allowances_charges == o.allowances_charges &&
      vat_rate == o.vat_rate &&
      manual_vat_rate == o.manual_vat_rate &&
      vat_category == o.vat_category &&
      period_start_date == o.period_start_date &&
      period_end_date == o.period_end_date &&
      purchase_order_line_ref == o.purchase_order_line_ref &&
       == o. &&
      additional_documents == o.additional_documents &&
      line_notes == o.line_notes
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


542
543
544
# File 'lib/factpulse/models/invoice_line.rb', line 542

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



548
549
550
# File 'lib/factpulse/models/invoice_line.rb', line 548

def hash
  [line_number, line_note, parent_line_id, line_sub_type, reference, buyer_assigned_id, product_global_id, product_global_id_scheme, item_name, item_description, origin_country, characteristics, classifications, quantity, unit, gross_unit_price, unit_net_price, price_basis_quantity, price_basis_unit, price_allowance_amount, line_net_amount, allowance_amount, allowance_reason_code, allowance_reason, allowances_charges, vat_rate, manual_vat_rate, vat_category, period_start_date, period_end_date, purchase_order_line_ref, , additional_documents, line_notes].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/factpulse/models/invoice_line.rb', line 411

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @line_number.nil?
    invalid_properties.push('invalid value for "line_number", line_number cannot be nil.')
  end

  if @item_name.nil?
    invalid_properties.push('invalid value for "item_name", item_name cannot be nil.')
  end

  if @quantity.nil?
    invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
  end

  if @unit.nil?
    invalid_properties.push('invalid value for "unit", unit cannot be nil.')
  end

  if @unit_net_price.nil?
    invalid_properties.push('invalid value for "unit_net_price", unit_net_price cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'lib/factpulse/models/invoice_line.rb', line 577

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

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



439
440
441
442
443
444
445
446
447
# File 'lib/factpulse/models/invoice_line.rb', line 439

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @line_number.nil?
  return false if @item_name.nil?
  return false if @quantity.nil?
  return false if @unit.nil?
  return false if @unit_net_price.nil?
  true
end