datev 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f9e40ec72d19dbed69b6822ea7620bd8492d777
4
- data.tar.gz: b7918aecf4f2f6f663cf6f6e1e253665a8ecd61e
3
+ metadata.gz: 9be98f6189b13517bf847be2bdddc9ce7f68eb65
4
+ data.tar.gz: 3e8ce045af515ed7d627a0e4ffca52b16b7e1059
5
5
  SHA512:
6
- metadata.gz: 2946308d40559ff1797aa4e6cc0577cabdd01db663aa1c01092432c58b5a2cbc53335b4917ef4cc1ab1b617ab379d747e8e0aa27582ee09c878c39cc585e32c5
7
- data.tar.gz: d6f547b2106860631de50cb5612c94e999b6e6eafc52234713de68938ceaf05c1080e120a19481c1821a210a7fd3da8dce0905374837a4a6cbe8fbbffa595d3a
6
+ metadata.gz: 49a002ffda0f1be07af7bb3e17e188b61c449e571f638a097c4c7ac64bc67b977a45e629aa9cba19a5108e5fb0a594a2121d584cd43aa0d34d270a351da0f4cf
7
+ data.tar.gz: bbe6649cf4e9fa92e0e0ffb336b4617604939ab46467a2aa4fc2b3db4f0c77127b8b51226d72b757d7d8705838cdc4579fbe61713229d0e59875afaebfee4c3c
data/README.md CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
25
25
  ## Usage
26
26
 
