Class: Skr::SoLine

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

Instance Method Summary collapse

Instance Method Details

#allocate_max_availableObject

allocate the maximum available qty to the line



51
52
53
54
# File 'lib/skr/so_line.rb', line 51

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



68
69
70
71
# File 'lib/skr/so_line.rb', line 68

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)


58
59
60
# File 'lib/skr/so_line.rb', line 58

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

#location=(location) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/skr/so_line.rb', line 42

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)


64
65
66
# File 'lib/skr/so_line.rb', line 64

def pickable_qty
    qty_allocated - qty_picking
end