Class: Store

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/store.rb

Overview

== Schema Information

Table name: stores
Database name: primary

id :integer not null, primary key
base_handling_charge :decimal(8, 2)
contact_email :string(255)
contact_number :string(255)
country_iso3 :string(3)
fax_number :string(255)
jde_branch :string(255)
name :string(255)
order_notification_emails :string default([]), is an Array
owner :string
short_name :string(255)
tax_identification_number_for_shipping :string(255)
company_id :integer
consignee_party_id :integer
customer_for_st_id :integer
mailing_address_id :integer
preferred_inbound_shipping_option_id :integer
preferred_outbound_shipping_option_id :integer
primary_catalog_id :integer
supplier_id :integer
warehouse_address_id :integer
warehouse_service_address_id :integer

Indexes

idx_country_iso3 (country_iso3)
idx_owner (owner)
index_stores_on_company_id (company_id)
index_stores_on_supplier_id (supplier_id)

Foreign Keys

fk_rails_... (consignee_party_id => parties.id)
fk_rails_... (customer_for_st_id => parties.id)
fk_rails_... (supplier_id => parties.id)

Constant Summary collapse

WARMLYYOURS_US_ID =

= Store.find(1)

1
WARMLYYOURS_CA_ID =

= Store.find(2)

2
PUBLIC_STORE_IDS =
[WARMLYYOURS_US_ID, WARMLYYOURS_CA_ID].freeze
STORE_TO_LOCALE =
{ 'WarmlyYours-US' => :'en-US', 'WarmlyYours-CA' => :'en-CA' }
LOCALE_TO_STORE =
{
  en: 'WarmlyYours-US',
  'en-US': 'WarmlyYours-US',
  'en-CA': 'WarmlyYours-CA',
  'fr-CA': 'WarmlyYours-CA'
}
LOCALE_TO_STORE_ID =
{
  en: 1,
  'en-US': 1,
  'en-CA': 2,
  'fr-CA': 2
}
CURRENCY_TO_STORE =
{ 'USD' => 'WarmlyYours-US', 'CAD' => 'WarmlyYours-CA' }
CARRIERS_FOR_MASS_SHIP_CONFIRM =
{ 'WarmlyYours-US' => %w[FedExGround FedExExpress FedExFreight UPS USPS],
'WarmlyYours-CA' => %w[FedExGround FedExExpress FedExFreight UPS Canadapost Canpar Purolator] }
CARRIER_PICKUP_TIMES =
{
  'WarmlyYours-US' => { 'FedExGround' => '16:30:00', 'FedExExpress' => '16:00:00', 'FedExFreight' => '17:00:00', 'UPS' => '17:30:00',
                        'USPS' => '14:00:00' }, 'WarmlyYours-CA' => { 'FedExGround' => '14:00:00', 'FedExFreight' => '17:00:00', 'UPS' => '16:00:00', 'Purolator' => '15:30:00', 'Canadapost' => '15:30:00', 'Canpar' => '14:30:00' }
}
CARRIER_PICKUP_CUT_OFF_TIMES =
{ 'WarmlyYours-US' => { 'FedExFreight' => '13:30:00', 'Saia' => '14:00:00', 'USPS' => '14:55:00' },
                                   'WarmlyYours-CA' => { 'FedEx' => '14:00:00', 'FedExFreight' => '13:30:00', 'Canadapost' => '14:55:00',
'Canpar' => '10:55:00' } }

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Instance Attribute Summary collapse

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Has one collapse

Has many collapse

Has and belongs to many collapse

Delegated Instance Attributes collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#company_idObject (readonly)



110
# File 'app/models/store.rb', line 110

validates :company_id, :name, :country_iso3, :warehouse_address, :supplier_id, presence: true

#contact_emailObject (readonly)



113
# File 'app/models/store.rb', line 113

validates :contact_email, email_format: true

#contact_numberObject (readonly)



114
# File 'app/models/store.rb', line 114

validates :contact_number, phone_format: true

#country_iso3Object (readonly)



110
# File 'app/models/store.rb', line 110

validates :company_id, :name, :country_iso3, :warehouse_address, :supplier_id, presence: true

#nameObject (readonly)



110
# File 'app/models/store.rb', line 110

validates :company_id, :name, :country_iso3, :warehouse_address, :supplier_id, presence: true

#order_notification_emailsObject (readonly)



