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

Version Path
epb_view_models-2.0.5 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-2.0.4 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-2.0.3 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-2.0.2 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-2.0.1 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-2.0.0 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.2.3 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.2.2 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.2.1 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.2.0 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.6 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.5 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.4 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.3 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.2 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.1 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.1.0 lib/helper/estimated_cost_potential_saving_helper.rb
epb_view_models-1.0.29 lib/helper/estimated_cost_potential_saving_helper.rb
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