Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes

This commit is contained in:
phyusin
2018-02-21 09:15:53 +06:30
6 changed files with 40 additions and 16 deletions

View File

@@ -102,7 +102,7 @@ $(function() {
instances = menu_items[field].instances ; instances = menu_items[field].instances ;
if (!instances.length > 0) { 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) { if (instances.length > 0) {
qty = 1; qty = 1;

View File

@@ -6,7 +6,8 @@ class Api::BillController < Api::ApiController
@status = false @status = false
@error_message = "Order ID or Booking ID is require to request for a bill." @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 #create Bill by Booking ID
table = 0 table = 0
if (params[:booking_id]) if (params[:booking_id])
@@ -41,8 +42,8 @@ class Api::BillController < Api::ApiController
end end
# Bind shift sale id to sale # Bind shift sale id to sale
@sale_data.shift_sale_id = shift_by_terminal.id # @sale_data.shift_sale_id = shift_by_terminal.id
@sale_data.save # @sale_data.save
Promotion.promo_activate(@sale) Promotion.promo_activate(@sale)

View File

@@ -92,6 +92,11 @@ class ApplicationController < ActionController::Base
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end end
# Get current Cashier
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end
def current_company def current_company
begin begin
return Company.first return Company.first

View File

@@ -5,16 +5,15 @@ class Origami::RequestBillsController < ApplicationController
@sale = Sale.new @sale = Sale.new
sale_order=SaleOrder.new sale_order=SaleOrder.new
if shift = ShiftSale.current_open_shift(current_user.id) # if shift = ShiftSale.current_open_shift(current_user.id)SSS
if !ShiftSale.current_shift.nil?
order_id = params[:id] # order_id order_id = params[:id] # order_id
bk_order = BookingOrder.find_by_order_id(order_id) bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil? if check_booking.sale_id.nil?
# Create Sale if it doesn't exist # Create Sale if it doesn't exist
# puts "current_login_employee" @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user)
# puts current_login_employee.name
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
@sale_data = Sale.find_by_sale_id(@sale_id) @sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id)
else else
@@ -23,8 +22,8 @@ class Origami::RequestBillsController < ApplicationController
end end
# Bind shift sale id to sale # Bind shift sale id to sale
@sale_data.shift_sale_id = shift.id # @sale_data.shift_sale_id = shift.id
@sale_data.save # @sale_data.save
# Promotion Activation # Promotion Activation
Promotion.promo_activate(@sale) Promotion.promo_activate(@sale)
@@ -55,4 +54,10 @@ class Origami::RequestBillsController < ApplicationController
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end end

View File

@@ -78,12 +78,25 @@ class Sale < ApplicationRecord
self.tax_type = "exclusive" self.tax_type = "exclusive"
# set cashier # set cashier
if cashier != nil open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift
shift = ShiftSale.current_open_shift(cashier.id)
# set cashier
if shift != nil
self.cashier_id = cashier.id self.cashier_id = cashier.id
self.cashier_name = cashier.name self.cashier_name = cashier.name
self.shift_sale_id = shift.id
else else
self.cashier_id = requested_by.id if open_cashier.nil?
self.cashier_name = requested_by.name self.cashier_id = requested_by.id
self.cashier_name = requested_by.name
self.shift_sale_id = current_shift.id
else
self.cashier_id = current_shift.employee_id
self.cashier_name = Employee.find(current_shift.employee_id).name
self.shift_sale_id = current_shift.id
end
end end
# set waiter # set waiter

View File

@@ -396,7 +396,7 @@
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1); var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
var total = $('#amount_due').text(); var total = $('#amount_due').text();
var amt = parseFloat(total) - parseFloat(othertotal); var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(parseFloat(amt).toFixed(2)); $('#cash').text(parseFloat(amt).toFixed(1));
update_balance(); update_balance();
break; break;
} }
@@ -485,7 +485,7 @@
$( "#loading_wrapper" ).hide(); $( "#loading_wrapper" ).hide();
if($('#balance').text() < 0){ if($('#balance').text() < 0){
swal({ swal({
title: "Information!", title: "Payment Successful!",
text: 'Changed amount ' + $('#balance').text() * (-1), text: 'Changed amount ' + $('#balance').text() * (-1),
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
@@ -497,7 +497,7 @@
}else{ }else{
$('#pay').text("Pay"); $('#pay').text("Pay");
swal({ swal({
title: "Information!", title: "Payment Successful!",
text: 'Thank You !', text: 'Thank You !',
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,