Class: KingDta::Booking
- Inherits:
-
Object
- Object
- KingDta::Booking
- 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
-
#account ⇒ Object
Returns the value of attribute account.
-
#account_key ⇒ Object
Returns the value of attribute account_key.
-
#text ⇒ Object
Returns the value of attribute text.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(account, value, text = nil, account_key = nil) ⇒ Booking
constructor
Eine Buchung ist definiert durch: - Konto (siehe Klasse Konto - Betrag Der Betrag kann , oder . als Dezimaltrenner enthalten. - optional Buchungstext.
- #pos? ⇒ Boolean
Methods included from Helper
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
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( account, value, text=nil, account_key=nil ) raise Exception.new("Hey, a booking should have an Account") unless account.kind_of?( Account ) @account = account @text = text ? convert_text( text ) : text @account_key = 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
#account ⇒ Object
Returns the value of attribute account.
11 12 13 |
# File 'lib/king_dta/booking.rb', line 11 def account @account end |
#account_key ⇒ Object
Returns the value of attribute account_key.
11 12 13 |
# File 'lib/king_dta/booking.rb', line 11 def account_key @account_key end |
#text ⇒ Object
Returns the value of attribute text.
11 12 13 |
# File 'lib/king_dta/booking.rb', line 11 def text @text end |
#value ⇒ Object
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
45 |
# File 'lib/king_dta/booking.rb', line 45 def pos?; @pos end |