Class: Skr::IaLine
Overview
Instance Method Summary collapse
-
#adjust_qty! ⇒ Object
Perform the adjustment.
-
#ea_qty ⇒ Object
The qty for the line expressed in terms of the single UOM.
-
#is_applied? ⇒ Boolean
Has the line been applied.
-
#is_removing_qty? ⇒ Boolean
Is the qty negative?.
-
#ledger_cost ⇒ BigDecimal
Either the current MAC for the sku’s location or the cost that was manually set.
-
#set_cost_from_sku_loc ⇒ Object
copies the cost from the sku_loc to the #cost field.
-
#sku_loc_mac ⇒ BigDecimal
The current moving average cost (mac) on the location, expressed in terms of the UOM.
-
#sku_loc_qty ⇒ Fixnum
The qty available on the location, expressed in terms of the UOM.
-
#total ⇒ BigDecimal
The total value of the line.
Instance Method Details
#adjust_qty! ⇒ Object
Perform the adjustment. Requires adjusting to be unlocked and #is_applied? must be false
It creates a SkuTran to adjust the inventory, and allocates available qty to the SoLine
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/skr/ia_line.rb', line 84 def adjust_qty! if ! is_adjusting_unlocked? || is_applied? raise "Unable to apply line, either not approved or previously applied" end set_cost_from_sku_loc Core.logger.debug( "Adjusting #{self.qty} #{combined_uom} of #{sku_code} into stock") self.build_sku_tran({ :origin=>self, :qty => self.qty, :sku_loc=>self.sku_loc, origin_description: "IA #{self.inventory_adjustment.visible_id}:#{self.sku.code}", cost: total, uom: self.uom, allocate_after_save: true, debit_gl_account: self.inventory_adjustment.reason.gl_account, credit_gl_account: self.sku.gl_asset_account }) self.sku_tran.save unless self.new_record? true end |
#ea_qty ⇒ Object
The qty for the line expressed in terms of the single UOM
54 55 56 |
# File 'lib/skr/ia_line.rb', line 54 def ea_qty self.uom_size * self.qty end |
#is_applied? ⇒ Boolean
Returns has the line been applied.
44 45 46 |
# File 'lib/skr/ia_line.rb', line 44 def is_applied? sku_tran.present? end |
#is_removing_qty? ⇒ Boolean
Returns is the qty negative?.
49 50 51 |
# File 'lib/skr/ia_line.rb', line 49 def is_removing_qty? qty && qty <=0 end |
#ledger_cost ⇒ BigDecimal
Returns either the current MAC for the sku’s location or the cost that was manually set.
65 66 67 68 69 70 71 |
# File 'lib/skr/ia_line.rb', line 65 def ledger_cost if cost_was_set? || is_applied? self.cost else self.sku_loc_mac end end |
#set_cost_from_sku_loc ⇒ Object
copies the cost from the sku_loc to the #cost field
74 75 76 77 78 79 |
# File 'lib/skr/ia_line.rb', line 74 def set_cost_from_sku_loc if ! cost_was_set? self.cost = self.sku_loc_mac end true end |
#sku_loc_mac ⇒ BigDecimal
Returns the current moving average cost (mac) on the location, expressed in terms of the UOM.
39 40 41 |
# File 'lib/skr/ia_line.rb', line 39 def sku_loc_mac self.sku_loc ? ( self.sku_loc.mac * self.uom_size ) : 0 end |
#sku_loc_qty ⇒ Fixnum
Returns The qty available on the location, expressed in terms of the UOM.
34 35 36 |
# File 'lib/skr/ia_line.rb', line 34 def sku_loc_qty ( self.uom_size && self.sku_loc ) ? BigDecimal.new( self.sku_loc.qty ) / self.uom_size : 0 end |
#total ⇒ BigDecimal
Returns the total value of the line.
59 60 61 |
# File 'lib/skr/ia_line.rb', line 59 def total self.ledger_cost * self.qty end |