From 5e36cf455e66cc8649f5f23ddf6e0dad4ab337a5 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 26 Jun 2008 16:39:20 -0700 Subject: [PATCH] Catch nil cost_per_hour and total_hours on the HourlyDeliverable.profit. #1387 --- app/models/hourly_deliverable.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/hourly_deliverable.rb b/app/models/hourly_deliverable.rb index 84b82f9..e466cdd 100644 --- a/app/models/hourly_deliverable.rb +++ b/app/models/hourly_deliverable.rb @@ -35,6 +35,7 @@ class HourlyDeliverable < Deliverable if read_attribute(:profit_percent).nil? return super else + return 0.0 if read_attribute(:cost_per_hour).nil? || read_attribute(:total_hours).nil? labor = (read_attribute(:cost_per_hour) * read_attribute(:total_hours)) return (read_attribute(:profit_percent).to_f / 100.0) * (labor + self.overhead)