abo_parser 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/abo.rb +32 -4
- data/lib/abo_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45bd0bd8188bc2d057ba687fdaf8ca5bf450066e4e4720f93cf2294b58939608
|
4
|
+
data.tar.gz: a0a72dd58fbd376fe2489844eaf4ea22532028e2827334476baf94481da600bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03c874077a9838ddc88dfc6d09da0694ce4788b1fc361ef97b9db8f6613b4b2b6bc970b866dc4eb358f79629675b6fdb186c980d8bcb85d38e621d7b8e7a205a
|
7
|
+
data.tar.gz: d1bd96bbe15a616c773cdbbe25d75e707f4cf0f00f9039d14dcd0a159607325b2d6781a29941eae334a28a688a3d3f0a345a95990136860cb80ca2d466d4ca60
|
data/CHANGELOG.md
CHANGED
data/lib/abo.rb
CHANGED
@@ -6,6 +6,7 @@ require "date"
|
|
6
6
|
class Abo
|
7
7
|
LINE_TYPE_STATEMENT = "statement"
|
8
8
|
LINE_TYPE_TRANSACTION = "transaction"
|
9
|
+
LINE_TYPE_TRANSACTION_NOTE = "transaction_note"
|
9
10
|
|
10
11
|
POSTING_CODE_DEBIT = 1
|
11
12
|
POSTING_CODE_CREDIT = 2
|
@@ -129,6 +130,14 @@ class Abo
|
|
129
130
|
File.open(path, "a:cp1250") do |file|
|
130
131
|
file.puts gpc
|
131
132
|
end
|
133
|
+
|
134
|
+
next if transaction[:note].nil?
|
135
|
+
|
136
|
+
gpc = "078#{transaction[:note].ljust(70, " ")}"
|
137
|
+
|
138
|
+
File.open(path, "a:cp1250") do |file|
|
139
|
+
file.puts gpc
|
140
|
+
end
|
132
141
|
end
|
133
142
|
end
|
134
143
|
|
@@ -174,6 +183,7 @@ class Abo
|
|
174
183
|
|
175
184
|
def parse_bank_statement_file(file_object)
|
176
185
|
@statement = AboStatement.new
|
186
|
+
transaction = nil
|
177
187
|
|
178
188
|
file_object.each_line do |line|
|
179
189
|
line = line.force_encoding("cp1250").encode("utf-8")
|
@@ -183,6 +193,9 @@ class Abo
|
|
183
193
|
when LINE_TYPE_TRANSACTION
|
184
194
|
transaction = parse_transaction_line(line)
|
185
195
|
@statement.transactions << transaction
|
196
|
+
when LINE_TYPE_TRANSACTION_NOTE
|
197
|
+
parse_transaction_note_line(transaction, line)
|
198
|
+
@statement.transactions[@statement.transactions.size - 1] = transaction
|
186
199
|
end
|
187
200
|
end
|
188
201
|
|
@@ -195,6 +208,8 @@ class Abo
|
|
195
208
|
LINE_TYPE_STATEMENT
|
196
209
|
when "075"
|
197
210
|
LINE_TYPE_TRANSACTION
|
211
|
+
when "078"
|
212
|
+
LINE_TYPE_TRANSACTION_NOTE
|
198
213
|
end
|
199
214
|
end
|
200
215
|
|
@@ -205,7 +220,7 @@ class Abo
|
|
205
220
|
# rubocop:disable Lint/UselessAssignment
|
206
221
|
@statement.client_account_prefix_number = line[pos += length, length = 6].gsub(/^0+/, "")
|
207
222
|
@statement.client_account_number = line[pos += length, length = 10].gsub(/^0+/, "")
|
208
|
-
@statement.abbreviated_client_name = line[pos += length, length = 20]
|
223
|
+
@statement.abbreviated_client_name = line[pos += length, length = 20].strip
|
209
224
|
@statement.old_balance_date = DateTime.strptime(line[pos += length, length = 6], "%d%m%y")
|
210
225
|
@statement.old_balance = (line[pos += length,
|
211
226
|
length = 14].to_i / 100.0) * (line[pos += length, length = 1] == "-" ? -1 : 1)
|
@@ -247,7 +262,7 @@ class Abo
|
|
247
262
|
transaction.constant_symbol = constant_symbol.gsub(/^0+/, "")
|
248
263
|
transaction.specific_symbol = line[pos += length, length = 10].gsub(/^0+/, "")
|
249
264
|
transaction.value = DateTime.strptime(line[pos += length, length = 6], "%d%m%y")
|
250
|
-
transaction.additional_information = line[pos += length, length = 20]
|
265
|
+
transaction.additional_information = line[pos += length, length = 20].strip
|
251
266
|
transaction.change_of_item_code = line[pos += length, length = 1]
|
252
267
|
transaction.type_of_data = line[pos += length, length = 4]
|
253
268
|
transaction.due_date = DateTime.strptime(line[pos += length, length = 6], "%d%m%y")
|
@@ -274,6 +289,15 @@ class Abo
|
|
274
289
|
transaction
|
275
290
|
end
|
276
291
|
|
292
|
+
def parse_transaction_note_line(transaction, line)
|
293
|
+
pos = 0
|
294
|
+
length = 3
|
295
|
+
|
296
|
+
# rubocop:disable Lint/UselessAssignment
|
297
|
+
transaction.note = line[pos += length, length = 6]
|
298
|
+
# rubocop:enable Lint/UselessAssignment
|
299
|
+
end
|
300
|
+
|
277
301
|
class AboStatement
|
278
302
|
attr_accessor :client_account_number, :client_account_prefix_number, :abbreviated_client_name, :old_balance_date,
|
279
303
|
:old_balance, :new_balance, :transactions_debit, :transactions_credit, :statement_sequence_number,
|
@@ -314,7 +338,8 @@ class Abo
|
|
314
338
|
attr_accessor :client_account_number, :client_account_prefix_number, :counter_account_number,
|
315
339
|
:counter_account_prefix_number, :document_number, :amount, :posting_code,
|
316
340
|
:variable_symbol, :constant_symbol, :specific_symbol, :value, :additional_information,
|
317
|
-
:change_of_item_code, :type_of_data, :due_date, :debit, :credit, :counter_account_bank_code
|
341
|
+
:change_of_item_code, :type_of_data, :due_date, :debit, :credit, :counter_account_bank_code,
|
342
|
+
:note
|
318
343
|
|
319
344
|
def initialize
|
320
345
|
@client_account_number = nil
|
@@ -336,6 +361,8 @@ class Abo
|
|
336
361
|
@debit = nil
|
337
362
|
@credit = nil
|
338
363
|
@counter_account_bank_code = nil
|
364
|
+
|
365
|
+
@note = nil
|
339
366
|
end
|
340
367
|
|
341
368
|
def to_hash
|
@@ -357,7 +384,8 @@ class Abo
|
|
357
384
|
due_date: @due_date,
|
358
385
|
debit: @debit,
|
359
386
|
credit: @credit,
|
360
|
-
counter_account_bank_code: @counter_account_bank_code
|
387
|
+
counter_account_bank_code: @counter_account_bank_code,
|
388
|
+
note: @note
|
361
389
|
}
|
362
390
|
end
|
363
391
|
end
|
data/lib/abo_parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abo_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rhemery
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|