Class: FactPulse::IncomingInvoice

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

Overview

Invoice received from a supplier via PDP/PA. This model contains essential metadata extracted from incoming invoices, regardless of their source format (CII, UBL, Factur-X). Amounts are Decimal in Python but will be serialized as strings in JSON to preserve monetary precision.

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

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

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

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

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

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

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

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

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

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  else
    self.currency = 'EUR'
  end

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#billing_site_name ⇒ Object

Recipient name / your company (BT-44)



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

def billing_site_name
  @billing_site_name
end

#billing_site_siret ⇒ Object

Returns the value of attribute billing_site_siret.



36
37
38
# File 'lib/factpulse/models/incoming_invoice.rb', line 36

def billing_site_siret
  @billing_site_siret
end

#contract_reference ⇒ Object

Returns the value of attribute contract_reference.



57
58
59
# File 'lib/factpulse/models/incoming_invoice.rb', line 57

def contract_reference
  @contract_reference
end

#currency ⇒ Object

ISO currency code (BT-5)



44
45
46
# File 'lib/factpulse/models/incoming_invoice.rb', line 44

def currency
  @currency
end

#document_base64 ⇒ Object

Returns the value of attribute document_base64.



61
62
63
# File 'lib/factpulse/models/incoming_invoice.rb', line 61

def document_base64
  @document_base64
end

#document_content_type ⇒ Object

Returns the value of attribute document_content_type.



63
64
65
# File 'lib/factpulse/models/incoming_invoice.rb', line 63

def document_content_type
  @document_content_type
end

#document_filename ⇒ Object

Returns the value of attribute document_filename.



65
66
67
# File 'lib/factpulse/models/incoming_invoice.rb', line 65

def document_filename
  @document_filename
end

#document_type ⇒ Object

Document type (BT-3)



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

def document_type
  @document_type
end

#due_date ⇒ Object

Returns the value of attribute due_date.



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

def due_date
  @due_date
end

#flow_id ⇒ Object

Returns the value of attribute flow_id.



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

def flow_id
  @flow_id
end

#gross_amount ⇒ Object

Total gross amount (BT-112)



53
54
55
# File 'lib/factpulse/models/incoming_invoice.rb', line 53

def gross_amount
  @gross_amount
end

#invoice_subject ⇒ Object

Returns the value of attribute invoice_subject.



59
60
61
# File 'lib/factpulse/models/incoming_invoice.rb', line 59

def invoice_subject
  @invoice_subject
end

#issue_date ⇒ Object

Invoice date (BT-2) - YYYY-MM-DD



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

def issue_date
  @issue_date
end

#net_amount ⇒ Object

Total net amount (BT-109)



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

def net_amount
  @net_amount
end

#purchase_order_number ⇒ Object

Returns the value of attribute purchase_order_number.



55
56
57
# File 'lib/factpulse/models/incoming_invoice.rb', line 55

def purchase_order_number
  @purchase_order_number
end

#source_format ⇒ Object

Invoice source format



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

def source_format
  @source_format
end

#supplier ⇒ Object

Invoice issuer (SellerTradeParty)



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

def supplier
  @supplier
end

#supplier_reference ⇒ Object

Invoice number issued by the supplier (BT-1)



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

def supplier_reference
  @supplier_reference
end

#vat_amount ⇒ Object

Total VAT amount (BT-110)



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

def vat_amount
  @vat_amount
end

Class Method Details

.acceptable_attribute_map ⇒ Object

Returns attribute mapping this model knows about



115
116
117
# File 'lib/factpulse/models/incoming_invoice.rb', line 115

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributes ⇒ Object

Returns all the JSON keys this model knows about



120
121
122
# File 'lib/factpulse/models/incoming_invoice.rb', line 120

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_map ⇒ Object

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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/factpulse/models/incoming_invoice.rb', line 90

