Class: Clearbooks::Item
Overview
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
Required.
-
#quantity ⇒ Fixnum
readonly
Required.
-
#type ⇒ String
readonly
Required.
-
#unit_price ⇒ BigDecimal
readonly
Required.
-
#vat ⇒ String
readonly
Required.
-
#vat_rate ⇒ String
readonly
Required.
Instance Method Summary collapse
-
#initialize(data) ⇒ Item
constructor
A new instance of Item.
-
#to_savon ⇒ Hash
Returns self as Savon readable Hash.
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ Item
Returns a new instance of Item.
50 51 52 53 54 55 56 57 |
# File 'lib/clearbooks/model/item.rb', line 50 def initialize data @description = data.savon :description @unit_price = BigDecimal.new data.savon(:unit_price), 2 @quantity = data.savon(:quantity).to_i @type = data.savon :type @vat = data.savon :vat @vat_rate = data.savon :vat_rate end |
Instance Attribute Details
#description ⇒ String (readonly)
Required.
16 17 18 |
# File 'lib/clearbooks/model/item.rb', line 16 def description @description end |
#quantity ⇒ Fixnum (readonly)
Required.
26 27 28 |
# File 'lib/clearbooks/model/item.rb', line 26 def quantity @quantity end |
#type ⇒ String (readonly)
Required. The account code identifying the revenue stream.
31 32 33 |
# File 'lib/clearbooks/model/item.rb', line 31 def type @type end |
#unit_price ⇒ BigDecimal (readonly)
Required.
21 22 23 |
# File 'lib/clearbooks/model/item.rb', line 21 def unit_price @unit_price end |
#vat ⇒ String (readonly)
Required. The total amount of VAT in pounds. Use either this field or vat_rate.
36 37 38 |
# File 'lib/clearbooks/model/item.rb', line 36 def vat @vat end |
#vat_rate ⇒ String (readonly)
Required. The percentage VAT as a decimal number. Use either this field or vat.
41 42 43 |
# File 'lib/clearbooks/model/item.rb', line 41 def vat_rate @vat_rate end |
Instance Method Details
#to_savon ⇒ Hash
Returns self as Savon readable Hash
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/clearbooks/model/item.rb', line 63 def to_savon { :@unitPrice => @unit_price.to_f, :@quantity => @quantity, :@type => @type, :@vat => @vat, :@vatRate => @vat_rate, :description => @description }.compact end |