updated for api bill controller

This commit is contained in:
Yan
2017-06-28 16:56:43 +06:30
54 changed files with 1066 additions and 163 deletions

View File

@@ -19,7 +19,7 @@ class Api::BillController < Api::ApiController
@sale_id = booking.sale_id
end
end
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
@@ -29,6 +29,7 @@ class Api::BillController < Api::ApiController
@sale_items = SaleItem.where("sale_id=?",@sale_id)
unique_code = "ReceiptBillPdf"
#shop detail
shop_details = Shop.find(1)

View File

@@ -2,7 +2,7 @@ class HomeController < ApplicationController
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
def index
@employees = Employee.all.order("name asc")
@employees = Employee.all_emp_except_waiter.order("name asc")
@login_form = LoginForm.new()
end
@@ -19,7 +19,7 @@ class HomeController < ApplicationController
if @employee != nil
session[:session_token] = @employee.token_session
redirect_to origami_root_path
route_by_role(@employee)
else
render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!"
end
@@ -37,7 +37,7 @@ class HomeController < ApplicationController
redirect_to dashboard_path
elsif @employee.role == "cashier"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
route_by_role(@employee)
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
@@ -74,4 +74,25 @@ class HomeController < ApplicationController
def settings_home_params
params.require(:login_form).permit(:emp_id, :password)
end
def route_by_role(employee)
if employee.role == "administrator"
redirect_to dashboard_path
elsif employee.role == "cashier"
#check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee)
if !shift.nil?
redirect_to origami_root_path
else
redirect_to new_origami_shift_path
end
elsif employee.role == "manager"
redirect_to oqs_root_path
elsif employee.role == "waiter"
redirect_to oqs_root_path
elsif employee.role == "crm"
redirect_to crm_root_path
end
end
end

View File

@@ -0,0 +1,10 @@
class Origami::CashMgmtController < ApplicationController
def index
end
def new
end
def create
end
end

View File

@@ -19,9 +19,9 @@ class Origami::HomeController < BaseOrigamiController
@orders = Order.get_orders()
end
def item_show
selection(params[:booking_id],1)
end
# def item_show
# selection(params[:booking_id],1)
# end
def selection(selected_id, is_ajax)
str = []
@@ -37,8 +37,8 @@ class Origami::HomeController < BaseOrigamiController
@order_details = OrderItem.get_order_items_details(params[:booking_id])
@order_details.each do |ord_detail|
str.push(ord_detail)
end
end
end
end
if is_ajax == 1
render :json => str.to_json

View File

@@ -0,0 +1,21 @@
class Origami::ShiftsController < BaseOrigamiController
def index
end
def show
end
def new
@float = Lookup.where('lookup_type=?','float')
end
def create
opening_balance = params[:opening_balance]
@shift = ShiftSale.new
@shift.create(opening_balance,current_user)
end
def edit
end
end

View File

@@ -25,7 +25,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed"
if sale.sale_status != "completed" && sale.sale_status != 'void'
@sale_array.push(sale)
end
end

View File

@@ -9,6 +9,14 @@ class Origami::VoidController < BaseOrigamiController
sale.sale_status = 'void'
sale.save
bookings = sale.bookings
bookings.each do |booking|
orders = booking.orders
orders.each do |order|
# order.status = 'void'
end
end
table_avaliable = true
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|