Class: Workarea::LegacyOrder

Inherits:
Object
  • Object
show all
Includes:
ApplicationDocument
Defined in:
app/models/workarea/legacy_order.rb,
app/models/workarea/legacy_order/item.rb,
app/models/workarea/legacy_order/tender.rb,
app/models/workarea/legacy_order/address.rb

Defined Under Namespace

Classes: Address, Item, Tender

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_email(email) ⇒ Object



29
30
31
# File 'app/models/workarea/legacy_order.rb', line 29

def self.for_email(email)
  where(email: email)
end

.lookup(id, postal_code) ⇒ Object



33
34
35
36
# File 'app/models/workarea/legacy_order.rb', line 33

def self.lookup(id, postal_code)
  order = find(id) rescue nil
  order&.billing_address&.postal_code == postal_code ? order : nil
end

Instance Method Details

#nameObject



38
39
40
# File 'app/models/workarea/legacy_order.rb', line 38

def name
  I18n.t('workarea.order.name', id: id)
end

#placed?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/workarea/legacy_order.rb', line 54

def placed?
  placed_at.present?
end

#quantityInteger

The number of units in this order.

Returns:

  • (Integer)


46
47
48
# File 'app/models/workarea/legacy_order.rb', line 46

def quantity
  items.sum(&:quantity)
end

#subtotal_priceObject



50
51
52
# File 'app/models/workarea/legacy_order.rb', line 50

def subtotal_price
  items.sum(&:price)
end