Sha256: 9cebd98b6555d9e234790df4bf72a63319cde0e395d059e65bd34a49a5152655

Contents?: true

Size: 957 Bytes

Versions: 49

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

49 entries across 49 versions & 1 rubygems

Version Path
epb_view_models-1.0.28 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.27 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.26 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.25 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.24 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.23 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.22 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.21 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.20 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.19 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.18 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.17 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.16 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.15 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.14 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.13 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.12 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.11 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.10 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.9 lib/helper/estimated_cost_potential_saving_helper.rb