route changes

This commit is contained in:
San Wai Lwin
2018-03-13 14:51:07 +06:30
parent 694feb9c06
commit 9228168ebc
49 changed files with 1906 additions and 707 deletions

1
.gitignore vendored
View File

@@ -26,6 +26,7 @@ capybara-*.html
/public/assets/* /public/assets/*
/public/uploads/* /public/uploads/*
/public/swf/* /public/swf/*
/public/receipts
/coverage/ /coverage/
/spec/tmp/* /spec/tmp/*
*.orig *.orig

View File

@@ -31,30 +31,75 @@ $(document).on('turbolinks:load', function() {
$(".oqs_append").addClass('hide') $(".oqs_append").addClass('hide')
}); });
$(".oqs_click").on("click", function(){ $(".tables").on("click", function(){
var table_id = $(this).val();
$('#table_id').val(table_id);
oqs_id = $("#oqs_id").val();
if (table_id){
var table = table_id
}else{
var table = null
}
if (oqs_id > 0) {
$(".oqs_click").removeClass('oqs_active'); $(".oqs_click").removeClass('oqs_active');
$(".queue_station").removeClass('queue_station_box'); $(".queue_station").removeClass('queue_station_box');
$("#completed").addClass('hide'); $("#completed").addClass('hide');
$(".oqs_append").removeClass('hide'); $(".oqs_append").removeClass('hide');
$(this).addClass('oqs_active'); $("#oqs_active").addClass('oqs_active');
$(".queue_station").addClass('queue_station_box'); $(".queue_station").addClass('queue_station_box');
oqs_id = $(this).find(".oqs-id").text(); // oqs_id = $(this).find(".oqs-id").text();
console.log(oqs_id); $("#oqs_active").attr('data-id',oqs_id);
var url = 'oqs/get_items/'+oqs_id; var url = 'oqs/get_items/'+oqs_id;
show_details(url); show_details(url,table);
}else{
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
}
});
$(".oqs_click").on("click", function(){
oqs_id = $(this).val();
var table_id = $('#table_id').val();
if (table_id){
var table = table_id
}else{
var table = null
}
if (oqs_id > 0) {
$(".oqs_click").removeClass('oqs_active');
$(".queue_station").removeClass('queue_station_box');
$("#completed").addClass('hide');
$(".oqs_append").removeClass('hide');
$("#oqs_active").addClass('oqs_active');
$(".queue_station").addClass('queue_station_box');
// oqs_id = $(this).find(".oqs-id").text();
$("#oqs_active").attr('data-id',oqs_id);
var url = 'oqs/get_items/'+oqs_id;
show_details(url,table);
}else{
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
}
}); //End Click }); //End Click
function show_details(url){ function show_details(url,table_id){
var oqs_append = $('.oqs_append'); var oqs_append = $('.oqs_append');
oqs_append.empty(); oqs_append.empty();
var filter = $('.filter').text(); var filter = $('.filter').text();
console.log(table_id)
//Start Ajax //Start Ajax
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: url, url: url,
data: {'filter':filter}, data: {'filter':filter,'table_id':table_id},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
for(var field in data) { for(var field in data) {
@@ -67,7 +112,8 @@ $(document).on('turbolinks:load', function() {
} }
var date = new Date(data[field]["created_at"]); var date = new Date(data[field]["created_at"]);
var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); // var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM');
var set_menu_items = data[field]["set_menu_items"]; var set_menu_items = data[field]["set_menu_items"];
var set_instance_items = ""; var set_instance_items = "";
if(set_menu_items!=null){ if(set_menu_items!=null){
@@ -100,7 +146,7 @@ $(document).on('turbolinks:load', function() {
+set_instance_items +set_instance_items
+'</p>' +'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>' +'<p class="card-text item-options">'+ options +'</p>'
+'<span class="card-text">' +'<span class="card-text">'
+'<span class="text-muted">Order at - ' +'<span class="text-muted">Order at - '

View File

@@ -46,8 +46,8 @@ $(function() {
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '" + product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '" + JSON.stringify(item_attributes) +"' data-options = '"
+ options +"' data-image='"+image_path+"'>" + options +"' data-image='"+image_path+"'>"
+"<i class='fa fa-plus material-icons'>" +"<i class='fa fa-bars material-icons'>"
+'add</i>' +'view_list</i>'
+'</div>' +'</div>'
+'</div>' +'</div>'
@@ -146,7 +146,7 @@ $(function() {
promotion_price = menu_items[field].promotion_price; promotion_price = menu_items[field].promotion_price;
}else{ }else{
fa_plus = 'material-icons'; fa_plus = 'material-icons';
add = 'add' add = 'view_list'
menu_item_box = 'menu_item_box'; menu_item_box = 'menu_item_box';
data_target = 'sx_item_detailModal'; data_target = 'sx_item_detailModal';
data_modal = '' data_modal = ''
@@ -760,7 +760,6 @@ $(function() {
$("#oqs_loading_wrapper").show(); $("#oqs_loading_wrapper").show();
type = window.location.href.indexOf("quick_service"); type = window.location.href.indexOf("quick_service");
if (type != -1) { if (type != -1) {
type = 'quick_service' type = 'quick_service'
var table_type = $('#table_type').text(); var table_type = $('#table_type').text();
@@ -985,19 +984,19 @@ $(function() {
$("#back").on("click", function(){ $("#back").on("click", function(){
var table_id = $('#table_id').text(); var table_id = $('#table_id').text();
var table_type = $('#table_type').text(); var table_type = $('#table_type').text();
type = window.location.href.indexOf("quick_service"); type = window.location.href.includes("quick_service");
if (type == 'true') { if (type == true) {
var table_type = $('#table_id').find("option:selected").data('type'); var table_type = $('#table_id').find("option:selected").data('type');
var table_id = $('#table_id').val(); var table_id = $('#table_id').val();
window.location.href = "/origami/dashboard" window.location.href = "/origami/dashboard";
}else{ }else{
var table_type = $('#table_type').text(); var table_type = $('#table_type').text();
var table_id = $('#table_id').text(); var table_id = $('#table_id').text();
if(table_type == "Table"){ if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id window.location.href = "/origami/table/" + table_id;
}else { }else {
window.location.href = "/origami/room/" + table_id window.location.href = "/origami/room/" + table_id;
} }
} }
}); });

View File

@@ -6,7 +6,6 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
disconnected: function() {}, disconnected: function() {},
received: function(data) { received: function(data) {
// console.log(data.order);
var oqs_id = $('.oqs_active').attr('data-id'); var oqs_id = $('.oqs_active').attr('data-id');
items = data.order; items = data.order;
for(var field in items) { for(var field in items) {

View File

@@ -21,32 +21,32 @@ $(document).ready(function() {
railBorderRadius: '0' railBorderRadius: '0'
}); });
$('.delete').click(function(){ // $('.delete').click(function(){
var method = $(this).attr('data-method'); // var method = $(this).attr('data-method');
var url = $(this).attr('data-ref'); // var url = $(this).attr('data-ref');
var html_text = $(this).siblings( "#delete_text" ).html(); // var html_text = $(this).siblings( "#delete_text" ).html();
//var page = url.substring(url.lastIndexOf('/') + 1); // //var page = url.substring(url.lastIndexOf('/') + 1);
swal({ // swal({
title: "Confirmation", // title: "Confirmation",
text: html_text, // text: html_text,
type: "warning", // type: "warning",
showCancelButton: true, // showCancelButton: true,
confirmButtonColor: "#DD6B55", // confirmButtonColor: "#DD6B55",
html: true // html: true
}, function (isConfirm) { // }, function (isConfirm) {
if (isConfirm) { // if (isConfirm) {
$.ajax({ // $.ajax({
type: method, // type: method,
url: url , // url: url ,
success: function(data) { // success: function(data) {
location.href = data.url; // location.href = data.url;
} // }
}); // });
} else { // } else {
swal("Cancelled", "Your imaginary file is safe :)", "error"); // swal("Cancelled", "Your imaginary file is safe :)", "error");
} // }
}); // });
}); // });
// for Notificaiotn message // for Notificaiotn message
var placementFrom = $("#notify_message").attr('data-placement-from'); var placementFrom = $("#notify_message").attr('data-placement-from');

View File

@@ -255,14 +255,14 @@ function setCommPorts(comPortLists) {
} }
/** pay with CB bank **/ /** pay with CB bank **/
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no) { function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) {
$("#loading_wrapper").show(); $("#loading_wrapper").show();
var com_port = $("#com_port_name").val(); var com_port = $("#com_port_name").val();
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port); reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
} }
//add req data to card_sale_trans table //add req data to card_sale_trans table
function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port) { function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) {
var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port}; var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port};
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -272,14 +272,14 @@ function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, rece
success: function(data) { success: function(data) {
if (data.status == "success"){ if (data.status == "success"){
card_sale_trans_id = data.card_sale_trans_id; card_sale_trans_id = data.card_sale_trans_id;
resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port); resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type);
} }
} }
}); });
} }
//add res data to card_sale_trans table //add res data to card_sale_trans table
function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port) { function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) {
var resMsg = ""; var resMsg = "";
var card_payment_type=""; var card_payment_type="";
@@ -306,7 +306,7 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
if(data.status == "success"){ if(data.status == "success"){
resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port); resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type);
} }
} }
}); });
@@ -317,7 +317,7 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo
} }
function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port) { function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) {
$("#loading_wrapper").hide(); $("#loading_wrapper").hide();
var jobj = $.parseJSON(resMsg); var jobj = $.parseJSON(resMsg);
if(jobj.STATUS == "Approved"){ if(jobj.STATUS == "Approved"){
@@ -334,7 +334,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment"; window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
}); });
} }
} }
@@ -352,7 +352,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment/"+payment_type; window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/"+payment_type;
}); });
} }
} }

View File

@@ -167,7 +167,7 @@ class Crm::CustomersController < BaseCrmController
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' }
else else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
end end
@@ -186,21 +186,21 @@ class Crm::CustomersController < BaseCrmController
if response["message"] == "Account has not exist." if response["message"] == "Account has not exist."
customer.destroy customer.destroy
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]} format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]}
else else
format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] } format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] }
end end
end end
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]} format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]}
else else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response["message"] } format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response["message"] }
end end
end end
else else
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'} format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created. noted'}
else else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' }
end end
@@ -209,7 +209,7 @@ class Crm::CustomersController < BaseCrmController
if params[:sale_id] if params[:sale_id]
flash[:errors] = @crm_customers.errors flash[:errors] = @crm_customers.errors
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page]}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity } format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
else else
flash[:errors] = @crm_customers.errors flash[:errors] = @crm_customers.errors

View File

@@ -92,6 +92,7 @@ class HomeController < ApplicationController
@sale_data = Array.new @sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to) @total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment| @total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
pay = Sale.payment_sale('card', today, current_user,@from,@to) pay = Sale.payment_sale('card', today, current_user,@from,@to)
@@ -101,6 +102,7 @@ class HomeController < ApplicationController
@sale_data.push({payment.payment_method => pay.payment_amount}) @sale_data.push({payment.payment_method => pay.payment_amount})
end end
end end
end
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to) @summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to)
@total_customer = Sale.total_customer(today,current_user,@from,@to) @total_customer = Sale.total_customer(today,current_user,@from,@to)
@total_dinein = Sale.total_dinein(today,current_user,@from,@to) @total_dinein = Sale.total_dinein(today,current_user,@from,@to)
@@ -111,12 +113,14 @@ class HomeController < ApplicationController
@total_order = Sale.total_order(today,current_user,@from,@to) @total_order = Sale.total_order(today,current_user,@from,@to)
@total_accounts = Sale.total_account(today,current_user,@from,@to) @total_accounts = Sale.total_account(today,current_user,@from,@to)
@account_data = Array.new @account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account| @total_accounts.each do |account|
acc = Sale.account_data(account.account_id, today,current_user,@from,@to) acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
if !acc.nil? if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end end
end end
end
@top_items = Sale.top_items(today,current_user,@from,@to) @top_items = Sale.top_items(today,current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to) @total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)

