Sha256: 9cebd98b6555d9e234790df4bf72a63319cde0e395d059e65bd34a49a5152655
Contents?: true
Size: 957 Bytes
Versions: 47
Compression:
Stored size: 957 Bytes
Contents
# frozen_string_literal: true require "bigdecimal" module Helper class EstimatedCostPotentialSavingHelper def estimated_cost( lighting_cost_current, heating_cost_current, hot_water_cost_current ) estimated_cost = [ lighting_cost_current, heating_cost_current, hot_water_cost_current, ].compact.map { |value| BigDecimal(value) }.sum sprintf("%.2f", estimated_cost) end def potential_saving( lighting_cost_potential, heating_cost_potential, hot_water_cost_potential, estimated_cost = BigDecimal(0) ) potential_saving_sum = [ lighting_cost_potential, heating_cost_potential, hot_water_cost_potential, ].compact.map { |value| BigDecimal(value) }.sum potential_saving = BigDecimal(estimated_cost) - potential_saving_sum sprintf("%.2f", potential_saving) end end end
Version data entries
47 entries across 47 versions & 1 rubygems