From a2d0aee1ab7a66aba0b1260d84e50e8a3e109cc7 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 20 Feb 2018 09:37:30 +0630 Subject: [PATCH] update applicaton contro and request bill --- app/controllers/application_controller.rb | 5 +++++ app/controllers/origami/request_bills_controller.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3a35a15b..9abc8990 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -92,6 +92,11 @@ class ApplicationController < ActionController::Base @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] end + # Get current Cashier + def get_cashier + @cashier = Employee.where("role = 'cashier' AND token_session <> ''") + end + def current_company begin return Company.first diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index c076a820..44d6f784 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -6,6 +6,7 @@ class Origami::RequestBillsController < ApplicationController sale_order=SaleOrder.new if shift = ShiftSale.current_open_shift(current_user.id) + # if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) order_id = params[:id] # order_id bk_order = BookingOrder.find_by_order_id(order_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id) @@ -14,7 +15,7 @@ class Origami::RequestBillsController < ApplicationController # 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