Class: SEPA::Transaction

Inherits:
Object
  • Object
show all
Extended by:
Converter
Includes:
ActiveModel::Model
Defined in:
lib/sepa_rator/transaction.rb

Constant Summary collapse

DEFAULT_REQUESTED_DATE =

Convention SEPA: 1999-01-01 signifies “execute as soon as possible” (ASAP). When no specific date is requested, this sentinel value tells the bank to process the payment at the earliest opportunity.

Date.new(1999, 1, 1).freeze
UETR_REGEX =
/\A[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}\z/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Converter

convert

Constructor Details

#initialize(attributes = {}) ⇒ Transaction

Returns a new instance of Transaction.



78
79
80
81
82
83
84
# File 'lib/sepa_rator/transaction.rb', line 78

def initialize(attributes = {})
  super
  self.requested_date ||= DEFAULT_REQUESTED_DATE
  self.reference ||= 'NOTPROVIDED'
  self.batch_booking = true if batch_booking.nil?
  self.currency ||= 'EUR'
end

Instance Attribute Details

#additional_remittance_informationObject

Returns the value of attribute additional_remittance_information.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def additional_remittance_information
  @additional_remittance_information
end

#agent_leiObject

Returns the value of attribute agent_lei.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def agent_lei
  @agent_lei
end

#amountObject

Returns the value of attribute amount.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def amount
  @amount
end

#batch_bookingObject

Returns the value of attribute batch_booking.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def batch_booking
  @batch_booking
end

#bicObject

Returns the value of attribute bic.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def bic
  @bic
end

#currencyObject

Returns the value of attribute currency.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def currency
  @currency
end

#ibanObject

Returns the value of attribute iban.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def iban
  @iban
end

#instructionObject

Returns the value of attribute instruction.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def instruction
  @instruction
end

#instruction_priorityObject

Returns the value of attribute instruction_priority.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def instruction_priority
  @instruction_priority
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def name
  @name
end

#purpose_codeObject

Returns the value of attribute purpose_code.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def purpose_code
  @purpose_code
end

#referenceObject

Returns the value of attribute reference.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def reference
  @reference
end

#remittance_informationObject

Returns the value of attribute remittance_information.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def remittance_information
  @remittance_information
end

#requested_dateObject

Returns the value of attribute requested_date.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def requested_date
  @requested_date
end

#structured_remittance_informationObject

Returns the value of attribute structured_remittance_information.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def structured_remittance_information
  @structured_remittance_information
end

#structured_remittance_issuerObject

Returns the value of attribute structured_remittance_issuer.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def structured_remittance_issuer
  @structured_remittance_issuer
end

#structured_remittance_reference_typeObject

Returns the value of attribute structured_remittance_reference_type.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def structured_remittance_reference_type
  @structured_remittance_reference_type
end

#uetrObject

Returns the value of attribute uetr.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def uetr
  @uetr
end

#ultimate_creditor_nameObject

Returns the value of attribute ultimate_creditor_name.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def ultimate_creditor_name
  @ultimate_creditor_name
end

#ultimate_debtor_nameObject

Returns the value of attribute ultimate_debtor_name.



13
14
15
# File 'lib/sepa_rator/transaction.rb', line 13

def ultimate_debtor_name
  @ultimate_debtor_name
end

Instance Method Details

#compatible_capabilities?(_profile) ⇒ Boolean

This method is abstract.

Subclasses override to check that fields requiring capabilities (uetr, lei, etc.) are only set when the profile advertises them.

Returns:

  • (Boolean)


96
97
98
# File 'lib/sepa_rator/transaction.rb', line 96

def compatible_capabilities?(_profile)
  true
end

#compatible_with?(profile) ⇒ Boolean

Returns whether this transaction can be rendered under the given profile. Delegates to ‘profile.accepts?` for profile-level rules (e.g. EPC currency restrictions) and to `#compatible_capabilities?` for capability-level checks (UETR, LEI, mandate info, …).

Returns:

  • (Boolean)

    whether this transaction can be rendered under the given profile. Delegates to ‘profile.accepts?` for profile-level rules (e.g. EPC currency restrictions) and to `#compatible_capabilities?` for capability-level checks (UETR, LEI, mandate info, …).



90
91
92
# File 'lib/sepa_rator/transaction.rb', line 90

def compatible_with?(profile)
  profile.accepts?(self) && compatible_capabilities?(profile)
end