fix
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -1,7 +1,6 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
|
||||
#ruby '2.5.0'
|
||||
ruby '2.4.1'
|
||||
#ruby '2.5.7'
|
||||
|
||||
|
||||
|
||||
@@ -380,5 +380,8 @@ DEPENDENCIES
|
||||
web-console (>= 3.3.0)
|
||||
whenever
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
|
||||
@@ -288,6 +288,10 @@ For Number Formats
|
||||
=> settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros,
|
||||
value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] }
|
||||
|
||||
For Booking checkin time limit
|
||||
settings/lookups =>
|
||||
{ lookup_type: checkin_time_limit, name: CheckinTimeLimit, value: total hours before checkout (e.g., '48')) }
|
||||
|
||||
/* Customer Types in lookups */
|
||||
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
|
||||
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }
|
||||
|
||||
@@ -629,7 +629,7 @@ $(function() {
|
||||
status = "selected-attribute";
|
||||
}
|
||||
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
||||
disabled = "disabled";
|
||||
// disabled = "disabled";
|
||||
}
|
||||
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||
@@ -1102,16 +1102,30 @@ $(function() {
|
||||
var total_price = 0;
|
||||
var total_qty = 0;
|
||||
var taxable_amount = 0;
|
||||
var exclusive_total =0;
|
||||
var inclusive_total =0;
|
||||
var inclusive_tax =$('#inclusive_tax').val();
|
||||
var exclusive_tax =$('#exclusive_tax').val();
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
$(item_row).each(function(i){
|
||||
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
|
||||
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
|
||||
total_qty += qty;
|
||||
total_price += qty*unit_price;
|
||||
});
|
||||
if (inclusive_tax >0){
|
||||
inclusive_total = total_price / inclusive_tax;
|
||||
total_price = total_price;
|
||||
}
|
||||
if (exclusive_tax >0){
|
||||
exclusive_total = total_price * exclusive_tax;
|
||||
total_price = total_price + exclusive_total;
|
||||
}
|
||||
|
||||
var fixed_total_price = parseFloat(total_price).toFixed(2);
|
||||
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
|
||||
$('#total_tax').empty();
|
||||
$('#total_tax').append(parseInt(exclusive_total) + parseInt(inclusive_total));
|
||||
|
||||
$('#sub_total').empty();
|
||||
$('#sub_total').append(fixed_total_price);
|
||||
@@ -1529,11 +1543,11 @@ $(function() {
|
||||
image_path = menu_items[field].image;
|
||||
}
|
||||
if (out_of_stock === true) {
|
||||
// oos_item = out_of_stock_item
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;pointer-events: none;opacity: 0.4;">'
|
||||
oos_header = '<div style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>'
|
||||
oos_item = out_of_stock_item
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;pointer-events: none;opacity: 0.4;">'
|
||||
oos_header = '<div class="head'+code+'" style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>'
|
||||
}else{
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
oos_header = ''
|
||||
}
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3">'
|
||||
@@ -1582,15 +1596,15 @@ $(function() {
|
||||
}else{
|
||||
if (out_of_stock === true) {
|
||||
// oos_item = out_of_stock_item
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%; pointer-events: none;opacity: 0.4;">'
|
||||
oos_header = '<div style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>'
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%; pointer-events: none;opacity: 0.4;">'
|
||||
oos_header = '<div class="head'+code+'" style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>'
|
||||
}else{
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%;">'
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%;">'
|
||||
oos_header = ''
|
||||
}
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 mt-1">'
|
||||
+ oos_item + oos_header
|
||||
+'<div class="custom-card-no-img-head card-head '+add_icon+' " style="margin:0px;display:flex;!important "'
|
||||
+'<div class="custom-card-no-img-head card-head '+add_icon+' " id="oos'+ code +'" style="margin:0px;display:flex;!important "'
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
|
||||
43
app/assets/javascripts/channels/out_of_stock.js
Normal file
43
app/assets/javascripts/channels/out_of_stock.js
Normal file
@@ -0,0 +1,43 @@
|
||||
App.checkin = App.cable.subscriptions.create('OutOfStockChannel', {
|
||||
|
||||
connected: function() {},
|
||||
|
||||
disconnected: function() {},
|
||||
|
||||
received: function(data) {
|
||||
if (data && data.item_instance_code) {
|
||||
console.log("out of stock channel!!!!");
|
||||
item_code = data.item_instance_code;
|
||||
item_code_id = '#' + data.item_instance_code;
|
||||
oos_id = '#oos' + data.item_instance_code;
|
||||
head_oos = 'head' + data.item_instance_code;
|
||||
rm_oos = '.' + head_oos;
|
||||
menus = localStorage.getItem('menus');
|
||||
|
||||
if (menus) {
|
||||
menus = jQuery.parseJSON(menus);
|
||||
menus.forEach(m =>
|
||||
m.categories.forEach(c =>
|
||||
c.items.forEach(i =>
|
||||
i.instances.forEach(instance => {
|
||||
if (instance.code == item_code) {
|
||||
if (data.status == true) {
|
||||
instance.out_of_stock = true;
|
||||
oos_header = '<div class="'+head_oos+'" style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>';
|
||||
$(item_code_id).css({"height": "100%", "pointer-events": "none", "opacity": "0.4"});
|
||||
$(oos_header).insertBefore($(oos_id));
|
||||
} else {
|
||||
instance.out_of_stock = false;
|
||||
$(item_code_id).css({"height": "", "pointer-events": "", "opacity": ""});
|
||||
$(rm_oos).remove();
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
localStorage.setItem('menus', JSON.stringify(menus));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,16 +1,16 @@
|
||||
App.checkin = App.cable.subscriptions.create('SecondDisplayChannel', {
|
||||
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||
|
||||
connected: function() {},
|
||||
|
||||
disconnected: function() {},
|
||||
|
||||
received: function(data) {
|
||||
received: function(data) {
|
||||
var hostname = location.hostname.trim();
|
||||
if(data.from == "" || hostname == data.from){
|
||||
if(data.from == "" || hostname == data.from){
|
||||
var data_obj = data.data;
|
||||
var status = data.status;
|
||||
var count = 0
|
||||
var count = 0
|
||||
var sub_total = 0
|
||||
if (data.status == "order") {
|
||||
for(var i in data_obj) {
|
||||
@@ -26,16 +26,15 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayChannel', {
|
||||
$(".second_display_items").append(row);
|
||||
}//end looping
|
||||
}else{
|
||||
$('#s_sub_total').empty();
|
||||
$('#s_sub_total').empty();
|
||||
$('#s_sub_total').append(data_obj.total_amount);
|
||||
$('#s_total_discount').empty();
|
||||
$('#s_total_discount').empty();
|
||||
$('#s_total_discount').append(data_obj.total_discount);
|
||||
$('#s_tatal_tax').empty();
|
||||
$('#s_tatal_tax').empty();
|
||||
$('#s_tatal_tax').append(data_obj.total_tax);
|
||||
$('#s_grand_total').empty();
|
||||
$('#s_grand_total').empty();
|
||||
$('#s_grand_total').append(data_obj.grand_total);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -261,9 +261,9 @@ function checkReceiptNoInFirstBillData(receipt_no,payment) {
|
||||
if (payment) {
|
||||
if (json_data.length>0) {
|
||||
return json_data[0]["payment"];
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ $(document).ready(function(){
|
||||
type: "POST",
|
||||
url: "/origami/" + unique_id,
|
||||
data: { 'booking_id' : unique_id },
|
||||
success:function(result){
|
||||
success:function(result){
|
||||
for (i = 0; i < result.length; i++) {
|
||||
var data = JSON.stringify(result[i]);
|
||||
var parse_data = JSON.parse(data);
|
||||
var show_date = "";
|
||||
var show_date = "";
|
||||
|
||||
// Receipt Header
|
||||
receipt_no = result[i].receipt_no;
|
||||
@@ -81,14 +81,14 @@ $(document).ready(function(){
|
||||
if(result[i].receipt_date != null){
|
||||
receipt_date = new Date(result[i].receipt_date);
|
||||
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
||||
}
|
||||
}
|
||||
|
||||
//Receipt Charges
|
||||
sub_total += parseFloat(parse_data.price);
|
||||
|
||||
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
||||
tax_amount = parse_data.tax_amount;
|
||||
grand_total_amount = parse_data.grand_total_amount;
|
||||
grand_total_amount = parse_data.grand_total_amount;
|
||||
|
||||
// Ordered Items
|
||||
var order_items_rows = "<tr>" +
|
||||
@@ -135,7 +135,7 @@ $(document).ready(function(){
|
||||
// Discount for Payment
|
||||
$('#discount').click(function() {
|
||||
var order_id=$(".selected-item").find(".orders-id").text().substr(0,16);
|
||||
|
||||
|
||||
if(order_id!=""){
|
||||
window.location.href = '/origami/' + order_id + '/discount'
|
||||
}
|
||||
@@ -164,7 +164,7 @@ $(document).ready(function(){
|
||||
}
|
||||
|
||||
// For Percentage Discount
|
||||
if(discount_type == 1){
|
||||
if(discount_type == 1){
|
||||
discount_amount=(sub_total*discount_value)/100;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ $(document).ready(function(){
|
||||
|
||||
$('#customer').click(function() {
|
||||
var sale = $(".selected-item").find(".orders-id").text().substr(0,16);
|
||||
if (sale.substring(0, 3)=="SAL") {
|
||||
if (sale.includes("SAL")) {
|
||||
var sale_id = sale
|
||||
}else{
|
||||
var sale_id = $(".selected-item").find(".order-cid").text();
|
||||
@@ -205,7 +205,7 @@ $(document).ready(function(){
|
||||
|
||||
$('#re-print').click(function() {
|
||||
var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16);
|
||||
|
||||
|
||||
window.location.href = '/origami/'+ sale_id + "/reprint"
|
||||
|
||||
return false;
|
||||
|
||||
@@ -225,3 +225,14 @@ i.logout_icon{
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.report-table-header {
|
||||
font-size: .95rem;
|
||||
font-weight: 500;
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.input-group-addon {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
}
|
||||
.bmd-form-group {
|
||||
position: relative;
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
.btn_create_induty{
|
||||
display: inline;
|
||||
@@ -93,4 +92,4 @@
|
||||
.add_to_charges{
|
||||
width:100%;
|
||||
padding:1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ module ApplicationCable
|
||||
|
||||
# Order Queue Station Channel
|
||||
class OrderQueueStationChannel < ActionCable::Channel::Base
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Order Queue Station Channel
|
||||
class BillChannel < ActionCable::Channel::Base
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Call Waiter Channel
|
||||
class CallWaiterChannel < ActionCable::Channel::Base
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
10
app/channels/out_of_stock_channel.rb
Normal file
10
app/channels/out_of_stock_channel.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class OutOfStockChannel < ApplicationCable::Channel
|
||||
def subscribed
|
||||
stream_from "out_of_stock_channel"
|
||||
end
|
||||
|
||||
def unsubscribed
|
||||
stop_all_streams
|
||||
# Any cleanup needed when channel is unsubscribed
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1,9 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
|
||||
|
||||
include MultiTenancy
|
||||
include TokenVerification
|
||||
include ActionController::MimeResponds
|
||||
include ActionView::Rendering
|
||||
include Customers
|
||||
|
||||
before_action :core_allow
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class Api::AuthenticateController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
# before_action :find_shop
|
||||
|
||||
def create
|
||||
emp_id = params[:emp_id]
|
||||
@@ -67,8 +66,5 @@ class Api::AuthenticateController < Api::ApiController
|
||||
params.permit(:emp_id, :password, :session_token)
|
||||
end
|
||||
|
||||
private
|
||||
def find_shop
|
||||
@shop = Shop.find_by_shop_code(params[:shop_code])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Api::BillController < Api::ApiController
|
||||
if !ShiftSale.current_shift.nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if (params[:booking_id])
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking.booking_orders.count > 0
|
||||
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
||||
@@ -52,13 +52,6 @@ class Api::BillController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "There is no order for '#{params[:booking_id]}'"
|
||||
end
|
||||
# elsif (params[:order_id])
|
||||
# order = Order.find(params[:order_id])
|
||||
# @status, @sale_id = Sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
||||
#
|
||||
# # for Job
|
||||
# booking = Booking.find_by_sale_id(@sale_id)
|
||||
# table = DiningFacility.find(booking.dining_facility_id)
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
@@ -148,7 +141,7 @@ class Api::BillController < Api::ApiController
|
||||
@order = Order.new
|
||||
@order.source = "cashier"
|
||||
@order.order_type = "Takeaway"
|
||||
@order.customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
@order.customer_id = takeaway.customer_id # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
|
||||
@@ -26,7 +26,7 @@ class Api::CallWaitersController < ActionController::API
|
||||
unique_code = "CallWaiterPdf"
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||
printer.print_call_waiter(print_settings,@table,@time,current_shop)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Api::CheckInProcessController < Api::ApiController
|
||||
# before_action :authenticate
|
||||
def check_in_time
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if params[:booking_id]
|
||||
data = Booking.where("dining_facility_id = #{params[:dining_id]} AND booking_id = '#{params[:booking_id]}'")
|
||||
if data.count > 0
|
||||
@@ -10,7 +10,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
else
|
||||
booking = nil
|
||||
end
|
||||
else
|
||||
else
|
||||
booking = dining_facility.get_current_booking
|
||||
end
|
||||
if !booking.nil?
|
||||
@@ -21,7 +21,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
#Send to background job for processing
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
||||
@@ -37,7 +37,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
end
|
||||
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
|
||||
|
||||
if !lookup_checkout_time.empty?
|
||||
now = Time.now.utc
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
@@ -52,16 +52,18 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
else
|
||||
render :json => { :status => false, :error_message => "No current booking!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false }
|
||||
end
|
||||
end
|
||||
|
||||
def check_in_process
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if dining_facility.is_active && dining_facility.status == "available"
|
||||
if params[:checkin_time]
|
||||
checkin_at = nil
|
||||
@@ -75,7 +77,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
if dining_facility.check_time(checkin_at, "checkin")
|
||||
booking = dining_facility.get_current_booking
|
||||
if booking.nil?
|
||||
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => checkin_at,:checkout_at =>nil, :booking_status => "assign", :reserved_at => nil, :reserved_by => nil })
|
||||
if booking.save!
|
||||
@@ -95,10 +97,10 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
render :json => { :status => false, :error_message => "Operation failed!" }
|
||||
end
|
||||
else
|
||||
booking = dining_facility.get_current_checkout_booking
|
||||
booking = dining_facility.current_checkout_booking
|
||||
if booking.nil?
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||
|
||||
|
||||
if !lookup_checkout_time.empty?
|
||||
today = Time.now.utc.getlocal
|
||||
checkout_at = Time.now.utc.getlocal
|
||||
@@ -118,7 +120,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
# else
|
||||
# type = "RoomBooking"
|
||||
# end
|
||||
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
if booking.save!
|
||||
@@ -133,13 +135,13 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# print when complete click
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility)
|
||||
end
|
||||
end
|
||||
end
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
render :json => { :status => true }
|
||||
@@ -176,7 +178,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||
error_message = "time is required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
elsif params[:booking_id].nil? && !params[:time].nil?
|
||||
|
||||
@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
|
||||
|
||||
if !order_reservation_id.nil? && flag
|
||||
shop = @shop
|
||||
shop = current_shop
|
||||
if !shop.nil?
|
||||
shop_code = shop.shop_code
|
||||
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||
|
||||
@@ -51,7 +51,7 @@ class Api::OrdersController < Api::ApiController
|
||||
# end
|
||||
|
||||
#
|
||||
return @shop.to_json
|
||||
return current_shop.to_json
|
||||
end
|
||||
|
||||
|
||||
@@ -66,24 +66,19 @@ class Api::OrdersController < Api::ApiController
|
||||
def create
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
@shop = Shop.find_by_shop_code(params[:shop_code])
|
||||
|
||||
current_shift = ShiftSale.current_shift
|
||||
if current_shift.nil?
|
||||
@status = false
|
||||
@message = "No Current Open Shift for This Employee"
|
||||
else
|
||||
current_user =Employee.find(current_shift.employee_id)
|
||||
current_user = Employee.find(current_shift.employee_id)
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
end
|
||||
if params[:table_id].present?
|
||||
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
booking = table.get_current_booking
|
||||
end
|
||||
end
|
||||
table = DiningFacility.find(params[:table_id]) if params[:table_id].present?
|
||||
|
||||
booking = table.current_checkin_booking if table
|
||||
booking ||= Booking.find(params[:booking_id]) if params[:booking_id].present?
|
||||
|
||||
#for extratime
|
||||
is_extra_time = false
|
||||
@@ -106,14 +101,14 @@ class Api::OrdersController < Api::ApiController
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@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 = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code = @shop.shop_code
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
@@ -126,8 +121,9 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if params[:order_source] != "app"
|
||||
@order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
|
||||
if @status && @booking
|
||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
@@ -135,11 +131,12 @@ class Api::OrdersController < Api::ApiController
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
end
|
||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') || (@order.source == 'app')
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_user)
|
||||
end
|
||||
end
|
||||
# # for parallel order
|
||||
# remoteIP = ""
|
||||
# begin
|
||||
# @status, @booking = @order.generate
|
||||
# remoteIP = request.remote_ip
|
||||
# end while request.remote_ip != remoteIP
|
||||
else
|
||||
return return_json_status_with_code(406, "Checkout time is over!")
|
||||
end
|
||||
@@ -202,7 +199,7 @@ class Api::OrdersController < Api::ApiController
|
||||
#checked checkin and checkout time
|
||||
def checkin_checkout_time(booking_id)
|
||||
status = true
|
||||
if !booking_id.nil?
|
||||
if booking_id.present?
|
||||
if booking = Booking.find(booking_id)
|
||||
if booking.checkout_at.present?
|
||||
if booking.checkout_at.utc <= Time.now.utc
|
||||
|
||||
@@ -10,7 +10,7 @@ class Api::Payment::CallbackController < Api::ApiController
|
||||
if trade_status == "PAY_SUCCESS"
|
||||
merch_order_id = params[:Request][:merch_order_id]
|
||||
|
||||
status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, 'kbzpay', merch_order_id)
|
||||
status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, current_shop, current_user, 'kbzpay', merch_order_id)
|
||||
render json: JSON.generate({:status => status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
|
||||
shop_detail = @shop
|
||||
shop_detail = current_shop
|
||||
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
|
||||
@@ -171,9 +171,9 @@ class Api::PaymentsController < Api::ApiController
|
||||
action_by = current_login_employee.name
|
||||
@status = true
|
||||
@message = ""
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.shop_code)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",sale.shop_code)
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
|
||||
@@ -8,8 +8,8 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
param_checksum = params[:checksum]
|
||||
# checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp
|
||||
|
||||
shop_code = params[:shop_code]
|
||||
all_menu = Menu.where('shop_code=?',shop_code).active.all
|
||||
all_menu = Menu.includes(:menu_categories => [:children, :menu_items => [:menu_item_instances => :menu_instance_item_sets, :item_sets => :menu_item_instances]]).active.all
|
||||
|
||||
@request_url = ''
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
@request_url = request.base_url
|
||||
@@ -17,10 +17,7 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
# to hash
|
||||
menu_array = []
|
||||
all_menu.each do |m|
|
||||
menu_array.push(m.to_json(:include => {:menu_categories =>
|
||||
{ :include => { :menu_items =>
|
||||
{ :include => [:menu_item_sets, :menu_item_instances =>
|
||||
{ :include => :menu_instance_item_sets}]} } }}))
|
||||
menu_array.push(m.to_json(:include => { :menu_categories => { :include => { :menu_items => { :include => [ :item_sets, :menu_item_instances => { :include => :menu_instance_item_sets } ] } } } } ))
|
||||
end
|
||||
|
||||
#export Checksum file generate by md5
|
||||
@@ -29,6 +26,10 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
if menu_checksum != param_checksum
|
||||
response.headers['CHECKSUM'] = menu_checksum
|
||||
@menus = all_menu
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
else
|
||||
render :json => nil
|
||||
end
|
||||
# @current_menu = Menu.current_menu
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ class Api::Restaurant::ZonesController < Api::ApiController
|
||||
|
||||
def index
|
||||
if (params[:filter] && params[:filter] = "all" )
|
||||
@all_tables = Table.active
|
||||
@all_rooms = Room.active
|
||||
@all_tables = Table.includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active
|
||||
@all_rooms = Room.includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active
|
||||
else
|
||||
@zones = Zone.includes([:tables, :rooms]).where("is_active = true")
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
|
||||
|
||||
#sound effect / alarm api for doemal side calling
|
||||
def sound_effect
|
||||
shop = @shop
|
||||
shop = current_shop
|
||||
if !shop.nil?
|
||||
shop_code = shop.shop_code
|
||||
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
include Customers
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail,:order_reservation, :bank_integration
|
||||
helper_method :current_shop,:order_reservation, :bank_integration
|
||||
# lookup domain for db from provision
|
||||
# before_action :set_locale
|
||||
# helper_method :current_company,:current_login_employee,:current_user
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
class BaseCrmController < ActionController::Base
|
||||
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "CRM"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseInventoryController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "inventory"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
class BaseOqsController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
|
||||
|
||||
layout "OQS"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class BaseOrigamiController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
include Customers
|
||||
|
||||
layout "origami"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
@@ -34,6 +33,7 @@ class BaseReportController < ActionController::Base
|
||||
if params[:from].present? && params[:to].present?
|
||||
from = Time.parse(params[:from])
|
||||
to = Time.parse(params[:to])
|
||||
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseWaiterController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "waiter"
|
||||
|
||||
18
app/controllers/concerns/customers.rb
Normal file
18
app/controllers/concerns/customers.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Customers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
helper_method :walkin, :takeaway if respond_to? :helper_method
|
||||
end
|
||||
|
||||
def walkin
|
||||
return @walkin if defined? @walkin
|
||||
@walkin = Customer.walkin
|
||||
end
|
||||
|
||||
def takeaway
|
||||
return @takeaway if defined? @takeaway
|
||||
@takeaway = Customer.takeaway
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,7 +2,7 @@ module LoginVerification
|
||||
extend ActiveSupport::Concern
|
||||
included do
|
||||
before_action :authenticate_session_token
|
||||
helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
|
||||
helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :current_shop
|
||||
end
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
@@ -16,32 +16,23 @@ module LoginVerification
|
||||
end
|
||||
end
|
||||
|
||||
def current_shop
|
||||
begin
|
||||
return @shop
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
@employee ||= current_user
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashiers
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
@cashier ||= Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = current_shop
|
||||
end
|
||||
# def shop_detail
|
||||
# @shop ||= current_shop
|
||||
# end
|
||||
|
||||
#check order reservation used
|
||||
def order_reservation
|
||||
|
||||
@@ -3,19 +3,19 @@ module MultiTenancy
|
||||
|
||||
included do
|
||||
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
||||
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
||||
before_action :set_current_tenant_by_subdomain_or_frist if respond_to? :before_action
|
||||
helper_method :current_shop if respond_to? :helper_method
|
||||
end
|
||||
|
||||
private
|
||||
def find_shop_by_subdomain_or_frist
|
||||
if request.subdomain.present?
|
||||
shop_code = request.subdomain.partition('-').last
|
||||
@shop = Shop.find_by(shop_code: shop_code)
|
||||
else
|
||||
# @shop = Shop.first
|
||||
@shop = Shop.find_by(shop_code: '262')
|
||||
def set_current_tenant_by_subdomain_or_frist
|
||||
if request.subdomains.last && request.subdomains.last != 'www'
|
||||
set_current_tenant(Shop.find_by(subdomain: request.subdomains.last))
|
||||
end
|
||||
set_current_tenant(@shop)
|
||||
set_current_tenant(Shop.first) if current_tenant.nil?
|
||||
end
|
||||
|
||||
def current_shop
|
||||
ActsAsTenant.current_tenant
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module NumberFormattable
|
||||
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
|
||||
end
|
||||
if @precision.nil?
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @print_settings
|
||||
if @print_settings
|
||||
@precision = @print_settings.precision.to_i
|
||||
else
|
||||
@@ -24,7 +24,7 @@ module NumberFormattable
|
||||
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
|
||||
end
|
||||
if @delimiter.nil?
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @print_settings
|
||||
if @print_settings && @print_settings.delimiter
|
||||
@delimiter = ","
|
||||
else
|
||||
@@ -42,10 +42,10 @@ module NumberFormattable
|
||||
end
|
||||
|
||||
def number_format(number, options = {})
|
||||
options[:precision] = options[:precision] || precision
|
||||
options[:precision] = options[:precision] || precision
|
||||
# options[:delimiter] = options[:delimiter] || delimiter
|
||||
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
|
||||
|
||||
|
||||
number = number.to_f.round(options[:precision])
|
||||
|
||||
if options[:precision] > 0
|
||||
|
||||
@@ -6,14 +6,13 @@ module TokenVerification
|
||||
before_action :authenticate
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_token
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
# Rails.logger.debug "token - " + token.to_s
|
||||
if(options.length !=0 && options["from"] == "DOEMAL")
|
||||
|
||||
@@ -9,15 +9,25 @@ class Crm::CustomersController < BaseCrmController
|
||||
filter = params[:filter]
|
||||
filter_card_no = params[:filter_card_no]
|
||||
type = params[:type]
|
||||
puts "type :"
|
||||
puts type
|
||||
puts "filter :"
|
||||
puts filter
|
||||
puts "filter card no"
|
||||
puts filter_card_no
|
||||
@customer_update_phone_email_membertype =false
|
||||
if filter_card_no==""
|
||||
@crm_customers = Customer.all
|
||||
puts "Filter card no"
|
||||
elsif !filter_card_no.nil?
|
||||
@crm_customers=Customer.where("card_no=?",filter_card_no)
|
||||
puts "Null filter card no"
|
||||
elsif filter.nil? || filter_card_no==""
|
||||
@crm_customers = Customer.all
|
||||
puts "filter null filter card no nulll"
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
puts "else"
|
||||
# paymal_customer = Customer.search_paypar_account_no(filter)
|
||||
# search account no from paypar
|
||||
if type == "card"
|
||||
@@ -38,7 +48,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.shop_code = @shop.shop_code
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
flash[:member_notice]='Customer was successfully created.'
|
||||
@@ -83,8 +92,9 @@ class Crm::CustomersController < BaseCrmController
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
@taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name")
|
||||
.joins(:lookup)
|
||||
.order("group_type ASC, order_by ASC")
|
||||
|
||||
@filter = filter
|
||||
|
||||
@@ -147,104 +157,101 @@ class Crm::CustomersController < BaseCrmController
|
||||
def new
|
||||
@crm_customer = Customer.new
|
||||
@membership = Customer.get_member_group()
|
||||
|
||||
end
|
||||
|
||||
# GET /crm/customers/1/edit
|
||||
def edit
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
|
||||
def sync
|
||||
@customer = Customer.find(params[:id])
|
||||
respond_to do |format|
|
||||
name = @customer.name
|
||||
phone = @customer.contact_no
|
||||
email = @customer.email
|
||||
dob = @customer.date_of_birth
|
||||
address = @customer.address
|
||||
nrc = @customer.nrc_no
|
||||
card_no = @customer.card_no
|
||||
paypar_account_no = @customer.paypar_account_no
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = @customer.membership_type
|
||||
if !id.present? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
respond_to do |format|
|
||||
name = @customer.name
|
||||
phone = @customer.contact_no
|
||||
email = @customer.email
|
||||
dob = @customer.date_of_birth
|
||||
address = @customer.address
|
||||
nrc = @customer.nrc_no
|
||||
card_no = @customer.card_no
|
||||
paypar_account_no = @customer.paypar_account_no
|
||||
id = @customer.membership_id
|
||||
member_group_id = @customer.membership_type
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
rescue Net::OpenTimeout
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
rescue OpenURI::HTTPError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue SocketError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
Rails.logger.debug "--------Sync Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully synced'
|
||||
else
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully synced'
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
end
|
||||
# When paypar account no not exist in paypar
|
||||
if response["message"] == "Account does not exist."
|
||||
customer.destroy
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] ='Member cannot created.Invalid Account.'
|
||||
else
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
end
|
||||
rescue SocketError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
Rails.logger.debug "--------Sync Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully synced'
|
||||
else
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully synced'
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
end
|
||||
# When paypar account no not exist in paypar
|
||||
if response["message"] == "Account does not exist."
|
||||
customer.destroy
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] ='Member cannot created.Invalid Account.'
|
||||
else
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
@@ -255,7 +262,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
if @checked_contact.nil?
|
||||
respond_to do |format|
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
@crm_customers.shop_code = @shop.shop_code
|
||||
if @crm_customers.save
|
||||
# update tax profile
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
|
||||
@@ -40,7 +40,6 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
# POST /crm/dining_queues.json
|
||||
def create
|
||||
@dining_queue = DiningQueue.new(dining_queue_params)
|
||||
@dining_queue.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @dining_queue.save
|
||||
|
||||
|
||||
@@ -135,7 +135,6 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code = @shop.shop_code
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
|
||||
@@ -87,8 +87,9 @@ class Foodcourt::CustomersController < BaseFoodcourtController
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
@taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name")
|
||||
.joins(:lookup)
|
||||
.order("group_type ASC, order_by ASC")
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
|
||||
@@ -22,7 +22,7 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
@accounts = Account.all
|
||||
end
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
|
||||
@@ -30,7 +30,7 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
|
||||
|
||||
@quick_service_only = true
|
||||
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||
if !lookup_dine_in.empty?
|
||||
@@ -47,7 +47,7 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||
.where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
|
||||
.where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
|
||||
render "foodcourt/addorders/detail"
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product.where("shop_code='#{@shop.shop_code}'")
|
||||
@product = Product.all
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
|
||||
@@ -4,13 +4,13 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
|
||||
@occupied_table = DiningFacility.where("status='occupied'").count
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
end
|
||||
|
||||
@@ -19,10 +19,10 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
@@ -30,8 +30,8 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
@membership = MembershipSetting.all
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
|
||||
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
|
||||
@order_items = Array.new
|
||||
@@ -103,16 +103,16 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
#for bank integration
|
||||
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
|
||||
@checkout_time = Lookup.collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
|
||||
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
|
||||
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@tax_arr.push(acc.name)
|
||||
end
|
||||
|
||||
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
@@ -120,7 +120,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
|
||||
#for edit order on/off
|
||||
@edit_order_origami = true
|
||||
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
|
||||
lookup_edit_order = Lookup.collection_of('edit_order')
|
||||
if !lookup_edit_order.empty?
|
||||
lookup_edit_order.each do |edit_order|
|
||||
if edit_order[0].downcase == "editorderorigami"
|
||||
@@ -133,7 +133,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
|
||||
@@ -71,12 +71,12 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||
.where("sales.sale_status !=? and orders.source='app' and bookings.shop_code=? and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
|
||||
.where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',Date.today).order("bookings.created_at desc").uniq
|
||||
end
|
||||
def completed
|
||||
customer =Customer.find_by_customer_id(params[:customer_id])
|
||||
phone_number =customer.contact_no
|
||||
if Order.send_message(phone_number,params[:order_id],@shop.name)
|
||||
if Order.send_message(phone_number,params[:order_id],current_shop.name)
|
||||
booking =Booking.find(params[:booking_id])
|
||||
booking.booking_status ='completed'
|
||||
booking.save!
|
||||
|
||||
@@ -20,7 +20,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
#shop_detail = Shop.first
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
@@ -154,7 +154,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,account_no, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,account_no, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
#end
|
||||
end
|
||||
@@ -223,7 +223,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@@ -270,7 +270,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
#end rounding adjustment
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -472,7 +472,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -547,7 +547,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -562,7 +562,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
@@ -571,7 +571,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -606,7 +606,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -631,7 +631,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
else
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
@@ -654,7 +654,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
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)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Foodcourt::PayparPaymentsController < BaseFoodcourtController
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
|
||||
@@ -118,7 +118,7 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
# make cancel void item
|
||||
|
||||
@@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
@cashier_type = params[:type]
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
#for bank integration
|
||||
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
@@ -15,8 +15,8 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code)
|
||||
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@terminal = CashierTerminal.available
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
cashier_terminal.save
|
||||
|
||||
#add shift_sale_id to card_settle_trans
|
||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
|
||||
bank_integration = Lookup.find_by_lookup_type('bank_integration')
|
||||
if !bank_integration.nil?
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
@@ -74,7 +74,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
@@ -88,17 +88,17 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
end
|
||||
shop_details = shop_detail
|
||||
shop_details = current_shop
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
if @lookup.to_i == 1
|
||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ class Foodcourt::SurveysController < BaseFoodcourtController
|
||||
if @booking.dining_facility_id.to_i>0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
|
||||
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
@@ -33,7 +33,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController
|
||||
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# set cashier
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
current_shift_user =Employee.find_by_id(current_user.employee_id)
|
||||
if open_cashier.count>0
|
||||
@@ -76,7 +76,6 @@ class Foodcourt::SurveysController < BaseFoodcourtController
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.shift_id = shift_by_terminal.id
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
@survey.shop_code = @shop.shop_code
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
redirect_to @url
|
||||
|
||||
@@ -64,7 +64,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
@@ -111,7 +111,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -126,13 +126,13 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -54,7 +54,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
|
||||
@@ -88,7 +88,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
@@ -96,7 +96,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -112,13 +112,13 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -18,8 +18,8 @@ class HomeController < ApplicationController
|
||||
|
||||
def index
|
||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
@employees = Employee.all.where("shop_code='#{@shop.shop_code}' and is_active = true").order("name asc")
|
||||
@roles = Employee.where("shop_code='#{@shop.shop_code}'").distinct.pluck(:role)
|
||||
@employees = Employee.all.where("is_active = true").order("name asc")
|
||||
@roles = Employee.distinct.pluck(:role)
|
||||
|
||||
# byebug
|
||||
# @roles = Lookup.collection_of("employee_roles")
|
||||
@@ -124,7 +124,7 @@ class HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
@inventories = StockJournal.inventory_balances(@from,@to, current_shop).sum(:balance)
|
||||
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
|
||||
|
||||
@total_trans = Sale.total_trans(current_user,@from,@to)
|
||||
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
||||
|
||||
@@ -3,14 +3,14 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(@shop,filter)
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(filter)
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(inventory_definition_id,@shop.shop_code)
|
||||
@stock_journals = StockJournal.where("item_code=? and shop_code='#{@shop.shop_code}'",inventory.item_code).order("id DESC")
|
||||
inventory = InventoryDefinition.find_by_id(inventory_definition_id)
|
||||
@stock_journals = StockJournal.where("item_code=?",inventory.item_code).order("id DESC")
|
||||
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# GET /inventory_definitions
|
||||
# GET /inventory_definitions.json
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'")
|
||||
@inventory_definitions = InventoryDefinition.all
|
||||
end
|
||||
|
||||
# GET /inventory_definitions/1
|
||||
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
|
||||
# GET /inventory_definitions/new
|
||||
def new
|
||||
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
|
||||
@menus = Menu.order('created_at asc')
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
end
|
||||
@@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code)
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
if inventory.nil?
|
||||
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
@@ -39,7 +39,6 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
@inventory_definition.min_order_level = params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.shop_code = @shop.shop_code
|
||||
@inventory_definition.created_by = current_user.id
|
||||
if @inventory_definition.save
|
||||
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
|
||||
@@ -84,16 +83,15 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# DELETE /inventory_definitions/1
|
||||
# DELETE /inventory_definitions/1.json
|
||||
def destroy
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
inventory = InventoryDefinition.find_by_id(params[:id])
|
||||
@inventory_definition.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
|
||||
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
StockJournal.delete_stock_journal(inventory.item_code,@shop)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code,@shop)
|
||||
StockJournal.delete_stock_journal(inventory.item_code)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code)
|
||||
if !inventory.nil?
|
||||
inventory.destroy
|
||||
flash[:message] = 'Inventory was successfully destroyed.'
|
||||
@@ -107,7 +105,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_inventory_definition
|
||||
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
@inventory_definition = InventoryDefinition.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
@@ -8,7 +8,6 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.where("inventory_definitions.shop_code='#{@shop.shop_code}'")
|
||||
.group("mi.menu_category_id")
|
||||
.order("mi.menu_category_id desc")
|
||||
unless !@category.nil?
|
||||
@@ -20,11 +19,11 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
item_list = JSON.parse(params[:stock_item])
|
||||
reason = params[:reason]
|
||||
check = StockCheck.new
|
||||
@check = check.create(current_user, reason, item_list,@shop)
|
||||
@check = check.create(current_user, reason, item_list)
|
||||
end
|
||||
|
||||
def show
|
||||
@check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
@check = StockCheck.find_by_id(params[:id])
|
||||
|
||||
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])
|
||||
|
||||
@@ -34,7 +33,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
check = params[:data]
|
||||
stockCheck = StockCheck.find_by_id(check)
|
||||
stockCheck.stock_check_items.each do |item|
|
||||
StockJournal.from_stock_check(item,@shop)
|
||||
StockJournal.from_stock_check(item)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +49,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
if !print_settings.nil?
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, current_shop)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ class StockJournalsController < ApplicationController
|
||||
# POST /stock_journals.json
|
||||
def create
|
||||
@stock_journal = StockJournal.new(stock_journal_params)
|
||||
@stock_journal.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @stock_journal.save
|
||||
format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' }
|
||||
|
||||
@@ -21,7 +21,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
zone_id = qid.zone_id
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
end
|
||||
@@ -57,14 +57,6 @@ class Oqs::HomeController < BaseOqsController
|
||||
end
|
||||
end
|
||||
|
||||
# booking_id = dining.get_new_booking
|
||||
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
|
||||
# order=Order.find(bo.order_id);
|
||||
# order.order_items.each do |oi|
|
||||
# items.push(oi)
|
||||
# end
|
||||
# end
|
||||
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
@@ -88,7 +80,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
end
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
|
||||
@@ -6,8 +6,8 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
# @tables = DiningFacility.all.active.order('status desc')
|
||||
@tables = DiningFacility.all.active.where("type = 'Table' and shop_code='#{@shop.shop_code}' ").order('status desc')
|
||||
@rooms = DiningFacility.all.active.where("type = 'Room' and shop_code='#{@shop.shop_code}' ").order('status desc')
|
||||
@tables = DiningFacility.all.active.where("type = 'Table'").order('status desc')
|
||||
@rooms = DiningFacility.all.active.where("type = 'Room'").order('status desc')
|
||||
|
||||
@filter = params[:filter]
|
||||
|
||||
@@ -232,7 +232,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
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")
|
||||
.where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
|
||||
query = query.where("df.shop_code='#{@shop.shop_code}' and 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}%",)
|
||||
.group("odt.order_items_id")
|
||||
.order("assigned_order_items.created_at desc")
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
||||
@all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
||||
|
||||
@tables = Table.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.active.order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.active.order('status desc')
|
||||
@all_room = Room.active.order('status desc')
|
||||
end
|
||||
|
||||
def detail
|
||||
@@ -18,7 +19,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -33,10 +34,11 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
@booking = @table.get_booking
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
if @obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,87 +100,85 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
if i["parent_order_item_id"];
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
|
||||
else
|
||||
end
|
||||
end
|
||||
if i["parent_order_item_id"]
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
# begin
|
||||
if params[:order_source] == "quick_service" && params[:table_id].to_i == 0
|
||||
customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
customer_id = takeaway.customer_id # for no customer id from mobile
|
||||
else
|
||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
end
|
||||
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = customer_id
|
||||
@order.items = items_arr
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code = @shop.shop_code
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||
Order.transaction do
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = customer_id
|
||||
@order.items = items_arr
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
if @status && @booking
|
||||
#send order broadcast to order_channel
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
type = 'order'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
|
||||
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
||||
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
end
|
||||
@status, @booking = @order.generate
|
||||
|
||||
if @status && @booking
|
||||
#send order broadcast to order_channel
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
type = 'order'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
|
||||
end
|
||||
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
||||
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
end
|
||||
# Order.send_customer_view(@booking)
|
||||
|
||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
||||
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||
|
||||
# for second display
|
||||
if @order.source == 'quick_service'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
||||
# for second display
|
||||
if @order.source == 'quick_service'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
||||
end
|
||||
#end
|
||||
result = {:status=> @status, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
#end
|
||||
result = {:status=> @status, :data => @sale }
|
||||
else
|
||||
result = {:status=> @status, :data => 0 }
|
||||
render :json => result.to_json
|
||||
end
|
||||
else
|
||||
result = {:status=> @status, :data => 0 }
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
@@ -220,66 +220,29 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def process_order_queue(order_id,table_id,order_source)
|
||||
print_status = nil
|
||||
cup_status = nil
|
||||
#Send to background job for processing
|
||||
order = Order.find(order_id)
|
||||
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
def process_order_queue(order_id, table_id, order_source)
|
||||
#Send to background job for processing
|
||||
order = Order.find(order_id)
|
||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
if Printer::PrinterWorker.printers.blank?
|
||||
msg = 'Print Error ! Please contact to service'
|
||||
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||
end
|
||||
end
|
||||
|
||||
if print_status
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
end
|
||||
else
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
cup_start = `#{"sudo service cups start"}`
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
end
|
||||
|
||||
if print_status
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
end
|
||||
else
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
from = ""
|
||||
msg = ' Print Error ! Please contact to service'
|
||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from
|
||||
end
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||
end
|
||||
end
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order, from: from
|
||||
end
|
||||
end
|
||||
|
||||
def check_cup_status(status)
|
||||
|
||||
@@ -23,7 +23,7 @@ class Origami::AlipayController < BaseOrigamiController
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -21,7 +21,7 @@ class Origami::CashInsController < BaseOrigamiController
|
||||
shift = shift
|
||||
else
|
||||
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Origami::CashOutsController < BaseOrigamiController
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
@@ -8,7 +8,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
total = sale_data.grand_total
|
||||
@creditcount = 0
|
||||
others = 0
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -55,7 +55,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@page = params[:dir_page]
|
||||
|
||||
if(@sale_id[0,3] == "SAL")
|
||||
if @sale_id.include? "SAL"
|
||||
@booking = Booking.find_by_sale_id(@sale_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@@ -87,17 +87,18 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
@taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name")
|
||||
.joins(:lookup)
|
||||
.order("group_type ASC, order_by ASC")
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type")
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
#get paypar accountno
|
||||
@paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no")
|
||||
#for create customer on/off
|
||||
@create_flag = true
|
||||
lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings')
|
||||
lookup_customer = Lookup.collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
@@ -117,7 +118,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
id = params[:sale_id]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
order_source = params[:type]
|
||||
@@ -129,7 +130,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
if(id == "SAL")
|
||||
if id.include? "SAL"
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: customer_id)
|
||||
sale.sale_orders.each do |sale_order|
|
||||
@@ -153,7 +154,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
if(id == "SAL")
|
||||
if id.include? "SAL"
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
end
|
||||
else
|
||||
@@ -168,9 +169,9 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
sale = Sale.find_by_receipt_no(receipt_no)
|
||||
@out = []
|
||||
action_by = current_user.name
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
|
||||
@@ -47,21 +47,21 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@current_user = current_user
|
||||
#dine-in cashier
|
||||
dinein_cashier = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dinein_cashier')
|
||||
dinein_cashier = Lookup.collection_of('dinein_cashier')
|
||||
@dinein_cashier = 0
|
||||
if !dinein_cashier[0].nil?
|
||||
@dinein_cashier = dinein_cashier[0][1]
|
||||
end
|
||||
|
||||
#quick service
|
||||
quick_service = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('quick_service')
|
||||
quick_service = Lookup.collection_of('quick_service')
|
||||
@quick_service = 0
|
||||
if !quick_service[0].nil?
|
||||
@quick_service = quick_service[0][1]
|
||||
end
|
||||
|
||||
#fourt court
|
||||
food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court')
|
||||
food_court = Lookup.collection_of('food_court')
|
||||
@food_court = 0
|
||||
@food_court_name = nil
|
||||
if !food_court[0].nil?
|
||||
@@ -70,7 +70,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#order reservation
|
||||
order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation')
|
||||
order_reservation = Lookup.collection_of('order_reservation')
|
||||
@order_reservation = 0
|
||||
if !order_reservation.empty?
|
||||
order_reservation.each do |order_reserve|
|
||||
@@ -81,7 +81,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#dashboard settings on/off for supervisor and cashier
|
||||
dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings')
|
||||
dashboard_settings = Lookup.collection_of('dashboard_settings')
|
||||
@setting_flag = true
|
||||
if !dashboard_settings.empty?
|
||||
dashboard_settings.each do |setting|
|
||||
@@ -92,7 +92,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#reservation
|
||||
reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation')
|
||||
reservation = Lookup.collection_of('reservation')
|
||||
@reservation = 0
|
||||
if !reservation.empty?
|
||||
reservation.each do |reserve|
|
||||
@@ -104,9 +104,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_all_menu
|
||||
|
||||
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.shop
|
||||
|
||||
@menus = Menu.includes(:menu_categories => [:children, :menu_items => [:menu_item_instances => :menu_instance_item_sets, :item_sets => :menu_item_instances]]).active.all
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class Origami::DingaController < BaseOrigamiController
|
||||
@membership_rebate_balance=0
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = @sale_data.receipt_no
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
else
|
||||
new_total = @sale_data.grand_total
|
||||
|
||||
@@ -21,8 +21,8 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@accounts = Account.all
|
||||
end
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
|
||||
@@ -17,12 +17,11 @@ class Origami::FoodCourtController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
||||
@zone = Zone.all.where("is_active= true")
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@cashier_type = "food_court"
|
||||
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
@@ -32,7 +31,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
|
||||
#checked quick_service only
|
||||
@quick_service_only = true
|
||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
@@ -57,7 +56,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
if params[:id].include? "BKI"
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
@@ -114,7 +113,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
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 = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
order.items = items_arr
|
||||
order.guest = params[:guest_info]
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@@ -161,7 +160,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product..where("shop_code='#{@shop.shop_code}'")
|
||||
@product = Product.all
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
|
||||
@@ -17,7 +17,7 @@ class Origami::GiftVoucherController < BaseOrigamiController
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -4,16 +4,14 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
|
||||
|
||||
@tables = Table.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@tables = Table.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@occupied_table = DiningFacility.where("status='occupied'").shop.count
|
||||
@occupied_table = DiningFacility.where("status='occupied'").count
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
end
|
||||
|
||||
@@ -23,9 +21,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
|
||||
@tables = Table.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@tables = Table.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
@@ -36,89 +33,56 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
|
||||
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
|
||||
@order_items = Array.new
|
||||
@shop = current_shop
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
@dining_booking = @dining.current_bookings
|
||||
|
||||
@order_items = Array.new
|
||||
@dining_booking.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
# @assigned_order_items = Array.new
|
||||
if booking.booking_orders.empty?
|
||||
@booking = booking
|
||||
else
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
@booking= booking
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
|
||||
# if !assigned_order_items.nil?
|
||||
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
|
||||
# end
|
||||
end
|
||||
@account_arr = Array.new
|
||||
if @customer.tax_profiles
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find_by_id(acc)
|
||||
if !account.nil?
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking= booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find_by_id(acc)
|
||||
if !account.nil?
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
@sale_taxes = []
|
||||
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@sale_taxes.push(sale_tax)
|
||||
end
|
||||
end
|
||||
if @obj_sale || @booking.blank?
|
||||
@booking = booking
|
||||
end
|
||||
|
||||
if booking.sale_id
|
||||
@obj_sale = booking.sale
|
||||
@sale_array.push(@obj_sale)
|
||||
@sale_taxes = @obj_sale.sale_taxes
|
||||
@status_sale = 'sale'
|
||||
else
|
||||
@order_items += booking.order_items
|
||||
@obj_order = booking.orders.first
|
||||
end
|
||||
|
||||
if @obj_sale || @customer.blank?
|
||||
if obj = @obj_sale || @obj_order
|
||||
@customer = obj.customer
|
||||
@date = obj.created_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if @obj_sale
|
||||
@status_order = 'sale'
|
||||
else
|
||||
@status_order = 'order'
|
||||
end
|
||||
|
||||
if (@obj_sale || @account_arr.blank?) && @customer
|
||||
@account_arr = TaxProfile.find_by(id: @customer.tax_profiles)
|
||||
end
|
||||
end
|
||||
|
||||
#for bank integration
|
||||
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
|
||||
@checkout_time = Lookup.collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
|
||||
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
|
||||
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@tax_arr.push(acc.name)
|
||||
end
|
||||
|
||||
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
@@ -126,7 +90,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
#for edit order on/off
|
||||
@edit_order_origami = true
|
||||
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
|
||||
lookup_edit_order = Lookup.collection_of('edit_order')
|
||||
if !lookup_edit_order.empty?
|
||||
lookup_edit_order.each do |edit_order|
|
||||
if edit_order[0].downcase == "editorderorigami"
|
||||
@@ -139,7 +103,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
class Origami::HomeController < ApplicationController
|
||||
def index
|
||||
if params[:booking_id] != nil
|
||||
type=params[:booking_id].split('-')[0];
|
||||
# Sale
|
||||
if type == "SAL"
|
||||
if params[:booking_id].include? "SAL"
|
||||
@selected_item = Sale.find(params[:booking_id])
|
||||
@selected_item_type="Sale"
|
||||
# Booking
|
||||
@@ -25,9 +24,8 @@ class Origami::HomeController < ApplicationController
|
||||
|
||||
def selection(selected_id, is_ajax)
|
||||
str = []
|
||||
type=selected_id.split('-')[0];
|
||||
# Sale
|
||||
if type == "SAL"
|
||||
if selected_id.include? "SAL"
|
||||
@order_details = SaleItem.get_order_items_details(params[:booking_id])
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
@@ -48,9 +46,7 @@ class Origami::HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
if(id == "SAL")
|
||||
if id.inlude? "SAL"
|
||||
sale = Sale.find(params[:sale_id])
|
||||
else
|
||||
sale = Order.find(params[:sale_id])
|
||||
|
||||
@@ -24,7 +24,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
@cashier_id = current_user.emp_id
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -23,7 +23,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -22,7 +22,7 @@ class Origami::MpuController < BaseOrigamiController
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj && (!path.include? ("credit_payment"))
|
||||
if current_shop.is_rounding_adj && (!path.include? ("credit_payment"))
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -98,12 +98,12 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_order_info
|
||||
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{current_shop.shop_code}'").count()
|
||||
order_reservation = OrderReservation.where("status = 'new'").count()
|
||||
render :json => order_reservation
|
||||
end
|
||||
|
||||
def check_receipt_bill
|
||||
receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation")
|
||||
receipt_bill = Lookup.collection_of("order_reservation")
|
||||
|
||||
status = 0
|
||||
if !receipt_bill.nil?
|
||||
|
||||
@@ -6,7 +6,7 @@ class Origami::PaymalController < BaseOrigamiController
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = sale_data.receipt_no
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
@@ -32,9 +32,9 @@ class Origami::PaymalController < BaseOrigamiController
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
|
||||
@@ -10,121 +10,73 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
member_info = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
if booking.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(sale_data.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
booking = sale_data.booking
|
||||
|
||||
if current_user.role == 'cashier'
|
||||
cashier_terminal = current_user.cashier_terminal
|
||||
elsif booking.dining_facility
|
||||
cashier_terminal = booking.cashier_terminal_by_dining_facility
|
||||
end
|
||||
|
||||
cashier_terminal ||= sale_data.cashier_terminal_by_shift_sale
|
||||
|
||||
customer = sale_data.customer
|
||||
|
||||
#record for sale audit
|
||||
action_by = current_user.name
|
||||
type = "FIRST_BILL"
|
||||
|
||||
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
# find order id by sale id
|
||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
|
||||
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
print_settings = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
|
||||
if !kbz_pay_method.nil?
|
||||
if kbz_pay_method.is_active == true
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
|
||||
|
||||
status, qr = KbzPay.pay(sale_data.grand_total.to_i, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
|
||||
end
|
||||
end
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code = "ReceiptBillPdf"
|
||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code = "ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, nil, current_shop, "Frt", current_balance, nil, other_amount, nil, nil, nil)
|
||||
|
||||
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 = unique_code#{}"ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
#shop detail
|
||||
## shop_detail = @shop
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer = Customer.find(sale_data.customer_id)
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = new_total - sale_data.grand_total
|
||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
end
|
||||
#end rounding adjustment
|
||||
#record for sale audit
|
||||
action_by = current_user.name
|
||||
type = "FIRST_BILL"
|
||||
# status, qr = KbzPay.query(sale_payment.sale_payment_id)
|
||||
|
||||
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
|
||||
# find order id by sale id
|
||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
|
||||
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
|
||||
if !kbz_pay_method.nil?
|
||||
if kbz_pay_method.is_active == true
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
|
||||
|
||||
status, qr = KbzPay.pay(sale_data.grand_total.to_i, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
|
||||
end
|
||||
end
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# status, qr = KbzPay.query(sale_payment.sale_payment_id)
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -138,25 +90,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
latest_order_no = nil
|
||||
is_kbz = params[:is_kbz]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
if saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
#shop_detail = @shop
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# if pay_from = 'kbzpay'
|
||||
# salePayment = SalePayment.find(sale_payment_id)
|
||||
# salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid')
|
||||
# else
|
||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
if is_kbz == 'false'
|
||||
Rails.logger.info '################ CASH PAYMENT #################'
|
||||
sale_payment = SalePayment.new
|
||||
@@ -166,134 +102,110 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
end
|
||||
else
|
||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
if !path.include? ("credit_payment")
|
||||
rebate_amount = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
bookings = saleObj.bookings[0]
|
||||
booking = saleObj.booking
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
if bookings.dining_facility_id.to_i > 0
|
||||
table = bookings.dining_facility
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if current_user.role == 'cashier'
|
||||
cashier_terminal = current_user.cashier_terminal
|
||||
elsif booking.dining_facility
|
||||
cashier_terminal = booking.cashier_terminal_by_dining_facility
|
||||
end
|
||||
|
||||
type = 'payment'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
cashier_terminal ||= saleObj.cashier_terminal_by_shift_sale
|
||||
|
||||
if booking.dining_facility
|
||||
ActionCable.server.broadcast(
|
||||
"order_channel",
|
||||
table: booking.dining_facility,
|
||||
type: 'payment',
|
||||
from: getCloudDomain
|
||||
)
|
||||
end
|
||||
|
||||
# For Print
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code = "ReceiptBillPdf"
|
||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code = "ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillA5Pdf"
|
||||
else
|
||||
unique_code = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code
|
||||
end
|
||||
|
||||
customer = saleObj.customer
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
member_info = Customer.get_member_account(customer)
|
||||
|
||||
if member_info["status"] == true
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if type == "quick_service"
|
||||
if booking.dining_facility_id.present?
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
|
||||
if !latest_order.nil?
|
||||
latest_order_no = latest_order.order_id
|
||||
end
|
||||
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
booking.booking_orders.each do |order|
|
||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
member_info = Customer.get_member_account(customer)
|
||||
|
||||
if member_info["status"] == true
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if type == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
|
||||
if !latest_order.nil?
|
||||
latest_order_no = latest_order.order_id
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||
end
|
||||
end
|
||||
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
if !card_sale_trans_ref_no.nil?
|
||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||
card_no = cash_sale_trans.pan.last(4)
|
||||
card_no = card_no.rjust(19,"**** **** **** ")
|
||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||
end
|
||||
end
|
||||
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
if !card_sale_trans_ref_no.nil?
|
||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||
card_no = cash_sale_trans.pan.last(4)
|
||||
card_no = card_no.rjust(19,"**** **** **** ")
|
||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||
end
|
||||
end
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil)
|
||||
|
||||
#end
|
||||
end
|
||||
logger.debug 'saleObj++++++++++++++++++++++++++'
|
||||
logger.debug saleObj.to_json
|
||||
if !saleObj.nil?
|
||||
# InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
@@ -313,7 +225,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def show
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -330,10 +242,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@membership_rebate_balance=0
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -358,17 +270,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
@@ -381,7 +293,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# @shop = shop_detail #show shop info
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
@@ -410,7 +322,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#end rounding adjustment
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -436,7 +348,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@@ -450,7 +362,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
@@ -612,7 +524,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -636,11 +548,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
current_balance = nil
|
||||
order_source = params[:type]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
if Sale.exists?(sale_id)
|
||||
saleObj = Sale.find(sale_id)
|
||||
#calculate cash acmount
|
||||
cash = saleObj.total_amount
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
saleObj.compute_by_sale_items(0, nil, order_source)
|
||||
@@ -648,9 +563,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
|
||||
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
@@ -659,8 +571,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
end
|
||||
|
||||
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
|
||||
@@ -703,7 +613,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
@@ -712,7 +622,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -747,7 +657,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -770,9 +680,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if cashier_type.strip.downcase == "doemal_order"
|
||||
unique_code = "ReceiptBillOrderPdf"
|
||||
else
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
@@ -795,7 +705,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
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)
|
||||
|
||||
@@ -817,8 +727,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:cashier_type]
|
||||
tax_type = params[:tax_type]
|
||||
remark = "Change tax to #{tax_type.upcase} for Sale ID #{sale_id} By #{current_login_employee.name}"
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
|
||||
SaleAudit.record_audit_change_tax(sale_id,remark,current_login_employee.name)
|
||||
|
||||
render json: JSON.generate({:status => true})
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
|
||||
@@ -14,7 +14,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
|
||||
def show
|
||||
id = params[:sale_id]
|
||||
if id.start_with?("SAL")
|
||||
if id.include? "SAL"
|
||||
@sale = Sale.find(id)
|
||||
if @sale.sale_status == "new"
|
||||
@bookings = @sale.bookings.first
|
||||
@@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
else
|
||||
redirect_to "/origami/#{params[:type]}" and return
|
||||
end
|
||||
elsif (id.start_with?("BKI") || id.start_with?("CBKI"))
|
||||
elsif id.include? "BKI"
|
||||
@bookings = Booking.find(id)
|
||||
@order = @bookings.orders.where(status: "new").first
|
||||
@order_items = @bookings.order_items
|
||||
|
||||
@@ -10,24 +10,27 @@ class Origami::QuickServiceController < ApplicationController
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
# if params[:menu] == "true"
|
||||
|
||||
@menus = []
|
||||
@menu = []
|
||||
@zone = Zone.all
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@tables = Table.active.order('status desc')
|
||||
@rooms = Room.active.order('status desc')
|
||||
@cashier_type = "quick_service"
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
if !display_type.nil? && display_type.value.to_i == 2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
|
||||
#checked quick_service only
|
||||
@quick_service_only = false
|
||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quickservice_add_order')
|
||||
@quick_service_only = Lookup.collection_of('quickservice_add_order').any? { |x| x == ["quickserviceaddorder", "1"] }
|
||||
|
||||
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
||||
# puts 'lookup_dine_in!!!!'
|
||||
# puts lookup_dine_in
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "quickserviceaddorder"
|
||||
@@ -37,7 +40,23 @@ class Origami::QuickServiceController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
divided_value =0
|
||||
exclusive =0
|
||||
tax_profiles = TaxProfile.where(group_type: "quick_service")
|
||||
if !tax_profiles.empty?
|
||||
tax_profiles.each do |tax|
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
tax_incl_exec = "inclusive"
|
||||
rate = tax.rate
|
||||
divided_value += (100 + rate)/rate
|
||||
else
|
||||
exclusive +=tax.rate / 100
|
||||
end
|
||||
end
|
||||
end
|
||||
@inclusive_tax =divided_value
|
||||
@exclusive_tax =exclusive
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
@@ -52,7 +71,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
if params[:id].include? "BKI"
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
@@ -109,7 +128,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
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 = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
order.items = items_arr
|
||||
order.guest = params[:guest_info]
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
|
||||
@@ -5,7 +5,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -18,96 +18,78 @@ class Origami::RequestBillsController < ApplicationController
|
||||
else
|
||||
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
||||
|
||||
if sale_data = booking.sale
|
||||
@status = true
|
||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
# in-duty update
|
||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||
if !in_duties.empty?
|
||||
in_duties.each do |in_duty|
|
||||
induty = InDuty.find(in_duty.id)
|
||||
induty.sale_id = sale_data.sale_id
|
||||
induty.out_time = Time.now.utc
|
||||
induty.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift.id
|
||||
# @sale_data.save
|
||||
|
||||
action_by = current_user.name
|
||||
type = "REQUEST_BILL"
|
||||
|
||||
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(sale_data)
|
||||
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
|
||||
if order.source == "cashier" || order.source == "quick_service"
|
||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
end
|
||||
if order.source == "quick_service" || order.source == "food_court"
|
||||
result = {:status=> @status, :data => sale_data.sale_id }
|
||||
render :json => result.to_json
|
||||
else
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
if !booking.dining_facility_id.nil?
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
||||
if booking.sale_id.nil?
|
||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||
# in-duty update
|
||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||
if !in_duties.empty?
|
||||
in_duties.each do |in_duty|
|
||||
induty = InDuty.find(in_duty.id)
|
||||
induty.sale_id = sale_data.sale_id
|
||||
induty.out_time = Time.now.utc
|
||||
induty.save
|
||||
end
|
||||
end
|
||||
|
||||
action_by = current_user.name
|
||||
type = "REQUEST_BILL"
|
||||
|
||||
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(sale_data)
|
||||
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
|
||||
if ["quick_service", "cashier"].include? order.source
|
||||
ActionCable.server.broadcast "bill_channel", table: table, from: from
|
||||
end
|
||||
|
||||
unless ["quick_service", "food_court"].include? order.source
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
if !booking.dining_facility_id.nil?
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@status = true
|
||||
sale_id = sale_data.sale_id
|
||||
else
|
||||
@status = false
|
||||
sale_id = nil
|
||||
end
|
||||
else
|
||||
@status = true
|
||||
sale_id = booking.sale_id
|
||||
end
|
||||
end
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
end
|
||||
|
||||
# Not Use for these printed bill cannot give customer
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
# shop_details = @shop
|
||||
# # customer= Customer.where('customer_id=' +.customer_id)
|
||||
# customer= Customer.find(@sale_data.customer_id)
|
||||
# # get member information
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# # get printer info
|
||||
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# # find order id by sale id
|
||||
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# # Calculate price_by_accounts
|
||||
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
|
||||
# printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
if ["quick_service", "food_court"].include? order.source
|
||||
result = {:status=> @status, :data => sale_data.sale_id }
|
||||
render :json => result.to_json
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -30,8 +30,8 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code)
|
||||
@membership = MembershipSetting.all
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
@dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
|
||||
|
||||
@@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
# make cancel void item
|
||||
|
||||
@@ -27,52 +27,33 @@ class Origami::SalesController < BaseOrigamiController
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
tax_type = params[:tax_type]
|
||||
sale_data = []
|
||||
table = DiningFacility.find(dining)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
table.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
order.status = 'billed'
|
||||
order.order_items.each do |item|
|
||||
item.order_item_status = 'billed'
|
||||
end
|
||||
# create sale item
|
||||
saleobj = Sale.find(sale_id)
|
||||
order.order_items.each do |orer_item|
|
||||
saleobj.add_item (orer_item)
|
||||
if !orer_item.set_menu_items.nil?
|
||||
saleobj.add_sub_item(orer_item.set_menu_items)
|
||||
end
|
||||
sale_data.push(orer_item)
|
||||
end
|
||||
Sale.transaction do
|
||||
table = DiningFacility.find(dining)
|
||||
booking = table.current_checkin_booking
|
||||
|
||||
# Re-compute for add
|
||||
saleobj.compute(order.source,tax_type)
|
||||
saleobj.save
|
||||
order.save
|
||||
booking.save
|
||||
sale = Sale.find(sale_id)
|
||||
existing = sale.booking
|
||||
|
||||
order_array.push(order.order_id)
|
||||
end
|
||||
sale.sale_items << booking.order_items.to_sale_items
|
||||
sale.orders << booking.orders
|
||||
|
||||
receipt_no = Sale.find(sale_id).receipt_no
|
||||
action_by = current_user.name
|
||||
type = "ADD_TO_EXISTING"
|
||||
sale.compute(booking.orders[0].source, tax_type)
|
||||
|
||||
remark = "#{action_by} add to existing order #{order_array} to Receipt No=>#{receipt_no} in #{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||
type = "ADD_TO_EXISTING"
|
||||
receipt_no = sale.receipt_no
|
||||
action_by = current_user.name
|
||||
order_ids = booking.orders.map(&:order_id)
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
bo.save
|
||||
end
|
||||
end
|
||||
remark = "#{action_by} add to existing order #{order_ids.to_s} to Receipt No=>#{receipt_no} in #{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id, remark, action_by, type)
|
||||
|
||||
booking.orders.update_all(status: "billed")
|
||||
booking.order_items.update_all(order_item_status: "billed")
|
||||
BookingOrder.where(booking_id: booking.booking_id).update_all(booking_id: existing)
|
||||
|
||||
booking.booking_status = "moved"
|
||||
booking.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code)
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@terminal = CashierTerminal.available
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
cashier_terminal.save
|
||||
|
||||
#add shift_sale_id to card_settle_trans
|
||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
|
||||
bank_integration = Lookup.find_by_lookup_type('bank_integration')
|
||||
if !bank_integration.nil?
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
@@ -74,7 +74,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
@@ -91,13 +91,13 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
if @lookup.to_i == 1
|
||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@@ -126,7 +126,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
if find_close_cashier_print[0][1].to_i > 0
|
||||
|
||||
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,current_shop, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -144,7 +144,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
|
||||
@@ -16,377 +16,118 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
@sale_data = Array.new
|
||||
@current_user = current_user
|
||||
|
||||
table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL")
|
||||
if !table_bookings.nil?
|
||||
table_bookings.each do |table_booking|
|
||||
if table_booking.sale.sale_status != 'waste' && table_booking.sale.sale_status != 'spoile'
|
||||
@sale_data.push(table_booking.sale)
|
||||
end
|
||||
end
|
||||
end
|
||||
@sale_data = @table.current_sales
|
||||
|
||||
if @booking
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
arr_order_items = Array.new
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@orders.push(@order)
|
||||
@orders = @booking.orders
|
||||
@order = @orders[0]
|
||||
@order_items = []
|
||||
order_items = []
|
||||
|
||||
@order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
@booking.order_items.each do |item|
|
||||
if item.set_menu_items.present?
|
||||
set_menu_items = JSON.parse(item.set_menu_items)
|
||||
item.set_menu_items = set_menu_items.map { |x| x["item_instance_name"] }
|
||||
item.price = item.price + set_menu_items.inject(0.0) { |sum, x| sum + x["item_instance_name"].to_f }
|
||||
end
|
||||
|
||||
arr_item = Hash.new
|
||||
if item.qty.to_i > 1
|
||||
i = 1
|
||||
while i <= item.qty.to_i do
|
||||
arr_item = {'order_items_id' => item.order_items_id,
|
||||
'order_id' => item.order_id,
|
||||
'order_item_status' => item.order_item_status,
|
||||
'item_order_by' => item.item_order_by,
|
||||
'item_code' => item.item_code,
|
||||
'item_instance_code' => item.item_instance_code,
|
||||
'item_name' => item.item_name,
|
||||
'alt_name' => item.alt_name,
|
||||
'account_id' => item.account_id,
|
||||
'qty' => '1.0',
|
||||
'price' => item.price,
|
||||
'remark' => item.remark,
|
||||
'options' => item.options,
|
||||
'set_menu_items' => item.set_menu_items,
|
||||
'taxable' => item.taxable,
|
||||
'completed_by' => item.completed_by,
|
||||
'created_at' => item.created_at,
|
||||
'updated_at' => item.updated_at}
|
||||
i += 1
|
||||
@order_items.push({@order.order_id => arr_item})
|
||||
arr_order_items.push(arr_item)
|
||||
end
|
||||
else
|
||||
arr_order_items.push(item)
|
||||
@order_items.push({@order.order_id => item})
|
||||
end
|
||||
end
|
||||
@order_items.push({'all_order' => arr_order_items})
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
@order_items += item.qty.to_i.times.map { i = item.as_json; i["qty"] = 1; order_items << i; { item.order_id => i } }
|
||||
end
|
||||
|
||||
@order_items << { 'all_order' => order_items }
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cashier_type = params[:cashier_type]
|
||||
dining_id = params[:dining_id]
|
||||
order_ids = params[:order_ids]
|
||||
arr_order_ids = nil
|
||||
if !params[:arr_order_ids].nil?
|
||||
arr_order_ids = JSON.parse(params[:arr_order_ids])
|
||||
end
|
||||
orders = nil
|
||||
if !params[:orders].empty?
|
||||
orders = JSON.parse(params[:orders])
|
||||
end
|
||||
order_items = nil
|
||||
if !params[:order_items].empty?
|
||||
order_items = JSON.parse(params[:order_items])
|
||||
end
|
||||
arr_order_ids = JSON.parse(params[:arr_order_ids]) if params[:arr_order_ids].present?
|
||||
orders = JSON.parse(params[:orders]) if params[:orders].present?
|
||||
order_items = JSON.parse(params[:order_items]) if params[:order_items].present?
|
||||
|
||||
status = false
|
||||
if !ShiftSale.current_shift.nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if !params[:booking_id].empty?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
# for Multiple Cashier by Zone
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
else
|
||||
table = nil
|
||||
cashier_zone = nil
|
||||
end
|
||||
#create Bill by Booking ID
|
||||
table = DiningFacility.find_by(id: params[:dining_id]) if params[:dining_id].present?
|
||||
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
||||
|
||||
if sale_data = booking.sale
|
||||
status = true
|
||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type,params[:current_checkin_induties_count])
|
||||
status = true
|
||||
Booking.transaction do
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
else
|
||||
status = false
|
||||
end
|
||||
else
|
||||
if params[:type] == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
type = "TableBooking" if params[:type] == "Table"
|
||||
type ||= "RoomBooking"
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
|
||||
:booking_status => "assign",
|
||||
:shop_code =>@shop.shop_code})
|
||||
split_orders = []
|
||||
new_order = nil
|
||||
|
||||
if !orders.nil?
|
||||
orders.each do |order|
|
||||
BookingOrder.find_by_order_id(order["id"]).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]})
|
||||
booking = Booking.create({:dining_facility_id => table.id, :type => type, :checkin_at => Time.now.utc, :checkin_by => current_user.name, :booking_status => "assign" })
|
||||
|
||||
if orders.present?
|
||||
split_orders += orders.map { |x| x["id"] }
|
||||
end
|
||||
elsif !order_items.nil?
|
||||
order_item_count = 0
|
||||
order_id_count = 0
|
||||
order_id = nil
|
||||
|
||||
arr_order_ids.each do |order|
|
||||
order.each do |odr|
|
||||
data = Order.find(odr[0])
|
||||
if data.order_items.count == odr[1]
|
||||
order_id = odr[0]
|
||||
order_id_count += 1
|
||||
if order_items.present?
|
||||
order_items = order_items.inject([]) do |arr, v|
|
||||
v["qty"] = v["qty"].to_i
|
||||
if i = arr.find { |x| x["id"] == v["id"] }
|
||||
i["qty"] = i["qty"] + v["qty"]
|
||||
else
|
||||
order_item_count += 1
|
||||
arr << v
|
||||
end
|
||||
arr
|
||||
end
|
||||
|
||||
Order.includes(:order_items).where(order_id: order_ids).each do |order|
|
||||
if order.order_items.any? { |x| order_items.none? { |y| x.order_items_id == y["id"] && x.qty == y["qty"] } }
|
||||
new_order ||= Order.create({ source: "cashier", order_type: order.order_type, customer_id: order.customer_id, item_count: order_items.length, waiters: current_user.name })
|
||||
order.order_items.each do |order_item|
|
||||
if split_item = order_items.find { |x| x["id"] == order_item.order_items_id }
|
||||
if split_item["qty"] == order_item.qty
|
||||
new_order.order_items << order_item
|
||||
else
|
||||
order_item.qty = order_item.qty - split_item["qty"]
|
||||
order_item.save
|
||||
order_item_dup = order_item.dup
|
||||
order_item_dup.qty = split_item["qty"]
|
||||
new_order.order_items << order_item_dup
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
split_orders << order
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if !order_id.nil?
|
||||
if order_id_count > 1
|
||||
|
||||
updated_order_id = Array.new
|
||||
arr_order_ids.each do |order|
|
||||
order.each do |odr|
|
||||
data = Order.find(odr[0])
|
||||
if data.order_items.count != odr[1]
|
||||
updated_order_id.push(odr[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if !updated_order_id.empty?
|
||||
order_ids.each do |odr_id|
|
||||
unless updated_order_id.include?(odr_id)
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
|
||||
order_items.each do |order_item|
|
||||
if updated_order_id.include?(order_item["order_id"])
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
order_ids.each do |odr_id|
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find_by_order_id(odr_id)
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
new_order_status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
new_order_status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(order_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if order_ids.count == 1 && order_item_count == 1
|
||||
if order_id_count == 0
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
else
|
||||
BookingOrder.find_by_order_id(order_ids[0]).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_ids[0], order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
if new_order.present?
|
||||
booking.orders << new_order
|
||||
end
|
||||
end
|
||||
|
||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
||||
status = true
|
||||
end
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale_data)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "bill_channel",table: table,from:from
|
||||
|
||||
render :json => { status: status }
|
||||
else
|
||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||
end
|
||||
end
|
||||
|
||||
def create_order(params,order_type,items_count,current_user)
|
||||
order = Order.new
|
||||
order.source = "cashier"
|
||||
order.order_type = order_type
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
order.item_count = items_count
|
||||
order.status = "new"
|
||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
||||
order.waiters = current_user.name
|
||||
order.employee_name = current_user.name
|
||||
order.guest_info = nil
|
||||
order.shop_code = @shop.shop_code
|
||||
order.save!
|
||||
|
||||
return order
|
||||
end
|
||||
|
||||
def update_order_item(order_id, order_item)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
set_menu_items_obj = Array.new
|
||||
if !orderItem.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(orderItem.set_menu_items)
|
||||
instance_item_sets.each_with_index do |instance_item, instance_index|
|
||||
instance_item_sets[instance_index]["quantity"] = (instance_item["quantity"].to_i - order_item['qty'].to_i).to_s
|
||||
set_menu_items_obj.push({'item_instance_code' => instance_item["item_instance_code"], 'quantity' => order_item['qty'].to_i, 'price' => instance_item["price"]})
|
||||
end
|
||||
orderItem.set_menu_items = instance_item_sets.to_json
|
||||
if split_orders.present?
|
||||
BookingOrder.where(order_id: split_orders).update_all(booking_id: booking.booking_id)
|
||||
end
|
||||
end
|
||||
|
||||
same_order = OrderItem.find_by_order_id(order_id)
|
||||
if same_order.nil?
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
orderItem.item_instance_code,
|
||||
orderItem.item_name,
|
||||
orderItem.alt_name,
|
||||
orderItem.account_id,
|
||||
order_item['qty'],
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
set_menu_items_obj.to_json,
|
||||
order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
else
|
||||
same_order.qty = same_order.qty.to_f + order_item['qty'].to_f
|
||||
same_order.set_menu_items = set_menu_items_obj.to_json
|
||||
same_order.save
|
||||
end
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order_id
|
||||
end
|
||||
orderItem.save!
|
||||
if booking.sale.nil?
|
||||
sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type, params[:current_checkin_induties_count])
|
||||
Promotion.promo_activate(sale_data)
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
|
||||
ActionCable.server.broadcast "bill_channel", table: table, from:from
|
||||
|
||||
render :json => { status: true }
|
||||
end
|
||||
else
|
||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||
end
|
||||
end
|
||||
|
||||
def update_sale
|
||||
|
||||
@@ -9,7 +9,7 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
if(@id[0,3] == "SAL")
|
||||
if @id.include? "SAL"
|
||||
@sale = Sale.find(@id)
|
||||
@receipt_no = @sale.receipt_no
|
||||
@grand_total = @sale.grand_total
|
||||
@@ -18,8 +18,8 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
if @booking.dining_facility_id.to_i>0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
|
||||
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
@@ -33,7 +33,7 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# set cashier
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
current_shift_user =Employee.find_by_id(current_user.employee_id)
|
||||
if open_cashier.count>0
|
||||
@@ -76,7 +76,6 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.shift_id = shift_by_terminal.id
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
@survey.shop_code = @shop.shop_code
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
redirect_to @url
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
shop = Shop.current_shop
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
|
||||
@@ -8,7 +9,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -31,36 +32,14 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale.grand_total)
|
||||
sale.rounding_adjustment = new_total-sale.grand_total
|
||||
sale.update_attributes(grand_total: new_total,old_grand_total: sale.grand_total,rounding_adjustment:sale.rounding_adjustment)
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != "waste" && sale.sale_status != "spoile"
|
||||
@sale_array.push(sale)
|
||||
end
|
||||
end
|
||||
end
|
||||
@sale_array = @table.current_sales
|
||||
|
||||
@sale = Sale.find(params[:invoice_id])
|
||||
@date = @sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@customer = @sale.customer
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
|
||||
@@ -21,7 +21,7 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -21,7 +21,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -72,7 +72,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
@@ -114,7 +114,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
@@ -122,7 +122,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -137,13 +137,13 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -7,7 +7,7 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
total = sale_data.grand_total
|
||||
@vouchercount = 0
|
||||
others = 0
|
||||
if @shop.is_rounding_adj
|
||||
if current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
|
||||
@@ -54,7 +54,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
|
||||
@@ -87,7 +87,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
@@ -95,7 +95,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -111,13 +111,13 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController
|
||||
# GET /print_settings/1
|
||||
# GET /print_settings/1.json
|
||||
def show
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
end
|
||||
|
||||
# GET /print_settings/new
|
||||
@@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# GET /print_settings/1/edit
|
||||
def edit
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
@server_mode = ENV["SERVER_MODE"]
|
||||
end
|
||||
|
||||
@@ -30,7 +30,6 @@ class PrintSettingsController < ApplicationController
|
||||
# POST /print_settings.json
|
||||
def create
|
||||
@print_setting = PrintSetting.new(print_setting_params)
|
||||
@print_setting.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @print_setting.save
|
||||
format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' }
|
||||
@@ -48,7 +47,7 @@ class PrintSettingsController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @print_setting.update(print_setting_params)
|
||||
if @print_setting.unique_code == 'CloseCashierPdf'
|
||||
Lookup.save_shift_sale_items_settings(params[:shift_sale_items],@shop.shop_code)
|
||||
Lookup.save_shift_sale_items_settings(params[:shift_sale_items])
|
||||
end
|
||||
|
||||
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }
|
||||
|
||||
@@ -6,7 +6,7 @@ class Reports::CommissionController < BaseReportController
|
||||
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.where("shop_code='#{@shop.shop_code}'")
|
||||
@commissioner = Commissioner.active
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
|
||||
@@ -23,7 +23,7 @@ class Reports::CommissionController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
|
||||
@@ -5,22 +5,22 @@ authorize_resource :class => false
|
||||
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@filter = params[:filter_check]
|
||||
@order_source = params[:order_source]
|
||||
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source,@shop.shop_code)
|
||||
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
@@ -7,7 +7,7 @@ class Reports::DailysaleController < BaseReportController
|
||||
@tax = SaleTax.get_tax(from,to)
|
||||
@from = from
|
||||
@to = to
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code=?",@shop.shop_code).pluck("payment_method")
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user