From 9ae1fb1084ffe4271d7f1f0d5f71fd031d1cfa00 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 20 Feb 2018 14:00:18 +0630 Subject: [PATCH 1/4] update requset bill for api --- app/controllers/api/bill_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 4b58e52d..c12eb596 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -6,7 +6,8 @@ class Api::BillController < Api::ApiController @status = false @error_message = "Order ID or Booking ID is require to request for a bill." - if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) + # if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) + if !ShiftSale.current_shift.nil? #create Bill by Booking ID table = 0 if (params[:booking_id]) @@ -41,8 +42,8 @@ class Api::BillController < Api::ApiController end # Bind shift sale id to sale - @sale_data.shift_sale_id = shift_by_terminal.id - @sale_data.save + # @sale_data.shift_sale_id = shift_by_terminal.id + # @sale_data.save Promotion.promo_activate(@sale) From 20103a54a5bc90b70839f327421abaadd55357d9 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 20 Feb 2018 14:33:36 +0630 Subject: [PATCH 2/4] update sale for request --- app/models/sale.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 417e4204..5cdd7dd1 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -157,7 +157,7 @@ class Sale < ApplicationRecord @sale = Sale.new sale_order=SaleOrder.new - if shift = ShiftSale.current_open_shift(current_user.id) + if !ShiftSale.current_shift.nil? order_id = order.order_id # order_id bk_order = BookingOrder.find_by_order_id(order_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id) @@ -166,7 +166,7 @@ class Sale < ApplicationRecord # Create Sale if it doesn't exist # puts "current_login_employee" # puts current_login_employee.name - @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil) + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee,current_user) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) else @@ -175,8 +175,8 @@ class Sale < ApplicationRecord end # Bind shift sale id to sale - @sale_data.shift_sale_id = shift.id - @sale_data.save + # @sale_data.shift_sale_id = shift.id + # @sale_data.save # Promotion Activation Promotion.promo_activate(@sale) From b0cc934625b8b98c91d1a8813107cffc956274b4 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 20 Feb 2018 15:29:19 +0630 Subject: [PATCH 3/4] update quick service for split bill --- app/controllers/origami/orders_controller.rb | 9 +++++++-- .../origami/pending_order_controller.rb | 2 -- .../origami/split_bill_controller.rb | 20 +++++++++++-------- app/views/origami/orders/show.html.erb | 11 +++++++--- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index f5b71bf8..13f5b684 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -11,8 +11,13 @@ class Origami::OrdersController < BaseOrigamiController @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}) + if booking.dining_facility_id.to_i > 0 + 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}) + else + @booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => nil}) + end + end #for split bill diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index dd2f4cc7..a1942a27 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -9,8 +9,6 @@ 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 - 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) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 037f3f6c..4c74d4a7 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -86,18 +86,22 @@ class Origami::SplitBillController < BaseOrigamiController end status = false - if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) + if !ShiftSale.current_shift.nil? #create Bill by Booking ID table = 0 if !params[:booking_id].empty? booking = Booking.find(params[:booking_id]) # for Multiple Cashier by Zone - table = DiningFacility.find(booking.dining_facility_id) + if booking.dining_facility_id.to_i>0 + table = DiningFacility.find(booking.dining_facility_id) + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + else + table = nil + end - cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) - - shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) - get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id) + # shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) + # get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id) + get_cashier_by_terminal = current_user if booking if booking.sale_id.nil? @@ -320,8 +324,8 @@ class Origami::SplitBillController < BaseOrigamiController end # Bind shift sale id to sale - sale_data.shift_sale_id = shift_by_terminal.id - sale_data.save + # sale_data.shift_sale_id = shift_by_terminal.id + # sale_data.save Promotion.promo_activate(sale) diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 4ffe9de6..57a55597 100755 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -334,11 +334,16 @@ swal("Information!", result.error_message); } else{ - if(type=='Table'){ - window.location.href = '/origami/table/' + dining_id; + if (dining_id == 0) { + window.location.href = '/origami'; }else{ - window.location.href = '/origami/room/' + dining_id; + if(type=='Table'){ + window.location.href = '/origami/table/' + dining_id; + }else{ + window.location.href = '/origami/room/' + dining_id; + } } + } } }); From 98c4737a2affcbe638218d8748f9fd4f42f59597 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 20 Feb 2018 16:09:11 +0630 Subject: [PATCH 4/4] fixed minor issuse --- app/assets/javascripts/addorder.js | 2 +- app/controllers/origami/request_bills_controller.rb | 4 +--- app/views/origami/payments/show.html.erb | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index cefa64fb..b9b03c3e 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -102,7 +102,7 @@ $(function() { instances = menu_items[field].instances ; if (!instances.length > 0) { - swal("Hello Please Check!","doesn't not have instance item in this menu items ("+ menu_items[field].name+")","warning"); + swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning"); } if (instances.length > 0) { qty = 1; diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 39296119..39ef789a 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -5,9 +5,7 @@ class Origami::RequestBillsController < ApplicationController @sale = Sale.new sale_order=SaleOrder.new - # if shift = ShiftSale.current_open_shift(current_user.id) - puts ShiftSale.current_shift - puts "sssssssssss" + # if shift = ShiftSale.current_open_shift(current_user.id)SSS if !ShiftSale.current_shift.nil? order_id = params[:id] # order_id bk_order = BookingOrder.find_by_order_id(order_id) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 96f69da9..1dbe960f 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -396,7 +396,7 @@ var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1); var total = $('#amount_due').text(); var amt = parseFloat(total) - parseFloat(othertotal); - $('#cash').text(parseFloat(amt).toFixed(2)); + $('#cash').text(parseFloat(amt).toFixed(1)); update_balance(); break; } @@ -485,7 +485,7 @@ $( "#loading_wrapper" ).hide(); if($('#balance').text() < 0){ swal({ - title: "Information!", + title: "Payment Successful!", text: 'Changed amount ' + $('#balance').text() * (-1), html: true, closeOnConfirm: false, @@ -497,7 +497,7 @@ }else{ $('#pay').text("Pay"); swal({ - title: "Information!", + title: "Payment Successful!", text: 'Thank You !', html: true, closeOnConfirm: false,