Class: Commission

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/commission.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(payment, filter_amount = true) ⇒ Object

METHODS



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

Instance Method Details

#titleObject



74
75
76
# File 'app/models/commission.rb', line 74

def title
  "##{id}"
end