Class: AdvancedBilling::ProformaInvoice

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/proforma_invoice.rb

Overview

ProformaInvoice Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(uid: SKIP, site_id: SKIP, customer_id: SKIP, subscription_id: SKIP, number: SKIP, sequence_number: SKIP, created_at: SKIP, delivery_date: SKIP, status: SKIP, collection_method: SKIP, payment_instructions: SKIP, currency: SKIP, consolidation_level: SKIP, product_name: SKIP, product_family_name: SKIP, role: SKIP, seller: SKIP, customer: SKIP, memo: SKIP, billing_address: SKIP, shipping_address: SKIP, subtotal_amount: SKIP, discount_amount: SKIP, tax_amount: SKIP, total_amount: SKIP, credit_amount: SKIP, paid_amount: SKIP, refund_amount: SKIP, due_amount: SKIP, line_items: SKIP, discounts: SKIP, taxes: SKIP, credits: SKIP, payments: SKIP, custom_fields: SKIP, public_url: SKIP, additional_properties: {}) ⇒ ProformaInvoice

Returns a new instance of ProformaInvoice.



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
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 315

def initialize(uid: SKIP, site_id: SKIP, customer_id: SKIP,
               subscription_id: SKIP, number: SKIP, sequence_number: SKIP,
               created_at: SKIP, delivery_date: SKIP, status: SKIP,
               collection_method: SKIP, payment_instructions: SKIP,
               currency: SKIP, consolidation_level: SKIP,
               product_name: SKIP, product_family_name: SKIP, role: SKIP,
               seller: SKIP, customer: SKIP, memo: SKIP,
               billing_address: SKIP, shipping_address: SKIP,
               subtotal_amount: SKIP, discount_amount: SKIP,
               tax_amount: SKIP, total_amount: SKIP, credit_amount: SKIP,
               paid_amount: SKIP, refund_amount: SKIP, due_amount: SKIP,
               line_items: SKIP, discounts: SKIP, taxes: SKIP,
               credits: SKIP, payments: SKIP, custom_fields: SKIP,
               public_url: SKIP, additional_properties: {})
  @uid = uid unless uid == SKIP
  @site_id = site_id unless site_id == SKIP
  @customer_id = customer_id unless customer_id == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @number = number unless number == SKIP
  @sequence_number = sequence_number unless sequence_number == SKIP
  @created_at = created_at unless created_at == SKIP
  @delivery_date = delivery_date unless delivery_date == SKIP
  @status = status unless status == SKIP
  @collection_method = collection_method unless collection_method == SKIP
  @payment_instructions = payment_instructions unless payment_instructions == SKIP
  @currency = currency unless currency == SKIP
  @consolidation_level = consolidation_level unless consolidation_level == SKIP
  @product_name = product_name unless product_name == SKIP
  @product_family_name = product_family_name unless product_family_name == SKIP
  @role = role unless role == SKIP
  @seller = seller unless seller == SKIP
  @customer = customer unless customer == SKIP
  @memo = memo unless memo == SKIP
  @billing_address = billing_address unless billing_address == SKIP
  @shipping_address = shipping_address unless shipping_address == SKIP
  @subtotal_amount = subtotal_amount unless subtotal_amount == SKIP
  @discount_amount = discount_amount unless discount_amount == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @total_amount = total_amount unless total_amount == SKIP
  @credit_amount = credit_amount unless credit_amount == SKIP
  @paid_amount = paid_amount unless paid_amount == SKIP
  @refund_amount = refund_amount unless refund_amount == SKIP
  @due_amount = due_amount unless due_amount == SKIP
  @line_items = line_items unless line_items == SKIP
  @discounts = discounts unless discounts == SKIP
  @taxes = taxes unless taxes == SKIP
  @credits = credits unless credits == SKIP
  @payments = payments unless payments == SKIP
  @custom_fields = custom_fields unless custom_fields == SKIP
  @public_url = public_url unless public_url == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#billing_addressInvoiceAddress

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



138
139
140
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 138

def billing_address
  @billing_address
end

#collection_methodCollectionMethod

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:



54
55
56
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 54

def collection_method
  @collection_method
