diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js
index 4aa0f1b0..ced5b3c2 100644
--- a/app/assets/javascripts/channels/check_new_order.js
+++ b/app/assets/javascripts/channels/check_new_order.js
@@ -19,21 +19,7 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', {
});
// alert(order_lists);
- // swal({
- // title: 'Information',
- // target: document.getElementById(shop_code+"_notify_new_order"),
- // text: "You have new orders
"+
- // "Are you accept or reject for these orders "+order_lists+"?",
- // type: 'success',
- // html: true,
- // closeOnConfirm: false,
- // closeOnCancel: false,
- // allowOutsideClick: false
- // }, function (isConfirm) {
- // if(isConfirm){
- // swal.close();
- // }
- // });
+ checkNewOrderAlert(shop_code, order_lists);
// $("#notify_new_order_lists").text(order_lists);
// if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){
// $("#"+shop_code+"_notify_new_order").removeClass("hidden");
diff --git a/app/assets/javascripts/channels/check_order_ready_to_delivery.js b/app/assets/javascripts/channels/check_order_ready_to_delivery.js
index dc406d5e..4ec3ea08 100644
--- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js
+++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js
@@ -19,21 +19,7 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe
});
// alert(order_lists);
- // swal({
- // title: 'Information',
- // target: document.getElementById(shop_code+"_notify_order_ready_to_delivery"),
- // text: "You have orders that are ready to deliver
"+
- // "Could you ready these orders "+order_lists+" to deliver?",
- // type: 'success',
- // html: true,
- // closeOnConfirm: false,
- // closeOnCancel: false,
- // allowOutsideClick: false
- // }, function (isConfirm) {
- // if(isConfirm){
- // swal.close();
- // }
- // });
+ checkOrderReadyToKitchenAlert(shop_code, order_lists);
// $("#notify_order_ready_to_delivery_lists").text(order_lists);
// if($("#notify_order_ready_to_delivery").hasClass("hidden")){
// $("#"+shop_code+"_notify_order_ready_to_delivery").removeClass("hidden");
diff --git a/app/assets/javascripts/channels/check_order_send_to_kitchen.js b/app/assets/javascripts/channels/check_order_send_to_kitchen.js
index 0d11207e..5e8751b1 100644
--- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js
+++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js
@@ -19,21 +19,7 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend
});
// alert(order_lists);
- // swal({
- // title: 'Information',
- // target: document.getElementById(shop_code+"_notify_order_send_to_kitchen"),
- // text: "You have to send order to kitchen
"+
- // "Could you send these orders "+order_lists+" to kitchen?",
- // type: 'success',
- // html: true,
- // closeOnConfirm: false,
- // closeOnCancel: false,
- // allowOutsideClick: false
- // }, function (isConfirm) {
- // if(isConfirm){
- // swal.close();
- // }
- // });
+ checkOrderSendToKitchen(shop_code, order_lists);
// $("#notify_order_send_to_kitchen_lists").text(order_lists);
// if($("#notify_order_send_to_kitchen").hasClass("hidden")){
// $("#"+shop_code+"_notify_order_send_to_kitchen").removeClass("hidden");
diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js
index ae8b727c..6d91f504 100644
--- a/app/assets/javascripts/custom.js
+++ b/app/assets/javascripts/custom.js
@@ -42,6 +42,15 @@ $(document).ready(function() {
railBorderRadius: '0',
touchScrollStep : 50
});
+ $('#menu1-slimscroll').slimScroll({
+ height: height-$('#menu1-slimscroll').attr('data-height'),
+ size: '5px',
+ color: 'rgba(0,0,0,0.5)',
+ alwaysVisible: false,
+ borderRadius: '0',
+ railBorderRadius: '0',
+ touchScrollStep : 50
+ });
$('#modal-slimscroll').slimScroll({
height: height-$('#modal-slimscroll').attr('data-height'),
@@ -148,3 +157,12 @@ $(document).ready(function() {
}
//end Notificaiotn message
});
+
+function audioPlayBackground(shop_code){
+ //audio play
+ var audio = new Audio('/'+shop_code+'-beep.mp3'); // define your audio
+ // setTimeout(function(){
+ // audio.loop = true;
+ audio.play();
+ // },10000);
+}
diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js
index 9284b889..fb210f6b 100644
--- a/app/assets/javascripts/order_reservation.js
+++ b/app/assets/javascripts/order_reservation.js
@@ -265,6 +265,7 @@ function show_order_detail(url,sr_no){
dataType: "json",
success: function(data) {
// console.log(data);
+ $("#order_remark").text("");
$(".tbl_customer").show();
if(data.status != "delivered"){
$('#accepted').show();
@@ -482,46 +483,81 @@ function showNewOrder(order_reservation,shop_code){
var date = new Date(order_reservation.requested_time);
var time = timeFormat(date);
var requested_date = date.getFullYear() + '-' + (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >= 10? date.getDate() : '0' + date.getDate()) +' '+time;
- //audio play
- var audio = new Audio('/'+shop_code+'-beep.mp3'); // define your audio
- // setTimeout(function(){
- // audio.loop = true;
- audio.play();
- // },10000);
+ $('.first-1').click();
+ audioPlayBackground(shop_code);
- // $("#new_order").text(order_reservation.order_reservation_id);
- // $("#new_order_date").text(requested_date);
- // if($("#"+shop_code+"_doemal_new_order").hasClass("hidden")){
- // $("#"+shop_code+"_doemal_new_order").removeClass("hidden");
- // }
- // $("#"+shop_code+"_doemal_new_order").on('shown.bs.modal', function(e){
- // // $(document).off('focusin.modal');
- // $("#"+shop_code+"_doemal_new_order").focus();
- // $("#"+shop_code+"_notify_new_order").addClass("hidden");
- // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
- // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
- // }).on('hide.bs.modal', function (e) {
- // $("#"+shop_code+"_doemal_new_order").addClass("hidden");
- // }).modal({show: true, keyboard: false, backdrop: false});
- // swal({
- // title: 'Information',
- // target: document.getElementById(shop_code+"_notify_new_order"),
- // text: "You have new order "+
- // ""+order_reservation.order_reservation_id+" requested for "+requested_date+"?",
- // type: 'success',
- // html: true,
- // closeOnConfirm: false,
- // closeOnCancel: false,
- // allowOutsideClick: false
- // }, function (isConfirm) {
- // if(isConfirm){
- // audio.pause();
- // swal.close();
- // }
- // });
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_new_order"),
+ text: "You have new order "+
+ ""+order_reservation.order_reservation_id+" requested for "+requested_date+"?",
+ type: 'success',
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function (isConfirm) {
+ if(isConfirm){
+ swal.close();
+ }
+ });
}
}
+function checkNewOrderAlert(shop_code, order_lists){
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_new_order"),
+ text: "You have new orders
"+
+ "Are you accept or reject for these orders "+order_lists+"?",
+ type: 'success',
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function (isConfirm) {
+ if(isConfirm){
+ swal.close();
+ }
+ });
+}
+
+function checkOrderSendToKitchen(shop_code, order_lists){
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_order_send_to_kitchen"),
+ text: "You have to send order to kitchen
"+
+ "Could you send these orders "+order_lists+" to kitchen?",
+ type: 'success',
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function (isConfirm) {
+ if(isConfirm){
+ swal.close();
+ }
+ });
+}
+
+function checkOrderReadyToKitchenAlert(shop_code, order_lists){
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_order_ready_to_delivery"),
+ text: "You have orders that are ready to deliver
"+
+ "Could you ready these orders "+order_lists+" to deliver?",
+ type: 'success',
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function (isConfirm) {
+ if(isConfirm){
+ swal.close();
+ }
+ });
+}
+
function getOrderMonth(month){
var MONTHS = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"];
return MONTHS[month];
diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb
index 1bb257de..a7929653 100644
--- a/app/controllers/api/order_reserve/order_reservation_controller.rb
+++ b/app/controllers/api/order_reserve/order_reservation_controller.rb
@@ -18,7 +18,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
end
if status
- check_customer = Customer.find_by_email_and_membership_id(params[:email],params[:membership_id])
+ check_customer = Customer.find_by_email_and_membership_id_and_customer_type(params[:email],params[:membership_id],'Doemal')
if !check_customer.nil?
customer_id = check_customer.customer_id
else
diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb
index 04480864..27fe327d 100644
--- a/app/controllers/api/survey_controller.rb
+++ b/app/controllers/api/survey_controller.rb
@@ -18,8 +18,8 @@ class Api::SurveyController < Api::ApiController
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)
- if params[:survey_id]
- survey = Survey.find(params[:survey_id])
+ if params[:id]
+ survey = Survey.find(params[:id])
else
survey = Survey.new
end
diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb
index e8f0edb5..73458b82 100644
--- a/app/controllers/oqs/edit_controller.rb
+++ b/app/controllers/oqs/edit_controller.rb
@@ -39,8 +39,10 @@ class Oqs::EditController < BaseOqsController
if ENV["SERVER_MODE"] != "cloud" && order.source == 'cashier' #no print in cloud server
# print
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
- assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
-
+ assigned_items = nil
+ if !assigned_item.nil?
+ assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
+ end
if !assigned_items.nil?
assigned_items.each do |assign_item|
# order queue stations
diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb
index 441cd94e..030b56e1 100755
--- a/app/controllers/origami/cash_ins_controller.rb
+++ b/app/controllers/origami/cash_ins_controller.rb
@@ -8,10 +8,34 @@ class Origami::CashInsController < BaseOrigamiController
amount = params[:amount]
payment_method = params[:payment_method]
payment_method_reference = params[:payment_method_reference]
+ type = params[:type]
p_jour = PaymentJournal.new
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id)
shift = ShiftSale.current_open_shift(current_user.id)
- shift.cash_in = shift.cash_in + amount.to_i
+
+ current_shift = ShiftSale.current_shift
+
+ # set cashier
+ if shift != nil
+ shift = shift
+ else
+ open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
+ if open_cashier.count>0
+
+ shift = ShiftSale.current_open_shift(open_cashier[0].id)
+
+ if shift
+ shift = ShiftSale.current_open_shift(shift.id)
+ else
+ shift = ShiftSale.current_open_shift(current_shift.id)
+ end
+ else
+ shift = Employee.find(current_shift.employee_id).name
+
+ end
+ end
+
+ shift.cash_in = shift.cash_in + amount.to_f
shift.save
end
diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb
index 8c81b5cb..d3716915 100755
--- a/app/controllers/origami/cash_outs_controller.rb
+++ b/app/controllers/origami/cash_outs_controller.rb
@@ -9,6 +9,28 @@ class Origami::CashOutsController < BaseOrigamiController
p_jour = PaymentJournal.new
p_jour.cash_out(reference, remark, amount, current_user.id)
shift = ShiftSale.current_open_shift(current_user.id)
+
+ current_shift = ShiftSale.current_shift
+
+ # set cashier
+ if shift != nil
+ shift = shift
+ else
+ open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
+ if open_cashier.count>0
+
+ shift = ShiftSale.current_open_shift(open_cashier[0].id)
+
+ if shift
+ shift = ShiftSale.current_open_shift(shift.id)
+ else
+ shift = ShiftSale.current_open_shift(current_shift.id)
+ end
+ else
+ shift = Employee.find(current_shift.employee_id).name
+
+ end
+ end
shift.cash_out = shift.cash_out + amount.to_i
shift.save
end
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 7df42118..045afafb 100755
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -6,7 +6,7 @@ class Origami::PaymentsController < BaseOrigamiController
def first_bill
sale_id = params[:sale_id] # sale_id
sale_data = Sale.find_by_sale_id(sale_id)
- sale_items = SaleItem.unscoped.select("sale_id,product_code,item_instance_code,product_name,product_alt_name,account_id,status,remark,SUM(qty) as qty,SUM(unit_price) as unit_price,SUM(taxable_price) as taxable_price,SUM(price) as price,is_taxable").where("sale_id=?",sale_id).group("item_instance_code,unit_price")
+ sale_items = SaleItem.get_all_sale_items(sale_id)
member_info = nil
# For Cashier by Zone
@@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
- sale_items = SaleItem.unscoped.select("sale_id,product_code,item_instance_code,product_name,product_alt_name,account_id,status,remark,SUM(qty) as qty,SUM(unit_price) as unit_price,SUM(taxable_price) as taxable_price,SUM(price) as price,is_taxable").where("sale_id=?",sale_id).group("item_instance_code,unit_price")
+ sale_items = SaleItem.get_all_sale_items(sale_id)
shop_details = Shop.first
# rounding adjustment
if shop_details.is_rounding_adj
@@ -335,10 +335,13 @@ class Origami::PaymentsController < BaseOrigamiController
end
@sale_data.sale_payments.each do |spay|
- if spay.payment_method == "cash"
+ if spay.payment_method == "cash"
@cash = spay.payment_amount
end
- @other_payment += spay.payment_amount
+ if spay.payment_method !="creditnote"
+ @other_payment += spay.payment_amount
+ end
+
if spay.payment_method == "mpu"
@other += spay.payment_amount
elsif spay.payment_method == "paypar"
diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb
index 4fa6002b..d6230993 100644
--- a/app/controllers/origami/pending_order_controller.rb
+++ b/app/controllers/origami/pending_order_controller.rb
@@ -62,7 +62,13 @@ class Origami::PendingOrderController < BaseOrigamiController
@table_id = nil
@dining = nil
end
+ end
+ def cash_ins
+ render "origami/cash_ins/new"
+ end
+ def cash_outs
+ render "origami/cash_outs/new"
end
end
diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb
index eee75e37..6f4980cc 100755
--- a/app/controllers/origami/sales_controller.rb
+++ b/app/controllers/origami/sales_controller.rb
@@ -41,7 +41,7 @@ class Origami::SalesController < BaseOrigamiController
end
# Re-compute for add
- saleobj.compute
+ saleobj.compute(order.source)
saleobj.save
order.save
booking.save
diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb
index 5d9aa923..45676492 100755
--- a/app/controllers/origami/void_controller.rb
+++ b/app/controllers/origami/void_controller.rb
@@ -29,6 +29,7 @@ class Origami::VoidController < BaseOrigamiController
end
end
+ sale.rounding_adjustment = 0.0
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
@@ -114,7 +115,8 @@ class Origami::VoidController < BaseOrigamiController
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
- current_balance = SaleAudit.paymal_search(sale_id)
+ # current_balance = SaleAudit.paymal_search(sale_id)
+ current_balance = 0
end
# get printer info
diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb
index aa1dd8bd..2e43da0b 100755
--- a/app/controllers/reports/receipt_no_controller.rb
+++ b/app/controllers/reports/receipt_no_controller.rb
@@ -5,18 +5,25 @@ authorize_resource :class => false
from, to = get_date_range_from_params
- @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
+ @shift_sale_range = ''
@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 ',shift_sale.shift_started_at)
- else
- @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
+ @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
+
+ @shift_sale = ShiftSale.find(params[:shift_name])
+ if to.blank?
+ @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
+ else
+ if @shift_sale.shift_closed_at.blank?
+ @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 = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
+ end
end
end
+
payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
@@ -42,18 +49,18 @@ authorize_resource :class => false
def show
from, to = get_date_range_from_params
- @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
+ @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
- date_arr = Array.new
- @sale_data.each do |sale|
- local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
- local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
- opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
- closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
- shift_id = sale.id.nil? ? '-' : sale.id
- str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
- date_arr.push(str)
- end
+ date_arr = Array.new
+ @sale_data.each do |sale|
+ local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
+ local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
+ opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
+ closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
+ shift_id = sale.id.nil? ? '-' : sale.id
+ str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
+ date_arr.push(str)
+ end
out = {:status => 'ok', :message => date_arr}
diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb
index 21ca498b..300e1079 100755
--- a/app/controllers/reports/shiftsale_controller.rb
+++ b/app/controllers/reports/shiftsale_controller.rb
@@ -28,7 +28,7 @@ class Reports::ShiftsaleController < BaseReportController
def show
from, to = get_date_range_from_params
- @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
+ @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
diff --git a/app/models/order.rb b/app/models/order.rb
index 01a7b583..66ac883f 100755
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -285,13 +285,18 @@ class Order < ApplicationRecord
#Process order items and send to order queue
def process_order_queue
- if ENV["SERVER_MODE"] != 'cloud'
+ print_status = nil
+ cup_status = nil
+
#Send to background job for processing
order = Order.find(self.id)
- cup_status = `#{"sudo service cups status"}`
- print_status = check_cup_status(cup_status)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
-
+
+ if ENV["SERVER_MODE"] != 'cloud'
+ cup_status = `#{"sudo service cups status"}`
+ print_status = check_cup_status(cup_status)
+ end
+
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
@@ -304,9 +309,11 @@ class Order < ApplicationRecord
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
- cup_start = `#{"sudo service cups start"}`
- cup_status = `#{"sudo service cups status"}`
- print_status = check_cup_status(cup_status)
+ 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?
@@ -320,33 +327,28 @@ class Order < ApplicationRecord
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
- msg = ' Print Error ! Please contact to service'
- #if ENV["SERVER_MODE"] != 'cloud'
+ if ENV["SERVER_MODE"] != 'cloud'
+
+ msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
- #end
- if !sidekiq.nil?
+ end
+ if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
- else
- if order
- oqs = OrderQueueStation.new
- oqs.process_order(order, self.table_id, self.source)
- end
- # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
- # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
- end
+ else
+ if order
+ oqs = OrderQueueStation.new
+ oqs.process_order(order, self.table_id, self.source)
+ end
+ assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
+ ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
+ end
end
end
- assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
- #if ENV["SERVER_MODE"] != 'cloud'
- ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
- #end
- end
-
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
- if ENV["SERVER_MODE"] != 'cloud'
+ # if ENV["SERVER_MODE"] != 'cloud'
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(id, table_id)
@@ -359,7 +361,7 @@ class Order < ApplicationRecord
assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
- end
+ # end
end
def check_cup_status(status)
diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb
index d0fab31a..057f6f9b 100644
--- a/app/models/order_reservation.rb
+++ b/app/models/order_reservation.rb
@@ -30,10 +30,19 @@ class OrderReservation < ApplicationRecord
customer.address = params[:address] ? params[:address] : ''
customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : ''
customer.membership_id = params[:membership_id]
- customer.customer_type = "Takeaway"
+ customer.customer_type = "Doemal"
customer.tax_profiles = ["2"]
customer.save
+ # unless customer.valid?
+ # render json: {
+ # status: 422,
+ # message: "Validation error",
+ # errors: customer.errors
+ # }.to_json
+ # return
+ # end
+
return customer
end
@@ -62,7 +71,7 @@ class OrderReservation < ApplicationRecord
end
if order_reserve[:reservation_info]
order_reservation.total_customer = order_reserve[:reservation_info][:total_user]
- order_reservation.order_remark = order_reserve[:reservation_info][:reservation_note]
+ # order_reservation.order_remark = order_reserve[:reservation_info][:reservation_note]
end
order_reservation.save!
if order_reserve[:order_info][:items]
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 9e621737..6803e8f2 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -752,7 +752,7 @@ def self.daily_sales_list(from,to)
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
- .joins("join (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sale_payments on sale_payments.sale_id = sales.sale_id")
+ .joins(" left join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sale_status = ? AND sales.receipt_date between ? and ? ", 'completed', from, to)
.group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
@@ -2692,6 +2692,7 @@ end
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
.joins("join orders as orders on orders.order_id = sale_orders.order_id")
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service")
+ query = query.where("DATE_FORMAT(sales.created_at,'%Y-%m-%d') = ? ",DateTime.now.strftime('%Y-%m-%d'))
.group("sales.sale_id")
end
diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb
index d01ee5e0..313be6a3 100755
--- a/app/models/sale_item.rb
+++ b/app/models/sale_item.rb
@@ -161,6 +161,20 @@ class SaleItem < ApplicationRecord
# return price
# end
+ def self.get_all_sale_items(sale_id)
+ sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
+ product_name,product_alt_name,account_id,status,remark,
+ (CASE WHEN qty > 0 AND remark IS NULL THEN SUM(qty) ELSE qty END) as qty,
+ unit_price,
+ taxable_price,
+ (CASE WHEN price > 0 AND remark IS NULL THEN SUM(price) ELSE price END) as price,
+ is_taxable")
+ .where("sale_id = ?",sale_id)
+ .order("product_name asc")
+ .group("status,product_name,item_instance_code,unit_price")
+ return sale_items
+ end
+
private
def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb
index 78b27e3f..08caf1b8 100644
--- a/app/pdf/receipt_bill_a5_pdf.rb
+++ b/app/pdf/receipt_bill_a5_pdf.rb
@@ -207,7 +207,9 @@ class ReceiptBillA5Pdf < Prawn::Document
# check for item not to show
if item.price != 0
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
- total_qty += item.qty
+ if item.status != 'Discount' && item.qty > 0
+ total_qty += item.qty
+ end
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index 59e6a320..5c1f8c01 100755
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -201,7 +201,9 @@ class ReceiptBillPdf < Prawn::Document
# check for item not to show
if item.price != 0
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
- total_qty += item.qty
+ if item.status != 'Discount' && item.qty > 0
+ total_qty += item.qty
+ end
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 65ea665b..38d30fa8 100644
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -29,7 +29,7 @@
<%end%>
-
| <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%> | +<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to ? @to.utc.getlocal.strftime("%Y-%b-%d") : '-'%> | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| <%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> - - <%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %> + <%= result[:shift_closed_at] ? result[:shift_closed_at].strftime("%e %b %I:%M%p") : '-' %> | <%= number_with_precision(result[:cash_sales].to_f, precision:precision.to_i,delimiter:delimiter) %> | diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 9cab82a5..049ca8c9 100755 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -67,8 +67,8 @@||||||||||||||||
| <%=s.product_name rescue ' '%> | <%=s.qty rescue ' '%> | -<%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%> | -<%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%> | +<%= number_with_precision(s.unit_price, :precision => 2, :delimiter => ',') rescue ' '%> | +<%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%> | <%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %> | <%=s.remark rescue ' '%> | ||||||||||