update pending and quick service

This commit is contained in:
Aung Myo
2018-02-15 15:26:34 +06:30
parent a8fdf2ec30
commit cf644892c9
9 changed files with 164 additions and 27 deletions

View File

@@ -161,9 +161,16 @@ class Origami::DiscountsController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
dining = DiningFacility.find(table_id)
table_type = dining.type
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
table_type = table.type
else
table_id = nil
table = nil
table_type = nil
end
discount_items = []
#destroy all discount sale item
@@ -182,14 +189,28 @@ class Origami::DiscountsController < BaseOrigamiController
sale.sale_items.destroy(discount_items)
action_by = current_user.id
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{dining.name} "
if table.nil?
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table"
else
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
result = {:status=> "Success", :table_id => table_id, :dining => dining.name, :table_type => table_type }
if table.nil?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => dining.name, :table_type => table_type }
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
end
render :json => result.to_json

View File

@@ -9,8 +9,15 @@ class Origami::PendingOrderController < BaseOrigamiController
@sale = Sale.find(params[:sale_id])
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
@booking = BookingOrder.find_by_order_id(@order).booking_id
@table_id = Booking.find(@booking).dining_facility_id
@dining = DiningFacility.find(@table_id)
puts "sssssssssss"
puts @booking
if Booking.find(@booking).dining_facility_id.to_i > 0
@table_id = Booking.find(@booking).dining_facility_id
@dining = DiningFacility.find(@table_id)
else
@table_id = nil
@dining = nil
end
end
helper_method :shop_detail
def shop_detail

View File

@@ -16,10 +16,18 @@ class Origami::QuickServiceController < ApplicationController
def modify_order
@menu = MenuCategory.all.active
@table_id = params[:id]
if(params[:id][0,3] == "BKI")
@table_id = nil
@table = nil
@booking = Booking.find(params[:id])
else
@table_id = params[:id]
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
end
@sale_id = params[:sale_id]
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
if @booking
@booking_id = @booking.booking_id
@order_items = Array.new
@@ -84,9 +92,13 @@ class Origami::QuickServiceController < ApplicationController
if !params["booking_id"].nil?
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if params[:table_id].to_i > 0
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
else
table_status = true
end
if booking
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
if table_status && booking.booking_status != 'moved'
if !booking.sale_id.nil?
sale_status = check_order_with_booking(booking)
if sale_status
@@ -97,17 +109,21 @@ class Origami::QuickServiceController < ApplicationController
@order.booking_id = params[:booking_id]
end
else
if params[:table_id].to_i > 0
sale_status = check_order_with_table(params[:table_id])
if sale_status
return return_json_status_with_code(400, "bill requested")
end
end
end
end #booking exists
else
sale_status = check_order_with_table(params[:table_id])
if sale_status
# return false , @message = "bill requested"
return return_json_status_with_code(400, "bill requested")
if params[:table_id].to_i > 0
sale_status = check_order_with_table(params[:table_id])
if sale_status
# return false , @message = "bill requested"
return return_json_status_with_code(400, "bill requested")
end
end
end
@@ -116,7 +132,12 @@ class Origami::QuickServiceController < ApplicationController
if @status && @booking && @order.source == 'quick_service'
if params[:sale_id]
@sale = Sale.find(params[:sale_id])
update = Sale.add_to_existing_pending_invoice(@order.table_id,params[:sale_id])
if @order.table_id.to_i > 0
@table_id = @order.table_id
else
@table_id = nil
end
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
end
result = {:status=> true, :data => @sale }

View File

@@ -3,7 +3,12 @@ class Origami::SaleEditController < BaseOrigamiController
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@table_id = params[:table_id]
if params[:table_id]
@table_id = params[:table_id]
else
@table_id = nil
end
@cashier_type = params[:type]
@saleobj = Sale.find(sale_id)
end