Class: Skr::SoLine

Inherits:
Model
  • Object
show all
Defined in:
lib/skr/models/so_line.rb

Instance Method Summary collapse

Instance Method Details

#allocate_max_availableObject

allocate the maximum available qty to the line



54
55
56
57
# File 'lib/skr/models/so_line.rb', line 54

def allocate_max_available
    self.qty_allocated = [ 0, [ sku_loc.qty_available+qty_allocated, qty ].min ].max if self.sku.does_track_inventory?
    self
end

#cancel!Object



71
72
73
74
# File 'lib/skr/models/so_line.rb', line 71

def cancel!
    self.update_attributes :qty_allocated => 0, :qty_picking=> 0
    pt_lines.picking.each{ |ptl| ptl.cancel! }
end

#is_fully_allocated?Boolean

A line is fully allocated if the qty_allocated is less than the qty ordered - the qty invoiced - the qty canceled

Returns:

  • (Boolean)


61
62
63
# File 'lib/skr/models/so_line.rb', line 61

def is_fully_allocated?
    self.qty_allocated >= qty - qty_invoiced - qty_canceled
end

#location=(location) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/skr/models/so_line.rb', line 45

def location=(location)
    self.cancel!
    self.sku_loc = self.sku.sku_locs.find_or_create_for( location )
    self.allocate_max_available
    self.save!
    self
end

#pickable_qtyFixnum

The pickable qty is the qty allocated - the qty already on pick tickets

Returns:

  • (Fixnum)


67
68
69
# File 'lib/skr/models/so_line.rb', line 67

def pickable_qty
    qty_allocated - qty_picking
end

#totalObject



76
77
78
# File 'lib/skr/models/so_line.rb', line 76

def total
    qty * price
end