Class: KingDta::Booking

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/king_dta/booking.rb

Constant Summary collapse

LASTSCHRIFT_ABBUCHUNG =

Die am häufigsten benötigten Textschlüssel

'04000'
LASTSCHRIFT_EINZUGSERMAECHTIGUNG =
'05000'
UEBERWEISUNG_GUTSCHRIFT =
'51000'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#convert_text

Constructor Details

#initialize(account, value, text = nil, account_key = nil) ⇒ Booking

Eine Buchung ist definiert durch:

  • Konto (siehe Klasse Konto

  • Betrag

Der Betrag kann , oder . als Dezimaltrenner enthalten.
  • optional Buchungstext

Raises:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/king_dta/booking.rb', line 17

def initialize( , value, text=nil, =nil )
  raise Exception.new("Hey, a booking should have an Account") unless .kind_of?(  )
  @account = 
  @text = text ? convert_text( text ) : text
  @account_key = 
  if value.is_a?(String)
    value = BigDecimal.new value.sub(',', '.')
  elsif value.is_a?(Numeric)
    value = BigDecimal.new value.to_s
  else
    raise Exception.new("Gimme a value as a String or Numeric. You gave me a #{value.class}")
  end
  value = ( value * 100 ).to_i  #€-Cent
  if value == 0
    raise Exception.new("A booking of 0.00 € makes no sence")
  elsif value > 0
    @value = value
    @pos   = true
  else
    @value = -value
    @pos   = false
  end
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



11
12
13
# File 'lib/king_dta/booking.rb', line 11

def 
  @account
end

#account_keyObject

Returns the value of attribute account_key.



11
12
13
# File 'lib/king_dta/booking.rb', line 11

def 
  @account_key
end

#textObject

Returns the value of attribute text.



11
12
13
# File 'lib/king_dta/booking.rb', line 11

def text
  @text
end

#valueObject

Returns the value of attribute value.



11
12
13
# File 'lib/king_dta/booking.rb', line 11

def value
  @value
end

Instance Method Details

#pos?Boolean

Returns:

  • (Boolean)


45
# File 'lib/king_dta/booking.rb', line 45

def pos?; @pos end