end

#consolidation_levelInvoiceConsolidationLevel

Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

  • “none”: A normal invoice with no consolidation.

  • “child”: An invoice segment which has been combined into a consolidated

invoice.

  • “parent”: A consolidated invoice, whose contents are composed of invoice

segments. “Parent” invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments. See also the [invoice consolidation documentation](maxio.zendesk.com/hc/en-us/articles/24252269909389- Invoice-Consolidation).



83
84
85
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 83

def consolidation_level
  @consolidation_level
end

#created_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


39
40
41
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 39

def created_at
  @created_at
end

#credit_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


168
169
170
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 168

def credit_amount
  @credit_amount
end

#creditsArray[ProformaInvoiceCredit]

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



203
204
205
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 203

def credits
  @credits
end

#currencyString

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:

  • (String)


68
69
70
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 68

def currency
  @currency
end

#custom_fieldsArray[InvoiceCustomField]

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



213
214
215
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 213

def custom_fields
  @custom_fields
end

#customerInvoiceCustomer

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



128
129
130
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 128

def customer
  @customer
end

#customer_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


23
24
25
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 23

def customer_id
  @customer_id
end

#delivery_dateDate

TODO: Write general description for this method

Returns:

  • (Date)


43
44
45
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 43

def delivery_date
  @delivery_date
end

#discount_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


153
154
155
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 153

def discount_amount
  @discount_amount
end

#discountsArray[ProformaInvoiceDiscount]

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



193
194
195
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 193

def discounts
  @discounts
end

#due_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


183
184
185
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 183

def due_amount
  @due_amount
end

#line_itemsArray[InvoiceLineItem]

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



188
189
190
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 188

def line_items
  @line_items
end

#memoString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


133
134
135
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 133

def memo
  @memo
end

#numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


31
32
33
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 31

def number
  @number
end

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


173
174
175
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 173

def paid_amount
  @paid_amount
end

#payment_instructionsString

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:

  • (String)


61
62
63
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 61

def payment_instructions
  @payment_instructions
end

#paymentsArray[ProformaInvoicePayment]

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



208
209
210
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 208

def payments
  @payments
end

#product_family_nameString

Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

  • “none”: A normal invoice with no consolidation.

  • “child”: An invoice segment which has been combined into a consolidated

invoice.

  • “parent”: A consolidated invoice, whose contents are composed of invoice

segments. “Parent” invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments. See also the [invoice consolidation documentation](maxio.zendesk.com/hc/en-us/articles/24252269909389- Invoice-Consolidation).

Returns:

  • (String)


113
114
115
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 113

def product_family_name
  @product_family_name
end

#product_nameString

Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

  • “none”: A normal invoice with no consolidation.

  • “child”: An invoice segment which has been combined into a consolidated

invoice.

  • “parent”: A consolidated invoice, whose contents are composed of invoice

segments. “Parent” invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments. See also the [invoice consolidation documentation](maxio.zendesk.com/hc/en-us/articles/24252269909389- Invoice-Consolidation).

Returns:

  • (String)


98
99
100
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 98

def product_name
  @product_name
end

#public_urlString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


218
219
220
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 218

def public_url
  @public_url
end

#refund_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


178
179
180
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 178

def refund_amount
  @refund_amount
end

#roleProformaInvoiceRole

‘proforma’ value is deprecated in favor of proforma_adhoc and proforma_automatic

Returns:



118
119
120
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 118

def role
  @role
end

#sellerInvoiceSeller

Information about the seller (merchant) listed on the masthead of the invoice.

Returns:



123
124
125
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 123

def seller
  @seller
end

#sequence_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


35
36
37
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 35

def sequence_number
  @sequence_number
end

#shipping_addressInvoiceAddress

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



143
144
145
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 143

def shipping_address
  @shipping_address
end

#site_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


19
20
21
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 19

def site_id
  @site_id
end

#statusProformaInvoiceStatus

TODO: Write general description for this method



47
48
49
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 47

def status
  @status
end

#subscription_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


27
28
29
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 27

def subscription_id
  @subscription_id
end

#subtotal_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


148
149
150
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 148

