Inventory Issue

This commit is contained in:
Myat Zin Wai Maw
2019-06-21 15:33:34 +06:30
parent c10dd611d7
commit ae2144cca9
2 changed files with 9 additions and 6 deletions

View File

@@ -4,8 +4,6 @@ class InventoryDefinition < ApplicationRecord
def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil)
if !saleObj.nil?
Rails.logger.debug "Hello count"
Rails.logger.debug saleObj.sale_items.count
saleObj.sale_items.each do |item|
found, inventory_definition = find_product_in_inventory(item)
if found
@@ -37,7 +35,7 @@ class InventoryDefinition < ApplicationRecord
end
def self.check_balance(item,inventory_definition) # item => saleItemOBj
stock = StockJournal.where('item_code=?', item.item_instance_code).last
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
unless stock.nil?
modify_balance(item, stock, inventory_definition)
else

View File

@@ -63,6 +63,7 @@ class Sale < ApplicationRecord
end
end
def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil, current_checkin_induties_count)
saleObj =''
booking = Booking.find(booking_id)
status = false
Rails.logger.debug "Booking -> " + booking.id.to_s
@@ -71,13 +72,17 @@ class Sale < ApplicationRecord
#get all order attached to this booking and combine into 1 invoice
booking.booking_orders.each do |order|
# puts "Hello order"
if booking.sale_id
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier, order_source)
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier, order_source)
else
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier, order_source)
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier, order_source)
end
booking.sale_id = sale_id
saleObj = Sale.find(sale_id)
end
# InventoryJob.perform_now(self.id)
InventoryDefinition.calculate_product_count(saleObj)
order = booking.booking_orders.take.order
link_order_sale(order.id)
@@ -225,7 +230,7 @@ class Sale < ApplicationRecord
# InventoryJob.perform_now(self.id)
saleObj = Sale.find(self.id)
InventoryDefinition.calculate_product_count(saleObj)
# InventoryDefinition.calculate_product_count(saleObj)
return true, self.id
end