Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.32 KB | None | 0 0
  1. class LineItem < ActiveRecord::Base
  2.   belongs_to :quote
  3.   belongs_to :part
  4.  
  5.   def calculate_price_from_gmpercent
  6.     update_attribute(:price, self.part.cost/(1-self.gmpercent))
  7.   end  
  8.  
  9.   def set_gmpercent(gmtarget)
  10.     update_attribute(:gmpercent, [gmtarget, 1-(self.part.cost/self.part.listprice)].min)
  11.   end  
  12.  
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement