From 65b4d7aa5bf779056fc93d66992a2966c15e6681 Mon Sep 17 00:00:00 2001 From: Aart van Halteren Date: Wed, 31 Jul 2013 11:58:29 +0200 Subject: [PATCH] reduce precision to 1 digit --- app/models/reading.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/models/reading.rb b/app/models/reading.rb index 978dc1c..cdf66e4 100644 --- a/app/models/reading.rb +++ b/app/models/reading.rb @@ -10,5 +10,25 @@ class Reading < ActiveRecord::Base self.total_m3_gas_consumed == reading.total_m3_gas_consumed && self.high_tarif == reading.high_tarif end + + # reduce precision to 1 digit behind comma + def total_kwh_consumed_high=(kwh) + write_attribute(:total_kwh_consumed_high,kwh.round(1)) + end + + # reduce precision to 1 digit behind comma + def total_kwh_consumed_low=(kwh) + write_attribute(:total_kwh_consumed_low,kwh.round(1)) + end + + # reduce precision to 1 digit behind comma + def total_kwh_produced_high=(kwh) + write_attribute(:total_kwh_produced_high,kwh.round(1)) + end + + # reduce precision to 1 digit behind comma + def total_kwh_produced_low=(kwh) + write_attribute(:total_kwh_produced_low,kwh.round(1)) + end end