sps_king 0.3.1 → 0.5.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: cd70e12d3810143618272131a6c71f938e0f3a38d12a3922b1096798bd56906d
4
- data.tar.gz: d3f2d858ed88af261d8fa635a04a1625e30d0b8b572477c91b672665999a0b1b
3
+ metadata.gz: 0bbc6291838df10ef7290cb3e04e1c97d573c92f67e13073e0734743a7d93fa7
4
+ data.tar.gz: 9611dd93cbfa199e0d32e50f39f6a9d77c4cc952a64a1d20d191d4644ecb0beb
5
5
  SHA512:
6
- metadata.gz: 202f18b83b35c8ba940eb8bb0827b65933893bf5ca307399940f8990146bdd69970e24c3ab9938067ea7f0343884f3c8523c891a394700d3ba83af0611305829
7
- data.tar.gz: 2bae9c411fcb2a036219ca61ca2c701a2f69a57431ec8a89375e6c5764e11e6390db65e2ecb60819bc44744050f55d108fb4a654151341cfe389f8e6514fbec0
6
+ metadata.gz: 7e50e84dac80865f798fe6bbbbfb4582d2500346d87f9e28420a1381c5cc7843db5d8999892fc4d41c34c83fff0cbfd24cf10dafbb13cee6966bac854aa7d59e
7
+ data.tar.gz: d6ccf85250954c8e84df1146bf4c59d07d0f0eb99f313fef315bd7e0b4a5a31e8cf204fa4bec4c320d33e289661532346533147b08a9bc60e4ad35828f78ef87
data/CHANGELOG.md ADDED
@@ -0,0 +1,60 @@
1
+ ## What's Changed in v0.5.0
2
+ * Add support for QRR type in structured remittance information by @tobischo in [#10](https://github.com/viafintech/sps_king/pull/10)
3
+ * Allow structured remittance information optionally for credits
4
+ * Bump version to 0.5.0
5
+ * Add support for QRR as value for proprietary
6
+ * Fix changelog links
7
+
8
+ ## What's Changed in v0.4.0
9
+ * Bump version to 0.4.0
10
+ * Make charge bearer optional instead of constant set to `SLEV` by @tobischo in [#7](https://github.com/viafintech/sps_king/pull/7)
11
+ * Make charge bearer optional instead of constant set to `SLEV`
12
+
13
+ **Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.3.1...v0.4.0
14
+
15
+ ## What's Changed in v0.3.1
16
+ * Bump version to 0.3.1
17
+ * Fix default currency on transactions by @tobischo in [#5](https://github.com/viafintech/sps_king/pull/5)
18
+ * Revert to old gemfile definition
19
+ * Re-add bundle install step
20
+ * Fix indentation
21
+ * Improve test setup
22
+ * Add newer ruby versions to test matrix
23
+ * Fix default currency on transactions
24
+
25
+ **Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.3.0...v0.3.1
26
+
27
+ ## What's Changed in v0.3.0
28
+ * Bump gem version
29
+ * Update tested activemodel versions
30
+ * Update test ruby version to 3.0
31
+
32
+ **Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.2.0...v0.3.0
33
+
34
+ ## What's Changed in v0.2.0
35
+ * Bump required ruby version to 2.7 by @martinseener in [#3](https://github.com/viafintech/sps_king/pull/3)
36
+ * Stick to ruby 2.7 support for now by @tobischo
37
+ * Fix CI setup by @tobischo
38
+ * Bump required ruby version to 2.7 by @tobischo
39
+ * Remove coveralls dependency by @martinseener in [#2](https://github.com/viafintech/sps_king/pull/2)
40
+ * Update version to 0.1.1 by @tobischo
41
+ * Add missing gemfiles for testing by @tobischo
42
+ * Remove coveralls dependency by @tobischo
43
+ * Update copyright notice and author mail address by @martinseener in [#1](https://github.com/viafintech/sps_king/pull/1)
44
+ * Update copyright notice and author mail address by @tobischo
45
+ * Add comment pointing to sepa_king for sepa files by @tobischo
46
+ * Fix gem description for next release by @tobischo
47
+
48
+ ## New Contributors
49
+ * @martinseener made their first contribution in [#3](https://github.com/viafintech/sps_king/pull/3)
50
+
51
+ **Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.1.0...v0.2.0
52
+
53
+ ## What's Changed in v0.1.0
54
+ * Add .gem to gitignore by @tobischo
55
+ * Adapt example account holder by @tobischo
56
+ * Fix status badges by @tobischo
57
+ * Fix copyright notice by @tobischo
58
+ * Initial implementation after fork from sepa_king gem by @tobischo
59
+
60
+ <!-- generated by git-cliff -->
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2018-2023 viafintech GmbH
1
+ Copyright (c) 2018-2024 viafintech GmbH
2
2
 
3
3
  Copyright (c) 2013-2017 Georg Leciejewski (Sales King GmbH) & Georg Ledermann for portions of this project copied from sepa_king
4
4
 
data/README.md CHANGED
@@ -91,7 +91,7 @@ sdd.add_transaction(
91
91
  # One of these strings:
92
92
  # 'CHTA' ("Banklastschrift") - Only for Swiss Direct Debits
93
93
  # 'CHDD' ("PostFinance-Lastschrift") - Only for Swiss Direct Debits
94
- service_level: 'CHTA'
94
+ service_level: 'CHTA',
95
95
 
96
96
  # Local instrument, in German "Lastschriftart"
97
97
  # One of these strings:
@@ -184,6 +184,19 @@ sct.add_transaction(
184
184
  # String, max. 140 char
185
185
  remittance_information: 'Rechnung vom 22.08.2013',
186
186
 
187
+ # OPTIONAL: Structured remittance information, in German "Strukturierter Verwendungszweck". Required for e.g. Swiss QR transfers
188
+ # StructuredRemittanceInformation
189
+ structured_remittance_information: SPS::StructuredRemittanceInformation.new(
190
+ # Defines how the reference field should be interpreted for Swiss Direct Debits
191
+ # One of these strings:
192
+ # 'IPI' ("IPI-Verwendungszweck")
193
+ # 'QRR' ("QR-Referenz")
194
+ proprietary: 'QRR',
195
+ # if proprietary is 'IPI': 20 character IPI remittance
196
+ # if proprietary is 'QRR': 27 character QR reference
197
+ reference: '000008207791225857421286694'
198
+ ),
199
+
187
200
  # OPTIONAL: Requested execution date, in German "Ausführungstermin"
188
201
  # Date
189
202
  requested_date: Date.new(2013,9,5),
@@ -198,6 +211,14 @@ sct.add_transaction(
198
211
  # 'URGP' ("Taggleiche Eilüberweisung")
199
212
  service_level: 'URGP'
200
213
 
214
+ # OPTIONAL: Charge Bearer
215
+ # One of these strings:
216
+ # 'DEBT' (Borne by Debitor)
217
+ # 'CRED' (Borne by Creditor)
218
+ # 'SHAR' (Shared)
219
+ # 'SLEV' (Service Level) - Must be SLEV for SEPA transfers
220
+ charge_bearer: 'SHAR',
221
+
201
222
  # OPTIONAL: Unstructured information to indicate the purpose of the payment
202
223
  # String, max. 4 char
203
224
  category_purpose: 'SALA',
data/cliff.toml ADDED
@@ -0,0 +1,88 @@
1
+ # git-cliff ~ configuration file
2
+ # https://git-cliff.org/docs/configuration
3
+
4
+ [remote.github]
5
+ owner = "viafintech"
6
+ repo = "sps_king"
7
+ # token = ""
8
+
9
+ [changelog]
10
+ # template for the changelog body
11
+ # https://keats.github.io/tera/docs/#introduction
12
+ body = """
13
+ ## What's Changed
14
+
15
+ {%- if version %} in {{ version }}{%- endif -%}
16
+ {% for commit in commits %}
17
+ {% if commit.github.pr_title -%}
18
+ {%- set commit_message = commit.github.pr_title -%}
19
+ {%- else -%}
20
+ {%- set commit_message = commit.message -%}
21
+ {%- endif -%}
22
+ * {{ commit_message | split(pat="\n") | first | trim }}\
23
+ {% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
24
+ {% if commit.github.pr_number %} in \
25
+ [#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }}) \
26
+ {%- endif %}
27
+ {%- endfor -%}
28
+
29
+ {%- if github -%}
30
+ {% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
31
+ {% raw %}\n{% endraw -%}
32
+ ## New Contributors
33
+ {%- endif %}\
34
+ {% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
35
+ * @{{ contributor.username }} made their first contribution
36
+ {%- if contributor.pr_number %} in \
37
+ [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
38
+ {%- endif %}
39
+ {%- endfor -%}
40
+ {%- endif -%}
41
+
42
+ {% if version %}
43
+ {% if previous.version %}
44
+ **Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
45
+ {% endif %}
46
+ {% else -%}
47
+ {% raw %}\n{% endraw %}
48
+ {% endif %}
49
+
50
+ {%- macro remote_url() -%}
51
+ https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
52
+ {%- endmacro -%}
53
+ """
54
+ # remove the leading and trailing whitespace from the template
55
+ trim = true
56
+ # changelog footer
57
+ footer = """
58
+ <!-- generated by git-cliff -->
59
+ """
60
+ # postprocessors
61
+ postprocessors = []
62
+
63
+ [git]
64
+ # parse the commits based on https://www.conventionalcommits.org
65
+ conventional_commits = false
66
+ # filter out the commits that are not conventional
67
+ filter_unconventional = true
68
+ # process each line of a commit as an individual commit
69
+ split_commits = false
70
+ # regex for preprocessing the commit messages
71
+ commit_preprocessors = [
72
+ # remove issue numbers from commits
73
+ { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
74
+ ]
75
+ # protect breaking changes from being skipped due to matching a skipping commit_parser
76
+ protect_breaking_commits = false
77
+ # filter out the commits that are not matched by commit parsers
78
+ filter_commits = false
79
+ # regex for matching git tags
80
+ tag_pattern = "v[0-9].*"
81
+ # regex for skipping tags
82
+ skip_tags = "beta|alpha"
83
+ # regex for ignoring tags
84
+ ignore_tags = "rc"
85
+ # sort the tags topologically
86
+ topo_order = false
87
+ # sort the commits inside sections by oldest/newest order
88
+ sort_commits = "newest"
@@ -16,7 +16,8 @@ module SPS
16
16
  requested_date: transaction.requested_date,
17
17
  batch_booking: transaction.batch_booking,
18
18
  service_level: transaction.service_level,
19
- category_purpose: transaction.category_purpose
19
+ category_purpose: transaction.category_purpose,
20
+ charge_bearer: transaction.charge_bearer,
20
21
  }
21
22
  end
22
23
 
@@ -56,7 +57,9 @@ module SPS
56
57
  builder.BIC(account.bic)
57
58
  end
58
59
  end
59
- builder.ChrgBr('SLEV')
60
+ if group[:charge_bearer]
61
+ builder.ChrgBr(group[:charge_bearer])
62
+ end
60
63
 
61
64
  transactions.each do |transaction|
62
65
  build_transaction(builder, transaction)
@@ -129,9 +132,24 @@ module SPS
129
132
  builder.IBAN(transaction.iban)
130
133
  end
131
134
  end
132
- if transaction.remittance_information
135
+ if transaction.remittance_information || transaction.structured_remittance_information
133
136
  builder.RmtInf do
134
- builder.Ustrd(transaction.remittance_information)
137
+ if transaction.remittance_information
138
+ builder.Ustrd(transaction.remittance_information)
139
+ end
140
+
141
+ if transaction.structured_remittance_information
142
+ builder.Strd do
143
+ builder.CdtrRefInf do
144
+ builder.Tp do
145
+ builder.CdOrPrtry do
146
+ builder.Prtry(transaction.structured_remittance_information.proprietary)
147
+ end
148
+ end
149
+ builder.Ref(transaction.structured_remittance_information.reference)
150
+ end
151
+ end
152
+ end
135
153
  end
136
154
  end
137
155
  end
@@ -6,7 +6,7 @@ module SPS
6
6
  attr_accessor :proprietary,
7
7
  :reference
8
8
 
9
- validates_inclusion_of :proprietary, in: %w(ESR IPI)
9
+ validates_inclusion_of :proprietary, in: %w(ESR IPI QRR)
10
10
  validates_length_of :reference, within: 1..35
11
11
 
12
12
  convert :proprietary, :reference, to: :text
@@ -3,10 +3,15 @@ module SPS
3
3
  class CreditTransferTransaction < Transaction
4
4
  attr_accessor :service_level,
5
5
  :creditor_address,
6
- :category_purpose
6
+ :category_purpose,
7
+ :charge_bearer
8
+
9
+ CHARGE_BEARERS = ['DEBT', 'CRED', 'SHAR', 'SLEV'].freeze
7
10
 
8
11
  validates_length_of :category_purpose, within: 1..4, allow_nil: true
9
12
 
13
+ validates :charge_bearer, inclusion: CHARGE_BEARERS, allow_nil: true
14
+
10
15
  validate { |t| t.validate_requested_date_after(Date.today) }
11
16
 
12
17
  def schema_compatible?(schema_name)
@@ -1,3 +1,3 @@
1
1
  module SPS
2
- VERSION = '0.3.1'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -261,6 +261,25 @@ describe SPS::CreditTransfer do
261
261
  end
262
262
  end
263
263
 
264
+ context 'with charge bearer' do
265
+ SPS::CreditTransferTransaction::CHARGE_BEARERS.each do |charge_bearer|
266
+ context "with value #{charge_bearer}" do
267
+ subject do
268
+ sct = credit_transfer
269
+
270
+ sct.add_transaction(credit_transfer_transaction.merge(charge_bearer: charge_bearer))
271
+
272
+ sct.to_xml
273
+ end
274
+
275
+ it 'should contain payment_information with <ChrgBr>' do
276
+ expect(subject)
277
+ .to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/ChrgBr', charge_bearer)
278
+ end
279
+ end
280
+ end
281
+ end
282
+
264
283
  context 'with different batch_booking given' do
265
284
  subject do
266
285
  sct = credit_transfer
@@ -345,6 +364,37 @@ describe SPS::CreditTransfer do
345
364
  )
346
365
  end
347
366
  end
367
+
368
+ context 'with structured remittance information given' do
369
+ subject do
370
+ sct = credit_transfer
371
+
372
+ sct.add_transaction(
373
+ name: 'Contoso AG',
374
+ iban: 'CH5481230000001998736',
375
+ bic: 'RAIFCH22',
376
+ amount: 102.50,
377
+ structured_remittance_information: SPS::StructuredRemittanceInformation.new(
378
+ proprietary: 'QRR',
379
+ reference: '185744810000000000200800628'
380
+ )
381
+ )
382
+
383
+ sct.to_xml
384
+ end
385
+
386
+ it 'should create valid XML file' do
387
+ expect(subject).to validate_against('pain.001.001.03.ch.02.xsd')
388
+ end
389
+
390
+ it 'should contain <Prtry>' do
391
+ expect(subject)
392
+ .to have_xml(
393
+ '//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/RmtInf/Strd/CdtrRefInf/Tp/CdOrPrtry/Prtry',
394
+ 'QRR'
395
+ )
396
+ end
397
+ end
348
398
  end
349
399
  end
350
400
  end
@@ -12,7 +12,7 @@ describe SPS::StructuredRemittanceInformation do
12
12
 
13
13
  describe :proprietary do
14
14
  it 'should accept valid value' do
15
- expect(SPS::StructuredRemittanceInformation).to accept('ESR', 'IPI', for: :proprietary)
15
+ expect(SPS::StructuredRemittanceInformation).to accept('ESR', 'IPI', 'QRR', for: :proprietary)
16
16
  end
17
17
 
18
18
  it 'should not accept invalid value' do
@@ -11,7 +11,7 @@ describe SPS::CreditTransferTransaction do
11
11
  bic: 'RAIFCH22',
12
12
  amount: 102.50,
13
13
  reference: 'XYZ-1234/123',
14
- remittance_information: 'Rechnung 123 vom 22.08.2013'
14
+ remittance_information: 'Rechnung 123 vom 22.08.2013',
15
15
  )
16
16
  ).to be_valid
17
17
  end
@@ -50,4 +50,16 @@ describe SPS::CreditTransferTransaction do
50
50
  expect(SPS::CreditTransferTransaction).not_to accept('', 'X' * 5, for: :category_purpose)
51
51
  end
52
52
  end
53
+
54
+ context 'Charge Bearer' do
55
+ it 'should allow valid value' do
56
+ expect(SPS::CreditTransferTransaction)
57
+ .to accept(nil, 'DEBT', 'CRED', 'SHAR', 'SLEV', for: :charge_bearer)
58
+ end
59
+
60
+ it 'should not allow invalid value' do
61
+ expect(SPS::CreditTransferTransaction)
62
+ .not_to accept('', 'X' * 5, 'X' * 4, for: :charge_bearer)
63
+ end
64
+ end
53
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps_king
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -119,11 +119,13 @@ files:
119
119
  - ".github/workflows/test.yml"
120
120
  - ".gitignore"
121
121
  - ".rspec"
122
+ - CHANGELOG.md
122
123
  - CONTRIBUTING.md
123
124
  - Gemfile
124
125
  - LICENSE.txt
125
126
  - README.md
126
127
  - Rakefile
128
+ - cliff.toml
127
129
  - gemfiles/Gemfile-activemodel-6.1.x
128
130
  - gemfiles/Gemfile-activemodel-7.0.x
129
131
  - gemfiles/Gemfile-activemodel-7.1.x