abo_parser 1.0.3 → 1.0.5

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
  SHA256:
3
- metadata.gz: 1f0fae80c6448847a79d585378663b905ba4cd82ea8e9d8da25af39d9c53b30d
4
- data.tar.gz: 0d42d96d28a640b3989c9750e66fb5155fabb125add9bad4d2c3aaa1a46c3f5b
3
+ metadata.gz: 773712f42277729a75eedb1f1c515e0136c7fff8d7571764a2b3bfefda52231c
4
+ data.tar.gz: b9af11dd27ffd1fd9244bd6529258722cb02761e9f6286ffccb0013066baf749
5
5
  SHA512:
6
- metadata.gz: 0d11deda7568b65c5619862f83495796252edc86279615e13a99483caec358cbd15dbae5bbc5ff8b30938893faed97ce25f04c76b23513a6a2207ee5b25494cb
7
- data.tar.gz: 419c1d3795b21948fd9731fda52ff30b80b3007e4c2018bab6801714772a3b53c75cec1cf09e8bc248208c1ae9a6d09de486c44ad2aea0e3c09515fa25ea7187
6
+ metadata.gz: cf3b958d78cc79de1b584a5d350424a2d4a31ed504f6d5e38b877e0c6734d9864c0036ea87c4708b283d0b413b474699e1e1b7ce307057bd081de7b9e495ad6e
7
+ data.tar.gz: 248a7629f21a98d2c1a3e20e200733bef816af9f17c5550bf3d1da2f39b2f6d955e782d6d985b7e3e81a5647daf72ad9daf03bb0b4caac71e9bb3e75a0fd1c5c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Released]
2
2
 
3
+ ## [1.0.4] - 2023-06-11
4
+
5
+ - Fixed parsing 078 lines in bank statement
6
+
7
+ ## [1.0.4] - 2023-06-11
8
+
9
+ - Added parsing 078 lines in bank statement
10
+
3
11
  ## [1.0.3] - 2023-06-03
4
12
 
5
13
  - Added documentation url
data/README.md CHANGED
@@ -59,6 +59,7 @@ AboStatement
59
59
  debit
60
60
  credit
61
61
  counter_account_bank_code
62
+ note
62
63
  ```
63
64
 
64
65
  ## P11 file
data/abo_parser.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.summary = "This gem is a parser/export for the ABO bank statements and payment orders."
11
11
  spec.required_ruby_version = ">= 2.6.0"
12
12
 
13
- spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/abo_parser"
13
+ spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/abo_parser"
14
14
 
15
15
  # spec.metadata["allowed_push_host"] = "Set to your gem server 'https://example.com'"
16
16
 
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 = 70]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AboParser
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.5"
5
5
  end
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.3
4
+ version: 1.0.5
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-03 00:00:00.000000000 Z
11
+ date: 2023-07-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -31,7 +31,7 @@ files:
31
31
  homepage:
32
32
  licenses: []
33
33
  metadata:
34
- documentation_uri: https://www.rubydoc.info/gems/abo_parser
34
+ documentation_uri: https://rubydoc.info/gems/abo_parser
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths: