Module: Smerp::Quotation::Engine::QuotationsHelper
- Defined in:
- app/helpers/smerp/quotation/engine/quotations_helper.rb
Instance Method Summary collapse
- #days_to_human_readable(days) ⇒ Object
- #extended_calculator_name(ec) ⇒ Object
- #extended_calculator_value_code(ec) ⇒ Object
- #extended_calculator_value_name(ec) ⇒ Object
- #is_children_hidden?(id) ⇒ Boolean
- #level_marker(level) ⇒ Object
- #level_seq_conv(level, seq) ⇒ Object
-
#render_item_tree_table(itm, level = 1, indx = 0, form = nil) ⇒ Object
cont += render_item_tree© end cont << “</ol>” cont end.
Instance Method Details
#days_to_human_readable(days) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 101 def days_to_human_readable(days) if days > 20 months = (days/20).to_i monthDays = months*20 balMonthDay = days - monthDays weeks = (balMonthDay/5).to_i weekDays = weeks*5 days = (balMonthDay - weekDays).to_i if days > 0 "#{months} month(s), #{weeks} week(s) and #{days} days (Calendar Based)" elsif balMonthDay > 0 "#{months} month(s) and #{weeks} week(s) (Calendar Based)" else "#{months} month(s) (Calendar Based)" end else "#{days} calendar day(s)" end end |
#extended_calculator_name(ec) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 66 def extended_calculator_name(ec) case ec when Smerp::Quotation::TaxCalculator "Tax Calculator" when Smerp::Quotation::DiscountCalculator "Discount Calculator" when Smerp::Quotation::RoundUpCalculator "Round Up Calculator" else ec end end |
#extended_calculator_value_code(ec) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 88 def extended_calculator_value_code(ec) case ec.params when Smerp::Common::FinUtils::Percent "#{ec.params.value}p" else "#{ec.params}" end end |
#extended_calculator_value_name(ec) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 79 def extended_calculator_value_name(ec) case ec.params when Smerp::Common::FinUtils::Percent "#{ec.params.value}%" else "#{ec.params.value}" end end |
#is_children_hidden?(id) ⇒ Boolean
97 98 99 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 97 def is_children_hidden?(id) not session[:hide_children_parent_id].nil? and session[:hide_children_parent_id].include?(id) end |
#level_marker(level) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 34 def level_marker(level) marker = [ "#DBFED8", #light green "#FEF0D8", "#D8F8FE", "#FED8D8", "#B7FFD8" ] marker[level%marker.length] end |
#level_seq_conv(level, seq) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 46 def level_seq_conv(level, seq) levelConv = [:to_i, :alpha_lowercase, :roman_lowercase, :alpha_upcase, :roman_upcase] conv = levelConv[level%levelConv.length] case conv when :to_i seq.to_i when :alpha_lowercase seq.to_i.int_to_alpha_downcase when :roman_lowercase seq.to_i.int_to_roman_downcase when :alpha_upcase seq.to_i.int_to_alpha when :roman_upcase seq.to_i.int_to_roman else seq.to_i end end |
#render_item_tree_table(itm, level = 1, indx = 0, form = nil) ⇒ Object
cont += render_item_tree©
end
cont << "</ol>"
cont
end
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/smerp/quotation/engine/quotations_helper.rb', line 19 def render_item_tree_table(itm, level = 1, indx = 0, form = nil) cont = [] level += 1 indx = 0 if session[:hide_children_parent_id].nil? or not session[:hide_children_parent_id].include?(itm.id) itm.children.each do |c| cont << render("quotation_item", quotation_item: c, level: level, index: indx, f: form) indx += 1 cont += render_item_tree_table(c, level, indx, form) end end cont end |