112
# File 'app/models/store.rb', line 112

validates :order_notification_emails, email_format: true

#short_nameObject (readonly)



111
# File 'app/models/store.rb', line 111

validates :name, :short_name, uniqueness: true

#supplier_idObject (readonly)



110
# File 'app/models/store.rb', line 110

validates :company_id, :name, :country_iso3, :warehouse_address, :supplier_id, presence: true

Class Method Details

.by_currency(currency) ⇒ Object

Todo make this more I18n



191
192
193
# File 'app/models/store.rb', line 191

def self.by_currency(currency)
  find_by(name: CURRENCY_TO_STORE[currency])
end

.defaultObject



201
202
203
# File 'app/models/store.rb', line 201

def self.default
  find_by(name: 'WarmlyYours-US')
end

.locale_to_catalog(locale = nil) ⇒ Object

Todo make this more I18n



185
186
187
188
# File 'app/models/store.rb', line 185

def self.locale_to_catalog(locale = nil)
  locale ||= I18n.locale
  Store.find(store_id_for_locale(locale))
end

.options_for_select(filters = nil) ⇒ Object



205
206
207
# File 'app/models/store.rb', line 205

def self.options_for_select(filters = nil)
  all.where(filters).order(:name).pluck(:name, :id)
end

.potential_ownersObject



129
130
131
# File 'app/models/store.rb', line 129

def self.potential_owners
  %w[warmlyyours amazon dimass]
end

.store_id_for_locale(locale = nil) ⇒ Object

Todo make this more I18n



180
181
182
# File 'app/models/store.rb', line 180

def self.store_id_for_locale(locale = nil)
  LOCALE_TO_STORE_ID[locale&.to_sym]
end

.store_locations_by_idObject



259
260
261
# File 'app/models/store.rb', line 259

def self.store_locations_by_id
  Store.all.each_with_object({}) { |s, locations| locations[s.id] = s.locations }
end

.warmlyyours_warehousesActiveRecord::Relation<Store>

A relation of Stores that are warmlyyours warehouses. Active Record Scope

Returns:

  • (ActiveRecord::Relation<Store>)

See Also:



124
# File 'app/models/store.rb', line 124

scope :warmlyyours_warehouses, -> { where(owner: 'warmlyyours') }

Instance Method Details

#alternative_storeObject

Todo make this more I18n



150
151
152
# File 'app/models/store.rb', line 150

def alternative_store
  find(id == WARMLYYOURS_US_ID ? WARMLYYOURS_CA_ID : WARMLYYOURS_US_ID)
end

#alternative_storesObject



170
171
172
# File 'app/models/store.rb', line 170

def alternative_stores
  Store.where.not(id:).where(owner: 'warmlyyours')
end

#carrier_pickup_for_datetime(carrier_account_id, datetime) ⇒ Object



271
272
273
# File 'app/models/store.rb', line 271

def carrier_pickup_for_datetime(, datetime)
  carrier_pickups.().for_datetime(datetime).first
end

#carrier_pickup_for_today(carrier_account_id) ⇒ Object



267
268
269
# File 'app/models/store.rb', line 267

def carrier_pickup_for_today()
  carrier_pickups.().for_today.first
end

#carrier_pickup_time(carrier) ⇒ Object



425
426
427
428
429
430
431
# File 'app/models/store.rb', line 425

def carrier_pickup_time(carrier)
  pu_time = nil
  if CARRIER_PICKUP_TIMES[name] && (pu_time_str = CARRIER_PICKUP_TIMES[name][carrier])
    pu_time = Time.zone.parse(pu_time_str)
  end
  pu_time
end

#carrier_pickupsActiveRecord::Relation<CarrierPickup>

Returns:

See Also:



97
# File 'app/models/store.rb', line 97

has_many :carrier_pickups, dependent: :destroy

#catalogsActiveRecord::Relation<Catalog>

Returns:

  • (ActiveRecord::Relation<Catalog>)

See Also:



91
# File 'app/models/store.rb', line 91

has_many :catalogs, inverse_of: :store

#companyCompany

Returns:

See Also:



78
# File 'app/models/store.rb', line 78

belongs_to :company, optional: true

#consignee_partyCustomer

Returns:

See Also:



79
# File 'app/models/store.rb', line 79

belongs_to :consignee_party, class_name: 'Customer', inverse_of: :consignment_stores, optional: true

