Class: Bankserv::Transmission::UserSet::EftOutput
- Defined in:
- lib/bankserv/transmission/set/eft_output.rb
Instance Method Summary collapse
Methods inherited from Set
#base_set, #build_header, #build_trailer, #contained_sets, #decorate_records, from_hash, #get_document, #header, #number_of_records, #parent, partial_class_name, #rec_status, #record_with_sequence_number, #set_type, #to_hash, #trailer, #transactions
Instance Method Details
#process ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bankserv/transmission/set/eft_output.rb', line 7 def process service = Bankserv::Service.active.select {|s| s.config[:user_code] == self.records.first.data[:bankserv_user_code]}.last if !service.nil? && service.is_a?(Bankserv::CreditService) self.sets.each do |set| set.transactions.each do |trans| ref = trans.reference.gsub(service.config[:client_abbreviated_name], "") credits = Bankserv::Credit.where(record_type: 'standard', action_date: trans.data[:transmission_date].to_date, status: ['accepted', 'pending', 'warning', 'rejected'], amount: trans.data[:amount].to_i).where('lower(user_ref) = ?', ref.downcase).select do |credit| branch_code = if trans.data[:homing_branch_code] == "0" then "" else trans.data[:homing_branch_code] end credit.bank_account.account_number == trans.data[:homing_account_number] && credit.bank_account.branch_code == branch_code && credit.bank_account.account_name.downcase == trans.data[:homing_account_name].downcase end rejection_reason_description = Absa::H2h::Eft::RejectionCode.reason_for_code(trans.data[:rejection_reason]), rejection_qualifier_description = Absa::H2h::Eft::RejectionCode.qualifier_for_code(trans.data[:rejection_qualifier]) credits.each do |credit| request_credits = Bankserv::Credit.where(bankserv_request_id: credit.bankserv_request_id) request_credits.each do |c| c.update_attributes!({ status: 'rejected', response: [{ code: rejection_reason_description, message: rejection_qualifier_description }] }) end end end end else sets.each{|s| s.process} end end |