def subtotal_amount
  @subtotal_amount
end

#tax_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


158
159
160
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 158

def tax_amount
  @tax_amount
end

#taxesArray[ProformaInvoiceTax]

Information about the customer who is owner or recipient the invoiced subscription.

Returns:



198
199
200
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 198

def taxes
  @taxes
end

#total_amountString

Information about the customer who is owner or recipient the invoiced subscription.

Returns:

  • (String)


163
164
165
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 163

def total_amount
  @total_amount
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 15

def uid
  @uid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
408
409
410
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 373

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  uid = hash.key?('uid') ? hash['uid'] : SKIP
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  number = hash.key?('number') ? hash['number'] : SKIP
  sequence_number =
    hash.key?('sequence_number') ? hash['sequence_number'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  delivery_date = hash.key?('delivery_date') ? hash['delivery_date'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  collection_method =
    hash.key?('collection_method') ? hash['collection_method'] : SKIP
  payment_instructions =
    hash.key?('payment_instructions') ? hash['payment_instructions'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  consolidation_level =
    hash.key?('consolidation_level') ? hash['consolidation_level'] : SKIP
  product_name = hash.key?('product_name') ? hash['product_name'] : SKIP
  product_family_name =
    hash.key?('product_family_name') ? hash['product_family_name'] : SKIP
  role = hash.key?('role') ? hash['role'] : SKIP
  seller = InvoiceSeller.from_hash(hash['seller']) if hash['seller']
  customer = InvoiceCustomer.from_hash(hash['customer']) if hash['customer']
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  billing_address = InvoiceAddress.from_hash(hash['billing_address']) if
    hash['billing_address']
  shipping_address = InvoiceAddress.from_hash(hash['shipping_address']) if
    hash['shipping_address']
  subtotal_amount =
    hash.key?('subtotal_amount') ? hash['subtotal_amount'] : SKIP
  discount_amount =
    hash.key?('discount_amount') ? hash['discount_amount'] : SKIP
  tax_amount = hash.key?('tax_amount') ? hash['tax_amount'] : SKIP
  total_amount = hash.key?('total_amount') ? hash['total_amount'] : SKIP
  credit_amount = hash.key?('credit_amount') ? hash['credit_amount'] : SKIP
  paid_amount = hash.key?('paid_amount') ? hash['paid_amount'] : SKIP
  refund_amount = hash.key?('refund_amount') ? hash['refund_amount'] : SKIP
  due_amount = hash.key?('due_amount') ? hash['due_amount'] : SKIP
  # Parameter is an array, so we need to iterate through it
  line_items = nil
  unless hash['line_items'].nil?
    line_items = []
    hash['line_items'].each do |structure|
      line_items << (InvoiceLineItem.from_hash(structure) if structure)
    end
  end

  line_items = SKIP unless hash.key?('line_items')
  # Parameter is an array, so we need to iterate through it
  discounts = nil
  unless hash['discounts'].nil?
    discounts = []
    hash['discounts'].each do |structure|
      discounts << (ProformaInvoiceDiscount.from_hash(structure) if structure)
    end
  end

  discounts = SKIP unless hash.key?('discounts')
  # Parameter is an array, so we need to iterate through it
  taxes = nil
  unless hash['taxes'].nil?
    taxes = []
    hash['taxes'].each do |structure|
      taxes << (ProformaInvoiceTax.from_hash(structure) if structure)
    end
  end

  taxes = SKIP unless hash.key?('taxes')
  # Parameter is an array, so we need to iterate through it
  credits = nil
  unless hash['credits'].nil?
    credits = []
    hash['credits'].each do |structure|
      credits << (ProformaInvoiceCredit.from_hash(structure) if structure)
    end
  end

  credits = SKIP unless hash.key?('credits')
  # Parameter is an array, so we need to iterate through it
  payments = nil
  unless hash['payments'].nil?
    payments = []
    hash['payments'].each do |structure|
      payments << (ProformaInvoicePayment.from_hash(structure) if structure)
    end
  end

  payments = SKIP unless hash.key?('payments')
  # Parameter is an array, so we need to iterate through it
  custom_fields = nil
  unless hash['custom_fields'].nil?
    custom_fields = []
    hash['custom_fields'].each do |structure|
      custom_fields << (InvoiceCustomField.from_hash(structure) if structure)
    end
  end

  custom_fields = SKIP unless hash.key?('custom_fields')
  public_url = hash.key?('public_url') ? hash['public_url'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  ProformaInvoice.new(uid: uid,
                      site_id: site_id,
                      customer_id: customer_id,
                      subscription_id: subscription_id,
                      number: number,
                      sequence_number: sequence_number,
                      created_at: created_at,
                      delivery_date: delivery_date,
                      status: status,
                      collection_method: collection_method,
                      payment_instructions: payment_instructions,
                      currency: currency,
                      consolidation_level: consolidation_level,
                      product_name: product_name,
                      product_family_name: product_family_name,
                      role: role,
                      seller: seller,
                      customer: customer,
                      memo: memo,
                      billing_address: billing_address,
                      shipping_address: shipping_address,
                      subtotal_amount: subtotal_amount,
                      discount_amount: discount_amount,
                      tax_amount: tax_amount,
                      total_amount: total_amount,
                      credit_amount: credit_amount,
                      paid_amount: paid_amount,
                      refund_amount: refund_amount,
                      due_amount: due_amount,
                      line_items: line_items,
                      discounts: discounts,
                      taxes: taxes,
                      credits: credits,
                      payments: payments,
                      custom_fields: custom_fields,
                      public_url: public_url,
                      additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 221

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['site_id'] = 'site_id'
  @_hash['customer_id'] = 'customer_id'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['number'] = 'number'
  @_hash['sequence_number'] = 'sequence_number'
  @_hash['created_at'] = 'created_at'
  @_hash['delivery_date'] = 'delivery_date'
  @_hash['status'] = 'status'
  @_hash['collection_method'] = 'collection_method'
  @_hash['payment_instructions'] = 'payment_instructions'
  @_hash['currency'] = 'currency'
  @_hash['consolidation_level'] = 'consolidation_level'
  @_hash['product_name'] = 'product_name'
  @_hash['product_family_name'] = 'product_family_name'
  @_hash['role'] = 'role'
  @_hash['seller'] = 'seller'
  @_hash['customer'] = 'customer'
  @_hash['memo'] = 'memo'
  @_hash['billing_address'] = 'billing_address'
  @_hash['shipping_address'] = 'shipping_address'
  @_hash['subtotal_amount'] = 'subtotal_amount'
  @_hash['discount_amount'] = 'discount_amount'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['total_amount'] = 'total_amount'
  @_hash['credit_amount'] = 'credit_amount'
  @_hash['paid_amount'] = 'paid_amount'
  @_hash['refund_amount'] = 'refund_amount'
  @_hash['due_amount'] = 'due_amount'
  @_hash['line_items'] = 'line_items'
  @_hash['discounts'] = 'discounts'
  @_hash['taxes'] = 'taxes'
  @_hash['credits'] = 'credits'
  @_hash['payments'] = 'payments'
  @_hash['custom_fields'] = 'custom_fields'
  @_hash['public_url'] = 'public_url'
  @_hash
end

.nullablesObject

An array for nullable fields



305
306
307
308
309
310
311
312
313
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 305

def self.nullables
  %w[
    customer_id
    subscription_id
    number
    sequence_number
    public_url
  ]
end

.optionalsObject

An array for optional fields



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
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 263

def self.optionals
  %w[
    uid
    site_id
    customer_id
    subscription_id
    number
    sequence_number
    created_at
    delivery_date
    status
    collection_method
    payment_instructions
    currency
    consolidation_level
    product_name
    product_family_name
    role
    seller
    customer
    memo
    billing_address
    shipping_address
    subtotal_amount
    discount_amount
    tax_amount
    total_amount
    credit_amount
    paid_amount
    refund_amount
    due_amount
    line_items
    discounts
    taxes
    credits
    payments
    custom_fields
    public_url
  ]
end

Instance Method Details

#to_custom_created_atObject



525
526
527
# File 'lib/advanced_billing/models/proforma_invoice.rb', line 525

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end