#countryCountry

Returns:

See Also:



77
# File 'app/models/store.rb', line 77

belongs_to :country, foreign_key: :country_iso3, primary_key: :iso3, optional: true

#country_codeObject



209
210
211
# File 'app/models/store.rb', line 209

def country_code
  country.iso
end

#currencyObject

Alias for Company#currency

Returns:

  • (Object)

    Company#currency

See Also:



199
# File 'app/models/store.rb', line 199

delegate :currency, to: :company

#currency_symbolObject



195
196
197
# File 'app/models/store.rb', line 195

def currency_symbol
  Money::Currency.new(currency).symbol
end

#current_shipping_document_print_profile(employee_record_id = nil) ⇒ Object



227
228
229
# File 'app/models/store.rb', line 227

def current_shipping_document_print_profile(employee_record_id = nil)
  printer_profile_for_scope(:shipping_document, employee_record_id)
end

#current_shipping_label_print_profile(employee_record_id = nil) ⇒ Object



231
232
233
# File 'app/models/store.rb', line 231

def current_shipping_label_print_profile(employee_record_id = nil)
  printer_profile_for_scope(:shipping_label, employee_record_id)
end

#current_upc_label_print_profile(employee_record_id = nil) ⇒ Object



223
224
225
# File 'app/models/store.rb', line 223

def current_upc_label_print_profile(employee_record_id = nil)
  printer_profile_for_scope(:upc_label, employee_record_id)
end

#customer_for_stCustomer

Returns:

See Also:



80
# File 'app/models/store.rb', line 80

belongs_to :customer_for_st, class_name: 'Customer', optional: true

#cycle_countsActiveRecord::Relation<CycleCount>

Returns:

See Also:



95
# File 'app/models/store.rb', line 95

has_many :cycle_counts

#default_shipping_methodObject



251
252
253
# File 'app/models/store.rb', line 251

def default_shipping_method
  { USA: 'ground', CAN: 'standard' }.dig(country.iso3)
end

#emailObject



243
244
245
246
247
248
249
# File 'app/models/store.rb', line 243

def email
  if country_iso3 == 'CAN'
    'warehousecanada@warmlyyours.com'
  else
    'warehouseusa@warmlyyours.com'
  end
end

#email_options_for_order_notification_emailsObject



154
155
156
# File 'app/models/store.rb', line 154

def email_options_for_order_notification_emails
  [order_notification_emails].flatten.compact.uniq
end

#floor_typesActiveRecord::Relation<FloorType>

Returns:

See Also:



105
# File 'app/models/store.rb', line 105

has_and_belongs_to_many :floor_types

#future_carrier_pickups(carrier_account_id) ⇒ Object



275
276
277
# File 'app/models/store.rb', line 275

def future_carrier_pickups()
  carrier_pickups.().future_days
end

#get_next_sales_rep_assignments_for_customer(customer) ⇒ Object



133
134
135
# File 'app/models/store.rb', line 133

def get_next_sales_rep_assignments_for_customer(customer)
  sales_rep_queue&.get_next_sales_rep_assignments_for_customer(customer)
end

#goods_accountObject



141
142
143
# File 'app/models/store.rb', line 141

def 
  warmlyyours_warehouse? ? PURCHASED_FINISHED_GOODS_ACCOUNT : CONSIGNMENT_ACCOUNT
end

#heating_element_product_line_optionsActiveRecord::Relation<HeatingElementProductLineOption>

Returns:

See Also:



98
# File 'app/models/store.rb', line 98

has_many :heating_element_product_line_options, inverse_of: :store

#import_catalog(catalog) ⇒ Object

Import a catalog's store item into this store assuming that will be the only catalog for that store



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'app/models/store.rb', line 280

