31 lines
719 B
Ruby
Executable File
31 lines
719 B
Ruby
Executable File
class CreditProduct < ActiveRecord::Base
|
|
|
|
def price_ttc
|
|
self.price_ht * 1.2
|
|
end
|
|
|
|
|
|
def price_ht_final(customer)
|
|
self.price_ht - customer.credits.between(Date.today, Date.today).boughts.sum("orders.price_ht")
|
|
end
|
|
|
|
def price_ttc_final(customer)
|
|
self.price_ht_final(customer)* 1.2
|
|
|
|
end
|
|
|
|
def nbr_credits_final(customer)
|
|
self.nbr_credits - customer.credits_boughts(Date.today)
|
|
end
|
|
|
|
def binary_points_final(customer)
|
|
self.binary_points - customer.credits.between(Date.today, Date.today).boughts.sum("orders.binary_points")
|
|
end
|
|
|
|
def nbr_parts_final(customer)
|
|
self.parts - customer.credits.between(Date.today, Date.today).boughts.sum("orders.nbr_parts")
|
|
end
|
|
|
|
end
|
|
|