27
27
  ```ruby
28
- export = Datev::Export.new(
28
+ export = Datev::BookingExport.new(
29
29
  'Herkunft' => 'XY',
30
30
  'Exportiert von' => 'Chief Accounting Officer',
31
31
  'Berater' => 123,
@@ -0,0 +1,5 @@
1
+ EXTF;510;20;Kontenbeschriftungen;2;20160623152500000;;XY;Chief Accounting Officer;;123;456;20160101;4;;;Beispiel-Konten;;;;;;;;;
2
+ Konto;Kontenbeschriftung;Sprach-ID
3
+ 400;Betriebsausstattung;de-DE
4
+ 1000;Kasse;de-DE
5
+ 1200;Girokonto;de-DE
data/lib/datev.rb CHANGED
@@ -1,2 +1,5 @@
1
1
  require 'datev/version'
2
- require 'datev/export'
2
+ require 'datev/account'
3
+ require 'datev/booking'
4
+ require 'datev/booking_export'
5
+ require 'datev/account_export'
@@ -0,0 +1,21 @@
1
+ require 'datev/base'
2
+
3
+ module Datev
4
+ class Account < Base
5
+ # http://www.datev.de/dnlexom/client/app/index.html#/document/1036228/D103622800011
6
+
7
+ # 1
8
+ field 'Konto', :integer, :limit => 8, :required => true
9
+ # Sachkontennummer (max. 8-stellig).
10
+
11
+ # 2
12
+ field 'Kontenbeschriftung', :string, :limit => 40
13
+ # Beschriftung des Sachkontos
14
+
15
+ # 3
16
+ field 'Sprach-ID', :string, :limit => 5
17
+ # Sprach-ID der Kontenbeschriftung
18
+ # de-DE = Deutsch
19
+ # en-GB = Englisch
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'datev/export'
2
+ require 'datev/account_header'
3
+ require 'datev/account'
4
+
5
+ module Datev
6
+ class AccountExport < Export
7
+ self.header_class = AccountHeader
8
+ self.row_class = Account
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ require 'datev/base'
2
+
3
+ module Datev
4
+ class AccountHeader < Header
5
+ self.default_attributes = {
6
+ 'DATEV-Format-KZ' => 'EXTF',
7
+ 'Versionsnummer' => 510,
8
+ 'Datenkategorie' => 20,
9
+ 'Formatname' => 'Kontenbeschriftungen',
10
+ 'Formatversion' => 2,
11
+ 'Erzeugt am' => Time.now.utc,
12
+ 'Sachkontenlänge' => 4,
13
+ 'Bezeichnung' => 'Kontenbeschriftungen'
14
+ }
15
+ end
16
+ end
data/lib/datev/base.rb CHANGED
@@ -3,10 +3,13 @@ require 'datev/field'
3
3
  module Datev
4
4
  class Base
5
5
  class << self
6
- attr_accessor :fields
7
- end
6
+ attr_accessor :fields, :default_attributes
8
7
 
9
- attr_accessor :attributes
8
+ def inherited(subclass)
9
+ subclass.fields = self.fields
10
+ subclass.default_attributes = self.default_attributes
11
+ end
12
+ end
10
13
 
11
14
  def self.field(name, type, options={}, &block)
12
15
  self.fields ||= []
@@ -23,8 +26,10 @@ module Datev
23
26
  self.fields.find { |f| f.name == name }
24
27
  end
25
28
 
29
+ attr_accessor :attributes
30
+
26
31
  def initialize(attributes)
27
- self.attributes = {}
32
+ self.attributes = self.class.default_attributes || {}
28
33
 
29
34
  raise ArgumentError.new('Hash required') unless attributes.is_a?(Hash)
30
35
 
data/lib/datev/booking.rb CHANGED
@@ -2,7 +2,7 @@ require 'datev/base'
2
2
 
3
3
  module Datev
4
4
  class Booking < Base
5
- # http://www.datev.de/dnlexom/client/app/index.html#/document/1036228
5
+ # http://www.datev.de/dnlexom/client/app/index.html#/document/1036228/D103622800010
6
6
 
7
7
  # 1
8
8
  field 'Umsatz (ohne Soll/Haben-Kz)', :decimal, :precision => 12, :scale => 2, :required => true
@@ -0,0 +1,10 @@
1
+ require 'datev/export'
2
+ require 'datev/booking_header'
3
+ require 'datev/booking'
4
+
5
+ module Datev
6
+ class BookingExport < Export
7
+ self.header_class = BookingHeader
8
+ self.row_class = Booking
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ require 'datev/base'
2
+
3
+ module Datev
4
+ class BookingHeader < Header
5
+ self.default_attributes = {
6
+ 'DATEV-Format-KZ' => 'EXTF',
7
+ 'Versionsnummer' => 510,
8
+ 'Datenkategorie' => 21,
9
+ 'Formatname' => 'Buchungsstapel',
10
+ 'Formatversion' => 7,
11
+ 'Erzeugt am' => Time.now.utc,
12
+ 'Sachkontenlänge' => 4,
13
+ 'Bezeichnung' => 'Buchungen',
14
+ 'Buchungstyp' => 1,
15
+ 'WKZ' => 'EUR'
16
+ }
17
+ end
18
+ end
data/lib/datev/export.rb CHANGED
@@ -1,18 +1,21 @@
1
1
  require 'csv'
2
2
  require 'datev/header'
3
- require 'datev/booking'
4
3
 
5
4
  module Datev
6
5
  class Export
7
6
  CSV_OPTIONS = { :col_sep => ';', :encoding => 'windows-1252' }
8
7
 
8
+ class << self
9
+ attr_accessor :header_class, :row_class
10
+ end
11
+
9
12
  def initialize(header_attributes)
10
- @header = Header.new header_attributes
13
+ @header = self.class.header_class.new(header_attributes)
11
14
  @rows = []
12
15
  end
13
16
 
14
17
  def <<(attributes)
15
- @rows << Datev::Booking.new(attributes)
18
+ @rows << self.class.row_class.new(attributes)
16
19
  end
17
20
 
18
21
  def to_s
@@ -31,7 +34,7 @@ module Datev
31
34
 
32
35
  def write(csv)
33
36
  csv << @header.output
34
- csv << Booking.fields.map(&:name)
37
+ csv << self.class.row_class.fields.map(&:name)
35
38
 
36
39
  @rows.each do |row|
37
40
  csv << row.output(@header)
data/lib/datev/field.rb CHANGED
@@ -75,7 +75,7 @@ module Datev
75
75
 
76
76
  case type
77
77
  when :string
78
- value
78
+ value.slice(0, limit || 255)
79
79
  when :integer
80
80
  value.to_s
81
81
  when :decimal
data/lib/datev/header.rb CHANGED
@@ -2,24 +2,6 @@ require 'datev/base'
2
2
 
3
3
  module Datev
4
4
  class Header < Base
5
- DEFAULT_ATTRIBUTES = {
6
- 'DATEV-Format-KZ' => 'EXTF',
7
- 'Versionsnummer' => 510,
8
- 'Datenkategorie' => 21,
9
- 'Formatname' => 'Buchungsstapel',
10
- 'Formatversion' => 7,
11
- 'Erzeugt am' => Time.now.utc,
12
- 'Sachkontenlänge' => 4,
13
- 'Bezeichnung' => 'Buchungen',
14
- 'Buchungstyp' => 1,
15
- 'WKZ' => 'EUR'
16
- }
17
-
18
- def initialize(attributes={})
19
- raise ArgumentError.new('Hash required') unless attributes.is_a?(Hash)
20
- super DEFAULT_ATTRIBUTES.merge(attributes)
21
- end
22
-
23
5
  # 1
24
6
  field 'DATEV-Format-KZ', :string, :limit => 4
25
7
  # vom Datev angegeben
@@ -32,17 +14,14 @@ module Datev
32
14
  # 3
33
15
  field 'Datenkategorie', :integer, :limit => 2
34
16
  # vom Datev angegeben
35
- # Buchungsstapel = 21
36
17
 
37
18
  # 4
38
19
  field 'Formatname', :string
39
20
  # vom Datev angegeben
40
- # 'Buchungsstapel'
41
21
 
42
22
  # 5
43
23
  field 'Formatversion', :integer, :limit => 3
44
24
  # vom Datev angegeben
45
- # Buchungsstapel = 2
46
25
 
47
26
  # 6
48
27
  field 'Erzeugt am', :date, :format => '%Y%m%d%H%M%S%L'
data/lib/datev/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Datev
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,9 +100,15 @@ files:
100
100
  - bin/setup
101
101
  - datev.gemspec
102
102
  - examples/EXTF_Buchungsstapel.csv
103
+ - examples/EXTF_Kontenbeschriftungen.csv
103
104
  - lib/datev.rb
105
+ - lib/datev/account.rb
106
+ - lib/datev/account_export.rb
107
+ - lib/datev/account_header.rb
104
108
  - lib/datev/base.rb
105
109
  - lib/datev/booking.rb
110
+ - lib/datev/booking_export.rb
111
+ - lib/datev/booking_header.rb
106
112
  - lib/datev/export.rb
107
113
  - lib/datev/field.rb
108
114
  - lib/datev/header.rb