fixed conflict after merge with dev branch for report query updated
This commit is contained in:
@@ -23,20 +23,9 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_product_in_inventory(item,shop_code=nil)
|
||||
# unless instance_code.empty?
|
||||
# instance_code = instance_code.to_s
|
||||
# instance_code[0] = ""
|
||||
# instance_code = instance_code.chomp("]")
|
||||
# else
|
||||
# instance_code = '"0"'
|
||||
# end
|
||||
#
|
||||
# if prod = InventoryDefinition.where("item_code IN(#{instance_code})")
|
||||
# puts "found prodcut+++++++++++++++++++++++++++++++++++==="
|
||||
# puts prod.to_json
|
||||
# end
|
||||
if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
||||
|
||||
def self.find_product_in_inventory(item)
|
||||
if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
||||
if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
||||
return true, product
|
||||
end
|
||||
@@ -44,13 +33,13 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.check_balance(item, inventory_definition) # item => saleItemOBj
|
||||
stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUT OF STOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||
StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
|
||||
end
|
||||
|
||||
stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
|
||||
end
|
||||
end
|
||||
|
||||
def self.modify_balance(item, stock, inventory_definition) #saleitemObj
|
||||
@@ -75,6 +64,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
elsif item.is_a? SaleItem
|
||||
trans_type = StockJournal::SALES_TRANS
|
||||
end
|
||||
# StockJournal.add_to_journal(instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
|
||||
StockJournal.add_to_journal(item.item_instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
|
||||
check_item.different = check_item.different - qty
|
||||
check_item.save
|
||||
|
||||
Reference in New Issue
Block a user