Skip to content

Commit

Permalink
Merge pull request #65 from skateinmars/optional-pain.001.001.03-tran…
Browse files Browse the repository at this point in the history
…saction-bic

Allow empty BIC for pain.001.001.03 credit transfers
  • Loading branch information
ledermann authored Aug 20, 2017
2 parents b827e5c + 2f52bbb commit 75b711a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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

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

0 comments on commit 75b711a

Please sign in to comment.