ABO 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/ABO.gemspec +30 -0
  2. data/CHANGES.rdoc +11 -0
  3. data/Manifest +6 -0
  4. data/README.rdoc +11 -0
  5. data/Rakefile +14 -0
  6. data/init.rb +1 -0
  7. data/lib/abo.rb +199 -0
  8. metadata +75 -0
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ABO}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Josef \305\240im\303\241nek"]
9
+ s.date = %q{2010-03-18}
10
+ s.description = %q{RUBY ABO banking format library}
11
+ s.email = %q{retro@ballgag.cz}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/abo.rb"]
13
+ s.files = ["CHANGES.rdoc", "Manifest", "README.rdoc", "Rakefile", "init.rb", "lib/abo.rb", "ABO.gemspec"]
14
+ s.homepage = %q{http://github.com/hexmotive/ABO}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "ABO", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{abo}
18
+ s.rubygems_version = %q{1.3.6}
19
+ s.summary = %q{RUBY ABO banking format library}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ = CHANGELOG
2
+
3
+ == 0.0.2
4
+
5
+ * New gem
6
+
7
+ == 0.0.1
8
+
9
+ * First public version
10
+ * GEM builded
11
+ * First readme
@@ -0,0 +1,6 @@
1
+ CHANGES.rdoc
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ init.rb
6
+ lib/abo.rb
@@ -0,0 +1,11 @@
1
+ == Preface
2
+
3
+ Format ABO is commonly used in the Czech Republic and Slovak for financial reporting.
4
+
5
+ == Specification
6
+
7
+ {Format specification (Czech)}[http://www.csas.cz/banka/content/inet/internet/cs/ABO_format.pdf]
8
+
9
+ == Installation
10
+
11
+ $ sudo gem install ABO
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('ABO', '0.0.2') do |p|
6
+ p.description = "RUBY ABO banking format library"
7
+ p.url = "http://github.com/hexmotive/ABO"
8
+ p.author = "Josef Šimánek"
9
+ p.email = "retro@ballgag.cz"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'ABO'
@@ -0,0 +1,199 @@
1
+ module ABO
2
+
3
+ class WrongFormatError < StandardError; end
4
+
5
+ class Writer
6
+ #záznam UHL1
7
+ attr_accessor :record
8
+
9
+ #Hlavička účetního souboru
10
+ attr_accessor :file_header
11
+
12
+ #Hlavička skupiny
13
+ attr_accessor :group_header
14
+
15
+ #Položka jednotlivého příkazu
16
+ attr_accessor :payment_order
17
+
18
+ class Record
19
+
20
+ #datum
21
+ attr_accessor :date
22
+
23
+ #název klienta
24
+ attr_accessor :client_name
25
+
26
+ #číslo klienta
27
+ attr_accessor :client_number
28
+
29
+ #interval účetních souborů, začátek
30
+ attr_accessor :interval_start
31
+
32
+ #interval účetních souborů, konec
33
+ attr_accessor :interval_stop
34
+
35
+ #kód pevná část
36
+ attr_accessor :public_code
37
+
38
+ #kód tajná část
39
+ attr_accessor :secret_code
40
+
41
+ def date=(value)
42
+ raise ABO::WrongFormatError, "Record#date=" unless value.instance_of?(Date)
43
+ @date = value
44
+ end
45
+
46
+ def date
47
+ raise ABO::WrongFormatError, "Record#date" unless @date.instance_of?(Date)
48
+ @date.strftime("%d%m%y")
49
+ end
50
+
51
+ def client_name
52
+ raise ABO::WrongFormatError, "Record#client_name" unless @client_name.instance_of?(String)
53
+ @client_name.rjust(20)
54
+ end
55
+
56
+ def client_number
57
+ raise ABO::WrongFormatError, "Record#client_number" unless @client_number.instance_of?(String)
58
+ @client_number.rjust(10)
59
+ end
60
+
61
+ def interval_start
62
+ raise ABO::WrongFormatError, "Record#interval_start" unless @interval_start.instance_of?(Fixnum)
63
+ "%03d" % @interval_start
64
+ end
65
+
66
+ def interval_stop
67
+ raise ABO::WrongFormatError, "Record#interval_stop" unless @interval_stop.instance_of?(Fixnum)
68
+ "%03d" % @interval_stop
69
+ end
70
+
71
+ def to_abo
72
+ "UHL1#{date}#{client_name}#{client_number}#{interval_start}#{interval_stop}#{public_code}#{secret_code}\n"
73
+ end
74
+ end
75
+
76
+ class FileHeader
77
+
78
+ PAYMENT = "1501"
79
+ INKASO = "1502"
80
+
81
+ #druh dat
82
+ attr_accessor :date_type
83
+
84
+ #číslo účetního souboru
85
+ attr_accessor :file_number
86
+
87
+ #směrový kód banky
88
+ attr_accessor :bank_code
89
+
90
+ def end_block
91
+ "5 +\n"
92
+ end
93
+
94
+ def to_abo
95
+ "1 #{date_type} #{file_number} #{bank_code}\n"
96
+ end
97
+
98
+ end
99
+
100
+ class GroupHeader
101
+
102
+ #číslo účtu příkazce
103
+ attr_accessor :payers_account_number
104
+
105
+ #celková částka skupiny
106
+ attr_accessor :group_amount
107
+
108
+ #datum splatnosti
109
+ attr_accessor :due_date
110
+
111
+ def due_date=(value)
112
+ raise ABO::WrongFormatError unless value.instance_of?(Date)
113
+ @due_date = value
114
+ end
115
+
116
+ def due_date
117
+ raise ABO::WrongFormatError unless @due_date.instance_of?(Date)
118
+ @due_date.strftime("%d%m%y")
119
+ end
120
+
121
+ def end_block
122
+ "3 +\n"
123
+ end
124
+
125
+ def to_abo
126
+ "2 #{payers_account_number} #{group_amount} #{due_date}\n"
127
+ end
128
+
129
+ end
130
+
131
+ class PaymentOrder
132
+
133
+ #číslo účtu kredit
134
+ attr_accessor :credit_account_number
135
+
136
+ #částka
137
+ attr_accessor :amount
138
+
139
+ #variabilní symbol
140
+ attr_accessor :variable_symbol
141
+
142
+ #konstantní symbol
143
+ attr_accessor :constant_symbol
144
+
145
+ def amount
146
+ "%012d" % @amount
147
+ end
148
+
149
+ def variable_symbol
150
+ "%010d" % @variable_symbol.to_i
151
+ end
152
+
153
+ def constant_symbol
154
+ "%010d" % @constant_symbol.to_i
155
+ end
156
+
157
+ def to_abo
158
+ "#{credit_account_number} #{amount} #{variable_symbol} #{constant_symbol}\n"
159
+ end
160
+
161
+ end
162
+
163
+ def initialize
164
+ @record = Record.new
165
+ @record.interval_start = 1
166
+ @record.interval_stop = 1
167
+ @file_header = FileHeader.new
168
+ @group_header = GroupHeader.new
169
+ @payment_orders = []
170
+ end
171
+
172
+ def to_abo
173
+ prepare
174
+ string = ""
175
+ string << @record.to_abo
176
+ string << @file_header.to_abo
177
+ string << @group_header.to_abo
178
+ @payment_orders.each do |p|
179
+ string << p.to_abo
180
+ end
181
+ string << @group_header.end_block
182
+ string << @file_header.end_block
183
+
184
+ string
185
+ end
186
+
187
+ private
188
+
189
+ def prepare
190
+ @group_header.group_amount = sum_amounts
191
+ end
192
+
193
+ def sum_amounts
194
+ @payment_orders.inject(0){|p,c| p + c.amount.to_i}
195
+ end
196
+
197
+ end
198
+
199
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ABO
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - "Josef \xC5\xA0im\xC3\xA1nek"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-18 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: RUBY ABO banking format library
22
+ email: retro@ballgag.cz
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.rdoc
29
+ - lib/abo.rb
30
+ files:
31
+ - CHANGES.rdoc
32
+ - Manifest
33
+ - README.rdoc
34
+ - Rakefile
35
+ - init.rb
36
+ - lib/abo.rb
37
+ - ABO.gemspec
38
+ has_rdoc: true
39
+ homepage: http://github.com/hexmotive/ABO
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --line-numbers
45
+ - --inline-source
46
+ - --title
47
+ - ABO
48
+ - --main
49
+ - README.rdoc
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 1
65
+ - 2
66
+ version: "1.2"
67
+ requirements: []
68
+
69
+ rubyforge_project: abo
70
+ rubygems_version: 1.3.6
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: RUBY ABO banking format library
74
+ test_files: []
75
+