Class: Sepa::DirectDebitOrder::DirectDebit

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa/direct_debit_order.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debtor, debtor_account, end_to_end_id, amount, currency, mandate_info, remittance_information = nil) ⇒ DirectDebit

Returns a new instance of DirectDebit.



254
255
256
# File 'lib/sepa/direct_debit_order.rb', line 254

def initialize debtor, , end_to_end_id, amount, currency, mandate_info, remittance_information = nil
  @debtor, @debtor_account, @end_to_end_id, @amount, @currency, @mandate_info, @remittance_information = debtor, , end_to_end_id, amount, currency, mandate_info, remittance_information
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def currency
  @currency
end

#debtorObject

Returns the value of attribute debtor.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def debtor
  @debtor
end

#debtor_accountObject

Returns the value of attribute debtor_account.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def 
  @debtor_account
end

#end_to_end_idObject

Returns the value of attribute end_to_end_id.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def end_to_end_id
  @end_to_end_id
end

#mandate_infoObject

Returns the value of attribute mandate_info.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def mandate_info
  @mandate_info
end

#remittance_informationObject

Returns the value of attribute remittance_information.



252
253
254
# File 'lib/sepa/direct_debit_order.rb', line 252

def remittance_information
  @remittance_information
end

Instance Method Details

#sequence_typeObject



258
259
260
# File 'lib/sepa/direct_debit_order.rb', line 258

def sequence_type
  mandate_info.sequence_type
end

#to_properties(prefix, opts) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/sepa/direct_debit_order.rb', line 262

def to_properties prefix, opts
  hsh = {
    "#{prefix}.payment_identification.end_to_end_identification"         => end_to_end_id,
    "#{prefix}.instructed_amount"                                        => ("%.2f" % amount),
    "#{prefix}.instructed_amount_currency"                               => "EUR",
    "#{prefix}.direct_debit_transaction.mandate_related_information.mandate_identification" => mandate_info.identification,
    "#{prefix}.direct_debit_transaction.mandate_related_information.date_of_signature"      => mandate_info.signature_date,
    "#{prefix}.remittance_information.unstructured_remittance_information"                  => remittance_information
  }
  hsh = hsh.merge debtor.to_properties("#{prefix}.debtor", opts)
  hsh = hsh.merge .to_properties("#{prefix}.debtor", opts)

  if opts[:pain_008_001_version] == "04"
    hsh["#{prefix}.payment_type_information.sequence_type"] = mandate_info.sequence_type
  end

  hsh
end