Class: Liquid::QuoteDrop
- Inherits:
-
Drop
- Object
- Drop
- Liquid::QuoteDrop
- Includes:
- Memery
- Defined in:
- app/models/liquid/quote_drop.rb
Overview
Helper class scoped to Liquid.
Instance Attribute Summary collapse
-
#quote ⇒ Object
readonly
Returns the value of attribute quote.
Delegated Instance Attributes collapse
-
#customer ⇒ Object
Alias for Quote#customer.
-
#expiration_date ⇒ Object
Alias for Quote#expiration_date.
-
#id ⇒ Object
Alias for Quote#id.
-
#line_total ⇒ Object
Alias for Quote#line_total.
-
#lookup_link ⇒ Object
Alias for Quote#lookup_link.
-
#opportunity ⇒ Object
Alias for Quote#opportunity.
-
#primary_sales_rep ⇒ Object
Alias for Quote#primary_sales_rep.
-
#quote_suffix ⇒ Object
Alias for Quote#suffix.
-
#recipient_email ⇒ Object
Alias for Quote#recipient_email.
-
#recipient_name ⇒ Object
Alias for Quote#recipient_name.
-
#reference_number ⇒ Object
Alias for Quote#reference_number.
-
#reference_number_with_name ⇒ Object
Alias for Quote#reference_number_with_name.
-
#reference_number_with_opp_name_when_specified ⇒ Object
Alias for Quote#reference_number_with_opp_name_when_specified.
-
#suffix ⇒ Object
Alias for Quote#suffix.
-
#tax_total ⇒ Object
Alias for Quote#tax_total.
-
#total ⇒ Object
Alias for Quote#total.
-
#total_amps ⇒ Object
Alias for Quote#total_amps.
Instance Method Summary collapse
- #can_be_paid_online? ⇒ Boolean
- #completed? ⇒ Boolean
- #country_iso3 ⇒ Object
- #coupon_total ⇒ Object
- #coupons ⇒ Object
- #disclaimer ⇒ Object
- #expiration_date_formatted ⇒ Object
- #for_direct_pro? ⇒ Boolean
- #for_homeowner? ⇒ Boolean
- #formatted_coupon_total ⇒ Object
- #formatted_tax_total ⇒ Object
- #friendly_shipping_method ⇒ Object
- #has_dropship_items? ⇒ Boolean
- #has_floor_heating? ⇒ Boolean
- #has_out_of_stock_items? ⇒ Boolean
- #has_rep? ⇒ Boolean
- #has_service_items? ⇒ Boolean
- #has_smartplans? ⇒ Boolean
- #has_snow_melting? ⇒ Boolean
-
#initialize(quote) ⇒ QuoteDrop
constructor
A new instance of QuoteDrop.
- #is_canada_quote? ⇒ Boolean
- #is_pickup? ⇒ Boolean
- #is_usa_quote? ⇒ Boolean
- #job_name ⇒ Object
- #pre_planning_invite_url ⇒ Object
- #public_link ⇒ Object
- #public_link_account_email ⇒ Object
- #public_path ⇒ Object
- #quote_number ⇒ Object
- #rep_email ⇒ Object
- #rep_name ⇒ Object
- #schedule_meeting_link ⇒ Object
- #service_only_quote? ⇒ Boolean
- #show_pre_planning_meeting? ⇒ Boolean
- #show_schedule_meeting_link ⇒ Object
- #taxes ⇒ Object
- #total_formatted ⇒ Object
- #total_operating_cost_dollars_per_hour_blurb ⇒ Object
Constructor Details
#initialize(quote) ⇒ QuoteDrop
Returns a new instance of QuoteDrop.
28 29 30 |
# File 'app/models/liquid/quote_drop.rb', line 28 def initialize(quote) @quote = quote end |
Instance Attribute Details
#quote ⇒ Object (readonly)
Returns the value of attribute quote.
7 8 9 |
# File 'app/models/liquid/quote_drop.rb', line 7 def quote @quote end |
Instance Method Details
#can_be_paid_online? ⇒ Boolean
129 130 131 |
# File 'app/models/liquid/quote_drop.rb', line 129 def can_be_paid_online? quote.complete? || quote.awaiting_transmission? end |
#completed? ⇒ Boolean
124 125 126 |
# File 'app/models/liquid/quote_drop.rb', line 124 def completed? quote.complete? end |
#country_iso3 ⇒ Object
146 147 148 |
# File 'app/models/liquid/quote_drop.rb', line 146 def country_iso3 quote.store.country_iso3 end |
#coupon_total ⇒ Object
67 68 69 |
# File 'app/models/liquid/quote_drop.rb', line 67 def coupon_total quote.line_discounts.sum(:amount) end |
#coupons ⇒ Object
139 140 141 142 143 |
# File 'app/models/liquid/quote_drop.rb', line 139 def coupons quote.discounts_grouped_by_coupon.map do |code, vals| { 'code' => code, 'title' => vals[:title], 'amount' => ActionController::Base.helpers.number_to_currency(vals[:amount]) } end end |
#customer ⇒ Object
Alias for Quote#customer
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#disclaimer ⇒ Object
89 90 91 |
# File 'app/models/liquid/quote_drop.rb', line 89 def disclaimer GENERAL_DISCLAIMER_ON_PRODUCT_INSTALLATION_AND_LOCAL_CODES end |
#expiration_date ⇒ Object
Alias for Quote#expiration_date
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#expiration_date_formatted ⇒ Object
40 41 42 |
# File 'app/models/liquid/quote_drop.rb', line 40 def expiration_date_formatted quote.expiration_date.strftime('%B %-d') end |
#for_direct_pro? ⇒ Boolean
208 209 210 |
# File 'app/models/liquid/quote_drop.rb', line 208 def for_direct_pro? customer.is_direct_pro? end |
#for_homeowner? ⇒ Boolean
203 204 205 |
# File 'app/models/liquid/quote_drop.rb', line 203 def for_homeowner? customer.is_homeowner? end |
#formatted_coupon_total ⇒ Object
62 63 64 |
# File 'app/models/liquid/quote_drop.rb', line 62 def formatted_coupon_total ActionController::Base.helpers.number_to_currency(quote.line_discounts.sum(:amount)) end |
#formatted_tax_total ⇒ Object
57 58 59 |
# File 'app/models/liquid/quote_drop.rb', line 57 def formatted_tax_total ActionController::Base.helpers.number_to_currency(quote.tax_total) end |
#friendly_shipping_method ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'app/models/liquid/quote_drop.rb', line 79 def friendly_shipping_method if quote.is_warehouse_pickup? 'Warehouse Pickup' elsif quote.friendly_shipping_method == 'Override' 'Shipping' else quote.friendly_shipping_method end end |
#has_dropship_items? ⇒ Boolean
93 94 95 |
# File 'app/models/liquid/quote_drop.rb', line 93 def has_dropship_items? quote.line_items.any?(&:dropship?) end |
#has_floor_heating? ⇒ Boolean
193 194 195 |
# File 'app/models/liquid/quote_drop.rb', line 193 def has_floor_heating? quote.line_items.floor_heating_elements.exists? end |
#has_out_of_stock_items? ⇒ Boolean
98 99 100 101 |
# File 'app/models/liquid/quote_drop.rb', line 98 def has_out_of_stock_items? item_availability = LineItem.availability_hash(quote.line_items) quote.line_items.any? { |li| li.show_out_of_stock?(item_availability) } end |
#has_rep? ⇒ Boolean
119 120 121 |
# File 'app/models/liquid/quote_drop.rb', line 119 def has_rep? quote.customer.primary_sales_rep.present? end |
#has_service_items? ⇒ Boolean
104 105 106 |
# File 'app/models/liquid/quote_drop.rb', line 104 def has_service_items? quote.line_items.any?(&:is_service?) end |
#has_smartplans? ⇒ Boolean
188 189 190 |
# File 'app/models/liquid/quote_drop.rb', line 188 def has_smartplans? quote.room_configurations.any?(&:installation_plan_image) end |
#has_snow_melting? ⇒ Boolean
198 199 200 |
# File 'app/models/liquid/quote_drop.rb', line 198 def has_snow_melting? quote.line_items.snow_melting_elements.exists? end |
#id ⇒ Object
Alias for Quote#id
229 |
# File 'app/models/liquid/quote_drop.rb', line 229 delegate :id, to: :quote |
#is_canada_quote? ⇒ Boolean
155 156 157 |
# File 'app/models/liquid/quote_drop.rb', line 155 def is_canada_quote? country_iso3 == 'CAN' end |
#is_pickup? ⇒ Boolean
159 160 161 |
# File 'app/models/liquid/quote_drop.rb', line 159 def is_pickup? quote.is_warehouse_pickup? end |
#is_usa_quote? ⇒ Boolean
151 152 153 |
# File 'app/models/liquid/quote_drop.rb', line 151 def is_usa_quote? country_iso3 == 'USA' end |
#job_name ⇒ Object
48 49 50 |
# File 'app/models/liquid/quote_drop.rb', line 48 def job_name opportunity.name end |
#line_total ⇒ Object
Alias for Quote#line_total
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#lookup_link ⇒ Object
Alias for Quote#lookup_link
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#opportunity ⇒ Object
Alias for Quote#opportunity
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#pre_planning_invite_url ⇒ Object
219 220 221 222 223 224 225 226 227 |
# File 'app/models/liquid/quote_drop.rb', line 219 def pre_planning_invite_url uri = Addressable::URI.parse(ContactConstants::ZOOM_PRE_PLANNING) uri.query_values = { name: recipient_name, email: recipient_email, a1: reference_number } uri.to_s end |
#primary_sales_rep ⇒ Object
Alias for Quote#primary_sales_rep
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#public_link ⇒ Object
175 176 177 178 179 180 |
# File 'app/models/liquid/quote_drop.rb', line 175 def public_link a = customer.account return nil if a.blank? "https://#{WEB_HOSTNAME}#{public_path}" end |
#public_link_account_email ⇒ Object
182 183 184 185 186 |
# File 'app/models/liquid/quote_drop.rb', line 182 def public_link_account_email return nil unless customer && customer.account.present? customer.account.email end |
#public_path ⇒ Object
169 170 171 172 173 |
# File 'app/models/liquid/quote_drop.rb', line 169 def public_path return nil if customer.account.blank? UrlHelper.instance.my_account_quote_path(quote) end |
#quote_number ⇒ Object
44 45 46 |
# File 'app/models/liquid/quote_drop.rb', line 44 def quote_number quote.reference_number end |
#quote_suffix ⇒ Object
Alias for Quote#suffix
26 |
# File 'app/models/liquid/quote_drop.rb', line 26 delegate :suffix, to: :quote, prefix: true |
#recipient_email ⇒ Object
Alias for Quote#recipient_email
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#recipient_name ⇒ Object
Alias for Quote#recipient_name
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#reference_number ⇒ Object
Alias for Quote#reference_number
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#reference_number_with_name ⇒ Object
Alias for Quote#reference_number_with_name
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#reference_number_with_opp_name_when_specified ⇒ Object
Alias for Quote#reference_number_with_opp_name_when_specified
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#rep_email ⇒ Object
114 115 116 |
# File 'app/models/liquid/quote_drop.rb', line 114 def rep_email quote.customer.primary_sales_rep&.email || INFO_EMAIL end |
#rep_name ⇒ Object
134 135 136 |
# File 'app/models/liquid/quote_drop.rb', line 134 def rep_name quote.customer.primary_sales_rep&.full_name end |
#schedule_meeting_link ⇒ Object
32 33 34 |
# File 'app/models/liquid/quote_drop.rb', line 32 def schedule_meeting_link primary_sales_rep&.effective_scheduler_link end |
#service_only_quote? ⇒ Boolean
109 110 111 |
# File 'app/models/liquid/quote_drop.rb', line 109 def service_only_quote? quote.line_items.non_shipping.any? && quote.line_items.non_shipping.all?(&:is_service?) end |
#show_pre_planning_meeting? ⇒ Boolean
213 214 215 216 |
# File 'app/models/liquid/quote_drop.rb', line 213 def show_pre_planning_meeting? # We're starting simply quote.total > 500 end |
#show_schedule_meeting_link ⇒ Object
36 37 38 |
# File 'app/models/liquid/quote_drop.rb', line 36 def show_schedule_meeting_link schedule_meeting_link.present? end |
#suffix ⇒ Object
Alias for Quote#suffix
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#tax_total ⇒ Object
Alias for Quote#tax_total
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#taxes ⇒ Object
71 72 73 74 75 76 77 |
# File 'app/models/liquid/quote_drop.rb', line 71 def taxes taxes = {} quote.taxes_grouped_by_type.each_value do |tax_info| taxes[tax_info[:name]] = ActionController::Base.helpers.number_to_currency(tax_info[:tax_amount]) end taxes end |
#total ⇒ Object
Alias for Quote#total
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#total_amps ⇒ Object
Alias for Quote#total_amps
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/liquid/quote_drop.rb', line 9 delegate :reference_number, :reference_number_with_name, :reference_number_with_opp_name_when_specified, :customer, :lookup_link, :opportunity, :line_total, :total_amps, :total, :tax_total, :expiration_date, :recipient_name, :recipient_email, :suffix, :primary_sales_rep, to: :quote |
#total_formatted ⇒ Object
52 53 54 |
# File 'app/models/liquid/quote_drop.rb', line 52 def total_formatted ActionController::Base.helpers.number_to_currency(quote.total) end |
#total_operating_cost_dollars_per_hour_blurb ⇒ Object
163 164 165 166 |
# File 'app/models/liquid/quote_drop.rb', line 163 def tot_op_cost_rate = quote.room_configurations.to_a.sum(&:calculate_operating_cost_rate_using_hep) "#{ActionController::Base.helpers.number_to_currency(tot_op_cost_rate)}/hour @ #{ActionController::Base.helpers.number_to_currency(ElectricityRate::US_AVERAGE_RATE)}/kWh" end |