Class: Clearbooks::Invoice
Overview
Instance Attribute Summary collapse
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#bank_payment_id ⇒ Fixnum
readonly
Optional.
-
#credit_terms ⇒ Fixnum
readonly
Required.
-
#date_accrual ⇒ DateTime
readonly
Optional.
-
#date_created ⇒ DateTime
readonly
Required.
-
#date_due ⇒ DateTime
readonly
Required.
-
#date_modified ⇒ DateTime
readonly
Date this invoice was last modified.
-
#description ⇒ String
readonly
Optional.
-
#entity_id ⇒ Fixnum
readonly
Required.
-
#external_id ⇒ Fixnum
readonly
Id used to link imported invoices.
-
#gross ⇒ Object
readonly
Returns the value of attribute gross.
-
#invoice_id ⇒ Fixnum
(also: #id)
readonly
Invoice Id.
-
#invoice_number ⇒ String
readonly
Invoice number.
-
#invoice_prefix ⇒ String
readonly
Invoice prefix.
-
#items ⇒ Item
readonly
Required.
-
#net ⇒ Object
readonly
Returns the value of attribute net.
-
#paid ⇒ Object
readonly
Returns the value of attribute paid.
-
#project ⇒ Fixnum
readonly
Optional.
-
#reference ⇒ String
readonly
Optional.
-
#statement_page ⇒ String
readonly
A link to a printable invoice page with a link to download as a PDF (top right corner).
-
#status ⇒ String
readonly
Invoice status: paid, unpaid.
-
#type ⇒ String
readonly
Optional.
-
#vat ⇒ Object
readonly
Returns the value of attribute vat.
Instance Method Summary collapse
-
#initialize(data) ⇒ Invoice
constructor
A new instance of Invoice.
-
#to_savon ⇒ Hash
Returns self as Savon readable Hash.
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ Invoice
Returns a new instance of Invoice.
111 112 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 |
# File 'lib/clearbooks/model/invoice.rb', line 111 def initialize data @invoice_id = Integer data.savon(:invoice_id) rescue nil @date_created = parse_date data.savon :date_created @date_due = parse_date data.savon :date_due @credit_terms = Integer data.savon(:credit_terms) rescue nil @description = data.savon :description @entity_id = Integer data.savon(:entity_id) rescue nil @reference = data.savon :reference @project = Integer data.savon(:project) rescue nil @status = data.savon :status @invoice_prefix = data.savon :invoice_prefix @invoice_number = data.savon :invoice_number @external_id = data.savon :external_id @statement_page = CGI.unescapeHTML data.savon :statement_page rescue nil @date_modified = parse_date data.savon :date_modified @date_accrual = parse_date data.savon :date_accrual @type = data.savon :type @bank_payment_id = Integer data.savon(:bank_payment_id) rescue nil @gross = BigDecimal data.savon(:gross) rescue nil @net = BigDecimal data.savon(:net) rescue nil @vat = BigDecimal data.savon(:vat) rescue nil @paid = BigDecimal data.savon(:paid) rescue nil @balance = BigDecimal data.savon(:balance) rescue nil @external_id = data.savon(:external_id) @items = Item.build( data[:items].is_a?(Array) ? data[:items] : data[:items][:item] ) end |
Instance Attribute Details
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
14 15 16 |
# File 'lib/clearbooks/model/invoice.rb', line 14 def balance @balance end |
#bank_payment_id ⇒ Fixnum (readonly)
Optional. The bank account code.
72 73 74 |
# File 'lib/clearbooks/model/invoice.rb', line 72 def bank_payment_id @bank_payment_id end |
#credit_terms ⇒ Fixnum (readonly)
Required. The number of days after the tax point that the invoice is due.
41 42 43 |
# File 'lib/clearbooks/model/invoice.rb', line 41 def credit_terms @credit_terms end |
#date_accrual ⇒ DateTime (readonly)
Optional. The invoice accrual date.
36 37 38 |
# File 'lib/clearbooks/model/invoice.rb', line 36 def date_accrual @date_accrual end |
#date_created ⇒ DateTime (readonly)
Required. The tax point of the invoice.
25 26 27 |
# File 'lib/clearbooks/model/invoice.rb', line 25 def date_created @date_created end |
#date_due ⇒ DateTime (readonly)
Required. The date the invoice is due. Use either this field or creditTerms.
30 31 32 |
# File 'lib/clearbooks/model/invoice.rb', line 30 def date_due @date_due end |
#date_modified ⇒ DateTime (readonly)
Returns Date this invoice was last modified.
77 78 79 |
# File 'lib/clearbooks/model/invoice.rb', line 77 def date_modified @date_modified end |
#description ⇒ String (readonly)
Optional.
46 47 48 |
# File 'lib/clearbooks/model/invoice.rb', line 46 def description @description end |
#entity_id ⇒ Fixnum (readonly)
Required. The customer or supplier id.
51 52 53 |
# File 'lib/clearbooks/model/invoice.rb', line 51 def entity_id @entity_id end |
#external_id ⇒ Fixnum (readonly)
Returns Id used to link imported invoices.
81 82 83 |
# File 'lib/clearbooks/model/invoice.rb', line 81 def external_id @external_id end |
#gross ⇒ Object (readonly)
Returns the value of attribute gross.
14 15 16 |
# File 'lib/clearbooks/model/invoice.rb', line 14 def gross @gross end |
#invoice_id ⇒ Fixnum (readonly) Also known as: id
Returns Invoice Id.
21 22 23 |
# File 'lib/clearbooks/model/invoice.rb', line 21 def invoice_id @invoice_id end |
#invoice_number ⇒ String (readonly)
Returns Invoice number.
85 86 87 |
# File 'lib/clearbooks/model/invoice.rb', line 85 def invoice_number @invoice_number end |
#invoice_prefix ⇒ String (readonly)
Returns Invoice prefix.
102 103 104 |
# File 'lib/clearbooks/model/invoice.rb', line 102 def invoice_prefix @invoice_prefix end |
#items ⇒ Item (readonly)
Required.
89 90 91 |
# File 'lib/clearbooks/model/invoice.rb', line 89 def items @items end |
#net ⇒ Object (readonly)
Returns the value of attribute net.
14 15 16 |
# File 'lib/clearbooks/model/invoice.rb', line 14 def net @net end |
#paid ⇒ Object (readonly)
Returns the value of attribute paid.
14 15 16 |
# File 'lib/clearbooks/model/invoice.rb', line 14 def paid @paid end |
#project ⇒ Fixnum (readonly)
Optional. The id of the project to assign the invoice to.
61 62 63 |
# File 'lib/clearbooks/model/invoice.rb', line 61 def project @project end |
#reference ⇒ String (readonly)
Optional. A reference string for the invoice.
56 57 58 |
# File 'lib/clearbooks/model/invoice.rb', line 56 def reference @reference end |
#statement_page ⇒ String (readonly)
Returns A link to a printable invoice page with a link to download as a PDF (top right corner).
94 95 96 |
# File 'lib/clearbooks/model/invoice.rb', line 94 def statement_page @statement_page end |
#status ⇒ String (readonly)
Returns Invoice status: paid, unpaid.
98 99 100 |
# File 'lib/clearbooks/model/invoice.rb', line 98 def status @status end |
#type ⇒ String (readonly)
Optional. A string identifying the type of the invoice. Value one of: purchases, sales, cn-sales, cn-purchases.
66 67 68 |
# File 'lib/clearbooks/model/invoice.rb', line 66 def type @type end |
#vat ⇒ Object (readonly)
Returns the value of attribute vat.
14 15 16 |
# File 'lib/clearbooks/model/invoice.rb', line 14 def vat @vat end |
Instance Method Details
#to_savon ⇒ Hash
Returns self as Savon readable Hash
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/clearbooks/model/invoice.rb', line 150 def to_savon { invoice: { :@dateCreated => @date_created, :@entityId => @entity_id, :@type => @type, :@dateDue => @date_due, :@dateAccural => @date_accural, :@creditTerms => @credit_terms, :@reference => @reference, :@project => @project, :@external_id => @external_id, description: @description, items: { item: items.map(&:to_savon) } }.compact } end |