abo_parser 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87f5599aaef3c486d2643be10c35b7a585cecf79e66cd9c543228bac1bc5a0e5
4
- data.tar.gz: 41193d7a9d01500cbd75c126af0b8544b5d476fab9abc9de1d4571a12e5dcf7f
3
+ metadata.gz: 45bd0bd8188bc2d057ba687fdaf8ca5bf450066e4e4720f93cf2294b58939608
4
+ data.tar.gz: a0a72dd58fbd376fe2489844eaf4ea22532028e2827334476baf94481da600bf
5
5
  SHA512:
6
- metadata.gz: 0a0b21fb435d8df19762b5eed670c1044a5114e15b148db8fbf9b1f3c266617834adb63510e005e88028cdaf763ae042b0c4b1d5bd4cf8b781b8debd1d0046c1
7
- data.tar.gz: 643033e95cda11b656f33b24a293225f34130b2740cdabae6123e0da791365c587560cc3ed64bcb54869da1cd73d9280164649d8c2293c9031aaf36231823886
6
+ metadata.gz: 03c874077a9838ddc88dfc6d09da0694ce4788b1fc361ef97b9db8f6613b4b2b6bc970b866dc4eb358f79629675b6fdb186c980d8bcb85d38e621d7b8e7a205a
7
+ data.tar.gz: d1bd96bbe15a616c773cdbbe25d75e707f4cf0f00f9039d14dcd0a159607325b2d6781a29941eae334a28a688a3d3f0a345a95990136860cb80ca2d466d4ca60
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Released]
2
2
 
3
+ ## [1.0.4] - 2023-06-11
4
+
5
+ - Added parsing 078 lines in bank statement
6
+
7
+ ## [1.0.3] - 2023-06-03
8
+
9
+ - Added documentation url
10
+
3
11
  ## [1.0.1] - 2023-06-03
4
12
 
5
13
  - Added documentation to README.md
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/#{AboParser::VERSION}/file/README.md"
13
+ spec.metadata["documentation_uri"] = "https://www.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 = 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AboParser
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.4"
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.2
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-03 00:00:00.000000000 Z
11
+ date: 2023-06-11 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/1.0.2/file/README.md
34
+ documentation_uri: https://www.rubydoc.info/gems/abo_parser
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths: