Class: Liquid::QuoteDrop
- Inherits:
-
Drop
- Object
- Drop
- Liquid::QuoteDrop
- Includes:
- Memery
- Defined in:
- app/models/liquid/quote_drop.rb
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.
27 28 29 |
# File 'app/models/liquid/quote_drop.rb', line 27 def initialize(quote) @quote = quote end |
Instance Attribute Details
#quote ⇒ Object (readonly)
Returns the value of attribute quote.
6 7 8 |
# File 'app/models/liquid/quote_drop.rb', line 6 def quote @quote end |
Instance Method Details
#can_be_paid_online? ⇒ Boolean
128 129 130 |
# File 'app/models/liquid/quote_drop.rb', line 128 def can_be_paid_online? quote.complete? || quote.awaiting_transmission? end |
#completed? ⇒ Boolean
123 124 125 |
# File 'app/models/liquid/quote_drop.rb', line 123 def completed? quote.complete? end |
#country_iso3 ⇒ Object
147 148 149 |
# File 'app/models/liquid/quote_drop.rb', line 147 def country_iso3 quote.store.country_iso3 end |
#coupon_total ⇒ Object
66 67 68 |
# File 'app/models/liquid/quote_drop.rb', line 66 def coupon_total quote.line_discounts.sum(:amount) end |
#coupons ⇒ Object
138 139 140 141 142 143 144 |
# File 'app/models/liquid/quote_drop.rb', line 138 def coupons coupons = [] quote.discounts_grouped_by_coupon.each do |code, vals| coupons << { 'code' => code, 'title' => vals[:title], 'amount' => ActionController::Base.helpers.number_to_currency(vals[:amount]) } end coupons end |
#customer ⇒ Object
Alias for Quote#customer
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
88 89 90 |
# File 'app/models/liquid/quote_drop.rb', line 88 def disclaimer GENERAL_DISCLAIMER_ON_PRODUCT_INSTALLATION_AND_LOCAL_CODES end |
#expiration_date ⇒ Object
Alias for Quote#expiration_date
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
39 40 41 |
# File 'app/models/liquid/quote_drop.rb', line 39 def expiration_date_formatted quote.expiration_date.strftime('%B %-d') end |
#for_direct_pro? ⇒ Boolean
209 210 211 |
# File 'app/models/liquid/quote_drop.rb', line 209 def for_direct_pro? customer.is_direct_pro? end |
#for_homeowner? ⇒ Boolean
204 205 206 |
# File 'app/models/liquid/quote_drop.rb', line 204 def for_homeowner? customer.is_homeowner? end |
#formatted_coupon_total ⇒ Object
61 62 63 |
# File 'app/models/liquid/quote_drop.rb', line 61 def formatted_coupon_total ActionController::Base.helpers.number_to_currency(quote.line_discounts.sum(:amount)) end |
#formatted_tax_total ⇒ Object
56 57 58 |
# File 'app/models/liquid/quote_drop.rb', line 56 def formatted_tax_total ActionController::Base.helpers.number_to_currency(quote.tax_total) end |
#friendly_shipping_method ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/models/liquid/quote_drop.rb', line 78 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
92 93 94 |
# File 'app/models/liquid/quote_drop.rb', line 92 def has_dropship_items? quote.line_items.any?(&:dropship?) end |
#has_floor_heating? ⇒ Boolean
194 195 196 |
# File 'app/models/liquid/quote_drop.rb', line 194 def has_floor_heating? quote.line_items.floor_heating_elements.exists? end |
#has_out_of_stock_items? ⇒ Boolean
97 98 99 100 |
# File 'app/models/liquid/quote_drop.rb', line 97 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
118 119 120 |
# File 'app/models/liquid/quote_drop.rb', line 118 def has_rep? quote.customer.primary_sales_rep.present? end |
#has_service_items? ⇒ Boolean
103 104 105 |
# File 'app/models/liquid/quote_drop.rb', line 103 def has_service_items? quote.line_items.any?(&:is_service?) end |
#has_smartplans? ⇒ Boolean
189 190 191 |
# File 'app/models/liquid/quote_drop.rb', line 189 def has_smartplans? quote.room_configurations.any?(&:installation_plan_image) end |
#has_snow_melting? ⇒ Boolean
199 200 201 |
# File 'app/models/liquid/quote_drop.rb', line 199 def has_snow_melting? quote.line_items.snow_melting_elements.exists? end |
#id ⇒ Object
Alias for Quote#id
230 |
# File 'app/models/liquid/quote_drop.rb', line 230 delegate :id, to: :quote |
#is_canada_quote? ⇒ Boolean
156 157 158 |
# File 'app/models/liquid/quote_drop.rb', line 156 def is_canada_quote? country_iso3 == 'CAN' end |
#is_pickup? ⇒ Boolean
160 161 162 |
# File 'app/models/liquid/quote_drop.rb', line 160 def is_pickup? quote.is_warehouse_pickup? end |
#is_usa_quote? ⇒ Boolean
152 153 154 |
# File 'app/models/liquid/quote_drop.rb', line 152 def is_usa_quote? country_iso3 == 'USA' end |
#job_name ⇒ Object
47 48 49 |
# File 'app/models/liquid/quote_drop.rb', line 47 def job_name opportunity.name end |
#line_total ⇒ Object
Alias for Quote#line_total
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
220 221 222 223 224 225 226 227 228 |
# File 'app/models/liquid/quote_drop.rb', line 220 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
176 177 178 179 180 181 |
# File 'app/models/liquid/quote_drop.rb', line 176 def public_link a = customer.account return nil unless a.present? "https://#{WEB_HOSTNAME}#{public_path}" end |
#public_link_account_email ⇒ Object
183 184 185 186 187 |
# File 'app/models/liquid/quote_drop.rb', line 183 def public_link_account_email return nil unless customer && customer.account.present? customer.account.email end |
#public_path ⇒ Object
170 171 172 173 174 |
# File 'app/models/liquid/quote_drop.rb', line 170 def public_path return nil unless customer.account.present? UrlHelper.instance.my_account_quote_path(quote) end |
#quote_number ⇒ Object
43 44 45 |
# File 'app/models/liquid/quote_drop.rb', line 43 def quote_number quote.reference_number end |
#quote_suffix ⇒ Object
Alias for Quote#suffix
25 |
# File 'app/models/liquid/quote_drop.rb', line 25 delegate :suffix, to: :quote, prefix: true |
#recipient_email ⇒ Object
Alias for Quote#recipient_email
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
113 114 115 |
# File 'app/models/liquid/quote_drop.rb', line 113 def rep_email quote.customer.primary_sales_rep&.email || INFO_EMAIL end |
#rep_name ⇒ Object
133 134 135 |
# File 'app/models/liquid/quote_drop.rb', line 133 def rep_name quote.customer.primary_sales_rep&.full_name end |
#schedule_meeting_link ⇒ Object
31 32 33 |
# File 'app/models/liquid/quote_drop.rb', line 31 def schedule_meeting_link primary_sales_rep&.effective_scheduler_link end |
#service_only_quote? ⇒ Boolean
108 109 110 |
# File 'app/models/liquid/quote_drop.rb', line 108 def service_only_quote? quote.line_items.non_shipping.any? && quote.line_items.non_shipping.all?(&:is_service?) end |
#show_pre_planning_meeting? ⇒ Boolean
214 215 216 217 |
# File 'app/models/liquid/quote_drop.rb', line 214 def show_pre_planning_meeting? # We're starting simply quote.total > 500 end |
#show_schedule_meeting_link ⇒ Object
35 36 37 |
# File 'app/models/liquid/quote_drop.rb', line 35 def show_schedule_meeting_link schedule_meeting_link.present? end |
#suffix ⇒ Object
Alias for Quote#suffix
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
70 71 72 73 74 75 76 |
# File 'app/models/liquid/quote_drop.rb', line 70 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/liquid/quote_drop.rb', line 8 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
51 52 53 |
# File 'app/models/liquid/quote_drop.rb', line 51 def total_formatted ActionController::Base.helpers.number_to_currency(quote.total) end |
#total_operating_cost_dollars_per_hour_blurb ⇒ Object
164 165 166 167 |
# File 'app/models/liquid/quote_drop.rb', line 164 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 |