Class: ODDB::Business::Invoice::Item

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, text, quantity, unit, price) ⇒ Item

Returns a new instance of Item.



15
16
17
18
19
# File 'lib/oddb/business/invoice.rb', line 15

def initialize(type, text, quantity, unit, price)
  @type, @text, @quantity, @unit, @price \
    = type, text, quantity.to_i, unit.to_s, price.to_f
  @time = Time.now
end

Instance Attribute Details

#expiry_timeObject

Returns the value of attribute expiry_time.



14
15
16
# File 'lib/oddb/business/invoice.rb', line 14

def expiry_time
  @expiry_time
end

#priceObject (readonly)

Returns the value of attribute price.



13
14
15
# File 'lib/oddb/business/invoice.rb', line 13

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



13
14
15
# File 'lib/oddb/business/invoice.rb', line 13

def quantity
  @quantity
end

#textObject (readonly)

Returns the value of attribute text.



13
14
15
# File 'lib/oddb/business/invoice.rb', line 13

def text
  @text
end

#timeObject (readonly)

Returns the value of attribute time.



13
14
15
# File 'lib/oddb/business/invoice.rb', line 13

def time
  @time
end

#typeObject (readonly)

Returns the value of attribute type.



13
14
15
# File 'lib/oddb/business/invoice.rb', line 13

def type
  @type
end

#vatObject (readonly)

Returns the value of attribute vat.



13
14
15
# File 'lib/oddb/business/invoice.rb', line 13

def vat
  @vat
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/oddb/business/invoice.rb', line 20

def expired?
  @expiry_time && @expiry_time < Time.now
end

#total_bruttoObject



23
24
25
# File 'lib/oddb/business/invoice.rb', line 23

def total_brutto
  total_netto + vat
end

#total_nettoObject



26
27
28
# File 'lib/oddb/business/invoice.rb', line 26

def total_netto
  @price * @quantity
end

#ydim_dataObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/oddb/business/invoice.rb', line 32

def ydim_data
  {
    :expiry_time	=>	@expiry_time,
    :price				=>	@price,
    :quantity			=>	@quantity,
    :text					=>	@text,
    :time					=>	@time,
    :unit					=>	@unit,
  }
end