check inventory
This commit is contained in:
@@ -12,7 +12,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.find_product_in_inventory(item)
|
||||
product = InventoryDefinition.find_by_item_code(item.product_code)
|
||||
product = InventoryDefinition.find_by_item_code(item.item_instance_code)
|
||||
if product.nil?
|
||||
return false, nil
|
||||
else
|
||||
@@ -21,7 +21,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.check_balance(item,inventory_definition) # item => saleItemOBj
|
||||
stock = StockJournal.where('item_code=?', item.product_code).order('created_at desc').take
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order('created_at desc').take
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
|
||||
@@ -8,7 +8,7 @@ class StockJournal < ApplicationRecord
|
||||
balance = calculate_balance(balance, item.qty)
|
||||
|
||||
journal = StockJournal.new
|
||||
journal.item_code = item.product_code
|
||||
journal.item_code = item.item_instance_code
|
||||
journal.inventory_definition_id = inventory_definition.id
|
||||
journal.debit = item.qty
|
||||
journal.balance = balance
|
||||
|
||||
Reference in New Issue
Block a user