mercredi 25 mars 2015

undefined method `txnid' for []:Array

I am trying to display the unique trasactions in my table. Actually I have some duplicate transactions as well. I am getting this below error when I call txnid.uniq on my table.(@all_settlement_details)



undefined method `txnid' for []:Array


Transaction.html.erb



<th>Merchant Name</th>
<th>Transaction ID</th>
<th>Payment Mode</th>
<th>Amount</th>
<th>Status</th>
<th>Transaction Fee</th>
<th>Discount</th>
<th>Additional Charges</th>
<th>Added On</th>
</tr>
</thead>
<tbody id="details">
<% @all_settlement_details.txnid.uniq.each do |sd| %>
<tr>
<td><%= sd.merchantname %></td>
<td><%= sd.txnid %></td>
<td><%= get_mode_ui.value(sd.mode) %></td>
<td><%= sd.amount %></td>
<td><%= get_status(sd.status) %></td>
<td><%= sd.mer_service_fee %></td>
<td><%= sd.discount %></td>
<td><%= sd.additional_charges%></td>
<td><%= get_added_on_date sd.addedon %></td>
</tr>
<% end %>
</tbody>


traansactions_helper.rb



def get_all_settlement_details
# Offset increments by 10 and Limit remains 11
_txn_filter_scope = {'transaction_status' => ["status", (params[:transaction_status].split(',') rescue nil)],
'payment_options' => ["payment_options", (params[:payment_options].split(',') rescue nil)],
'transaction_id' => ['transaction_id', params[:transaction_id]],
'transaction_amount' => ['amount_range', ((params[:transaction_amount].split(',')[0] || 0) rescue nil), ((params[:transaction_amount].split(',')[1] || 100000000) rescue nil)],
'merchant_mid' => ['merchant_mid',params[:merchant_mid]],
'merchant_name' => ['merchant_name', params[:merchant_name]],
'clicks' => ['txn_offset', ((params[:clicks].to_i)*10 rescue 0)]
}
method_array = [['settlement_details'],["date_filter", @start_date, @end_date]]
method_array << ["txn_limit", 11] unless @csv_format
method_array << ['merchant_mid', @merchant_mid] if @merchant_mid
records = call_scope_methods_dynamically(method_array, _txn_filter_scope)
records.empty? ? nil : records
end

# Get the multiple payment modes of a trasaction, if any.
def get_multiple_payment_modes txn_id, payment_modes
debugger
PG_MODE
@all_modes = []
@total_trasactions = []
_multiple_modes = {'transaction_id' => ['transaction_id', params[:transaction_id]]}
methods = [['settlement_details'],['merchant_mid'],['transaction_id'], ['payment_modes']]
@total_transactions << ['transaction_id', txn_id] if payment_modes.present?
if @total_transactions[:payment_modes] > 1
payment_modes.each do |m|
@all_modes << m
end
@all_modes
end
end

def get_uniq_transactions txn_id
@all_modes = []
uniq_tr = @all_settlement_details.txn_id.uniq
uniq_tr.payment_modes.each do |m|
@all_modess << m
end
end


How to fix this error and display only uniq traasactions?


Thanks for your help!


Aucun commentaire:

Enregistrer un commentaire