58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/commission.rb', line 58
def self.for(payment, filter_amount=true)
commission = payment.provider.commissions.actual.first
return [] if commission.blank?
rates = commission.commission_sections.
by_terminal_profile_and_agent_ids(payment.terminal.terminal_profile_id, payment.terminal.agent_id).
by_payment_type(payment.payment_type)
rates.select!{|x|
x.min <= payment.paid_amount &&
x.max >= payment.paid_amount
} if filter_amount
rates.sort_by(&:weight).reverse
end
|