Class: DTAUS::Buchung
- Inherits:
-
Object
- Object
- DTAUS::Buchung
- Defined in:
- lib/dtaus/buchung.rb
Overview
Buchungsdaten mit zwei Konten (Auftraggeber und Kunde), Betrag und Verwendungszweck
Instance Attribute Summary collapse
-
#auftraggeber_konto ⇒ Object
readonly
Returns the value of attribute auftraggeber_konto.
-
#betrag ⇒ Object
readonly
Returns the value of attribute betrag.
-
#kunden_konto ⇒ Object
readonly
Returns the value of attribute kunden_konto.
-
#positiv ⇒ Object
(also: #positiv?)
readonly
Returns the value of attribute positiv.
-
#transaktionstyp ⇒ Object
readonly
Returns the value of attribute transaktionstyp.
-
#verwendungszweck ⇒ Object
readonly
Returns the value of attribute verwendungszweck.
Instance Method Summary collapse
-
#erweiterungen ⇒ Object
Alle Erweiterungen der Buchung, bestehend aus * Inhaber Kundenkonto * Verwendungszweck dieser Buchung.
-
#initialize(params = {}) ⇒ Buchung
constructor
Buchung erstellen.
Constructor Details
#initialize(params = {}) ⇒ Buchung
Buchung erstellen
params
as Hash:
:kunden_konto
-
DTAUS::Konto des Kunden
:betrag
-
der Betrag der Buchung in
Float
:transaktionstyp
-
Art der Transaktion
-
:lastschrift
Lastschrift des Einzugsermächtigungsverfahren -
:gutschrift
Überweisungs-Gutschrift
optional, Default-Wert ist
:lastschrift
-
:verwendungszweck
-
der Verwendungszweck der Buchung; optional, Default-Wert ist “”
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/dtaus/buchung.rb', line 22 def initialize(params = {}) # defaults params = { :transaktionstyp => :lastschrift, :verwendungszweck => '' }.merge(params) [:betrag, :kunden_konto].each do |attr| raise ArgumentError.new("Missing params[:#{attr}] for new Buchung.") if params[attr].nil? end unless params[:kunden_konto].is_a?(Konto) raise DTAUSException.new("Konto expected for Parameter 'kunden_konto', got #{params[:kunden_konto].class}") end unless [:lastschrift, :gutschrift].include?(params[:transaktionstyp]) raise DTAUSException.new("Transaktionstyp has to be one of [:lastschrift, :gutschrift]") end # betrag to BigDecimal if params[:betrag].is_a? String params[:betrag] = BigDecimal.new params[:betrag].sub(',', '.') elsif params[:betrag].is_a? Numeric params[:betrag] = BigDecimal.new params[:betrag].to_s else raise DTAUSException.new("Betrag is a #{params[:betrag].class}, expected String or Numeric") end # Betrag in Cent params[:betrag] = ( params[:betrag] * 100 ).to_i if params[:betrag] == 0 raise DTAUSException.new("Betrag must not be 0.00 €!") elsif params[:betrag] > 0 @betrag = params[:betrag] @positiv = true else @betrag = params[:betrag] * -1 @positiv = false end @kunden_konto = params[:kunden_konto] @transaktionstyp = params[:transaktionstyp] @verwendungszweck = Converter.convert_text(params[:verwendungszweck]) if erweiterungen.size > 15 raise IncorrectSizeException.new("Zuviele Erweiterungen: #{erweiterungen.size}, maximal 15. Verwendungszweck zu lang?") end end |
Instance Attribute Details
#auftraggeber_konto ⇒ Object (readonly)
Returns the value of attribute auftraggeber_konto.
9 10 11 |
# File 'lib/dtaus/buchung.rb', line 9 def auftraggeber_konto @auftraggeber_konto end |
#betrag ⇒ Object (readonly)
Returns the value of attribute betrag.
9 10 11 |
# File 'lib/dtaus/buchung.rb', line 9 def betrag @betrag end |
#kunden_konto ⇒ Object (readonly)
Returns the value of attribute kunden_konto.
9 10 11 |
# File 'lib/dtaus/buchung.rb', line 9 def kunden_konto @kunden_konto end |
#positiv ⇒ Object (readonly) Also known as: positiv?
Returns the value of attribute positiv.
9 10 11 |
# File 'lib/dtaus/buchung.rb', line 9 def positiv @positiv end |
#transaktionstyp ⇒ Object (readonly)
Returns the value of attribute transaktionstyp.
9 10 11 |
# File 'lib/dtaus/buchung.rb', line 9 def transaktionstyp @transaktionstyp end |
#verwendungszweck ⇒ Object (readonly)
Returns the value of attribute verwendungszweck.
9 10 11 |
# File 'lib/dtaus/buchung.rb', line 9 def verwendungszweck @verwendungszweck end |
Instance Method Details
#erweiterungen ⇒ Object
Alle Erweiterungen der Buchung, bestehend aus
-
Inhaber Kundenkonto
-
Verwendungszweck dieser Buchung
Die Erweiterung für das auftraggeber_konto werden hier nicht aufgeführt!
76 77 78 79 |
# File 'lib/dtaus/buchung.rb', line 76 def erweiterungen kunden_konto.erweiterungen + Erweiterung.from_string(:verwendungszweck, verwendungszweck) end |