Class: FactPulse::FacturXInvoice

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

Overview

Data model for an invoice to be converted to Factur-X.

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 = {}) ⇒ FacturXInvoice

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `FactPulse::FacturXInvoice` 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::FacturXInvoice`. 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?(:'invoice_number')
    self.invoice_number = attributes[:'invoice_number']
  else
    self.invoice_number = nil
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



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

def comment
  @comment
end

#current_user_idObject

Returns the value of attribute current_user_id.



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

def current_user_id
  @current_user_id
end

#invoice_dateObject

Returns the value of attribute invoice_date.



23
24
25
# File 'lib/factpulse/models/factur_x_invoice.rb', line 23

def invoice_date
  @invoice_date
end

#invoice_linesObject

Returns the value of attribute invoice_lines.



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

def invoice_lines
  @invoice_lines
end

#invoice_numberObject

Returns the value of attribute invoice_number.



19
20
21
# File 'lib/factpulse/models/factur_x_invoice.rb', line 19

def invoice_number
  @invoice_number
end

#invoicing_frameworkObject

Returns the value of attribute invoicing_framework.



31
32
33
# File 'lib/factpulse/models/factur_x_invoice.rb', line 31

def invoicing_framework
  @invoicing_framework
end

#notesObject

Returns the value of attribute notes.



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

def notes
  @notes
end

#payeeObject

Returns the value of attribute payee.



49
50
51
# File 'lib/factpulse/models/factur_x_invoice.rb', line 49

def payee
  @payee
end

#payment_due_dateObject

Returns the value of attribute payment_due_date.



21
22
23
# File 'lib/factpulse/models/factur_x_invoice.rb', line 21

def payment_due_date
  @payment_due_date
end

#recipientObject

Returns the value of attribute recipient.



27
28
29
# File 'lib/factpulse/models/factur_x_invoice.rb', line 27

def recipient
  @recipient
end

#referencesObject

Returns the value of attribute references.



33
34
35
# File 'lib/factpulse/models/factur_x_invoice.rb', line 33

def references
  @references
end

#submission_modeObject

Returns the value of attribute submission_mode.



25
26
27
# File 'lib/factpulse/models/factur_x_invoice.rb', line 25

def submission_mode
  @submission_mode
end

#supplementary_attachmentsObject

Returns the value of attribute supplementary_attachments.



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

def supplementary_attachments
  @supplementary_attachments
end

#supplierObject

Returns the value of attribute supplier.



29
30
31
# File 'lib/factpulse/models/factur_x_invoice.rb', line 29

def supplier
  @supplier
end

#totalsObject

Returns the value of attribute totals.



35
36
37
# File 'lib/factpulse/models/factur_x_invoice.rb', line 35

def totals
  @totals
end

#vat_linesObject

Returns the value of attribute vat_lines.



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

def vat_lines
  @vat_lines
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



96
97
98
# File 'lib/factpulse/models/factur_x_invoice.rb', line 96

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



101
102
103
# File 'lib/factpulse/models/factur_x_invoice.rb', line 101

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/factpulse/models/factur_x_invoice.rb', line 74

def self.attribute_map
  {
    :'invoice_number' => :'invoice_number',
    :'payment_due_date' => :'payment_due_date',
    :'invoice_date' => :'invoice_date',
    :'submission_mode' => :'submission_mode',
    :'recipient' => :'recipient',
    :'supplier' => :'supplier',
    :'invoicing_framework' => :'invoicing_framework',
    :'references' => :'references',
    :'totals' => :'totals',
    :'invoice_lines' => :'invoice_lines',
    :'vat_lines' => :'vat_lines',
    :'notes' => :'notes',
    :'comment' => :'comment',
    :'current_user_id' => :'current_user_id',
    :'supplementary_attachments' => :'supplementary_attachments',
    :'payee' => :'payee'
  }
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



415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/factpulse/models/factur_x_invoice.rb', line 415

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



128
129
130
131
132
133
134
135
# File 'lib/factpulse/models/factur_x_invoice.rb', line 128

def self.openapi_nullable
  Set.new([
    :'comment',
    :'current_user_id',
    :'supplementary_attachments',
    :'payee'
  ])
end

.openapi_typesObject

Attribute type mapping.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/factpulse/models/factur_x_invoice.rb', line 106

def self.openapi_types
  {
    :'invoice_number' => :'String',
    :'payment_due_date' => :'String',
    :'invoice_date' => :'String',
    :'submission_mode' => :'SubmissionMode',
    :'recipient' => :'Recipient',
    :'supplier' => :'Supplier',
    :'invoicing_framework' => :'InvoicingFramework',
    :'references' => :'InvoiceReferences',
    :'totals' => :'InvoiceTotals',
    :'invoice_lines' => :'Array<InvoiceLine>',
    :'vat_lines' => :'Array<VATLine>',
    :'notes' => :'Array<InvoiceNote>',
    :'comment' => :'String',
    :'current_user_id' => :'Integer',
    :'supplementary_attachments' => :'Array<SupplementaryAttachment>',
    :'payee' => :'Payee'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/factpulse/models/factur_x_invoice.rb', line 379

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      invoice_number == o.invoice_number &&
      payment_due_date == o.payment_due_date &&
      invoice_date == o.invoice_date &&
      submission_mode == o.submission_mode &&
      recipient == o.recipient &&
      supplier == o.supplier &&
      invoicing_framework == o.invoicing_framework &&
      references == o.references &&
      totals == o.totals &&
      invoice_lines == o.invoice_lines &&
      vat_lines == o.vat_lines &&
      notes == o.notes &&
      comment == o.comment &&
      current_user_id == o.current_user_id &&
      supplementary_attachments == o.supplementary_attachments &&
      payee == o.payee
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


402
403
404
# File 'lib/factpulse/models/factur_x_invoice.rb', line 402

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



408
409
410
# File 'lib/factpulse/models/factur_x_invoice.rb', line 408

def hash
  [invoice_number, payment_due_date, invoice_date, submission_mode, recipient, supplier, invoicing_framework, references, totals, invoice_lines, vat_lines, notes, comment, current_user_id, supplementary_attachments, payee].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

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

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

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

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

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

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

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

  if @totals.nil?
    invalid_properties.push('invalid value for "totals", totals 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



437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/factpulse/models/factur_x_invoice.rb', line 437

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



284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/factpulse/models/factur_x_invoice.rb', line 284

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @invoice_number.nil?
  return false if @payment_due_date.nil?
  return false if @submission_mode.nil?
  return false if @recipient.nil?
  return false if @supplier.nil?
  return false if @invoicing_framework.nil?
  return false if @references.nil?
  return false if @totals.nil?
  true
end