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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e3b76466f9a0fa80b6b9580abbf8cfdc8c1e530914d833848f16962bf49f1c0
4
- data.tar.gz: '08059bad5cd7a74208fad02c15769de2cb5e84b3ae7cb622165af5081bc8a4df'
3
+ metadata.gz: bbdd7991d9da595e8a78eef4ede917a4bf96f425305da1ea0f908e9c04c23750
4
+ data.tar.gz: 5ac2d38ed83dec60f68ea9f70b8be7bd16e01385457c41f58f15dc00990e07a9
5
5
  SHA512:
6
- metadata.gz: 1c7f07f705f9afb8c6bcd0e91c3371b4f496e0649dd93b3dab85b5167223393d428d652cbf90147aa415ec63af3d9a01ac6f416a13c4190d28276b49d4a79b30
7
- data.tar.gz: 20670910d9fe37671c90dc4189756757ed109b3110429631726b3b479e9ed625927db391002b6f9a01af4ba2e87ea921cd28c5c6e628daa3ec73483f7aa34904
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
- else
55
+ elsif schema_name != PAIN_001_001_03_CH_02
56
56
  builder.Othr do
57
57
  builder.Id('NOTPROVIDED')
58
58
  end
@@ -24,7 +24,7 @@ module SEPA
24
24
  }
25
25
  end
26
26
 
27
- def build_payment_informations(builder)
27
+ def build_payment_informations(builder, schema_name)
28
28
  # Build a PmtInf block for every group of transactions
29
29
  grouped_transactions.each do |group, transactions|
30
30
  builder.PmtInf do
@@ -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, PAIN_001_001_03, PAIN_001_001_03_CH_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("../../../lib/schema/#{schema_name}.xsd", __FILE__)))
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
@@ -23,7 +23,7 @@ module SEPA
23
23
  value = record.send(field_name)
24
24
 
25
25
  if value
26
- unless value.to_s.match(REGEX)
26
+ unless value.to_s.match?(REGEX)
27
27
  record.errors.add(field_name, :invalid, message: options[:message])
28
28
  end
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module SEPA
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.0'
3
3
  end
data/sepa_king.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path('lib', __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'sepa_king/version'
5
5
 
data/spec/account_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::Account do
4
+ RSpec.describe SEPA::Account do
5
5
  describe :new do
6
6
  it 'should not accept unknown keys' do
7
7
  expect {
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::Converter do
4
+ RSpec.describe SEPA::Converter do
5
5
  include SEPA::Converter::InstanceMethods
6
6
 
7
7
  describe :convert_text do
@@ -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
- it 'should create valid XML file' do
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 fail for pain.001.001.03' do
119
- expect {
120
- subject.to_xml(SEPA::PAIN_001_001_03)
121
- }.to raise_error(SEPA::Error, /Incompatible with schema/)
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
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::CreditTransferTransaction do
4
+ RSpec.describe SEPA::CreditTransferTransaction do
5
5
  describe :initialize do
6
6
  it 'should initialize a valid transaction' do
7
7
  expect(
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::CreditorAccount do
4
+ RSpec.describe SEPA::CreditorAccount do
5
5
  it 'should initialize a new account' do
6
6
  expect(
7
7
  SEPA::CreditorAccount.new name: 'Gläubiger GmbH',
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DebtorAccount do
4
+ RSpec.describe SEPA::DebtorAccount do
5
5
  it 'should initialize a new account' do
6
6
  expect(
7
7
  SEPA::DebtorAccount.new name: 'Gläubiger GmbH',
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DebtorAddress do
4
+ RSpec.describe SEPA::DebtorAddress do
5
5
  it 'should initialize a new address' do
6
6
  expect(
7
7
  SEPA::DebtorAddress.new country_code: 'CH',
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DirectDebit do
4
+ RSpec.describe SEPA::DirectDebit do
5
5
  let(:message_id_regex) { /SEPA-KING\/[0-9a-z_]{22}/ }
6
6
 
7
7
  let(:direct_debit) {
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DirectDebitTransaction do
4
+ RSpec.describe SEPA::DirectDebitTransaction do
5
5
  describe :initialize do
6
6
  it 'should create a valid transaction' do
7
7
  expect(
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(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
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
@@ -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 'Adress' do
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(
@@ -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')
@@ -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.13.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-04-15 00:00:00.000000000 Z
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.11
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