def import_catalog(catalog)
  return if catalog.store_id == id
  return if catalog.store.country_iso3 != country_iso3

  # Now we can proceed, clone only active
  Catalog.transaction do
    # Clone catalog
    if new_catalog = catalogs.first
      logger.info "Existing catalog: #{new_catalog.name}"
    else
      new_catalog = catalog.dup
      new_catalog.store_id = id
      new_catalog.parent_catalog_id = nil
      new_catalog.price_sync_policy = :price_sync_manual
      new_catalog.price_sync_delay = nil
      new_catalog.save!
      logger.info "New catalog created: #{new_catalog.id}"
    end

    catalog.catalog_items.with_item.active.each do |ci|
      item_sku = ci.store_item.item.sku
      logger.info "Evaluating #{item_sku} from catalog #{catalog.name} for import into store id #{id} - #{name}"
      # Does this store item already exist?
      if new_si = store_items.where(item_id: ci.store_item.item_id).first
        logger.info 'Store item already exists'
      else
        logger.info 'New store item required'
        # clone the store item
        new_si = ci.store_item.dup
        new_si.qty_on_hand = 0
        new_si.qty_committed = 0
        new_si.unit_cogs = 0
        new_si.last_item_ledger_entry_id = nil
        new_si.store_id = id
        new_si.save!
        logger.info "New Store item saved as #{new_si.id}"
      end
      # Was this catalog item already mapped
      if new_ci = new_si.catalog_items.first
        logger.info 'Existing catalog item'
        new_ci.attributes = ci.attributes
      else
        logger.info 'New catalog item'
        new_ci = ci.dup
      end
      new_ci.catalog_id = new_catalog.id
      new_ci.store_item_id = new_si.id
      new_ci.save!
      logger.info "Catalog item #{new_ci.id} saved to catalog id #{new_catalog.id}"
    end # end catalog item
  end
end

#invoicesActiveRecord::Relation<Invoice>

Returns:

  • (ActiveRecord::Relation<Invoice>)

See Also:



103
# File 'app/models/store.rb', line 103

has_many :invoices

#itemsActiveRecord::Relation<Item>

Returns:

  • (ActiveRecord::Relation<Item>)

See Also:



90
# File 'app/models/store.rb', line 90

has_many :items, through: :store_items

#locales_servedObject

Todo make this more I18n, look at its catalog?



175
176
177
# File 'app/models/store.rb', line 175

def locales_served
  country.locales_for_country
end

#locationsObject



255
256
257
# File 'app/models/store.rb', line 255

def locations
  store_items.pluck(:location).uniq
end

#mailing_addressAddress

Returns:

See Also:



76
# File 'app/models/store.rb', line 76

belongs_to :mailing_address, class_name: 'Address', optional: true

#manifestsActiveRecord::Relation<Manifest>

Returns:

See Also:



99
# File 'app/models/store.rb', line 99

has_many :manifests, inverse_of: :store

#mass_ship_confirm_counter(carrier) ⇒ Object



421
422
423
# File 'app/models/store.rb', line 421

def mass_ship_confirm_counter(carrier)
  query_mass_ship_confirm_delivery_candidates(carrier).size
end

#notify_of_new_delivery(delivery) ⇒ Object

Trigger an email whenever a delivery arrives at a store



159
160
161
162
163
164
165
166
167
168
# File 'app/models/store.rb', line 159

def notify_of_new_delivery(delivery)
  return unless delivery.store.order_notification_emails.present?

  mail = InternalMailer.new_delivery_notification(delivery)
  if Rails.env.development?
    mail.deliver_now
  else
    mail.deliver_later(wait: 1.minute)
  end
end

#partiesActiveRecord::Relation<Party>

Returns:

  • (ActiveRecord::Relation<Party>)

See Also:



88
# File 'app/models/store.rb', line 88

has_many :parties, through: :catalogs

#preferred_inbound_shipping_optionShippingOption



83
# File 'app/models/store.rb', line 83

belongs_to :preferred_inbound_shipping_option, class_name: 'ShippingOption', optional: true

#preferred_outbound_shipping_optionShippingOption



84
# File 'app/models/store.rb', line 84

belongs_to :preferred_outbound_shipping_option, class_name: 'ShippingOption', optional: true

#primary_catalogCatalog

Returns:

See Also:



82
# File 'app/models/store.rb', line 82

belongs_to :primary_catalog, class_name: 'Catalog', optional: true

#printer_profile_for_scope(scope_name, employee_record_id = nil) ⇒ Object



213
214
215
216
217
218
219
220
221
# File 'app/models/store.rb', line 213

def printer_profile_for_scope(scope_name, employee_record_id = nil)
  profiles = PrintProfile.in_store_id(id).send(scope_name).order(:id)
  profiles = if employee_record_id && profiles.where(employee_record_id:).exists? # If there is a specificity use it
               profiles.where(employee_record_id:)
             else # Take the default
               profiles.where(employee_record_id: nil)
             end
  profiles.first
