Class: FacturX::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/factur_x/invoice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number:, issued_on:, seller:, buyer:, lines:, tax_breakdowns:, totals:, type_code: Codes::COMMERCIAL_INVOICE, currency: "EUR", business_process: nil, notes: [], buyer_reference: nil, payee: nil, tax_representative: nil, ship_to: nil, delivered_on: nil, payment_reference: nil, creditor_reference: nil, payment_means: [], payment_terms: nil, allowances: [], charges: [], purchase_order_reference: nil, sales_order_reference: nil, contract_reference: nil, project_reference: nil, project_name: nil, despatch_advice_reference: nil, receiving_advice_reference: nil, preceding_invoices: [], billing_period_start: nil, billing_period_end: nil) ⇒ Invoice

Returns a new instance of Invoice.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/factur_x/invoice.rb', line 17

def initialize(number:, issued_on:, seller:, buyer:, lines:, tax_breakdowns:, totals:,
               type_code: Codes::COMMERCIAL_INVOICE, currency: "EUR",
               business_process: nil, notes: [], buyer_reference: nil,
               payee: nil, tax_representative: nil, ship_to: nil, delivered_on: nil,
               payment_reference: nil, creditor_reference: nil,
               payment_means: [], payment_terms: nil,
               allowances: [], charges: [],
               purchase_order_reference: nil, sales_order_reference: nil,
               contract_reference: nil, project_reference: nil, project_name: nil,
               despatch_advice_reference: nil, receiving_advice_reference: nil,
               preceding_invoices: [],
               billing_period_start: nil, billing_period_end: nil)
  @number = number
  @type_code = type_code
  @issued_on = issued_on
  @currency = currency
  @business_process = business_process
  @notes = Array(notes)
  @buyer_reference = buyer_reference
  @seller = seller
  @buyer = buyer
  @payee = payee
  @tax_representative = tax_representative
  @ship_to = ship_to
  @delivered_on = delivered_on
  @payment_reference = payment_reference
  @creditor_reference = creditor_reference
  @payment_means = Array(payment_means)
  @payment_terms = payment_terms
  @lines = number_lines(Array(lines))
  @allowances = Array(allowances)
  @charges = Array(charges)
  @tax_breakdowns = Array(tax_breakdowns)
  @totals = totals
  @purchase_order_reference = purchase_order_reference
  @sales_order_reference = sales_order_reference
  @contract_reference = contract_reference
  @project_reference = project_reference
  @project_name = project_name
  @despatch_advice_reference = despatch_advice_reference
  @receiving_advice_reference = receiving_advice_reference
  @preceding_invoices = Array(preceding_invoices)
  @billing_period_start = billing_period_start
  @billing_period_end = billing_period_end
end

Instance Attribute Details

#allowancesObject (readonly)

Returns the value of attribute allowances.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def allowances
  @allowances
end

#billing_period_endObject (readonly)

Returns the value of attribute billing_period_end.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def billing_period_end
  @billing_period_end
end

#billing_period_startObject (readonly)

Returns the value of attribute billing_period_start.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def billing_period_start
  @billing_period_start
end

#business_processObject (readonly)

Returns the value of attribute business_process.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def business_process
  @business_process
end

#buyerObject (readonly)

Returns the value of attribute buyer.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def buyer
  @buyer
end

#buyer_referenceObject (readonly)

Returns the value of attribute buyer_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def buyer_reference
  @buyer_reference
end

#chargesObject (readonly)

Returns the value of attribute charges.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def charges
  @charges
end

#contract_referenceObject (readonly)

Returns the value of attribute contract_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def contract_reference
  @contract_reference
end

#creditor_referenceObject (readonly)

Returns the value of attribute creditor_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def creditor_reference
  @creditor_reference
end

#currencyObject (readonly)

Returns the value of attribute currency.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def currency
  @currency
end

#delivered_onObject (readonly)

Returns the value of attribute delivered_on.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def delivered_on
  @delivered_on
end

#despatch_advice_referenceObject (readonly)

Returns the value of attribute despatch_advice_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def despatch_advice_reference
  @despatch_advice_reference
end

#issued_onObject (readonly)

Returns the value of attribute issued_on.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def issued_on
  @issued_on
end

#linesObject (readonly)

Returns the value of attribute lines.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def lines
  @lines
end

#notesObject (readonly)

Returns the value of attribute notes.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def notes
  @notes
end

#numberObject (readonly)

Returns the value of attribute number.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def number
  @number
end

#payeeObject (readonly)

Returns the value of attribute payee.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def payee
  @payee
end

#payment_meansObject (readonly)

Returns the value of attribute payment_means.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def payment_means
  @payment_means
end

#payment_referenceObject (readonly)

Returns the value of attribute payment_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def payment_reference
  @payment_reference
end

#payment_termsObject (readonly)

Returns the value of attribute payment_terms.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def payment_terms
  @payment_terms
end

#preceding_invoicesObject (readonly)

Returns the value of attribute preceding_invoices.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def preceding_invoices
  @preceding_invoices
end

#project_nameObject (readonly)

Returns the value of attribute project_name.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def project_name
  @project_name
end

#project_referenceObject (readonly)

Returns the value of attribute project_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def project_reference
  @project_reference
end

#purchase_order_referenceObject (readonly)

Returns the value of attribute purchase_order_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def purchase_order_reference
  @purchase_order_reference
end

#receiving_advice_referenceObject (readonly)

Returns the value of attribute receiving_advice_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def receiving_advice_reference
  @receiving_advice_reference
end

#sales_order_referenceObject (readonly)

Returns the value of attribute sales_order_reference.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def sales_order_reference
  @sales_order_reference
end

#sellerObject (readonly)

Returns the value of attribute seller.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def seller
  @seller
end

#ship_toObject (readonly)

Returns the value of attribute ship_to.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def ship_to
  @ship_to
end

#tax_breakdownsObject (readonly)

Returns the value of attribute tax_breakdowns.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def tax_breakdowns
  @tax_breakdowns
end

#tax_representativeObject (readonly)

Returns the value of attribute tax_representative.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def tax_representative
  @tax_representative
end

#totalsObject (readonly)

Returns the value of attribute totals.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def totals
  @totals
end

#type_codeObject (readonly)

Returns the value of attribute type_code.



7
8
9
# File 'lib/factur_x/invoice.rb', line 7

def type_code
  @type_code
end

Instance Method Details

#billing_period?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/factur_x/invoice.rb', line 67

def billing_period?
  !billing_period_start.nil? || !billing_period_end.nil?
end

#credit_note?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/factur_x/invoice.rb', line 63

def credit_note?
  type_code == Codes::CREDIT_NOTE
end

#to_xml(**options) ⇒ Object



71
72
73
# File 'lib/factur_x/invoice.rb', line 71

def to_xml(**options)
  FacturX.build(self, **options)
end