Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -22,27 +22,19 @@ class Api::OrdersController < Api::ApiController
|
||||
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == table_id.to_i
|
||||
@booking = booking
|
||||
if booking.booking_status == 'assign'
|
||||
if booking.sale_id.nil?
|
||||
@booking = booking
|
||||
end
|
||||
end
|
||||
else
|
||||
table = DiningFacility.find(table_id)
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == table_id.to_i
|
||||
@booking = booking
|
||||
end
|
||||
end
|
||||
@booking = table.get_booking
|
||||
end
|
||||
end
|
||||
else
|
||||
puts "only table"
|
||||
table = DiningFacility.find(table_id)
|
||||
booking = table.get_current_booking
|
||||
puts booking
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == table_id.to_i
|
||||
@booking = booking
|
||||
end
|
||||
end
|
||||
@booking = table.get_booking
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,54 +65,47 @@ class Api::OrdersController < Api::ApiController
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
check_order_with_booking(booking)
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
puts "booking sale is null"
|
||||
end
|
||||
else
|
||||
# booking.table id not equal current table
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
end
|
||||
end
|
||||
check_order_with_table(params[:table_id])
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
#no booking id
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
end
|
||||
check_order_with_table(params[:table_id])
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
end
|
||||
# Description
|
||||
# This API - allow order to add new items to existing orders, does not allow you to remove confirm items
|
||||
# Update customer info, Guest Info
|
||||
|
||||
@@ -46,7 +46,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(params[:id])
|
||||
@customer = Customer.find(params[:id])
|
||||
@response = Customer.get_membership_transactions(@customer)
|
||||
#end customer amount
|
||||
|
||||
@@ -93,7 +93,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
@@ -163,7 +164,8 @@ end
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
@@ -201,6 +203,6 @@ end
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salution,:gender,:nrc_no,:address,:card_no)
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,10 @@ class Oqs::HomeController < BaseOqsController
|
||||
def index
|
||||
queue_stations=OrderQueueStation.all
|
||||
|
||||
# Query for OQS with delivery status false
|
||||
@queue_items_details = queue_items_query(false)
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
@queue_completed_item = queue_items_query(true)
|
||||
|
||||
@queue_stations_items=Array.new
|
||||
@@ -79,29 +81,17 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
# Query for OQS with status
|
||||
def queue_items_query(status)
|
||||
puts status
|
||||
puts "put what is status"
|
||||
# AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
|
||||
# .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
|
||||
# left join dining_facilities as df on df.zone_id = oqpz.zone_id
|
||||
# left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id
|
||||
# left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
# left join order_items as odt ON odt.item_code = assigned_order_items.item_code
|
||||
# left join customers as cus ON cus.customer_id = od.customer_id")
|
||||
# .where("assigned_order_items.delivery_status = #{status}")
|
||||
# .group("assigned_order_items.assigned_order_item_id")
|
||||
# .order("odt.item_name DESC")
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status}")
|
||||
.group("assigned_order_items.assigned_order_item_id,oqs.station_name,oqs.is_active,df.name,odt.item_code,odt.item_name,odt.price, odt.qty, odt.item_order_by,cus.name,odt.created_at")
|
||||
.group("odt.order_items_id")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,10 @@ class Oqs::PrintController < ApplicationController
|
||||
# Print Order Item
|
||||
def print
|
||||
unique_code="OrderItemPdf"
|
||||
assigned_item_id=params[:id]
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
assigned_item_id = params[:id]
|
||||
options = params[:options]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
@@ -13,9 +14,9 @@ class Oqs::PrintController < ApplicationController
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
|
||||
# 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(oqs, assigned_item.order_id, assigned_item.item_code, print_status )
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status, options )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
@@ -27,10 +28,10 @@ class Oqs::PrintController < ApplicationController
|
||||
# Print Order Details with booking id
|
||||
def print_order_summary
|
||||
unique_code="OrderSummaryPdf"
|
||||
assigned_item_id=params[:id]
|
||||
table_name=params[:table_name]
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
assigned_item_id = params[:id]
|
||||
table_name = params[:table_name]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
@@ -43,13 +44,13 @@ class Oqs::PrintController < ApplicationController
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
|
||||
# print when complete click
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_booking_summary(oqs, booking.booking_id, print_status)
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status=true
|
||||
ai.print_status = true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,5 +39,29 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
if(id == "SAL")
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: params[:customer_id])
|
||||
else
|
||||
@booking = BookingOrder.find_by_order_id(params[:sale_id])
|
||||
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
|
||||
|
||||
@orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
status = order.update_attributes(customer_id: params[:customer_id])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
def index
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.complete_sale
|
||||
@complete = Sale.all
|
||||
@orders = Order.all.order('date desc')
|
||||
end
|
||||
|
||||
@@ -12,27 +12,30 @@ class Origami::HomeController < BaseOrigamiController
|
||||
def show
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.complete_sale
|
||||
@complete = Sale.all
|
||||
@orders = Order.all.order('date desc')
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
@dining.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
@order_items = Array.new
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
@dining.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
@obj_order = order
|
||||
@date = order.created_at
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@date = order.created_at
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed"
|
||||
puts "enter"
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
@@ -42,7 +45,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@obj_sale = sale
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -44,7 +44,7 @@ class Origami::MovetableController < BaseOrigamiController
|
||||
bookings = Booking.where('dining_facility_id=?',change_from)
|
||||
booking_array = Array.new
|
||||
bookings.each do | booking |
|
||||
if booking.sale_id.nil? || booking.sale.sale_status != 'completed'
|
||||
if booking.sale_id.nil? || booking.sale.sale_status != 'completed' || booking.booking_status != 'moved'
|
||||
booking_array.push(booking)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
def show
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.complete_sale
|
||||
@complete = Sale.all
|
||||
@orders = Order.all.order('status desc')
|
||||
@order = Order.find(params[:order_id])
|
||||
sale_order = SaleOrder.find_by_order_id(@order.order_id)
|
||||
|
||||
@@ -6,8 +6,24 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
# limit redeem_amount
|
||||
rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
|
||||
nonrebate_prices = sale_data.total_amount - rebate_prices
|
||||
# rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
|
||||
# nonrebate_prices = sale_data.total_amount - rebate_prices
|
||||
# @payparcount = 0
|
||||
# others = 0
|
||||
# sale_data.sale_payments.each do |sale_payment|
|
||||
# if sale_payment.payment_method == "paypar"
|
||||
# @payparcount = @payparcount + sale_payment.payment_amount
|
||||
# else
|
||||
# others = others + sale_payment.payment_amount
|
||||
# end
|
||||
# end
|
||||
# non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
|
||||
# if non_rebate_exceed < 0
|
||||
# @redeem_prices = rebate_prices - @payparcount
|
||||
# else
|
||||
# @redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
|
||||
# end
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
@@ -17,12 +33,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
|
||||
if non_rebate_exceed < 0
|
||||
@redeem_prices = rebate_prices - @payparcount
|
||||
else
|
||||
@redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
|
||||
end
|
||||
@redeem_prices = sale_data.grand_total - @payparcount -others
|
||||
|
||||
|
||||
if sale_data
|
||||
if sale_data.customer_id
|
||||
|
||||
@@ -22,7 +22,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
unique_code = "ReceiptBillPdf"
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
|
||||
customer= Customer.find( @sale_data.customer_id)
|
||||
customer= Customer.find(@sale_data.customer_id)
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
# get printer info
|
||||
|
||||
@@ -3,7 +3,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
def show
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.complete_sale
|
||||
@complete = Sale.all
|
||||
@orders = Order.all.order('date desc')
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
@room.bookings.each do |booking|
|
||||
|
||||
@@ -3,8 +3,42 @@ class Origami::SalesController < BaseOrigamiController
|
||||
def show
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.complete_sale
|
||||
@complete = Sale.all
|
||||
@orders = Order.all.order('date desc')
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
end
|
||||
|
||||
def add_to_existing_invoice
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
table = DiningFacility.find(dining)
|
||||
table.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
order.status = 'billed'
|
||||
order.order_items.each do |item|
|
||||
item.order_item_status = 'billed'
|
||||
end
|
||||
# create sale item
|
||||
saleobj = Sale.find(sale_id)
|
||||
order.order_items.each do |orer_item|
|
||||
saleobj.add_item (orer_item)
|
||||
end
|
||||
saleobj.save
|
||||
order.save
|
||||
booking.save
|
||||
end
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
bo.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -4,6 +4,10 @@ class Reports::DailySaleController < BaseReportController
|
||||
from, to ,report_type = get_date_range_from_params
|
||||
@sale_data = Sale.daily_sales_list(from,to)
|
||||
@tax = SaleTax.get_tax(from,to)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -8,6 +8,10 @@ class Reports::ReceiptNoController < BaseReportController
|
||||
puts to
|
||||
@sale_data = Sale.get_receipt_no_list(from,to)
|
||||
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -5,6 +5,11 @@ class Reports::SaleItemController < BaseReportController
|
||||
from, to, report_type = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
Reference in New Issue
Block a user