end

#printersActiveRecord::Relation<Printer>

Returns:

  • (ActiveRecord::Relation<Printer>)

See Also:



101
# File 'app/models/store.rb', line 101

has_many :printers

#purchase_ordersActiveRecord::Relation<PurchaseOrder>

Returns:

See Also:



100
# File 'app/models/store.rb', line 100

has_many :purchase_orders

#query_awaiting_carrier_assignment_ordersObject



350
351
352
# File 'app/models/store.rb', line 350

def query_awaiting_carrier_assignment_orders
  Order.by_store_id(id).where(state: 'awaiting_carrier_assignment').with_associations
end

#query_mass_ship_confirm_delivery_candidates(carrier) ⇒ Object



409
410
411
412
413
414
415
416
417
418
419
# File 'app/models/store.rb', line 409

def query_mass_ship_confirm_delivery_candidates(carrier)
  carrier_to_use = carrier
  carrier_to_use = 'FedEx' if %w[FedExGround FedExExpress].include?(carrier) # deal with annoying FedEx ground vs express
  deliveries_query = Delivery.by_store_id(id).with_shipment_carrier(carrier_to_use).pending_ship_confirm.ship_labeled_before(carrier_pickup_time(carrier))
  if carrier == 'FedExGround'
    deliveries_query = deliveries_query.fedex_ground
  elsif carrier == 'FedExExpress'
    deliveries_query = deliveries_query.fedex_express
  end
  deliveries_query.distinct.order(:created_at)
end

#query_recently_shippedObject



393
394
395
396
397
398
399
400
401
402
403
# File 'app/models/store.rb', line 393

def query_recently_shipped
  Delivery.by_store_id(id)
          .where(state: %w[shipped invoiced])
          .where(Delivery[:shipped_date].gteq(Date.current))
          .includes(:uploads,
                    :destination_address,
                    :shipping_option,
                    line_items: [:item],
                    order: [:uploads, :creator, { customer: :primary_sales_rep }])
          .order(:created_at)
end

#query_serial_numbers_pending_printObject



389
390
391
# File 'app/models/store.rb', line 389

def query_serial_numbers_pending_print
  serial_numbers.pending_print.order(:number)
end

#query_warehouse_amazon_ordersObject



375
376
377
378
379
# File 'app/models/store.rb', line 375

def query_warehouse_amazon_orders
  Order.by_store_id(id).limit_to_fba.where(state: %w[in_cr_hold crm_back_order] + Order::SHIPPING_STATES).joins(:deliveries).order(
    Delivery[:future_release_date], Delivery[:created_at]
  )
end

#query_warehouse_back_ordersObject



354
355
356
# File 'app/models/store.rb', line 354

def query_warehouse_back_orders
  Order.by_store_id(id).back_order.with_associations
end

#query_warehouse_deliveries(state: nil) ⇒ Object



364
365
366
367
368
369
370
371
372
373
# File 'app/models/store.rb', line 364

def query_warehouse_deliveries(state: nil)
  deliveries = Delivery.by_store_id(id).all_at_warehouse.with_active_parent
                       .includes(:uploads,
                                 :destination_address,
                                 :shipping_option,
                                 line_items: [:item],
                                 order: [:uploads, :creator, { customer: :primary_sales_rep }])
  deliveries = deliveries.where(state:) if state.present?
  deliveries
end

#query_warehouse_deliveries_groupedObject



381
382
383
# File 'app/models/store.rb', line 381

def query_warehouse_deliveries_grouped
  deliveries_by_state = query_warehouse_deliveries.group_by(&:state)
end

#query_warehouse_deliveries_grouped_countersObject



385
386
387
# File 'app/models/store.rb', line 385

def query_warehouse_deliveries_grouped_counters
  query_warehouse_deliveries.group('deliveries.state').count
end

#query_warehouse_held_ordersObject



346
347
348
# File 'app/models/store.rb', line 346

def query_warehouse_held_orders
  Order.by_store_id(id).held.with_associations
end

#query_warehouse_orders_need_attentionObject



358
359
360
361
362
# File 'app/models/store.rb', line 358

def query_warehouse_orders_need_attention
  Order.by_store_id(id).all_awaiting_deliveries.with_associations.joins(:deliveries).where(Delivery[:state].eq('quoting')).order(
    Delivery[:future_release_date], Delivery[:created_at]
  )
