Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty BIC for pain.001.001.03 credit transfers #65

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sepa_king/transaction/credit_transfer_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(attributes = {})
def schema_compatible?(schema_name)
case schema_name
when PAIN_001_001_03
self.bic.present? && self.service_level == 'SEPA'
self.service_level == 'SEPA'
when PAIN_001_002_03
self.bic.present? && self.service_level == 'SEPA' && self.currency == 'EUR'
when PAIN_001_003_03
Expand Down
32 changes: 32 additions & 0 deletions spec/credit_transfer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
expect(subject.to_xml).to validate_against('pain.001.003.03.xsd')
end

it 'should fail for pain.001.001.03' do
expect {
subject.to_xml(SEPA::PAIN_001_001_03)
}.to raise_error(RuntimeError)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this adds an unrelated test to cover the mandatory presence of the BIC for the debtor)


it 'should fail for pain.001.002.03' do
expect {
subject.to_xml(SEPA::PAIN_001_002_03)
Expand Down Expand Up @@ -327,6 +333,32 @@
}.to raise_error(RuntimeError)
end
end

context 'with a transaction without a bic' do
subject do
sct = credit_transfer

sct.add_transaction name: 'Telekomiker AG',
iban: 'DE37112589611964645802',
amount: 102.50

sct
end

it 'should validate against pain.001.001.03' do
expect(subject.to_xml('pain.001.001.03')).to validate_against('pain.001.001.03.xsd')
end

it 'should fail for pain.001.002.03' do
expect {
subject.to_xml(SEPA::PAIN_001_002_03)
}.to raise_error(RuntimeError)
end

it 'should validate against pain.001.003.03' do
expect(subject.to_xml(SEPA::PAIN_001_003_03)).to validate_against('pain.001.003.03.xsd')
end
end
end
end
end
1 change: 1 addition & 0 deletions spec/credit_transfer_transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
context 'for pain.001.001.03' do
it 'should succeed for valid attributes' do
expect(SEPA::CreditTransferTransaction.new(:bic => 'SPUEDE2UXXX', :currency => 'CHF')).to be_schema_compatible('pain.001.001.03')
expect(SEPA::CreditTransferTransaction.new(:bic => nil)).to be_schema_compatible('pain.001.003.03')
end
end
end
Expand Down