sepa_king 0.13.0 → 0.14.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 +4 -4
- data/lib/sepa_king/message/credit_transfer.rb +2 -2
- data/lib/sepa_king/message/direct_debit.rb +1 -1
- data/lib/sepa_king/message.rb +4 -4
- data/lib/sepa_king/validator.rb +1 -1
- data/lib/sepa_king/version.rb +1 -1
- data/sepa_king.gemspec +1 -1
- data/spec/account_spec.rb +1 -1
- data/spec/converter_spec.rb +1 -1
- data/spec/credit_transfer_spec.rb +15 -6
- data/spec/credit_transfer_transaction_spec.rb +1 -1
- data/spec/creditor_account_spec.rb +1 -1
- data/spec/debtor_account_spec.rb +1 -1
- data/spec/debtor_address_spec.rb +1 -1
- data/spec/direct_debit_spec.rb +1 -1
- data/spec/direct_debit_transaction_spec.rb +1 -1
- data/spec/message_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -1
- data/spec/transaction_spec.rb +2 -2
- data/spec/validation_spec.rb +2 -2
- data/spec/validator_spec.rb +4 -4
- metadata +3 -4
- data/spec/support/active_model.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbdd7991d9da595e8a78eef4ede917a4bf96f425305da1ea0f908e9c04c23750
|
4
|
+
data.tar.gz: 5ac2d38ed83dec60f68ea9f70b8be7bd16e01385457c41f58f15dc00990e07a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10dd0ce9bae0413cc3ed0d65b470fc8f0911bd4035cc19a3a4505a88d6076ee552b1c0d4cd8e8d0d0ab9542a9d42eb717418d43a7e5c6ad5212fab2d4d042123
|
7
|
+
data.tar.gz: a27678581e7f3d371d47fe58ad77b9245bade4d05adaa69dd1ec0425efb253fb4db8f624f77e5ce2cbf18b9000e429614b4068b61fa466e46a9d347a03ccd75b
|
@@ -17,7 +17,7 @@ module SEPA
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
def build_payment_informations(builder)
|
20
|
+
def build_payment_informations(builder, schema_name)
|
21
21
|
# Build a PmtInf block for every group of transactions
|
22
22
|
grouped_transactions.each do |group, transactions|
|
23
23
|
# All transactions with the same requested_date are placed into the same PmtInf block
|
@@ -52,7 +52,7 @@ module SEPA
|
|
52
52
|
builder.FinInstnId do
|
53
53
|
if account.bic
|
54
54
|
builder.BIC(account.bic)
|
55
|
-
|
55
|
+
elsif schema_name != PAIN_001_001_03_CH_02
|
56
56
|
builder.Othr do
|
57
57
|
builder.Id('NOTPROVIDED')
|
58
58
|
end
|
data/lib/sepa_king/message.rb
CHANGED
@@ -46,7 +46,7 @@ module SEPA
|
|
46
46
|
builder.Document(xml_schema(schema_name)) do
|
47
47
|
builder.__send__(xml_main_tag) do
|
48
48
|
build_group_header(builder)
|
49
|
-
build_payment_informations(builder)
|
49
|
+
build_payment_informations(builder, schema_name)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -63,9 +63,9 @@ module SEPA
|
|
63
63
|
raise ArgumentError.new("Schema #{schema_name} is unknown!") unless self.known_schemas.include?(schema_name)
|
64
64
|
|
65
65
|
case schema_name
|
66
|
-
when PAIN_001_002_03, PAIN_008_002_02
|
66
|
+
when PAIN_001_002_03, PAIN_008_002_02
|
67
67
|
account.bic.present? && transactions.all? { |t| t.schema_compatible?(schema_name) }
|
68
|
-
when PAIN_001_003_03, PAIN_008_003_02, PAIN_008_001_02
|
68
|
+
when PAIN_001_001_03, PAIN_001_001_03_CH_02, PAIN_001_003_03, PAIN_008_003_02, PAIN_008_001_02
|
69
69
|
transactions.all? { |t| t.schema_compatible?(schema_name) }
|
70
70
|
end
|
71
71
|
end
|
@@ -161,7 +161,7 @@ module SEPA
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def validate_final_document!(document, schema_name)
|
164
|
-
xsd = Nokogiri::XML::Schema(File.read(File.expand_path("
|
164
|
+
xsd = Nokogiri::XML::Schema(File.read(File.expand_path("../../lib/schema/#{schema_name}.xsd", __dir__)))
|
165
165
|
errors = xsd.validate(document).map { |error| error.message }
|
166
166
|
raise SEPA::Error.new("Incompatible with schema #{schema_name}: #{errors.join(', ')}") if errors.any?
|
167
167
|
end
|
data/lib/sepa_king/validator.rb
CHANGED
data/lib/sepa_king/version.rb
CHANGED
data/sepa_king.gemspec
CHANGED
data/spec/account_spec.rb
CHANGED
data/spec/converter_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe SEPA::CreditTransfer do
|
4
|
+
RSpec.describe SEPA::CreditTransfer do
|
5
5
|
let(:message_id_regex) { /SEPA-KING\/[0-9a-z_]{22}/ }
|
6
6
|
let(:credit_transfer) {
|
7
7
|
SEPA::CreditTransfer.new name: 'Schuldner GmbH',
|
@@ -105,20 +105,29 @@ describe SEPA::CreditTransfer do
|
|
105
105
|
bic: 'PBNKDEFF370',
|
106
106
|
iban: 'DE37112589611964645802',
|
107
107
|
amount: 102.50,
|
108
|
+
currency: currency,
|
108
109
|
reference: 'XYZ-1234/123',
|
109
110
|
remittance_information: 'Rechnung vom 22.08.2013'
|
110
111
|
|
111
112
|
sct
|
112
113
|
end
|
113
114
|
|
114
|
-
|
115
|
+
let(:currency) { nil }
|
116
|
+
|
117
|
+
it 'should validate against pain.001.003.03' do
|
115
118
|
expect(subject.to_xml(SEPA::PAIN_001_003_03)).to validate_against('pain.001.003.03.xsd')
|
116
119
|
end
|
117
120
|
|
118
|
-
it 'should
|
119
|
-
expect
|
120
|
-
|
121
|
-
|
121
|
+
it 'should validate against pain.001.001.03' do
|
122
|
+
expect(subject.to_xml(SEPA::PAIN_001_001_03)).to validate_against('pain.001.001.03.xsd')
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with CHF as currency' do
|
126
|
+
let(:currency) { 'CHF' }
|
127
|
+
|
128
|
+
it 'should validate against pain.001.001.03.ch.02' do
|
129
|
+
expect(subject.to_xml(SEPA::PAIN_001_001_03_CH_02)).to validate_against('pain.001.001.03.ch.02.xsd')
|
130
|
+
end
|
122
131
|
end
|
123
132
|
|
124
133
|
it 'should fail for pain.001.002.03' do
|
data/spec/debtor_account_spec.rb
CHANGED
data/spec/debtor_address_spec.rb
CHANGED
data/spec/direct_debit_spec.rb
CHANGED
data/spec/message_spec.rb
CHANGED
@@ -10,7 +10,7 @@ class DummyMessage < SEPA::Message
|
|
10
10
|
self.transaction_class = DummyTransaction
|
11
11
|
end
|
12
12
|
|
13
|
-
describe SEPA::Message do
|
13
|
+
RSpec.describe SEPA::Message do
|
14
14
|
describe :amount_total do
|
15
15
|
subject do
|
16
16
|
message = DummyMessage.new
|
@@ -86,7 +86,7 @@ describe SEPA::Message do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
describe :creation_date_time do
|
89
|
+
describe :creation_date_time do
|
90
90
|
subject { DummyMessage.new }
|
91
91
|
|
92
92
|
describe 'getter' do
|
data/spec/spec_helper.rb
CHANGED
@@ -18,12 +18,13 @@ require 'sepa_king'
|
|
18
18
|
|
19
19
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
20
20
|
# in spec/support/ and its subdirectories.
|
21
|
-
Dir[File.expand_path(File.join(
|
21
|
+
Dir[File.expand_path(File.join(__dir__, 'support', '**', '*.rb'))].each {|f| require f}
|
22
22
|
|
23
23
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
24
24
|
RSpec.configure do |config|
|
25
25
|
config.run_all_when_everything_filtered = true
|
26
26
|
config.filter_run :focus
|
27
|
+
config.disable_monkey_patching!
|
27
28
|
|
28
29
|
# Run specs in random order to surface order dependencies. If you find an
|
29
30
|
# order dependency and want to debug it, you can fix the order by providing
|
data/spec/transaction_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe SEPA::Transaction do
|
4
|
+
RSpec.describe SEPA::Transaction do
|
5
5
|
describe :new do
|
6
6
|
it 'should have default for reference' do
|
7
7
|
expect(SEPA::Transaction.new.reference).to eq('NOTPROVIDED')
|
@@ -26,7 +26,7 @@ describe SEPA::Transaction do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context '
|
29
|
+
context 'Address' do
|
30
30
|
context 'with address_line' do
|
31
31
|
it 'should accept valid value' do
|
32
32
|
expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
|
data/spec/validation_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Credit Transfer Initiation' do
|
3
|
+
RSpec.describe 'Credit Transfer Initiation' do
|
4
4
|
it "should validate example file" do
|
5
5
|
expect(File.read('spec/examples/pain.001.002.03.xml')).to validate_against('pain.001.002.03.xsd')
|
6
6
|
expect(File.read('spec/examples/pain.001.003.03.xml')).to validate_against('pain.001.003.03.xsd')
|
@@ -12,7 +12,7 @@ describe 'Credit Transfer Initiation' do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe 'Direct Debit Initiation' do
|
15
|
+
RSpec.describe 'Direct Debit Initiation' do
|
16
16
|
it 'should validate example file' do
|
17
17
|
expect(File.read('spec/examples/pain.008.002.02.xml')).to validate_against('pain.008.002.02.xsd')
|
18
18
|
expect(File.read('spec/examples/pain.008.003.02.xml')).to validate_against('pain.008.003.02.xsd')
|
data/spec/validator_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe SEPA::IBANValidator do
|
4
|
+
RSpec.describe SEPA::IBANValidator do
|
5
5
|
class Validatable
|
6
6
|
include ActiveModel::Model
|
7
7
|
attr_accessor :iban, :iban_the_terrible
|
@@ -29,7 +29,7 @@ describe SEPA::IBANValidator do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe SEPA::BICValidator do
|
32
|
+
RSpec.describe SEPA::BICValidator do
|
33
33
|
class Validatable
|
34
34
|
include ActiveModel::Model
|
35
35
|
attr_accessor :bic, :custom_bic
|
@@ -52,7 +52,7 @@ describe SEPA::BICValidator do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe SEPA::CreditorIdentifierValidator do
|
55
|
+
RSpec.describe SEPA::CreditorIdentifierValidator do
|
56
56
|
class Validatable
|
57
57
|
include ActiveModel::Model
|
58
58
|
attr_accessor :creditor_identifier, :crid
|
@@ -93,7 +93,7 @@ describe SEPA::CreditorIdentifierValidator do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
describe SEPA::MandateIdentifierValidator do
|
96
|
+
RSpec.describe SEPA::MandateIdentifierValidator do
|
97
97
|
class Validatable
|
98
98
|
include ActiveModel::Model
|
99
99
|
attr_accessor :mandate_id, :mid
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sepa_king
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Leciejewski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -187,7 +187,6 @@ files:
|
|
187
187
|
- spec/examples/pain.008.003.02.xml
|
188
188
|
- spec/message_spec.rb
|
189
189
|
- spec/spec_helper.rb
|
190
|
-
- spec/support/active_model.rb
|
191
190
|
- spec/support/custom_matcher.rb
|
192
191
|
- spec/support/factories.rb
|
193
192
|
- spec/support/validations.rb
|
@@ -213,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
212
|
- !ruby/object:Gem::Version
|
214
213
|
version: '0'
|
215
214
|
requirements: []
|
216
|
-
rubygems_version: 3.3.
|
215
|
+
rubygems_version: 3.3.23
|
217
216
|
signing_key:
|
218
217
|
specification_version: 4
|
219
218
|
summary: Ruby gem for creating SEPA XML files
|
@@ -1,30 +0,0 @@
|
|
1
|
-
unless defined?(ActiveModel::Model)
|
2
|
-
# ActiveModel::Model is available since ActiveModel 4.0 only.
|
3
|
-
#
|
4
|
-
# If it's missing, add the code from
|
5
|
-
# https://github.com/rails/rails/blob/master/activemodel/lib/active_model/model.rb
|
6
|
-
module ActiveModel
|
7
|
-
module Model
|
8
|
-
def self.included(base)
|
9
|
-
base.class_eval do
|
10
|
-
extend ActiveModel::Naming
|
11
|
-
extend ActiveModel::Translation
|
12
|
-
include ActiveModel::Validations
|
13
|
-
include ActiveModel::Conversion
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(params={})
|
18
|
-
params.each do |attr, value|
|
19
|
-
self.public_send("#{attr}=", value)
|
20
|
-
end if params
|
21
|
-
|
22
|
-
super()
|
23
|
-
end
|
24
|
-
|
25
|
-
def persisted?
|
26
|
-
false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|