def self.attribute_map
  {
    :'flow_id' => :'flowId',
    :'source_format' => :'sourceFormat',
    :'supplier_reference' => :'supplierReference',
    :'document_type' => :'documentType',
    :'supplier' => :'supplier',
    :'billing_site_name' => :'billingSiteName',
    :'billing_site_siret' => :'billingSiteSiret',
    :'issue_date' => :'issueDate',
    :'due_date' => :'dueDate',
    :'currency' => :'currency',
    :'net_amount' => :'netAmount',
    :'vat_amount' => :'vatAmount',
    :'gross_amount' => :'grossAmount',
    :'purchase_order_number' => :'purchaseOrderNumber',
    :'contract_reference' => :'contractReference',
    :'invoice_subject' => :'invoiceSubject',
    :'document_base64' => :'documentBase64',
    :'document_content_type' => :'documentContentType',
    :'document_filename' => :'documentFilename'
  }
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



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/factpulse/models/incoming_invoice.rb', line 451

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_nullable ⇒ Object

List of attributes with nullable: true



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/factpulse/models/incoming_invoice.rb', line 150

def self.openapi_nullable
  Set.new([
    :'flow_id',
    :'billing_site_siret',
    :'due_date',
    :'purchase_order_number',
    :'contract_reference',
    :'invoice_subject',
    :'document_base64',
    :'document_content_type',
    :'document_filename'
  ])
end

.openapi_types ⇒ Object

Attribute type mapping.



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/factpulse/models/incoming_invoice.rb', line 125

def self.openapi_types
  {
    :'flow_id' => :'String',
    :'source_format' => :'InvoiceFormat',
    :'supplier_reference' => :'String',
    :'document_type' => :'InvoiceTypeCodeOutput',
    :'supplier' => :'IncomingSupplier',
    :'billing_site_name' => :'String',
    :'billing_site_siret' => :'String',
    :'issue_date' => :'String',
    :'due_date' => :'String',
    :'currency' => :'String',
    :'net_amount' => :'String',
    :'vat_amount' => :'String',
    :'gross_amount' => :'String',
    :'purchase_order_number' => :'String',
    :'contract_reference' => :'String',
    :'invoice_subject' => :'String',
    :'document_base64' => :'String',
    :'document_content_type' => :'String',
    :'document_filename' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object) —

    to be compared



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

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      flow_id == o.flow_id &&
      source_format == o.source_format &&
      supplier_reference == o.supplier_reference &&
      document_type == o.document_type &&
      supplier == o.supplier &&
      billing_site_name == o.billing_site_name &&
      billing_site_siret == o.billing_site_siret &&
      issue_date == o.issue_date &&
      due_date == o.due_date &&
      currency == o.currency &&
      net_amount == o.net_amount &&
      vat_amount == o.vat_amount &&
      gross_amount == o.gross_amount &&
      purchase_order_number == o.purchase_order_number &&
      contract_reference == o.contract_reference &&
      invoice_subject == o.invoice_subject &&
      document_base64 == o.document_base64 &&
      document_content_type == o.document_content_type &&
      document_filename == o.document_filename
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object) —

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


438
439
440
# File 'lib/factpulse/models/incoming_invoice.rb', line 438

def eql?(o)
  self == o
end

#hash ⇒ Integer

Calculates hash code according to all attributes.

Returns:

  • (Integer) —

    Hash code



444
445
446
# File 'lib/factpulse/models/incoming_invoice.rb', line 444

def hash
  [flow_id, source_format, supplier_reference, document_type, supplier, billing_site_name, billing_site_siret, issue_date, due_date, currency, net_amount, vat_amount, gross_amount, purchase_order_number, contract_reference, invoice_subject, document_base64, document_content_type, document_filename].hash
end

#list_invalid_properties ⇒ Object

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

Returns:

  • Array for valid properties with the reasons



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

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

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

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

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

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

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

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

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

  invalid_properties
end

#to_hash ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash) —

    Returns the object in the form of hash



473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/factpulse/models/incoming_invoice.rb', line 473

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



317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/factpulse/models/incoming_invoice.rb', line 317

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @source_format.nil?
  return false if @supplier_reference.nil?
  return false if @supplier.nil?
  return false if @billing_site_name.nil?
  return false if @issue_date.nil?
  return false if @net_amount.nil?
  return false if @vat_amount.nil?
  return false if @gross_amount.nil?
  true
end