Sha256: 38ef9a0f88d756479abfb6ad9ceab3304dfe339ad54e4af88cb4fcec091d0850
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
# encoding: utf-8 module SEPA class DirectDebitTransaction < Transaction SEQUENCE_TYPES = %w(FRST OOFF RCUR FNAL) LOCAL_INSTRUMENTS = %w(CORE COR1 B2B) attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type, :creditor_account, :original_debtor_account, :same_mandate_new_debtor_agent validates_with MandateIdentifierValidator, field_name: :mandate_id, message: "%{value} is invalid" validates_presence_of :mandate_date_of_signature validates_inclusion_of :local_instrument, in: LOCAL_INSTRUMENTS validates_inclusion_of :sequence_type, in: SEQUENCE_TYPES validate { |t| t.validate_requested_date_after(Date.today.next) } validate do |t| if creditor_account errors.add(:creditor_account, 'is not correct') unless creditor_account.valid? end if t.mandate_date_of_signature.is_a?(Date) errors.add(:mandate_date_of_signature, 'is in the future') if t.mandate_date_of_signature > Date.today else errors.add(:mandate_date_of_signature, 'is not a Date') end end def initialize(attributes = {}) super self.local_instrument ||= 'CORE' self.sequence_type ||= 'OOFF' end def schema_compatible?(schema_name) case schema_name when PAIN_008_002_02 self.bic.present? && %w(CORE B2B).include?(self.local_instrument) when PAIN_008_003_02, PAIN_008_001_02 true end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sepa_king-0.9.0 | lib/sepa_king/transaction/direct_debit_transaction.rb |