Skip to content

Commit

Permalink
Adds InstrId support for direct debits (#57)
Browse files Browse the repository at this point in the history
Also added 'instruction' to credit transfer example in README
  • Loading branch information
tobischo authored and ledermann committed Dec 14, 2016
1 parent 936b2b2 commit 0abb2de
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ sct.add_transaction(
# Number with two decimal digit
amount: 102.50,

# OPTIONAL: Instruction Identification, will not be submitted to the creditor
# String, max. 35 char
instruction: '12345',

# OPTIONAL: End-To-End-Identification, will be submitted to the creditor
# String, max. 35 char
reference: 'XYZ-1234/123',
Expand Down
3 changes: 3 additions & 0 deletions lib/sepa_king/message/direct_debit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def build_amendment_informations(builder, transaction)
def build_transaction(builder, transaction)
builder.DrctDbtTxInf do
builder.PmtId do
if transaction.instruction.present?
builder.InstrId(transaction.instruction)
end
builder.EndToEndId(transaction.reference)
end
builder.InstdAmt('%.2f' % transaction.amount, Ccy: 'EUR')
Expand Down
18 changes: 18 additions & 0 deletions spec/direct_debit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,24 @@
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlDbtrAgt/FinInstnId/Othr/Id', 'SMNDA')
end
end

context 'with instruction given' do
subject do
sct = direct_debit

sct.add_transaction(direct_debt_transaction.merge(instruction: '1234/ABC'))

sct.to_xml
end

it 'should create valid XML file' do
expect(subject).to validate_against('pain.008.003.02.xsd')
end

it 'should contain <InstrId>' do
expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/PmtId/InstrId', '1234/ABC')
end
end
end
end
end

0 comments on commit 0abb2de

Please sign in to comment.