Pull from master

This commit is contained in:
San Wai Lwin
2018-08-20 11:26:07 +06:30
parent 3c2faf5970
commit d1852d24c3
28 changed files with 464 additions and 216 deletions

View File

@@ -1,8 +1,36 @@
class Inventory::InventoryController < BaseInventoryController
load_and_authorize_resource
def index
@products = InventoryDefinition.all.active.order('created_at desc')
end
load_and_authorize_resource
def index
least_stock = "SELECT (CASE WHEN SIGN(MIN(stock_journals.balance)) > 0
THEN MIN(stock_journals.balance) WHEN stock_journals.remark NOT LIKE '%out of stock%'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code
AND remark NOT LIKE '%out of stock%'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals
WHERE stock_journals.item_code = inventory_definitions.item_code
ORDER BY stock_journals.created_at DESC"
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
(#{least_stock}) as balance")
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
.group("inventory_definitions.item_code")
.order("(CASE WHEN sj.balance > 0 THEN MIN(sj.balance) ELSE NULL END )")
end
def show
inventory_definition_id = params[:inventory_definition_id]
inventory = InventoryDefinition.find(inventory_definition_id)
@stock_journals = StockJournal.where(item_code: inventory.item_code)
respond_to do |format|
format.html
format.xls
end
end
#Shop Name in Navbor
helper_method :shop_detail

View File

@@ -24,7 +24,14 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions
# POST /inventory_definitions.json
def create
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
else
@inventory_definition = InventoryDefinition.find(inventory.id)
@inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
end
@inventory_definition.created_by = current_user.id
respond_to do |format|
if @inventory_definition.save

View File

@@ -2,7 +2,7 @@ class Oqs::PrintController < ApplicationController
authorize_resource :class => false
# Print Order Item
def print
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all
unique_code="OrderItemPdf"
@@ -41,19 +41,30 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
filename, receipt_no, cashier_printer = order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status=true
ai.save
end
end
end
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
if ENV["SERVER_MODE"] == "cloud"
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
end
# end
end
# Print Order Details with booking id
def print_order_summary
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all
unique_code="OrderSummaryPdf"
@@ -98,14 +109,25 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
filename, receipt_no, cashier_printer = order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status = true
ai.save
end
end
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
if ENV["SERVER_MODE"] == "cloud"
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
end
# end
end
end

View File

@@ -26,15 +26,16 @@ class Origami::SalesController < BaseOrigamiController
dining = params[:dining_id]
sale_id = params[:sale_id]
tax_type = params[:tax_type]
sale_data = []
table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id)
table.bookings.each do |booking|
# if !booking.checkout_at.nil?
# existing_booking.update_attributes(checkout_at: checkout_at)
# end
if booking.sale_id.nil?
order_array = []
booking.booking_orders.each do |booking_order|
if booking.sale_id.nil?
order_array = []
booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved'
order = Order.find(booking_order.order_id)
@@ -49,6 +50,7 @@ class Origami::SalesController < BaseOrigamiController
if !orer_item.set_menu_items.nil?
saleobj.add_sub_item(orer_item.set_menu_items)
end
sale_data.push(orer_item)
end
# Re-compute for add
@@ -58,7 +60,7 @@ class Origami::SalesController < BaseOrigamiController
booking.save
order_array.push(order.order_id)
end
receipt_no = Sale.find(sale_id).receipt_no
@@ -75,6 +77,10 @@ class Origami::SalesController < BaseOrigamiController
end
end
end
if !sale_data.empty?
# InventoryJob.perform_now(self.id)
InventoryDefinition.calculate_product_count(nil,sale_data)
end
end
end