Class: Rebate

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(payment) ⇒ Object

METHODS



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/models/rebate.rb', line 67

def self.for(payment)
  rebate = payment.gateway.rebates.actual.first
  return nil if rebate.blank?

  rates = rebate.provider_rebates.
    by_provider(payment.provider).
    by_commission(payment.commission_amount).
    by_payment_type(payment.payment_type)
  rates.select{|x| 
    x.min <= payment.paid_amount && 
    x.max >= payment.paid_amount
  }.sort_by(&:weight).reverse.first
end

Instance Method Details

#titleObject



81
82
83
# File 'app/models/rebate.rb', line 81

def title
  "##{id}"
end