From f7563fc9190561eb4d03ecc4ee51a9c0cc6a4ca5 Mon Sep 17 00:00:00 2001 From: Lenno Nagel Date: Thu, 8 May 2014 17:42:30 +0200 Subject: [PATCH] Implement the Instruction Identification tag, which is mandatory for Swedbank Estonia --- README.md | 4 ++++ lib/sepa_king/message/credit_transfer.rb | 3 +++ lib/sepa_king/transaction.rb | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4833661..2ddc08c 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ sdd.add_transaction( # Number with two decimal digit amount: 39.99, + # OPTIONAL: Instruction Identification, will not be submitted to the debtor + # String, max. 35 char + instruction: '12345', + # OPTIONAL: End-To-End-Identification, will be submitted to the debtor # String, max. 35 char reference: 'XYZ/2013-08-ABO/6789', diff --git a/lib/sepa_king/message/credit_transfer.rb b/lib/sepa_king/message/credit_transfer.rb index fd32ce4..0797bac 100644 --- a/lib/sepa_king/message/credit_transfer.rb +++ b/lib/sepa_king/message/credit_transfer.rb @@ -63,6 +63,9 @@ def build_payment_informations(builder) def build_transaction(builder, transaction) builder.CdtTrfTxInf do builder.PmtId do + if transaction.instruction.present? + builder.InstrId(transaction.instruction) + end builder.EndToEndId(transaction.reference) end builder.Amt do diff --git a/lib/sepa_king/transaction.rb b/lib/sepa_king/transaction.rb index 15c37c1..4353c95 100644 --- a/lib/sepa_king/transaction.rb +++ b/lib/sepa_king/transaction.rb @@ -4,11 +4,12 @@ class Transaction include ActiveModel::Validations extend Converter - attr_accessor :name, :iban, :bic, :amount, :reference, :remittance_information, :requested_date, :batch_booking - convert :name, :reference, :remittance_information, to: :text + attr_accessor :name, :iban, :bic, :amount, :instruction, :reference, :remittance_information, :requested_date, :batch_booking + convert :name, :instruction, :reference, :remittance_information, to: :text convert :amount, to: :decimal validates_length_of :name, within: 1..70 + validates_length_of :instruction, within: 1..35, allow_nil: true validates_length_of :reference, within: 1..35, allow_nil: true validates_length_of :remittance_information, within: 1..140, allow_nil: true validates_numericality_of :amount, greater_than: 0