View File

@@ -7,7 +7,8 @@ class Oqs::HomeController < BaseOqsController
# @queue_items_details = queue_items_query(false) # @queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true # Query for OQS with delivery status true
@tables = DiningFacility.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@filter = params[:filter] @filter = params[:filter]
@@ -113,7 +114,11 @@ class Oqs::HomeController < BaseOqsController
def get_items_by_oqs def get_items_by_oqs
oqs_id = params[:id] oqs_id = params[:id]
filter = params[:filter] filter = params[:filter]
items = queue_items_query(false,oqs_id,filter) table_id = params[:table_id]
puts params
puts table_id
puts "sssssssssssss"
items = queue_items_query(false,oqs_id,filter,table_id)
if !items.empty? if !items.empty?
items.each do |item| items.each do |item|
if !item.set_menu_items.nil? if !item.set_menu_items.nil?
@@ -151,13 +156,20 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status # Query for OQS with delivery status
def queue_items_query(status,oqs_id=nil,filter) def queue_items_query(status,oqs_id=nil,filter,table_id)
if oqs_id == nil if oqs_id == nil
oqs = '' oqs = ''
else else
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' " oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
end end
if table_id.to_i>0
table = "and df.id = '#{table_id}' "
else
table = ''
end
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
oqs.id as station_id, oqs.station_name, oqs.id as station_id, oqs.station_name,
oqs.is_active, oqpz.zone_id, oqs.is_active, oqpz.zone_id,
@@ -173,7 +185,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ") .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table}")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.order("assigned_order_items.assigned_order_item_id desc") .order("assigned_order_items.assigned_order_item_id desc")
.group("odt.order_items_id") .group("odt.order_items_id")

View File

@@ -103,10 +103,15 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
} }
# begin # begin
if params[:order_source] == "quick_service"
customer_id = "CUS-000000000002" # for no customer id from mobile
else
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
end
@order = Order.new @order = Order.new
@order.source = params[:order_source] @order.source = params[:order_source]
@order.order_type = params[:order_type] @order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.customer_id = customer_id
@order.items = items_arr @order.items = items_arr
@order.guest = params[:guest_info] @order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id @order.table_id = params[:table_id] # this is dining facilities's id

View File

@@ -50,6 +50,7 @@ class Origami::CustomersController < BaseOrigamiController
@sale_id = params[:sale_id] @sale_id = params[:sale_id]
@cashier_type = params[:type] @cashier_type = params[:type]
@page = params[:page]
if(@sale_id[0,3] == "SAL") if(@sale_id[0,3] == "SAL")
@booking = Booking.find_by_sale_id(@sale_id) @booking = Booking.find_by_sale_id(@sale_id)
@@ -62,7 +63,11 @@ class Origami::CustomersController < BaseOrigamiController
else else
@booking_order = BookingOrder.find_by_order_id(@sale_id) @booking_order = BookingOrder.find_by_order_id(@sale_id)
@booking = Booking.find(@booking_order.booking_id) @booking = Booking.find(@booking_order.booking_id)
if @booking.dining_facility_id.to_i > 0
@dining_facility = DiningFacility.find(@booking.dining_facility_id) @dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@dining_facility = nil
end
end end
filter = params[:filter] filter = params[:filter]

View File

@@ -30,33 +30,33 @@ class Origami::HomeController < BaseOrigamiController
bookings = Booking.all bookings = Booking.all
if !bookings.today.nil? if !bookings.today.nil?
@order_items_count = Hash.new @order_items_count = Hash.new
bookings.each do |booking| # bookings.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved' # if booking.sale_id.nil? && booking.booking_status != 'moved'
if !booking.booking_orders.empty? # if !booking.booking_orders.empty?
booking.booking_orders.each do |booking_order| # booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id) # order = Order.find(booking_order.order_id)
if !order.order_items.empty? # if !order.order_items.empty?
if !@order_items_count.key?(booking.dining_facility_id) # if !@order_items_count.key?(booking.dining_facility_id)
@order_items_count.store(booking.dining_facility_id, order.order_items.count) # @order_items_count.store(booking.dining_facility_id, order.order_items.count)
else # else
@order_items_count[booking.dining_facility_id] += order.order_items.count # @order_items_count[booking.dining_facility_id] += order.order_items.count
end # end
end # end
end # end
end # end
else # else
if !booking.sale_id.nil? # if !booking.sale_id.nil?
sale = Sale.find(booking.sale_id) # sale = Sale.find(booking.sale_id)
if sale.sale_status !='completed' # if sale.sale_status !='completed'
if !@order_items_count.key?(booking.dining_facility_id) # if !@order_items_count.key?(booking.dining_facility_id)
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count) # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
else # else
@order_items_count[booking.dining_facility_id] = sale.sale_items.count # @order_items_count[booking.dining_facility_id] = sale.sale_items.count
end # end
end # end
end # end
end # end
end # end
end end
@dining.bookings.active.each do |booking| @dining.bookings.active.each do |booking|

View File

@@ -28,8 +28,21 @@ class Origami::PaymentsController < BaseOrigamiController
end end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
# Print for First Bill to Customer # Print for First Bill to Customer
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
end
end
end
end
#shop detail #shop detail
shop_details = Shop::ShopDetail shop_details = Shop::ShopDetail
# customer= Customer.where('customer_id=' +.customer_id) # customer= Customer.where('customer_id=' +.customer_id)
@@ -95,7 +108,6 @@ class Origami::PaymentsController < BaseOrigamiController
sale_payment = SalePayment.new sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "cash") sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
rebate_amount = nil rebate_amount = nil
# For Cashier by Zone # For Cashier by Zone
@@ -118,7 +130,20 @@ class Origami::PaymentsController < BaseOrigamiController
# For Print # For Print
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
end
end
end
end
customer= Customer.find(saleObj.customer_id) customer= Customer.find(saleObj.customer_id)
# get member information # get member information
@@ -151,7 +176,9 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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) filename, sale_receipt_no, printer_name = 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)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
if params[:type] == "quick_service" if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id) booking = Booking.find_by_sale_id(sale_id)
@@ -438,4 +465,30 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
#print function for receipt
def print
filename = params[:filename]
receipt_no = params[:receipt_no]
printer_name = params[:printer_name]
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
end
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
render :json => {status: true}
end
end end

View File

@@ -26,33 +26,33 @@ class Origami::RoomsController < BaseOrigamiController
bookings = Booking.all bookings = Booking.all
if !bookings.today.nil? if !bookings.today.nil?
@order_items_count = Hash.new @order_items_count = Hash.new
bookings.each do |booking| # bookings.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved' # if booking.sale_id.nil? && booking.booking_status != 'moved'
if !booking.booking_orders.empty? # if !booking.booking_orders.empty?
booking.booking_orders.each do |booking_order| # booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id) # order = Order.find(booking_order.order_id)
if !order.order_items.empty? # if !order.order_items.empty?
if !@order_items_count.key?(booking.dining_facility_id) # if !@order_items_count.key?(booking.dining_facility_id)
@order_items_count.store(booking.dining_facility_id, order.order_items.count) # @order_items_count.store(booking.dining_facility_id, order.order_items.count)
else # else
@order_items_count[booking.dining_facility_id] += order.order_items.count # @order_items_count[booking.dining_facility_id] += order.order_items.count
end # end
end # end
end # end
end # end
else # else
if !booking.sale_id.nil? # if !booking.sale_id.nil?
sale = Sale.find(booking.sale_id) # sale = Sale.find(booking.sale_id)
if sale.sale_status !='completed' # if sale.sale_status !='completed'
if !@order_items_count.key?(booking.dining_facility_id) # if !@order_items_count.key?(booking.dining_facility_id)
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count) # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
else # else
@order_items_count[booking.dining_facility_id] = sale.sale_items.count # @order_items_count[booking.dining_facility_id] = sale.sale_items.count
end # end
end # end
end # end
end # end
end # end
end end
@room.bookings.active.each do |booking| @room.bookings.active.each do |booking|

View File

@@ -66,6 +66,7 @@ class Ability
can :reprint, :payment can :reprint, :payment
can :rounding_adj, :payment can :rounding_adj, :payment
can :foc, :payment can :foc, :payment
can :print, :payment
can :move_dining, :movetable can :move_dining, :movetable
can :moving, :movetable can :moving, :movetable
@@ -111,10 +112,10 @@ class Ability
can :index, :other_charge can :index, :other_charge
can :create, :other_charge can :create, :other_charge
# can :index, :discount can :index, :discount
# can :create, :discount can :create, :discount
# can :remove_discount_items, :discount can :remove_discount_items, :discount
# can :remove_all_discount, :discount can :remove_all_discount, :discount
can :member_discount, :discount can :member_discount, :discount
can :first_bill, :payment can :first_bill, :payment
@@ -122,6 +123,7 @@ class Ability
can :create, :payment can :create, :payment
can :reprint, :payment can :reprint, :payment
can :rounding_adj, :payment can :rounding_adj, :payment
can :print, :payment
can :move_dining, :movetable can :move_dining, :movetable
can :moving, :movetable can :moving, :movetable
@@ -180,6 +182,7 @@ class Ability
can :show, :payment can :show, :payment
can :reprint, :payment can :reprint, :payment
can :rounding_adj, :payment can :rounding_adj, :payment
can :print, :payment
can :manage, Commission can :manage, Commission
can :manage, Commissioner can :manage, Commissioner
@@ -191,6 +194,26 @@ class Ability
elsif user.role == "waiter" elsif user.role == "waiter"
can :index, :home can :index, :home
can :show, :home can :show, :home
can :manage, Customer
can :get_customer, Customer
can :add_customer, Customer
can :update_sale_by_customer, Customer
can :index, :other_charge
can :create, :other_charge
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :member_discount, :discount
#ability for move table
can :move_dining, :movetable
can :moving, :movetable
can :move_dining, :moveroom
#ability for split_bill #ability for split_bill
can :index, :split_bill can :index, :split_bill
can :create, :split_bill can :create, :split_bill

View File