end

#query_warehouse_purchase_orders_shippedObject



405
406
407
# File 'app/models/store.rb', line 405

def query_warehouse_purchase_orders_shipped
  purchase_orders.where(state: 'shipped')
end

#room_typesActiveRecord::Relation<RoomType>

Returns:

See Also:



106
# File 'app/models/store.rb', line 106

has_and_belongs_to_many :room_types

#sales_rep_queueSalesRepQueue



86
# File 'app/models/store.rb', line 86

has_one :sales_rep_queue

#serial_numbersActiveRecord::Relation<SerialNumber>

Returns:

See Also:



96
# File 'app/models/store.rb', line 96

has_many :serial_numbers, through: :store_items

#services_accountObject



145
146
147
# File 'app/models/store.rb', line 145

def 
  warmlyyours_warehouse? ? SERVICES_PENDING_FULFILLMENT_DEBIT_ACCOUNT : CONSIGNMENT_ACCOUNT
end

#set_carrier_pickup(carrier, carrier_account_id, pickup_resp, pickup_number, scheduled_start, scheduled_end) ⇒ Object



333
334
335
336
337
338
339
340
341
342
343
344
# File 'app/models/store.rb', line 333

def set_carrier_pickup(carrier, , pickup_resp, pickup_number, scheduled_start, scheduled_end)
  Rails.logger.debug { "set_carrier_pickup: carrier: #{carrier}" }
  Rails.logger.debug { "set_carrier_pickup: carrier_account_id: #{}" }
  Rails.logger.debug { "set_carrier_pickup: pickup_resp: #{pickup_resp.inspect}" }
  Rails.logger.debug { "set_carrier_pickup: pickup_number: #{pickup_number}" }
  Rails.logger.debug { "set_carrier_pickup: scheduled_start: #{scheduled_start}" }
  Rails.logger.debug { "set_carrier_pickup: scheduled_end: #{scheduled_end}" }
  pickup = CarrierPickup.new(store_id: id, carrier:, carrier_account_id:, carrier_pickup_id: pickup_number,
                             scheduled_start:, scheduled_end:)
  carrier_pickups << pickup
  pickup
end

#storage_locationsActiveRecord::Relation<StorageLocation>

Returns:

See Also:



102
# File 'app/models/store.rb', line 102

has_many :storage_locations

#store_itemsActiveRecord::Relation<StoreItem>

Returns:

See Also:



89
# File 'app/models/store.rb', line 89

has_many :store_items, dependent: :destroy

#store_items_with_sku_for_selectObject



263
264
265
# File 'app/models/store.rb', line 263

def store_items_with_sku_for_select
  store_items.includes(:item).order('items.sku').pluck('items.sku', :id)
end

#store_transfersActiveRecord::Relation<StoreTransfer>

Returns:

See Also:



92
# File 'app/models/store.rb', line 92

has_many :store_transfers, foreign_key: :from_store_id, primary_key: :id

#supplierSupplier

Returns:

See Also:



81
# File 'app/models/store.rb', line 81

belongs_to :supplier, class_name: 'Supplier'

#time_zone_stringObject



235
236
237
238
239
240
241
# File 'app/models/store.rb', line 235

def time_zone_string
  if country_iso3 == 'CAN'
    'Eastern Time (US & Canada)'
  else
    'America/Chicago'
  end
end

#uploadsActiveRecord::Relation<Upload>

Returns:

  • (ActiveRecord::Relation<Upload>)

See Also:



94
# File 'app/models/store.rb', line 94

has_many :uploads, as: :resource, dependent: :destroy

#warehouse_addressAddress

Returns:

See Also:

Validations:



74
# File 'app/models/store.rb', line 74

belongs_to :warehouse_address, class_name: 'Address', optional: true

#warehouse_packagesActiveRecord::Relation<WarehousePackage>

Returns:

See Also:



93
# File 'app/models/store.rb', line 93

has_many :warehouse_packages, -> { order(:sort_order, :volume) }, dependent: :destroy

#warehouse_service_addressAddress

Returns:

See Also:



75
# File 'app/models/store.rb', line 75

belongs_to :warehouse_service_address, class_name: 'Address', optional: true

#warmlyyours_warehouse?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'app/models/store.rb', line 137

def warmlyyours_warehouse?
  owner == 'warmlyyours'
end