Sha256: 05a2ca501c9c9bade593259758eb81e3475024cfcdf1be6c432ef2e9ca69e170
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 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 validates_with MandateIdentifierValidator, field_name: :mandate_id validates_presence_of :mandate_date_of_signature validates_inclusion_of :local_instrument, in: LOCAL_INSTRUMENTS validates_inclusion_of :sequence_type, in: SEQUENCE_TYPES 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 if t.requested_date.is_a?(Date) errors.add(:requested_date, 'is not in the future') if t.requested_date <= Date.today 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
4 entries across 4 versions & 1 rubygems