X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fmodels%2Fcoitem.rb;h=b9d902481d62d2ec435820d6fe883e31f7e4c3b6;hb=bbf13350a73e14c5448f6fb0077126b7d92cdb48;hp=513625a985a539bc37dbe951f95bcdc8d026234a;hpb=d95e8f6a8205bf08d7de6d4f069acba9933cdba0;p=cs356-p2-videostore.git diff --git a/app/models/coitem.rb b/app/models/coitem.rb index 513625a..b9d9024 100644 --- a/app/models/coitem.rb +++ b/app/models/coitem.rb @@ -21,6 +21,11 @@ class Coitem < ActiveRecord::Base return due_date < Time.now.to_date end + def late_fee + days_late = Time.now.to_date - (due_date) + return VideoPolicy.find_by_day(8).fee * days_late.to_i + end + protected def validate errors.add(:customer_id, "does not exist is the database") if customer.nil?