lib/datev/export.rb in datev-0.2.2 vs lib/datev/export.rb in datev-0.2.3
- old
+ new
@@ -4,27 +4,12 @@
module Datev
class Export
CSV_OPTIONS = { :col_sep => ';', :encoding => 'windows-1252' }
- DEFAULT_HEADER_ATTRIBUTES = {
- 'DATEV-Format-KZ' => 'EXTF',
- 'Versionsnummer' => 510,
- 'Datenkategorie' => 21,
- 'Formatname' => 'Buchungsstapel',
- 'Formatversion' => 7,
- 'Erzeugt am' => Time.now.utc,
- 'Sachkontenlänge' => 4,
- 'Bezeichnung' => 'Buchungen',
- 'Buchungstyp' => 1,
- 'WKZ' => 'EUR'
- }
-
def initialize(header_attributes)
- raise ArgumentError.new('Hash required') unless header_attributes.is_a?(Hash)
-
- @header = Header.new DEFAULT_HEADER_ATTRIBUTES.merge(header_attributes)
+ @header = Header.new header_attributes
@rows = []
end
def <<(attributes)
@rows << Datev::Booking.new(attributes)
@@ -43,14 +28,14 @@
end
private
def write(csv)
- csv << @header.to_a
+ csv << @header.output
csv << Booking.fields.map(&:name)
@rows.each do |row|
- csv << row.to_a
+ csv << row.output(@header)
end
end
end
end