@@ -286,23 +286,51 @@ class Order < ApplicationRecord
#Process order items and send to order queue #Process order items and send to order queue
def process_order_queue def process_order_queue
#Send to background job for processing #Send to background job for processing
order = Order.find(self.id)
cup_status = `#{"sudo service cups status"}` cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status) print_status = check_cup_status(cup_status)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if print_status if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id) OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else else
cup_start = `#{"sudo service cups start"}` cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}` cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status) print_status = check_cup_status(cup_status)
if print_status if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id) OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else else
msg = ' Print Error ! Please contact to service' msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error' ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id) OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end end
end end
@@ -310,8 +338,18 @@ class Order < ApplicationRecord
#Process order items and send to order queue #Process order items and send to order queue
def self.pay_process_order_queue(id,table_id) def self.pay_process_order_queue(id,table_id)
#Send to background job for processing sidekiq = Lookup.find_by_lookup_type("sidekiq")
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(id, table_id) OrderQueueProcessorJob.perform_later(id, table_id)
else
order = Order.find(id)
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end end
def check_cup_status(status) def check_cup_status(status)

View File

@@ -197,17 +197,28 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
print_settings.print_copies = 1 print_settings.print_copies = 1
print_settings.save! print_settings.save!
directory_name = 'public/receipts'
Dir.mkdir(directory_name) unless File.exists?(directory_name)
begin begin
if count == 1 if count == 1
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf" filename = "/receipts/receipt_bill_#{sale_data.receipt_no}.pdf"
self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name) pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
if printed_status != 'Paid'
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
end
else else
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" filename = "/receipts/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
self.print("tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name) pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
if printed_status != 'Paid'
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name)
end
end end
count -= 1 count -= 1
end until count == 0 end until count == 0
return filename, sale_data.receipt_no, cashier_terminal.printer_name
end end
# stock check # stock check
@@ -247,4 +258,23 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
self.print("tmp/print_call_waiter.pdf") self.print("tmp/print_call_waiter.pdf")
end end
#print receipt pdf from js
def print_receipt_pdf(filename,receipt_no,print_copies,printer_name)
count = print_copies.to_i
# if count == 0
# self.print("public"+filename, printer_name)
# else
begin
if count == 1
self.print("public"+filename, printer_name)
else
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
self.print(filename, printer_name)
end
count -= 1
end until count == 0
# end
end
end end

2
app/models/receipt.rb Normal file
View File

@@ -0,0 +1,2 @@
class Receipt < ApplicationRecord
end

View File

@@ -0,0 +1,2 @@
class ReceiptDetail < ApplicationRecord
end

View File

@@ -548,11 +548,22 @@ class Sale < ApplicationRecord
#Generate new Receipt No when it is not assigned #Generate new Receipt No when it is not assigned
def generate_receipt_no def generate_receipt_no
#shop_code and client_code
shop_details = Shop::ShopDetail
#Date-Shift- #Date-Shift-
if self.receipt_no.nil? if self.receipt_no.nil?
prefix = DateTime.now().utc prefix = DateTime.now().utc
#self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s #self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s
if !shop_details.nil?
if !shop_details.shop_code.nil?
self.receipt_no = shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s
else
self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s
end
else
self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s
end
self.receipt_date = prefix self.receipt_date = prefix
Rails.logger.debug "Receipt No #{self.receipt_no} | Date #{ self.receipt_date.to_s}" Rails.logger.debug "Receipt No #{self.receipt_no} | Date #{ self.receipt_date.to_s}"
@@ -1170,7 +1181,7 @@ end
if current_user.nil? if current_user.nil?
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total") total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total") total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total")
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
@@ -1184,7 +1195,7 @@ end
if current_user.nil? if current_user.nil?
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
@@ -1202,7 +1213,7 @@ end
if current_user.nil? if current_user.nil?
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
@@ -1215,7 +1226,7 @@ end
if current_user.nil? if current_user.nil?
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
@@ -1234,7 +1245,7 @@ end
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount") .sum("sp.payment_amount")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount") .sum("sp.payment_amount")
@@ -1253,7 +1264,7 @@ end
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount") .sum("sp.payment_amount")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today) query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount") .sum("sp.payment_amount")
@@ -1276,7 +1287,7 @@ end
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount") .sum("payment_amount")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ?',from,to) query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ?',from,to)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount") .sum("payment_amount")
@@ -1295,7 +1306,7 @@ end
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount") .sum("payment_amount")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today) query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount") .sum("payment_amount")
@@ -1318,7 +1329,7 @@ end
.where('sale_status = "completed" and receipt_date between ? and ?',from,to) .where('sale_status = "completed" and receipt_date between ? and ?',from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
.where('sale_status = "completed" and receipt_date between ? and ?',from,to) .where('sale_status = "completed" and receipt_date between ? and ?',from,to)
.first() .first()
@@ -1337,7 +1348,7 @@ end
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.first() .first()
@@ -1360,7 +1371,7 @@ end
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("distinct sp.payment_method") query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
@@ -1379,7 +1390,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("distinct sp.payment_method") query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
@@ -1406,7 +1417,7 @@ end
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to)
@@ -1437,7 +1448,7 @@ end
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today) query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
@@ -1482,7 +1493,7 @@ end
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(sales.customer_id) as total_dinein_cus") query = Sale.select("count(sales.customer_id) as total_dinein_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to)
@@ -1504,7 +1515,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(sales.customer_id) as total_dinein_cus") query = Sale.select("count(sales.customer_id) as total_dinein_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
@@ -1530,7 +1541,7 @@ end
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(sales.customer_id) as total_take_cus") query = Sale.select("count(sales.customer_id) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to)
@@ -1552,7 +1563,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(sales.customer_id) as total_take_cus") query = Sale.select("count(sales.customer_id) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
@@ -1578,7 +1589,7 @@ end
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to)
@@ -1600,7 +1611,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
@@ -1626,7 +1637,7 @@ end
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(sales.customer_id) as total_cus") query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
@@ -1648,7 +1659,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(sales.customer_id) as total_cus") query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
@@ -1675,7 +1686,7 @@ end
.where('b.status = "billed" and sales.receipt_date between ? and ?',from,to) .where('b.status = "billed" and sales.receipt_date between ? and ?',from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(distinct a.order_id) as total_order") query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id") .joins("JOIN orders as b ON b.order_id = a.order_id")
@@ -1700,7 +1711,7 @@ end
.where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(distinct a.order_id) as total_order") query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id") .joins("JOIN orders as b ON b.order_id = a.order_id")
@@ -1728,7 +1739,7 @@ end
.joins("JOIN accounts as b ON b.id = a.account_id") .joins("JOIN accounts as b ON b.id = a.account_id")
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("distinct b.id as account_id, b.title as title") query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id") .joins("JOIN accounts as b ON b.id = a.account_id")
@@ -1750,7 +1761,7 @@ end
.joins("JOIN accounts as b ON b.id = a.account_id") .joins("JOIN accounts as b ON b.id = a.account_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("distinct b.id as account_id, b.title as title") query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id") .joins("JOIN accounts as b ON b.id = a.account_id")
@@ -1776,7 +1787,7 @@ end
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to) .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to) .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to)
@@ -1798,7 +1809,7 @@ end
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
@@ -1826,7 +1837,7 @@ end
.order("SUM(a.qty) DESC") .order("SUM(a.qty) DESC")
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ?",from,to) .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ?",from,to)
@@ -1854,7 +1865,7 @@ end
.order("SUM(a.qty) DESC") .order("SUM(a.qty) DESC")
.first() .first()
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
@@ -1883,7 +1894,7 @@ end
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to) .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to)
.sum("a.qty") .sum("a.qty")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to) .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to)
.sum("a.qty") .sum("a.qty")
@@ -1902,7 +1913,7 @@ end
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.sum("a.qty") .sum("a.qty")
else else
if current_user.role == 'administrator' if current_user.role == 'administrator' || current_user.role == 'manager'
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.sum("a.qty") .sum("a.qty")
@@ -2011,6 +2022,44 @@ end
.group("bookings.booking_id") .group("bookings.booking_id")
end end
def self.all_receipts
query = Sale.select("sales.*, sale_payments.created_at as receipt_close_time,
case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
SUM(sale_items.qty) as qty,
sales.cashier_name as cashier_name,
surveys.child as child,
surveys.adult as adult")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join sale_taxes on sale_taxes.sale_id = sales.sale_id")
.joins("join sale_items on sale_items.sale_id = sales.sale_id")
.joins("join sale_audits on sale_audits.sale_id = sales.sale_id")
.joins("left join surveys on surveys.receipt_no = sales.receipt_no")
query = query.where("sale_status != 'new' && sale_payments.payment_amount > 0")
.group("sale_id")
return query
end
def self.all_receipt_details
query = SaleItem.select("sale_items.*, sale_payments.created_at as receipt_close_time,
sales.requested_at as requested_at, sales.receipt_no as receipt_no,sales.sale_id as s_id")
.joins("join sale_payments on sale_payments.sale_id = sale_items.sale_id")
.joins("join sales on sales.sale_id = sale_items.sale_id")
.group("sale_items.sale_item_id")
query = query.where("qty > 0 and sales.sale_status !='new'")
return query
end
private private
def generate_custom_id def generate_custom_id

View File

@@ -359,7 +359,7 @@ class SalePayment < ApplicationRecord
if check_foc if check_foc
update_shift update_shift
elsif paid_amount != "0.0" elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
update_shift update_shift
end end
end end

View File

@@ -112,6 +112,7 @@ class ReceiptBillA5Pdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end end
if sale_data.bookings[0].dining_facility_id.to_i > 0 if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
@@ -121,10 +122,16 @@ class ReceiptBillA5Pdf < Prawn::Document
move_down line_move move_down line_move
y_position = cursor y_position = cursor
bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([0, y_position], :width => self.item_description_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left
end
end
bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
end end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
end end
move_down line_move move_down line_move

View File

@@ -108,9 +108,10 @@ class ReceiptBillPdf < Prawn::Document
move_down line_move move_down line_move
# move_down 2 # move_down 2
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end end
if sale_data.bookings[0].dining_facility_id.to_i > 0 if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
@@ -120,7 +121,13 @@ class ReceiptBillPdf < Prawn::Document
move_down line_move move_down line_move
y_position = cursor y_position = cursor
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([0,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left
end
end
bounding_box([self.label_width, y_position], :width =>self.label_width, :height => self.item_height) do
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
end end
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do

View File

@@ -23,10 +23,10 @@
<input type="hidden" name="type" id="type" value=""> <input type="hidden" name="type" id="type" value="">
</div> </div>
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> --> <!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn btn-sm bg-blue waves-effect" style="margin-right: 10px;"><%= t("views.btn.search") %></button> <button type="submit" class="btn btn-sm bg-blue waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.search") %></button>
<!-- </div> --> <!-- </div> -->
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;"><%= t("views.btn.memeber_card") %></button> <button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.memeber_card") %></button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;"><%= t("views.btn.qr_code") %></button> <button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
</div> </div>
<% end %> <% end %>
</div> </div>
@@ -145,7 +145,8 @@ $(function() {
$("#qr_code").on('click', function(e){ $("#qr_code").on('click', function(e){
var code = ""; var code = "";
setTimeout(function(){ setTimeout(function(){
var hi=getQRCode(); code=getQRCode();
setQRCode(code);
},100); },100);
}); });

View File

@@ -228,16 +228,15 @@
<% else %> <% else %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4"> <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<% end %> <% end %>
<% if !@total_customer.nil? && @total_customer.to_i > 0 %>
<div class="card"> <div class="card">
<div class="body"> <div class="body">
<h6><%= t :customer %></h6> <h6><%= t :customer %></h6>
<table class="table"> <table class="table">
<% if !@total_customer.nil? %>
<tr> <tr>
<td><%= t("views.right_panel.detail.total") %> <%= t :customer %> : </td> <td><%= t("views.right_panel.detail.total") %> <%= t :customer %> : </td>
<td align="right"><%= @total_customer %></td> <td align="right"><%= @total_customer %></td>
</tr> </tr>
<% end %>
<% if !@total_dinein.nil? %> <% if !@total_dinein.nil? %>
<tr> <tr>
<td><%= t("views.right_panel.detail.dine_in") %> : </td> <td><%= t("views.right_panel.detail.dine_in") %> : </td>
@@ -265,6 +264,7 @@
</table> </table>
</div> </div>
</div> </div>
<% end %>
</div> </div>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %> <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
</div> </div>
@@ -317,8 +317,9 @@
</div> </div>
</div> </div>
</div> </div>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
</div> </div>
</div> <% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -16,7 +16,11 @@
<!-- <a href="javascript:void(0);" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false"></a> --> <!-- <a href="javascript:void(0);" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false"></a> -->
<%if current_login_employee.role !="waiter" %> <%if current_login_employee.role !="waiter" %>
<a href="javascript:void(0);" class="bars"></a> <a href="javascript:void(0);" class="bars"></a>
<% if current_login_employee.role != "cashier" %>
<a class="navbar-brand" href="<%=dashboard_path%>" style="margin-left: 20px;"> <a class="navbar-brand" href="<%=dashboard_path%>" style="margin-left: 20px;">
<% else %>
<a class="navbar-brand" href="<%=origami_dashboard_path%>" style="margin-left: 20px;">
<% end %>
<% else %> <% else %>
<a class="navbar-brand m-0" href="<%= origami_dashboard_path%>"> <a class="navbar-brand m-0" href="<%= origami_dashboard_path%>">
<%end%> <%end%>
@@ -56,13 +60,11 @@
</li> </li>
<% end %> <% end %>
<li> <li>
<!-- <%if current_login_employee.role !="waiter" %> -->
<!-- <%end%> -->
<!-- <p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete"> <!-- <p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-10 logout_icon">exit_to_app</i> <i class="material-icons font-10 logout_icon">exit_to_app</i>
<span class="font-18">Logout</span> <span class="font-18">Logout</span>
</p> --> </p> -->
<p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete"> <p class="delete waves-effect waves-block p-l-30 m-b-5 logout" data-ref="<%= logout_path %>" data-method="delete">
<i class="material-icons font-7 logout_icon">exit_to_app</i> <i class="material-icons font-7 logout_icon">exit_to_app</i>
<span class="font-15">Logout</span> <span class="font-15">Logout</span>
</p> </p>
@@ -79,9 +81,39 @@
</div> </div>
</div> </div>
</nav> </nav>
<script type="text/javascript"> <script type="text/javascript">
if((document.getElementById("otherPayment")!=undefined) && (document.getElementById("otherPayment")!=null) && (document.getElementById("otherPayment")!="")){ if((document.getElementById("otherPayment")!=undefined) && (document.getElementById("otherPayment")!=null) && (document.getElementById("otherPayment")!="")){
var otherPayment = location.href.split('/')[location.href.split('/').length -1 ]; var otherPayment = location.href.split('/')[location.href.split('/').length -1 ];
document.getElementById("otherPayment").innerHTML = otherPayment; document.getElementById("otherPayment").innerHTML = otherPayment;
} }
$(function(){
$('.delete').click(function(){
var method = $(this).attr('data-method');
var url = $(this).attr('data-ref');
var html_text = $(this).siblings( "#delete_text" ).html();
//var page = url.substring(url.lastIndexOf('/') + 1);
swal({
title: "Confirmation",
text: html_text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
html: true
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: method,
url: url ,
success: function(data) {
location.href = data.url;
}
});
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
});
</script> </script>

122
app/views/oqs/home/index.html.erb Executable file → Normal file
View File

@@ -1,71 +1,52 @@
<!-- Column One --> <!-- Column One -->
<div class="row clearfix"> <div class="row clearfix" style="margin-top:-50px !important">
<div class="col-lg-8 col-md-8 col-sm-8"> <div class="col-lg-11 col-md-11 col-sm-11">
<div class="body p-l-10"> <div class="body p-l-10">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="row clearfix"> <div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12"> <div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" class="form-control" placeholder="Search"> <span class="hidden" id="oqs_active"></span>
<select class="form-control select oqs_click" name="oqs_id" id="oqs_id">
</div> <option value="0" data-id="0">Processed</option>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> <% @queue_stations.each do |qsi| %>
<button type="submit" class="btn bg-blue waves-effect waves-effect">Search</button> <% if qsi.is_active != false %>
</div>
</div>
<% end %>
</div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<!-- <li class="nav-item nav-search <%= @filter.to_s.length > 0? " " : "hide"%>">
<a class="nav-link <%= @filter.to_s.length > 0? "active" : " "%>" data-toggle="tab" href="#search" role="tab">Searching .. <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li> -->
<li class="nav-item nav-completed">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed
<span class="badge bg-blue-grey" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<% # For Tab Disable for Station is inactive
status=""
i=0
@queue_stations.each do |qsi|
if qsi.is_active == false
status="disabled"
end %>
<li class="nav-item oqs_click" data-id="<%= qsi.id %>">
<p class="hidden oqs-id"><%= qsi.id %></p> <p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-id="<%= qsi.id %>" data-toggle="tab" href="" role="tab" <%= status %>> <option value="<%= qsi.id %>" data-id="<%= qsi.id %>" style="padding:5px 20px !important;"> <%= qsi.station_name %></option>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge bg-blue-grey oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>" id="completed_count">
<!-- <span class="badge badge-pill badge-default oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>"> --> <%= qsi.assigned_order_items.where("delivery_status=0 AND created_at >= '#{Time.now.beginning_of_day.utc}'").count %>
</span>
<%else%>
<span class="label-count badge bg-blue-grey" data-id="<%= qsi.id %>">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %> <% end %>
</a> <% end %>
</li> </select>
<% i+=1%> </div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<span class="hidden" id="table_id"></span>
<select class="form-control select tables" name="table_id" id="tables">
<option value="">Select Table</option>
<% @tables.each do |table| %>
<option value="<%= table.id %>" data-id="<%= table.id %>"> <%= table.name %></option>
<% end %> <% end %>
</ul> </select>
<!-- Nav tabs - End --> </div>
<!--
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<span class="hidden" id="room_id"></span>
<select class="form-control select rooms" name="table_id" id="rooms">
<option value="">Select Room</option>
<% @rooms.each do |table| %>
<option value="<%= table.id %>" data-id="<%= table.id %>"> <%= table.name %></option>
<% end %>
</select>
</div> -->
</div>
</div>
<p class="hidden filter"><%= @filter %></p> <p class="hidden filter"><%= @filter %></p>
<div class="card">
<div class="card-block">
<div class="tab-content" id="custom-slimscroll" style=""> <div class="tab-content" id="custom-slimscroll" style="">
<!--- Panel 0 - Completed -->
<div class="tab-pane in active" id="completed" role="tabpanel"> <div class="tab-pane in active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;column-count: ;">
<% <%
@queue_completed_item.each do |qid| @queue_completed_item.each do |qid|
%> %>
@@ -115,23 +96,20 @@
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p> <p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div> </div>
</div> </div>
<% <% end %>
end
%>
</div> </div>
</div> </div>
<!-- End Panel 0 - Completed -->
<!--- Order Items -->
<div class="card-columns oqs_append" id="oqs_container" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns oqs_append" id="oqs_container" style="padding-top:10px; column-gap: 1.2rem;">
</div> </div>
<!--- end of Items-->
</div> </div>
</div> </div>
</div>
</div>
<!-- Column Two --> <!-- Column Two -->
<div class="col-lg-3 col-md-3 col-sm-3"> <!-- <div class="col-lg-3 col-md-3 col-sm-3">
<div class="card" > <div class="card" >
<div class="card-header"> <div class="card-header">
<div><strong id="order-title">ORDER DETAILS</strong></div> <div><strong id="order-title">ORDER DETAILS</strong></div>
@@ -143,20 +121,18 @@
<tr> <tr>
<th style="width:33%; text-align:">Order By</th> <th style="width:33%; text-align:">Order By</th>
<th style="width:33%; text-align:">Order At</th> <th style="width:33%; text-align:">Order At</th>
<!-- <th style="width:33%; text-align:">Customer</th> -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td id="order-by" style="width:33%; text-align:"></td> <td id="order-by" style="width:33%; text-align:"></td>
<td id="order-at" style="width:33%; text-align:"></td> <td id="order-at" style="width:33%; text-align:"></td>
<!-- <td id="order-customer" style="width:33%; text-align:"></td> --> </tr> -->
</tr> <!-- <tr>
<tr>
<td><strong class="hidden cus_name">Customer</strong></td> <td><strong class="hidden cus_name">Customer</strong></td>
<td id="order-customer" colspan="2"></td> <td id="order-customer" colspan="2"></td>
</tr> </tr> -->
</tbody> <!-- </tbody>
</table> </table>
</div> </div>
<div class="card-text" id="order-detail-slimscroll" style="min-height:; max-height:; overflow:"> <div class="card-text" id="order-detail-slimscroll" style="min-height:; max-height:; overflow:">
@@ -168,17 +144,17 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- Bind With JS -->
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
-->
<!-- Column Three --> <!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons --> <!-- OQS Buttons -->
<br>
<a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a> <a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a>
<% if ENV["SERVER_MODE"] != "cloud" %> <% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a> <button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>

View File

@@ -0,0 +1,196 @@
<!-- Column One -->
<div class="row clearfix">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="body p-l-10">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" class="form-control" placeholder="Search">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
<button type="submit" class="btn bg-blue waves-effect waves-effect">Search</button>
</div>
</div>
<% end %>
</div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<!-- <li class="nav-item nav-search <%= @filter.to_s.length > 0? " " : "hide"%>">
<a class="nav-link <%= @filter.to_s.length > 0? "active" : " "%>" data-toggle="tab" href="#search" role="tab">Searching .. <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li> -->
<li class="nav-item nav-completed">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed
<span class="badge bg-blue-grey" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<% # For Tab Disable for Station is inactive
status=""
i=0
@queue_stations.each do |qsi|
if qsi.is_active == false
status="disabled"
end %>
<li class="nav-item oqs_click" data-id="<%= qsi.id %>">
<p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-id="<%= qsi.id %>" data-toggle="tab" href="" role="tab" <%= status %>>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge bg-blue-grey oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>" id="completed_count">
<!-- <span class="badge badge-pill badge-default oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>"> --> <%= qsi.assigned_order_items.where("delivery_status=0 AND created_at >= '#{Time.now.beginning_of_day.utc}'").count %>
</span>
<%else%>
<span class="label-count badge bg-blue-grey" data-id="<%= qsi.id %>">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% i+=1%>
<% end %>
</ul>
<!-- Nav tabs - End -->
<p class="hidden filter"><%= @filter %></p>
<div class="tab-content" id="custom-slimscroll" style="">
<!--- Panel 0 - Completed -->
<div class="tab-pane in active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_completed_item.each do |qid|
%>
<div class="card queue_station" data-order-no="<%= qid.order_id %>">
<div class="card-block">
<div class="row">
<%if qid.type.present?%>
<span class="col-md-4 order-zone-type font-13"><%= qid.type %>-<%= qid.zone %></span>
<%else%>
<span class="col-md-4 order-zone-type font-13"></span>
<%end%>
<span class="order-zone hidden font-13"><%= qid.zone %></span>
<span class="col-md-8"><small class="float-right font-13"><%= qid.order_id %></small></span>
</div>
<p class="m-b--10">
<span class="order-item font-16">
<%= qid.item_name %>
</span> [x
<span class="order-qty">
<%= qid.qty %>
</span> ]
<% if !qid.set_menu_items.nil? %>
<% qid.set_menu_items.each do |item_instance|%>
<br><span class="font-12">
<%= item_instance %>
</span>
<% end %>
<% end %>
</p>
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<span class="card-text">
<span class="text-muted">Order at -
<span class="order-at font-13">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> <br>
Order By - <span class="order-by font-13">
<%= qid.item_order_by %>
</span>
</span>
</span>
<p class="hidden order-status">completed</p>
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
</div>
<%
end
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!--- Order Items -->
<div class="card-columns oqs_append" id="oqs_container" style="padding-top:10px; column-gap: 1.2rem;">
</div>
<!--- end of Items-->
</div>
</div>
<!-- Column Two -->
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">ORDER DETAILS</strong></div>
</div>
<div class="card-block">
<div class="card-title">
<table class="">
<thead>
<tr>
<th style="width:33%; text-align:">Order By</th>
<th style="width:33%; text-align:">Order At</th>
<!-- <th style="width:33%; text-align:">Customer</th> -->
</tr>
</thead>
<tbody>
<tr>
<td id="order-by" style="width:33%; text-align:"></td>
<td id="order-at" style="width:33%; text-align:"></td>
<!-- <td id="order-customer" style="width:33%; text-align:"></td> -->
</tr>
<tr>
<td><strong class="hidden cus_name">Customer</strong></td>
<td id="order-customer" colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div class="card-text" id="order-detail-slimscroll" style="min-height:; max-height:; overflow:">
<table class="table" id="oqs-order-details-table">
<thead>
<tr>
<th style="width:80%; text-align:left">Items</th>
<th style="width:20%; text-align:right">QTY</th>
</tr>
</thead>
<tbody>
<!-- Bind With JS -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons -->
<a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a>
<% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>
<button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<%end%>
</div>
</div>
<script type="text/javascript">
$(document).on('turbolinks:load', function() {
$('#back').on('click', function () {
window.location.href = '/dashboard';
});
});
</script>

View File

@@ -34,12 +34,14 @@
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12"> <input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> <!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn bg-blue waves-effect waves-effect">Search</button> <button type="submit" class="btn bg-blue waves-effect waves-effect" style="height: 30%;margin-right: 10px;">Search</button>
</div> <!-- </div> -->
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;">Member Card</button> <button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;">Member Card</button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
</div> </div>
<% end %> <% end %>
</div> </div>
@@ -114,6 +116,8 @@
<span class="patch_method"></span> <span class="patch_method"></span>
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" /> <input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<input type="hidden" id="type" name="type" value="<%= @cashier_type %>" />
<input type="hidden" id="page" name="page" value="<%= @page %>" />
<%if !@dining_facility.nil?%> <%if !@dining_facility.nil?%>
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" /> <input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" /> <input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
@@ -263,6 +267,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var cashier_type = "<%= @cashier_type %>"; var cashier_type = "<%= @cashier_type %>";
var page = "<%= @page %>";
$(function() { $(function() {
/*$('.datepicker').datepicker({ /*$('.datepicker').datepicker({
setDate: '12-12-1999', setDate: '12-12-1999',
@@ -299,18 +304,19 @@
if(sale_id != 0 && customer_mamber_card_no != 0){ if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "get_customer" , url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"}, data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
if (data[0].customer_id == false) { if (data[0].customer_id == false) {
$.alert({ swal("Alert!", data[0].message, "error");
title: 'Alert!', // $.alert({
content: data[0].message, // title: 'Alert!',
type: 'red', // content: data[0].message,
typeAnimated: true, // type: 'red',
btnClass: 'btn-danger', // typeAnimated: true,
}); // btnClass: 'btn-danger',
// });
}else{ }else{
customer_id = data[0].customer_id; customer_id = data[0].customer_id;
customer_name = data[0].name; customer_name = data[0].name;
@@ -339,13 +345,33 @@
} }
} }
// QR Code Reader
$("#qr_code").on('click', function(e){
var code = "";
setTimeout(function(){
code=getQRCode();
setQRCode(code);
},100);
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
}
// get QRCode from Java
function setQRCode(code){
$("#qr_code").text(code);
$("#search").val(code);
}
$(document).on('click',".customer_tr",function(){ $(document).on('click',".customer_tr",function(){
// if(this.checked){ // if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true ); $(this).closest('tr').find('.checkbox_check').prop( "checked", true );
var sale_id = $("#sale_id").val() || 0; var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).attr('data-ref'); var customer_id = $(this).attr('data-ref');
var customer_name = $(this).children("td:nth-child(3)").text(); var customer_name = $(this).children("td:nth-child(3)").text();
console.log(sale_id);
if(sale_id != 0){ if(sale_id != 0){
// var url = "/"+customer_id; // var url = "/"+customer_id;
update_sale(customer_id, customer_name,sale_id); update_sale(customer_id, customer_name,sale_id);
@@ -433,7 +459,7 @@
}, function () { }, function () {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "update_sale" , url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id}, data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
@@ -441,8 +467,19 @@
{ {
var id = $("#table_id").val(); var id = $("#table_id").val();
var type = $("#type").val(); var type = $("#type").val();
var booking_id = "";
<% if !@booking_order.nil? %>
booking_id = "<%= @booking_order.booking_id %>";
<% end %>
if (cashier_type == "quick_service") { if (cashier_type == "quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/'; if(booking_id!= "" && page == "pending"){
window.location.href = '/origami/'+cashier_type+'/pending_order/'+booking_id;
}else{
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/customers/payment/';
}
}else{
if(page == "payment"){
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/customers/payment/';
}else{ }else{
if (type=="Table") { if (type=="Table") {
window.location.href = '/origami/table/'+id window.location.href = '/origami/table/'+id
@@ -450,6 +487,7 @@
window.location.href = '/origami/room/'+id window.location.href = '/origami/room/'+id
} }
} }
}
}else{ }else{
swal("Alert!", "Record not found!", "error"); swal("Alert!", "Record not found!", "error");
location.reload(); location.reload();
@@ -460,17 +498,25 @@
} }
$('#back').on('click',function(){ $('#back').on('click',function(){
var id = $("#table_id").val() var id = $("#table_id").val();
var type = $("#type").val() var type = $("#type").val();
var sale_id = $("#sale_id").val() var sale_id = $("#sale_id").val();
if (cashier_type == "quick_service") { if (cashier_type == "quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/'; window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{ }else{
if (type=="Table") { if(page == "pending"){
window.location.href = '/origami/table/'+id window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/pending/';
}else{
window.location.href = '/origami/room/'+id
} }
else if(page == "payment"){
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if (type=="Table") {
window.location.href = '/origami/table/'+id;
}else{
window.location.href = '/origami/room/'+id;
}
}
} }
}) })

View File

@@ -50,11 +50,11 @@
<% end %> <% end %>
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(table.id) %> <% if @order_items_count.key?(table.id) %>
(Orders : <%= @order_items_count[table.id] %>) (Orders : <%= @order_items_count[table.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span> <span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
<div style="font-size:12px;"></div> <div style="font-size:12px;"></div>
</div> </div>
@@ -67,11 +67,11 @@
<% end %> <% end %>
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(table.id) %> <% if @order_items_count.key?(table.id) %>
(Orders : <%= @order_items_count[table.id] %>) (Orders : <%= @order_items_count[table.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="float-right font-12 new_text_<%= table.id %>"> new</span> <span class="float-right font-12 new_text_<%= table.id %>"> new</span>
</div> </div>
</div> </div>
@@ -97,11 +97,11 @@
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>"> <div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(room.id) %> <% if @order_items_count.key?(room.id) %>
(Orders : <%= @order_items_count[room.id] %>) (Orders : <%= @order_items_count[room.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="float-right font-12 new_text_<%= room.id %>"> billed</span> <span class="float-right font-12 new_text_<%= room.id %>"> billed</span>
</div> </div>
</div> </div>
@@ -109,11 +109,11 @@
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>"> <div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(room.id) %> <% if @order_items_count.key?(room.id) %>
(Orders : <%= @order_items_count[room.id] %>) (Orders : <%= @order_items_count[room.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="float-right font-12 new_text_<%= room.id %>"> new</span> <span class="float-right font-12 new_text_<%= room.id %>"> new</span>
</div> </div>
</div> </div>
@@ -196,7 +196,7 @@
<div class="card-title"> <div class="card-title">
<div class="row p-l-5 p-r-5"> <div class="row p-l-5 p-r-5">
<% if (!@sale_array.empty?) && (!@date.nil?) %> <% if (!@sale_array.empty?) && (!@date.nil?) %>
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-8 col-md-8 col-sm-8">
&nbsp; Receipt No: <span id="receipt_no"> &nbsp; Receipt No: <span id="receipt_no">
<% if @status_sale == 'sale' %> <% if @status_sale == 'sale' %>
<%= @sale_array[0].receipt_no rescue '' %> <%= @sale_array[0].receipt_no rescue '' %>
@@ -204,7 +204,7 @@
</span> </span>
<br> <br>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-4 col-md-4 col-sm-4 text-right">
Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span> Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span>
<br> <br>
</div> </div>
@@ -425,10 +425,7 @@
<%= t("views.btn.back") %> <%= t("views.btn.back") %>
</button> </button>
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button> <button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button> <button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<% if @dining.status != "available" %> <% if @dining.status != "available" %>
<% if @status_order == 'order' && @status_sale != 'sale' %> <% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button> <button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
@@ -455,10 +452,10 @@
<% if current_login_employee.role != "waiter" %> <% if current_login_employee.role != "waiter" %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button> <button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button> <button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button> <button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button> <button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<% end %>
<% if !@split_bill.nil? %> <% if !@split_bill.nil? %>
<% if @split_bill == '1' %> <% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button> <button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
@@ -515,7 +512,6 @@
</div> </div>
</div> </div>
</div> </div>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@@ -544,7 +540,7 @@
</div> </div>
</div> </div>
<script> <script>
cashier_type = "cashier" var cashier_type = "cashier";
$(document).ready(function () { $(document).ready(function () {
/* start check first bill or not*/ /* start check first bill or not*/
var receipt_no = ""; var receipt_no = "";
@@ -627,7 +623,7 @@
} }
var table_id = $('.tables').attr("data-id"); var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers" window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers/normal";
}); });

View File

@@ -199,6 +199,7 @@
$("#reference_no_Err").html(""); $("#reference_no_Err").html("");
if(reference_no.length > 0){ if(reference_no.length > 0){
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click"); $(this).off("click");
//start member discount 5% by pay card //start member discount 5% by pay card
// var sub_total = $('#sub-total').text(); // var sub_total = $('#sub-total').text();
@@ -215,8 +216,7 @@
// } // }
//end member discount //end member discount
if(bank_integration == '1'){ if(bank_integration == '1'){
$("#reference_no").val(""); pay_withBank("SALE", "master", amount, sale_id, receipt_no,cashier_type);
pay_withBank("SALE", "master", amount, sale_id, receipt_no);
}else{ }else{
$.ajax({type: "POST", $.ajax({type: "POST",
url: "<%= origami_payment_master_path %>", url: "<%= origami_payment_master_path %>",

View File

@@ -44,7 +44,11 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;" > <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;" >
<% @rooms.each do |room| %> <% @rooms.each do |room| %>
<% if room.status == 'occupied' %> <% if room.status == 'occupied' %>
<% if room.get_booking.nil? %>
<div class="card rooms red text-white" data-id="<%= room.id %>" data-name="<%= room.name %>"> <div class="card rooms red text-white" data-id="<%= room.id %>" data-name="<%= room.name %>">
<% else %>
<div class="card rooms blue text-white" data-id="<%= room.id %>" data-name="<%= room.name %>">
<% end %>
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
</div> </div>

View File

@@ -59,7 +59,11 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;" > <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;" >
<% @rooms.each do |room| %> <% @rooms.each do |room| %>
<% if room.status == 'occupied' %> <% if room.status == 'occupied' %>
<% if room.get_booking.nil? %>
<div class="card rooms red text-white" data-id="<%= room.id %>" data-name="<%= room.name %>"> <div class="card rooms red text-white" data-id="<%= room.id %>" data-name="<%= room.name %>">
<% else %>
<div class="card rooms blue text-white" data-id="<%= room.id %>" data-name="<%= room.name %>">
<% end %>
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
</div> </div>

View File

@@ -122,10 +122,11 @@
</div> </div>
</div> </div>
<script> <script>
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function() { $(document).ready(function() {
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>"; var bank_integration = "<%= @bank_integration %>";
var cashier_type = "<%= @cashier_type %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){} if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else { else {
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash"))); $('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
@@ -220,8 +221,7 @@
// } // }
//end member discount //end member discount
if(bank_integration == '1'){ if(bank_integration == '1'){
$("#reference_no").val(""); pay_withBank("SALE", "mpu", amount, sale_id, receipt_no,cashier_type);
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
}else{ }else{
$.ajax({type: "POST", $.ajax({type: "POST",
url: "<%= origami_payment_mpu_path %>", url: "<%= origami_payment_mpu_path %>",
@@ -242,6 +242,7 @@
} }
}); });
} }
}else{ }else{
if (amount>0) { if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" ); swal ( "Oops" , "Paid Amount is over!" , "error" );

View File

@@ -33,7 +33,7 @@
</div> </div>
<div class="row p-l-5 p-r-5"> <div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Customer :</strong> <%= @sale_data.customer.name%> <span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span> <div class="col-lg-6 col-md-6 col-sm-6"><strong>Customer :</strong> <span id="customer_name"> <%= @sale_data.customer.name%></span> <span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span></div> <span class="hidden" id="member_discount"><%= @member_discount%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %> <div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
<%end%></div> <%end%></div>
@@ -385,9 +385,89 @@
</div> </div>
</div> </div>
</div> </div>
<script>
<!-- pdf light box -->
<div class="modal fade" id="pdfModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="pdfModalLabel"></h4>
</div>
<div class="modal-body">
<input type="hidden" name="sale_receipt_no" id="sale_receipt_no">
<input type="hidden" name="filename" id="filename">
<input type="hidden" name="printer_name" id="printer_name">
<p id="changed_amount"></p>
<div class="text-center">
<iframe id="receipt_pdf" src="" style="width: 400px; height: 600px;"></iframe>
</div>
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<% if ENV["SERVER_MODE"] != 'cloud' %>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect print_receipt">Print</button>
</div>
<% end %>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect btn_pdf_close" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- customer light box -->
<div class="modal fade" id="is_memberModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="is_memberModalLabel">Are you Member?</h3>
</div>
<div class="modal-body">
<div class="row text-center">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-green waves-effect btn_customer_yes">Yes</button>
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect" data-dismiss="modal">No</button>
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_member">Member</button>
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_qr_code">QR</button>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>"; var cashier_type = "<%= @cashier_type %>";
var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>";
$(document).ready(function(){ $(document).ready(function(){
//start customer modal popup
if((customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
}
}
/* start check first bill or not*/ /* start check first bill or not*/
var member_id = $('#membership_id').text(); var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text(); var member_discount = $('#member_discount').text();
@@ -402,7 +482,6 @@ var cashier_type = "<%= @cashier_type %>";
console.log("ssssssssssss") console.log("ssssssssssss")
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment") payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if (member_id && member_discount) { if (member_id && member_discount) {
console.log("fffffffffffff")
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){ if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide(); $("#credit_payment").hide();
} else{ } else{
@@ -436,6 +515,188 @@ console.log("fffffffffffff")
$('#cash').text(localStorage.getItem("cash")); $('#cash').text(localStorage.getItem("cash"));
} }
update_balance(); update_balance();
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
$('#credit_payment').click(function() {
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/credit_payment"
return false;
});
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment"
return false;
});
$('#pay').click(function() {
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Oops","Please Pay with MPU Payment","warning");
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Visa Payment","warning");
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Credit Payment","warning");
}else{
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops", "Insufficient Amount!" , "error" );
$("#loading_wrapper").hide();
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
if (credit <= 0) {
calculate_member_discount(sale_id);
}
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$("#loading_wrapper" ).hide();
//PDF lightbox data
$("#sale_receipt_no").val(result.receipt_no);
$("#filename").val(result.filename);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", result.filename);
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Payment Successful!");
$("#changed_amount").text("");
if($('#balance').text() < 0){
<% if precision.to_i > 0 %>
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
<% else %>
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
<% end %>
}
//PDF lightbox data
// if($('#balance').text() < 0){
// swal({
// title: "Payment Successful!",
// text: 'Changed amount ' + $('#balance').text() * (-1),
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function () {
// if (cashier_type=="cashier") {
// window.location.href = '/origami';
// }else{
// window.location.href = '/origami/quick_service';
// }
// });
// }else{
// $('#pay').text("Pay");
// swal({
// title: "Payment Successful!",
// text: 'Thank You !',
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function () {
// if (cashier_type=="cashier") {
// window.location.href = '/origami';
// }else{
// window.location.href = '/origami/quick_service';
// }
// });
// }
}
});
}
}
});
// $('#void').on('click',function () {
// if ($(this).attr('active') === "true") {
// var sale_id = $('#sale_id').text();
// var remark = $("#remark").val();
// var ajax_url = "/origami/sale/" + sale_id + '/void';
// $.ajax({
// type: 'POST',
// url: ajax_url,
// data: "remark="+ remark + "&sale_id=" + sale_id,
// success: function () {
// window.location.href = '/origami/';
// }
// })
// }else{
// swal("Opps","You are not authorized for void","warning")
// }
// });
$('#void').on('click', function () {
if ($(this).attr('active')=== "true") {
swal({
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').text();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
})
}
});
}else{
swal("Oops","You are not authorized for void","warning")
}
});
}); });
// bind survey to order or sale // bind survey to order or sale
@@ -447,7 +708,7 @@ console.log("fffffffffffff")
var sale_id = $('#dining').text(); var sale_id = $('#dining').text();
} }
//var table_id = $('.tables').attr("data-id"); //var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id +"/"+ cashier_type + "/surveys" window.location.href = '/origami/' + sale_id +"/"+ cashier_type + "/surveys";
}); });
// bind customer to order or sale // bind customer to order or sale
@@ -459,7 +720,7 @@ console.log("fffffffffffff")
var sale_id = $('#save_order_id').attr('data-order'); var sale_id = $('#save_order_id').attr('data-order');
} }
var table_id = $('.tables').attr("data-id"); var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id + "/"+cashier_type+"/customers" window.location.href = '/origami/' + sale_id + "/"+cashier_type+"/customers/payment";
}); });
// Add Other Charges // Add Other Charges
@@ -529,6 +790,9 @@ console.log("fffffffffffff")
$('#cash').text(input_value); $('#cash').text(input_value);
update_balance(); update_balance();
}else{ }else{
if($('#cash').text() == '0'){
$('#cash').text("");
}
$('#cash').append(input_value); $('#cash').append(input_value);
update_balance(); update_balance();
} }
@@ -577,174 +841,6 @@ console.log("fffffffffffff")
} }
}); });
$( document ).ready(function() {
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
$('#credit_payment').click(function() {
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/credit_payment"
return false;
});
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment"
return false;
});
$('#pay').click(function() {
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Oops","Please Pay with MPU Payment","warning");
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Visa Payment","warning");
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Credit Payment","warning");
}else{
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops", "Insufficient Amount!" , "error" );
$("#loading_wrapper").hide();
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
if (credit <= 0) {
calculate_member_discount(sale_id);
}
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type,
async: false,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$( "#loading_wrapper" ).hide();
if($('#balance').text() < 0){
swal({
title: "Payment Successful!",
text: 'Changed amount ' + $('#balance').text() * (-1),
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
}else{
$('#pay').text("Pay");
swal({
title: "Payment Successful!",
text: 'Thank You !',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
}
}
});
}
}
});
// $('#void').on('click',function () {
// if ($(this).attr('active') === "true") {
// var sale_id = $('#sale_id').text();
// var remark = $("#remark").val();
// var ajax_url = "/origami/sale/" + sale_id + '/void';
// $.ajax({
// type: 'POST',
// url: ajax_url,
// data: "remark="+ remark + "&sale_id=" + sale_id,
// success: function () {
// window.location.href = '/origami/';
// }
// })
// }else{
// swal("Opps","You are not authorized for void","warning")
// }
// });
$('#void').on('click', function () {
if ($(this).attr('active')=== "true") {
swal({
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').text();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
})
}
});
}else{
swal("Oops","You are not authorized for void","warning")
}
});
});
function update_balance(){ function update_balance(){
var cash = $('#cash').text(); var cash = $('#cash').text();
var credit = $('#credit').text(); var credit = $('#credit').text();
@@ -832,5 +928,158 @@ console.log("fffffffffffff")
} }
}); });
} }
} }
//print pdf function
$(".print_receipt").on('click',function(){
var sale_id = $('#sale_id').text();
var filename = $("#filename").val();
var printer_name = $("#printer_name").val();
var receipt_no = $("#sale_receipt_no").val();
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
// swal({
// title: "Alert",
// text: "Are you sure want to print?",
// type: "warning",
// showCancelButton: true,
// confirmButtonColor: "#DD6B55",
// confirmButtonText: "Print",
// closeOnConfirm: false
// }, function (isConfirm) {
// if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params,
success:function(result){
console.log(result);
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
});
// }
// });
});
$(".btn_pdf_close").on('click',function(){
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
$(".btn_customer_yes").on('click',function(){
var sale_id = $('#sale_id').text();
window.location.href = "/origami/"+sale_id+"/"+cashier_type+"/customers/payment";
});
// Read Card Reader
$(".btn_member").on('click', function(){
var cardNo = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var customer_mamber_card_no = 0;
$("#is_memberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
}
});
}
},100);
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
}
}
// QR Code Reader
$(".btn_qr_code").on('click', function(e){
$("#is_memberModal").hide();
var code = "";
setTimeout(function(){
code=getQRCode();
$("#qr_code").val(code);
},100);
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {
var customer="";
if(customer_name != ""){
customer = '(' + customer_name + ')';
}
swal({
title: "Confirmation !",
text: 'Are You Sure to assign this customer' + customer + '!',
showCancelButton: true,
confirmButtonColor: "green",
confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger',
closeOnConfirm: false,
}, function () {
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
//change customer detail
$("#customer_name").html(customer_name);
$("#membership_id").html(membership_id);
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
swal("Alert!", "Record not found!", "error");
location.reload();
}
}
});
});
}
</script> </script>

View File

@@ -153,6 +153,14 @@
<% if current_user.role != "waiter" || @status != "sale"%> <% if current_user.role != "waiter" || @status != "sale"%>
<button type="button" id="addorder" class="btn bg-blue btn-block">Add Order</button> <button type="button" id="addorder" class="btn bg-blue btn-block">Add Order</button>
<%end%> <%end%>
<!-- <% if @status != "order"%>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<% end %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
<% if @status != "order"%>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<% end %> -->
<% if current_user.role != "waiter" && @status != "order"%> <% if current_user.role != "waiter" && @status != "order"%>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button> <button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<%end%> <%end%>
@@ -163,6 +171,7 @@
</div> </div>
</div> </div>
<script> <script>
var cashier_type = "quick_service";
$(document).ready(function(){ $(document).ready(function(){
$(".sales").on('click',function(){ $(".sales").on('click',function(){
var sale_id = $(this).attr("data-id"); var sale_id = $(this).attr("data-id");
@@ -203,5 +212,61 @@ $(document).ready(function(){
} }
}); });
}); });
// bind survey to order or sale
$("#survey").on('click', function () {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/' + sale_id +"/"+ cashier_type + "/surveys";
});
// bind customer to order or sale
$("#customer").on('click', function () {
var sale = $('#sale_id').val();
if (sale.includes("SAL")) {
var sale_id = sale;
} else {
var sale_id = $('#save_order_id').val();
}
window.location.href = '/origami/' + sale_id + "/"+cashier_type+"/customers/pending";
});
// Add Other Charges
$('#other-charges').click(function () {
var sale = $('#sale_id').val();
if (sale != "") {
var sale_id = sale
} else {
var sale_id = $('#save_order_id').val();
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id +"/"+cashier_type+ '/other_charges';
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
});
// Discount for Payment
$('#discount').click(function () {
if ($(this).attr('active')=== "true") {
var sale = $('#sale_id').val();
if (sale != "") {
var sale_id = sale
} else {
var sale_id = $('#save_order_id').val();
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + "/"+cashier_type+'/discount';
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
swal("Oops","You are not authorized for Discount","warning")
}
return false;
});
}); });
</script> </script>

View File

@@ -50,11 +50,11 @@
<% end %> <% end %>
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(table.id) %> <% if @order_items_count.key?(table.id) %>
(Orders : <%= @order_items_count[table.id] %>) (Orders : <%= @order_items_count[table.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="pull-right font-12 new_text_<%= table.id %>"> billed</span> <span class="pull-right font-12 new_text_<%= table.id %>"> billed</span>
</div> </div>
</div> </div>
@@ -66,11 +66,11 @@
<% end %> <% end %>
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(table.id) %> <% if @order_items_count.key?(table.id) %>
(Orders : <%= @order_items_count[table.id] %>) (Orders : <%= @order_items_count[table.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="pull-right font-12 new_text_<%= table.id %>"> new</span> <span class="pull-right font-12 new_text_<%= table.id %>"> new</span>
</div> </div>
</div> </div>
@@ -97,11 +97,11 @@
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>"> <div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(room.id) %> <% if @order_items_count.key?(room.id) %>
(Orders : <%= @order_items_count[room.id] %>) (Orders : <%= @order_items_count[room.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="pull-right font-12 new_text_<%= room.id %>"> billed</span> <span class="pull-right font-12 new_text_<%= room.id %>"> billed</span>
<div style="font-size:12px;"></div> <div style="font-size:12px;"></div>
</div> </div>
@@ -110,11 +110,11 @@
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>"> <div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if !@order_items_count.nil? %> <!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(room.id) %> <% if @order_items_count.key?(room.id) %>
(Orders : <%= @order_items_count[room.id] %>) (Orders : <%= @order_items_count[room.id] %>)
<% end %> <% end %>
<% end %> <% end %> -->
<span class="pull-right font-12 new_text_<%= room.id %>"> new</span> <span class="pull-right font-12 new_text_<%= room.id %>"> new</span>
</div> </div>
</div> </div>
@@ -193,12 +193,15 @@
<div class="card-title row p-l-5 p-r-5"> <div class="card-title row p-l-5 p-r-5">
<% if @status_sale == 'sale' %> <% if @status_sale == 'sale' %>
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-8 col-md-8 col-sm-8">
&nbsp; Receipt No: &nbsp; Receipt No:
<span id="receipt_no"> <span id="receipt_no">
<%= @obj_sale.receipt_no rescue '' %> <%= @obj_sale.receipt_no rescue '' %>
</span> </span>
</div> </div>
<div class="col-lg-4 col-md-4 col-sm-4 text-right">
Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span>
</div>
<% else %> <% else %>
<div class="col-lg-7 col-md-7 col-sm-7"> <div class="col-lg-7 col-md-7 col-sm-7">
&nbsp; Order No: &nbsp; Order No:
@@ -206,17 +209,10 @@
<%= @obj_order.order_id rescue '' %> <%= @obj_order.order_id rescue '' %>
</span> </span>
</div> </div>
<% end %>
<% if @status_sale == 'sale' %>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span>
</div>
<% else %>
<div class="col-lg-5 col-md-5 col-sm-5 text-right"> <div class="col-lg-5 col-md-5 col-sm-5 text-right">
Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-'%></span> Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-'%></span>
</div> </div>
<% end %> <% end %>
</div> </div>
<div class="card-title row customer_detail p-l-5 p-r-5" > <div class="card-title row customer_detail p-l-5 p-r-5" >
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
@@ -396,10 +392,7 @@
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i> Back</button> <button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i> Back</button>
<button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button> <button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button> <button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<% if @room.bookings.length >= 1 %> <% if @room.bookings.length >= 1 %>
<% if @status_order == 'order' && @status_sale != 'sale' %> <% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> --> <!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> -->
@@ -423,14 +416,14 @@
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> --> <!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button> <button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<% if current_login_employee.role != "waiter" %> <% if current_login_employee.role != "waiter" %>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button> <button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button> <button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button> <button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn bg-blue btn-block" >Charges</button> <button type="button" id="other-charges" class="btn bg-blue btn-block" >Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<% end %>
<% if !@split_bill.nil? %> <% if !@split_bill.nil? %>
<% if @split_bill == '1' %> <% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button> <button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
@@ -485,11 +478,11 @@
<% end %> <% end %>
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> --> <!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
<% end %> <% end %>
<% end %>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
var cashier_type = "cashier";
$(document).ready(function(){ $(document).ready(function(){
// $(".tables").on('click', function(){ // $(".tables").on('click', function(){
// var customer_id=$(".customer-id").text(); // var customer_id=$(".customer-id").text();
@@ -585,7 +578,7 @@ $(document).ready(function(){
var sale_id = "<%= @room.id %>"; var sale_id = "<%= @room.id %>";
} }
//var table_id = $('.tables').attr("data-id"); //var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id + "/surveys" window.location.href = '/origami/' + sale_id +"/"+cashier_type+ "/surveys"
}); });
// bind customer to order or sale // bind customer to order or sale
$("#customer").on('click', function(){ $("#customer").on('click', function(){
@@ -597,7 +590,7 @@ $(document).ready(function(){
} }
var table_id = $('.tables').attr("data-id"); var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/'+ sale_id + "/customers" window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers/normal";
}); });
@@ -620,7 +613,7 @@ $(document).ready(function(){
} }
if (sale_id != "") { if (sale_id != "") {
window.location.href = '/origami/' + sale_id + '/discount' window.location.href = '/origami/' + sale_id +"/"+cashier_type+ '/discount'
} }
else { else {
swal ( "Oops" , "Please select an table!" , "warning" ); swal ( "Oops" , "Please select an table!" , "warning" );
@@ -642,7 +635,7 @@ $(document).ready(function(){
} }
if(sale_id!=""){ if(sale_id!=""){
window.location.href = '/origami/' + sale_id + '/other_charges' window.location.href = '/origami/' + sale_id +"/"+cashier_type+ '/other_charges'
} }
else { else {
swal ( "Oops" , "Please select an table!" , "warning" ); swal ( "Oops" , "Please select an table!" , "warning" );

View File

@@ -200,6 +200,7 @@
var reference_no = $('#reference_no').val(); var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>"; var receipt_no = "<%= @receipt_no %>";
$("#reference_no_Err").html(""); $("#reference_no_Err").html("");
if(reference_no.length > 0){ if(reference_no.length > 0){
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
@@ -220,8 +221,7 @@
//end member discount //end member discount
var bank_integration = "<%= @bank_integration %>"; var bank_integration = "<%= @bank_integration %>";
if(bank_integration == '1'){ if(bank_integration == '1'){
$("#reference_no").val(""); pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no, cashier_type);
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no);
} }
else{ else{
$.ajax({type: "POST", $.ajax({type: "POST",

View File

@@ -220,8 +220,7 @@
//end member discount //end member discount
var bank_integration = "<%= @bank_integration %>"; var bank_integration = "<%= @bank_integration %>";
if(bank_integration == '1'){ if(bank_integration == '1'){
$("#reference_no").val(""); pay_withBank("SALE", "visa", amount, sale_id, receipt_no,cashier_type);
pay_withBank("SALE", "visa", amount, sale_id, receipt_no);
} }
else{ else{
$.ajax({type: "POST", $.ajax({type: "POST",
@@ -253,5 +252,5 @@
}else{ }else{
$("#reference_no_Err").html("can't be blank"); $("#reference_no_Err").html("can't be blank");
} }
}) });
</script> </script>

View File

@@ -165,6 +165,7 @@ scope "(:locale)", locale: /en|mm/ do
post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj', :as => "calculate_rouding_adjs" post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj', :as => "calculate_rouding_adjs"
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => {:format => 'json'} get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => {:format => 'json'}
get 'sale/:sale_id/:type/payment' => 'payments#show' get 'sale/:sale_id/:type/payment' => 'payments#show'
post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt
post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'} post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'}
post 'payment/cash' => 'payments#create' post 'payment/cash' => 'payments#create'
@@ -198,9 +199,9 @@ scope "(:locale)", locale: /en|mm/ do
#---------Add Customer --------------# #---------Add Customer --------------#
#resources :customers #resources :customers
get '/:sale_id/:type/customers', to: "customers#add_customer" get '/:sale_id/:type/customers/:page', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details" get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details"
post '/:sale_id/:type/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table post '/:sale_id/:type/customers/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table
post '/:sale_id/get_customer' => "customers#get_customer" post '/:sale_id/get_customer' => "customers#get_customer"

View File

@@ -3,6 +3,9 @@ class CreateShops < ActiveRecord::Migration[5.1]
create_table :shops do |t| create_table :shops do |t|
t.string :logo t.string :logo
t.string :name, :null => false t.string :name, :null => false
t.string :shop_code, :null => false
t.string :client_name, :null => false
t.string :client_code, :null => false
t.string :address, :null => false t.string :address, :null => false
t.string :township, :null => false t.string :township, :null => false
t.string :city, :null => false t.string :city, :null => false

View File

@@ -6,7 +6,9 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1]
t.string :template t.string :template
t.string :font, :default => "" t.string :font, :default => ""
t.string :printer_name, :null => false t.string :printer_name, :null => false
t.string :api_settings t.string :api_settings,
t.string :brand_name
t.string :type
t.decimal :page_width, :null => false, :default => 210 t.decimal :page_width, :null => false, :default => 210
t.decimal :page_height, :null => false, :default => 1450 t.decimal :page_height, :null => false, :default => 1450
t.integer :print_copies, :null => false, :default => 1 t.integer :print_copies, :null => false, :default => 1

View File

@@ -0,0 +1,42 @@
class CreateReceipts < ActiveRecord::Migration[5.1]
def change
create_table :receipts do |t|
t.string :client_code, :limit => 16, :null => false
t.string :client_name, :null => false
t.string :shop_code, :limit => 16, :null => false
t.string :shop_name, :null => false
t.integer :receipt_no, :limit => 8, :null => false
t.datetime :transaction_time, :null => false
t.datetime :receipt_open_time, :null => false
t.datetime :receipt_close_time, :null => false
t.decimal :gross_sales, :null => false, :default => 0
t.decimal :discount_amount, :null => false, :default => 0
t.decimal :sales, :null => false, :default => 0
t.decimal :tax_amount, :null => false, :default => 0
t.decimal :service_charges, :null => false, :default => 0
t.decimal :net_sales, :null => false, :default => 0
t.decimal :credit_card_sales, :null => false, :default => 0
t.decimal :voucher_sales, :null => false, :default => 0
t.decimal :foc_amount, :null => false, :default => 0
t.decimal :staff_meal_amount, :null => false, :default => 0
t.decimal :rounding_amount, :null => false, :default => 0
t.decimal :raw_wastage_amount, :null => false, :default => 0
t.decimal :semi_wastage_amount, :null => false, :default => 0
t.decimal :wastage_amount, :null => false, :default => 0
t.decimal :spoilage_amount, :null => false, :default => 0
t.decimal :sampling_amount, :null => false, :default => 0
t.integer :qty, :null => false, :default => 0
t.integer :no_of_pax, :null => false, :default => 0
t.integer :no_of_adult, :null => false, :default => 0
t.integer :no_of_child, :null => false, :default => 0
t.string :terminal_id, :null => false
t.string :employee_code, :limit => 4, :null => false
t.string :employee_name, :null => false
t.boolean :is_valid, :null => false, :default => false
t.boolean :overing, :null => false, :default => false
t.boolean :cancle, :null => false, :default => false
t.text :remarks
t.timestamps
end
end
end

View File

@@ -0,0 +1,43 @@
class CreateReceiptDetails < ActiveRecord::Migration[5.1]
def change
create_table :receipt_details do |t|
t.string :client_code, :null => false
t.string :client_name, :null => false
t.string :shop_code, :null => false
t.string :shop_name, :null => false
t.string :receipt_no, :null => false
t.datetime :receipt_date, :null => false
t.datetime :transaction_date, :null => false
t.integer :item_sequence, :null => false
t.string :category_code, :null => false
t.string :category_name, :null => false
t.string :sub_category_code, :null => false
t.string :sub_category_name, :null => false
t.string :report_group_code, :null => false
t.string :report_group_name, :null => false
t.string :item_code, :null => false
t.string :item_name, :null => false
t.integer :qty, :null => false, :default => 0
t.string :transaction_type, :null => false
t.decimal :gross_sales, :null => false, :default => 0
t.string :discount_code, :null => false
t.decimal :discount_amount, :null => false, :default => 0
t.decimal :sales, :null => false, :default => 0
t.decimal :tax_amount, :null => false, :default => 0
t.decimal :service_charges, :null => false, :default => 0
t.decimal :net_sales, :null => false, :default => 0
t.boolean :is_foc, :null => false, :default => false
t.boolean :is_set_item, :null => false, :default => false
t.boolean :is_staff_meal, :null => false, :default => false
t.boolean :is_raw_wastage, :null => false, :default => false
t.boolean :is_semi_wastage, :null => false, :default => false
t.boolean :is_wastage, :null => false, :default => false
t.boolean :is_spoilage, :null => false, :default => false
t.boolean :is_sampling, :null => false, :default => false
t.boolean :tax_able, :null => false, :default => false
t.boolean :is_void, :null => false, :default => false
t.text :remarks
t.timestamps
end
end
end

View File

@@ -89,6 +89,10 @@ delete from sym_node;
# Create Trigger for Setting Channel # Create Trigger for Setting Channel
insert into sym_trigger
(trigger_id,source_table_name,channel_id,last_update_time,create_time)
values('seed_generators','seed_generators','setting',current_timestamp,current_timestamp);
insert into sym_trigger insert into sym_trigger
(trigger_id,source_table_name,channel_id,last_update_time,create_time) (trigger_id,source_table_name,channel_id,last_update_time,create_time)
values('lookups','lookups','setting',current_timestamp,current_timestamp); values('lookups','lookups','setting',current_timestamp,current_timestamp);
@@ -119,11 +123,11 @@ delete from sym_node;
insert into sym_trigger insert into sym_trigger
(trigger_id,source_table_name,channel_id,last_update_time,create_time) (trigger_id,source_table_name,channel_id,last_update_time,create_time)
values('tax_profiles','customers','setting',current_timestamp,current_timestamp); values('tax_profiles','tax_profiles','setting',current_timestamp,current_timestamp);
insert into sym_trigger insert into sym_trigger
(trigger_id,source_table_name,channel_id,last_update_time,create_time) (trigger_id,source_table_name,channel_id,last_update_time,create_time)
values('display_images','customers','setting',current_timestamp,current_timestamp); values('display_images','display_images','setting',current_timestamp,current_timestamp);
# Create Trigger for Dining Channel # Create Trigger for Dining Channel
@@ -339,6 +343,11 @@ delete from sym_node;
# Add triggers for tables with router # Add triggers for tables with router
# Setting Channel # From cloud to Master # Setting Channel # From cloud to Master
insert into sym_trigger_router
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('seed_generators','cloud_2_sx', 100, current_timestamp, current_timestamp);
insert into sym_trigger_router insert into sym_trigger_router
(trigger_id,router_id,initial_load_order,last_update_time,create_time) (trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('lookups','cloud_2_sx', 100, current_timestamp, current_timestamp); values('lookups','cloud_2_sx', 100, current_timestamp, current_timestamp);
@@ -376,6 +385,11 @@ delete from sym_node;
values('display_images','cloud_2_sx', 100, current_timestamp, current_timestamp); values('display_images','cloud_2_sx', 100, current_timestamp, current_timestamp);
# Setting Channel # From Master to cloud # Setting Channel # From Master to cloud
insert into sym_trigger_router
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('seed_generators','sx_2_cloud', 100, current_timestamp, current_timestamp);
insert into sym_trigger_router insert into sym_trigger_router
(trigger_id,router_id,initial_load_order,last_update_time,create_time) (trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('lookups','sx_2_cloud', 100, current_timestamp, current_timestamp); values('lookups','sx_2_cloud', 100, current_timestamp, current_timestamp);

View File

@@ -17,6 +17,7 @@ namespace :clear do
Survey.delete_all Survey.delete_all
DiningFacility.update_all(status:'available') DiningFacility.update_all(status:'available')
CashierTerminal.update_all(is_currently_login: 0) CashierTerminal.update_all(is_currently_login: 0)
SeedGenerator.where("id > 1").update(:current => 0, :next => 1)
puts "Clear Data Done." puts "Clear Data Done."
end end
end end

238
lib/tasks/receipt.rake Normal file
View File

@@ -0,0 +1,238 @@
namespace :consolidate do
desc "Receipt"
task :receipt => :environment do
Receipt.delete_all
sales = Sale.all_receipts
shop = Shop.find(1)
sales.each do |sale|
receipt = Receipt.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.receipt_no = sale.receipt_no
receipt.transaction_time = sale.requested_at #requet-at
receipt.receipt_open_time = sale.requested_at #before disco/after tax /after/ser_char
receipt.receipt_close_time = sale.receipt_close_time
receipt.gross_sales = sale.total_amount + sale.total_tax #before disco/after tax /after/ser_char
receipt.discount_amount = sale.total_discount + sale.item_discount
receipt.sales = sale.grand_total #after disco/after tax /after/ser_char /no roundingadn
receipt.tax_amount = sale.total_tax
receipt.service_charges = sale.service_charges
receipt.net_sales = sale.total_amount + sale.total_discount #after disco/before tax / no rounding
receipt.credit_card_sales = sale.mpu_amount + sale.master_amount + sale.visa_amount + sale.jcb_amount + sale.unionpay_amount + sale.credit_amount #
receipt.voucher_sales = 0
receipt.foc_amount = sale.foc_amount + sale.item_foc
receipt.staff_meal_amount = 0
receipt.rounding_amount = sale.rounding_adjustment
receipt.raw_wastage_amount = 0
receipt.semi_wastage_amount = 0
receipt.wastage_amount = 0
receipt.spoilage_amount = 0
receipt.sampling_amount = 0
receipt.qty = sale.qty
receipt.no_of_pax = 0
receipt.no_of_adult = (sale.adult) ? sale.adult : 0
receipt.no_of_child = (sale.child) ? sale.child : 0
receipt.terminal_id = ShiftSale.find(sale.shift_sale_id).cashier_terminal_id
receipt.employee_code = Employee.find(sale.cashier_id).emp_id
receipt.employee_name = sale.cashier_name
receipt.is_valid = (sale.payment_status=="void") ? false : true #void is false
receipt.overing =false
receipt.cancle = (sale.payment_status=="void") ? false : true # void is cancel
receipt.remarks = sale.remark
receipt.save
end
end
desc "Receipt Detail"
task :receipt_detail => :environment do
ReceiptDetail.delete_all
sales = Sale.all_receipt_details
shop = Shop.find(1)
sale_id = ''
count = 0
@total_qty = 0
@total_gross_sales = 0
@total_sales = 0
@total_net_sales = 0
@z =1
@item_sequence = 1
sale_count = sales.to_a.count
sales.each do |sale|
if sale.qty > 0
if sale.item_instance_code !=nil
menu_category = MenuCategory.find(MenuItem.find_by_item_code(sale.product_code).menu_category_id)
name = menu_category.name
code = menu_category.code
menu_item = MenuItem.find_by_item_code(sale.product_code)
menu_name = menu_item.name
menu_code = menu_item.item_code
menu_type = menu_item.type
end
if sale.product_code == "Other Charges" && sale.status == "Other Charges"
code = sale.product_code
name = sale.product_code
menu_name = sale.product_code
menu_code = sale.product_code
menu_type = sale.product_code
end
@receipt_no = sale.receipt_no
@requested_at = sale.requested_at
if sale_id == sale.sale_id || count == 0 || @z ==0
@total_qty += sale.qty
@total_gross_sales += sale.price
@total_sales += sale.price
@total_net_sales += sale.taxable_price
end
if sale_id != sale.sale_id && count !=0
receipt = ReceiptDetail.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.receipt_no = @receipt_no
receipt.receipt_date = @requested_at #requet-at
receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char
receipt.item_sequence = @item_sequence
receipt.category_code = ''
receipt.category_name = ''
receipt.sub_category_code = 0
receipt.sub_category_name = 0
receipt.report_group_code = 0
receipt.report_group_name = 0
receipt.item_code = ''
receipt.item_name = ''
receipt.qty = @total_qty
receipt.transaction_type = "Tender"
receipt.gross_sales = @total_gross_sales
receipt.discount_code = ''
receipt.discount_amount = 0
receipt.sales = @total_sales
receipt.tax_amount = 0
receipt.service_charges = 0
receipt.net_sales = @total_net_sales
receipt.is_set_item = false
receipt.is_foc = false
receipt.is_staff_meal = false
receipt.is_raw_wastage = false
receipt.is_semi_wastage = false
receipt.is_wastage = false
receipt.is_spoilage = false
receipt.is_sampling = false
receipt.tax_able = false
receipt.is_void = false
receipt.remarks = ""
receipt.save
@type = "Tender"
@item_sequence = 1
@total_qty = 0
@total_gross_sales = 0
@total_sales = 0
@total_net_sales = 0
@z = 0
end
discount_amount = (sale.status=="Discount") ? sale.price : 0
receipt = ReceiptDetail.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.receipt_no = sale.receipt_no
receipt.receipt_date = sale.requested_at #requet-at
receipt.transaction_date = sale.requested_at #before disco/after tax /after/ser_char
receipt.item_sequence = @item_sequence
receipt.category_code = name
receipt.category_name = code
receipt.sub_category_code = 0
receipt.sub_category_name = 0
receipt.report_group_code = 0
receipt.report_group_name = 0
receipt.item_code = menu_name
receipt.item_name = menu_code
receipt.qty = sale.qty
receipt.transaction_type = (sale.status==nil) ? "Sales" : sale.status
receipt.gross_sales = sale.price
receipt.discount_code = sale.sale_item_id
receipt.discount_amount = discount_amount
receipt.sales = sale.price
receipt.tax_amount = 0
receipt.service_charges = 0
receipt.net_sales = sale.taxable_price
receipt.is_set_item = (menu_type=="SetMenuItem")? true : false
receipt.is_foc = (sale.status=="foc") ? true : false
receipt.is_staff_meal = false
receipt.is_raw_wastage = false
receipt.is_semi_wastage = false
receipt.is_wastage = false
receipt.is_spoilage = false
receipt.is_sampling = false
receipt.tax_able = sale.is_taxable
receipt.is_void = (sale.status=="void")? true : false
receipt.remarks = sale.remark
receipt.save
end
@z += 1
count += 1
@item_sequence += 1
sale_id = sale.sale_id
end
if count == sale_count
receipt = ReceiptDetail.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.receipt_no = @receipt_no
receipt.receipt_date = @requested_at #requet-at
receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char
receipt.item_sequence = @item_sequence
receipt.category_code = ''
receipt.category_name = ''
receipt.sub_category_code = 0
receipt.sub_category_name = 0
receipt.report_group_code = 0
receipt.report_group_name = 0
receipt.item_code = ''
receipt.item_name = ''
receipt.qty = @total_qty
receipt.transaction_type = "Tender"
receipt.gross_sales = @total_gross_sales
receipt.discount_code = ''
receipt.discount_amount = 0
receipt.sales = @total_sales
receipt.tax_amount = 0
receipt.service_charges = 0
receipt.net_sales = @total_net_sales
receipt.is_set_item = false
receipt.is_foc = false
receipt.is_staff_meal = false
receipt.is_raw_wastage = false
receipt.is_semi_wastage = false
receipt.is_wastage = false
receipt.is_spoilage = false
receipt.is_sampling = false
receipt.tax_able = false
receipt.is_void = false
receipt.remarks = ""
receipt.save
end
end
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ReceiptDetail, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Receipt, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end