equal split and order split in order tab'
This commit is contained in:
@@ -5,6 +5,16 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@order = Order.find(params[:order_id])
|
||||
booking = Booking.select('bookings.booking_id, bookings.dining_facility_id')
|
||||
.joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id")
|
||||
.where("bo.order_id='#{params[:order_id]}'").first()
|
||||
|
||||
@booking = Array.new
|
||||
if !booking.nil?
|
||||
dining_facilities = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type})
|
||||
end
|
||||
|
||||
sale_order = SaleOrder.find_by_order_id(@order.order_id)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
@@ -12,19 +22,17 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
@sale_status = sale.sale_status
|
||||
end
|
||||
end
|
||||
|
||||
@orders.each do |order|
|
||||
order.order_items.each_with_index do |item, index|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
order.order_items[index].set_menu_items = arr_instance_item_sets
|
||||
|
||||
@order.order_items.each_with_index do |item, order_item_index|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
@order.order_items[order_item_index].set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
sale_items = SaleItem.where("sale_id=?",sale_id)
|
||||
member_info = nil
|
||||
|
||||
survey = Survey.find_by_receipt_no(sale_data.receipt_no)
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
@@ -60,7 +61,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
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_details, "Frt",current_balance,nil)
|
||||
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_details, "Frt",current_balance,nil,survey)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,6 +73,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -139,7 +141,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data,survey)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -245,7 +247,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
member_info = nil
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
@@ -292,7 +295,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data,survey)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -306,7 +309,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(rounding_adjustment: 0)
|
||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
|
||||
@@ -344,7 +348,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil,survey)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,10 +18,10 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
if @booking
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
arr_order_items = Array.new
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@orders.push(@order)
|
||||
@order_items.push({'all_order' => @order.order_items})
|
||||
|
||||
@order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
@@ -59,19 +59,19 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
'updated_at' => item.updated_at}
|
||||
i += 1
|
||||
@order_items.push({@order.order_id => arr_item})
|
||||
arr_order_items.push(arr_item)
|
||||
end
|
||||
else
|
||||
arr_order_items.push(item)
|
||||
@order_items.push({@order.order_id => item})
|
||||
end
|
||||
end
|
||||
@order_items.push({'all_order' => arr_order_items})
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
|
||||
puts "@order_items"
|
||||
puts @order_items.to_json
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -160,19 +160,19 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
if !updated_order_id.empty?
|
||||
order_ids.each do |odr_id|
|
||||
unless updated_order_id.include?(odr_id)
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
# BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
|
||||
order_items.each do |order_item|
|
||||
if updated_order_id.include?(order_item["order_id"])
|
||||
update_order_item(order_item)
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
order_ids.each do |odr_id|
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
# BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
@@ -181,12 +181,15 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_item)
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
if order_ids.count == 1 && order_id_count > 0 && order_item_count == 1
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_ids[0], order_item)
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
@@ -214,7 +217,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_item)
|
||||
update_order_item(order.id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -239,7 +242,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def update_order_item(order_item)
|
||||
def update_order_item(order_id, order_item)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
@@ -251,13 +254,13 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
orderItem.set_menu_items,
|
||||
orderItem.order_id,
|
||||
order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order.order_id
|
||||
orderItem.order_id = order_id
|
||||
end
|
||||
orderItem.save!
|
||||
end
|
||||
|
||||
@@ -30,6 +30,33 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
def create_survey
|
||||
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
|
||||
survey = Survey.find_by_receipt_no(params[:receipt_no])
|
||||
|
||||
if survey.nil?
|
||||
survey = Survey.new
|
||||
survey.dining_name = dining_facility.name
|
||||
survey.receipt_no = params[:receipt_no]
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.created_by = current_user.name
|
||||
survey.total_customer = params[:total_customer]
|
||||
survey.total_amount = params[:total_amount]
|
||||
survey.save!
|
||||
else
|
||||
survey.total_customer = params[:total_customer]
|
||||
survey.save!
|
||||
end
|
||||
render :json => {status: true}
|
||||
else
|
||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
@date = @sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@customer = @sale.customer
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
|
||||
@@ -6,6 +6,8 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
survey = Survey.find_by_receipt_no(sale.receipt_no)
|
||||
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0)
|
||||
@@ -107,7 +109,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,survey)
|
||||
end
|
||||
|
||||
#end print
|
||||
|
||||
Reference in New Issue
Block a user