Pull from master
This commit is contained in:
@@ -2,11 +2,20 @@ class InventoryDefinition < ApplicationRecord
|
||||
|
||||
scope :active, -> {where(:is_active => true)}
|
||||
|
||||
def self.calculate_product_count(saleObj)
|
||||
saleObj.sale_items.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil)
|
||||
if !saleObj.nil?
|
||||
saleObj.sale_items.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
end
|
||||
end
|
||||
else
|
||||
saleobj_after_req_bill.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -16,7 +25,12 @@ class InventoryDefinition < ApplicationRecord
|
||||
if product.nil?
|
||||
return false, nil
|
||||
else
|
||||
return true, product
|
||||
stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
|
||||
if stock_check_item.nil?
|
||||
return false, nil
|
||||
else
|
||||
return true, product
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,11 +45,19 @@ class InventoryDefinition < ApplicationRecord
|
||||
|
||||
def self.modify_balance(item, stock, inventory_definition) #saleitemObj
|
||||
if stock.balance.to_i >= item.qty
|
||||
puts ">> stock is greater than orde qty"
|
||||
puts ">> stock is greater than order qty"
|
||||
StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition)
|
||||
else
|
||||
puts " << stock is less than order qty"
|
||||
StockJournal.add_to_journal(item, stock.balance, "out of stock", inventory_definition)
|
||||
item_data = item
|
||||
if stock.balance.to_i > 0
|
||||
item_data.qty = item.qty.to_i - stock.balance.to_i
|
||||
StockJournal.add_to_journal(item_data, stock.balance, "out of stock", inventory_definition)
|
||||
item.qty = stock.balance.to_i
|
||||
StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition)
|
||||
else
|
||||
StockJournal.add_to_journal(item_data, stock.balance, "out of stock", inventory_definition)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user