camt_parser 2.12.0 → 2.13.0

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: 450aa5c4c5b4b16c77da3a86e7b5d9ab5e9a7aca8afe6e7bcaf786b6cf113eb2
4
- data.tar.gz: 788cc86a10e854d71195d3471076e8391f97a6fd2557767e38b1b1fb47cdaa48
3
+ metadata.gz: 48ce4fa8cfd3edea30779f066aa7c5b28cfa0468dc0771b581f7b573d5b5b0f0
4
+ data.tar.gz: a41fc83ca576fc1afa7d637826b332665f4d12c5f63c22774d80f4ef0a03a192
5
5
  SHA512:
6
- metadata.gz: d2ba043b5611080cb8ecd5d06419f4bdaa4a430dc5c62f5117882deb8e1ed01f836b9ebd771f3b3900ba0b99e194d322c4764602a45092f8ea2458465767267c
7
- data.tar.gz: d7c7d4724a22548d74f46929511849e264f4e29cc125aa097688cfb055d6b4059dee8d0053dbcc1a271d42053c16160f867a4a001c5f52c3ebe3d54f3d57afb6
6
+ metadata.gz: '08e238218f3be5721932a2412cdf327eeb6879576a1e311f145b9264038bec3a07a7e67f0a96e39865106993b2c03d7b68f29022df3b32384f2734e19c94ae95'
7
+ data.tar.gz: 70ff83c9b0340ff2a3776b4f93e3f4d10790381693727f27ce1c7d3174e76248c92ef9bb1da75810028966252745f74718a10de516b27f710ccec6173c59091c
@@ -37,8 +37,9 @@ module CamtParser
37
37
  @opening_balance ||= begin
38
38
  bal = @xml_data.xpath('Bal/Tp//Cd[contains(text(), "PRCD")]').first.ancestors('Bal')
39
39
  date = bal.xpath('Dt/Dt/text()').text
40
+ credit = bal.xpath('CdtDbtInd/text()').text == 'CRDT'
40
41
  currency = bal.xpath('Amt').attribute('Ccy').value
41
- CamtParser::AccountBalance.new bal.xpath('Amt/text()').text, currency, date, true
42
+ CamtParser::AccountBalance.new bal.xpath('Amt/text()').text, currency, date, credit
42
43
  end
43
44
  end
44
45
  alias_method :opening_or_intermediary_balance, :opening_balance
@@ -47,8 +48,9 @@ module CamtParser
47
48
  @closing_balance ||= begin
48
49
  bal = @xml_data.xpath('Bal/Tp//Cd[contains(text(), "CLBD")]').first.ancestors('Bal')
49
50
  date = bal.xpath('Dt/Dt/text()').text
51
+ credit = bal.xpath('CdtDbtInd/text()').text == 'CRDT'
50
52
  currency = bal.xpath('Amt').attribute('Ccy').value
51
- CamtParser::AccountBalance.new bal.xpath('Amt/text()').text, currency, date, true
53
+ CamtParser::AccountBalance.new bal.xpath('Amt/text()').text, currency, date, credit
52
54
  end
53
55
  end
54
56
  alias_method :closing_or_intermediary_balance, :closing_balance
@@ -41,18 +41,19 @@ module CamtParser
41
41
  @opening_balance ||= begin
42
42
  bal = @xml_data.xpath('Bal/Tp//Cd[contains(text(), "OPBD") or contains(text(), "PRCD")]').first.ancestors('Bal')
43
43
  date = bal.xpath('Dt/Dt/text()').text
44
+ credit = bal.xpath('CdtDbtInd/text()').text == 'CRDT'
44
45
  currency = bal.xpath('Amt').attribute('Ccy').value
45
- AccountBalance.new bal.xpath('Amt/text()').text, currency, date, true
46
+ AccountBalance.new bal.xpath('Amt/text()').text, currency, date, credit
46
47
  end
47
48
  end
48
- alias_method :opening_or_intermediary_balance, :opening_balance
49
49
 
50
50
  def closing_balance
51
51
  @closing_balance ||= begin
52
52
  bal = @xml_data.xpath('Bal/Tp//Cd[contains(text(), "CLBD")]').first.ancestors('Bal')
53
53
  date = bal.xpath('Dt/Dt/text()').text
54
+ credit = bal.xpath('CdtDbtInd/text()').text == 'CRDT'
54
55
  currency = bal.xpath('Amt').attribute('Ccy').value
55
- AccountBalance.new bal.xpath('Amt/text()').text, currency, date, true
56
+ AccountBalance.new bal.xpath('Amt/text()').text, currency, date, credit
56
57
  end
57
58
  end
58
59
  alias_method :closing_or_intermediary_balance, :closing_balance
@@ -32,6 +32,10 @@ module CamtParser
32
32
  CamtParser::Misc.to_amount_in_cents(@amount)
33
33
  end
34
34
 
35
+ def signed_amount
36
+ amount * sign
37
+ end
38
+
35
39
  def to_h
36
40
  {
37
41
  'amount' => amount,
@@ -13,7 +13,7 @@ module CamtParser
13
13
  def to_amount(value)
14
14
  return nil if value == nil || value.strip == ''
15
15
 
16
- BigDecimal(value.gsub(',', '.'))
16
+ BigDecimal(value.tr(',', '.'))
17
17
  end
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module CamtParser
2
- VERSION = '2.12.0'.freeze
2
+ VERSION = '2.13.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camt_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.0
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2022-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -100,11 +100,11 @@ files:
100
100
  - lib/camt_parser/string.rb
101
101
  - lib/camt_parser/version.rb
102
102
  - lib/camt_parser/xml.rb
103
- homepage: https://github.com/Barzahlen/camt_parser
103
+ homepage: https://github.com/viafintech/camt_parser
104
104
  licenses:
105
105
  - MIT
106
106
  metadata: {}
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -119,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.0.3.1
123
- signing_key:
122
+ rubygems_version: 3.1.4
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: Gem for parsing camt files into a speaking object.
126
126
  test_files: []