diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js
index ced5b3c2..f4d4aa9f 100644
--- a/app/assets/javascripts/channels/check_new_order.js
+++ b/app/assets/javascripts/channels/check_new_order.js
@@ -19,7 +19,9 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', {
});
// alert(order_lists);
- checkNewOrderAlert(shop_code, order_lists);
+ if (typeof checkNewOrderAlert !== 'undefined' && $.isFunction(checkNewOrderAlert)) {
+ 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 4ec3ea08..3f7f53b1 100644
--- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js
+++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js
@@ -19,7 +19,9 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe
});
// alert(order_lists);
- checkOrderReadyToKitchenAlert(shop_code, order_lists);
+ if (typeof checkOrderReadyToKitchenAlert !== 'undefined' && $.isFunction(checkOrderReadyToKitchenAlert)) {
+ 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 5e8751b1..892e0590 100644
--- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js
+++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js
@@ -19,7 +19,9 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend
});
// alert(order_lists);
- checkOrderSendToKitchen(shop_code, order_lists);
+ if (typeof checkOrderSendToKitchen !== 'undefined' && $.isFunction(checkOrderSendToKitchen)) {
+ 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/order_reservation.js b/app/assets/javascripts/order_reservation.js
index fb210f6b..1a1e6e64 100644
--- a/app/assets/javascripts/order_reservation.js
+++ b/app/assets/javascripts/order_reservation.js
@@ -308,13 +308,26 @@ function show_order_detail(url,sr_no){
item_price = items[i].unit_price;
}
var total = items[i].qty * item_price;
+ if(items[i].options!='[]'){
+ row = '
'
+ +''+items[i].item_name
+ +' '
+ +' '+items[i].options+' '+
+ ''+items[i].qty+ ' X'+items[i].unit_price+''
+ +' | '
+ +''+ total +' | '
+ +'
';
+ }else{
row = ''
- +''+items[i].item_name
- +' '+items[i].qty+ ' X'+items[i].unit_price+''
- +' | '
- +''+ total +' | '
- +'
';
- $('.summary-items').append(row);
+ +''+items[i].item_name
+ +' '+
+ ''+items[i].qty+ ' X'+items[i].unit_price+''
+ +' | '
+ +''+ total +' | '
+ +'';
+ }
+
+ $('.summary-items').append(row);
}
if(data.discount_amount > 0){
@@ -565,5 +578,5 @@ function getOrderMonth(month){
function getOrderDay(day){
var DAYS = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
- return DAYS[day];
+ return DAYS[day - 1];
}
\ No newline at end of file
diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb
index 0f27567a..b9b2c5d4 100755
--- a/app/controllers/origami/sale_edit_controller.rb
+++ b/app/controllers/origami/sale_edit_controller.rb
@@ -52,7 +52,7 @@ class Origami::SaleEditController < BaseOrigamiController
end
# FOr Sale Audit
action_by = current_user.name
- if access_code != "null"
+ if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
@@ -88,7 +88,7 @@ class Origami::SaleEditController < BaseOrigamiController
order = Order.find(order_id)
action_by = current_user.name
- if access_code != "null"
+ if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
@@ -132,7 +132,7 @@ class Origami::SaleEditController < BaseOrigamiController
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
action_by = current_user.name
- if access_code != "null"
+ if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "Update Qty #{update_qty} Price [#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
@@ -185,7 +185,7 @@ class Origami::SaleEditController < BaseOrigamiController
order = Order.find(order_id)
action_by = current_user.name
- if access_code != "null"
+ if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb
index 45676492..891cd398 100755
--- a/app/controllers/origami/void_controller.rb
+++ b/app/controllers/origami/void_controller.rb
@@ -73,7 +73,7 @@ class Origami::VoidController < BaseOrigamiController
# FOr Sale Audit
action_by = current_user.name
- if access_code != "null"
+ if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb
index 9cfde698..d008a54d 100755
--- a/app/controllers/origami/waste_spoile_controller.rb
+++ b/app/controllers/origami/waste_spoile_controller.rb
@@ -55,7 +55,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
# FOr Sale Audit
action_by = current_user.name
- if access_code != "null"
+ if access_code != "null" && current_user.role == "cashier"
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}"
diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb
index 057f6f9b..0b4ccc77 100644
--- a/app/models/order_reservation.rb
+++ b/app/models/order_reservation.rb
@@ -53,7 +53,7 @@ class OrderReservation < ApplicationRecord
order_reservation = OrderReservation.new
order_reservation.order_reservation_type = order_reserve[:order_type]
order_reservation.customer_id = order_reserve[:cus_info]
- order_reservation.requested_time = Time.parse(order_reserve[:requested_time]).utc
+ order_reservation.requested_time = Time.zone.parse(order_reserve[:requested_time]).utc
order_reservation.callback_url = order_reserve[:callback_url]
order_reservation.transaction_ref = order_reserve[:reference]
if order_reserve[:order_info]
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 6803e8f2..1441c759 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -1295,7 +1295,7 @@ end
query = query.group('mi.name')
.order("SUM(i.qty) DESC").limit(20)
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
" i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
@@ -1336,7 +1336,7 @@ end
.group('mi.name')
.order("SUM(i.qty) DESC").limit(20)
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
" i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
@@ -1376,7 +1376,7 @@ end
query = query.group('mi.name')
.order("SUM(i.qty) ASC").limit(20)
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
" i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
@@ -1417,7 +1417,7 @@ end
.group('mi.name')
.order("SUM(i.qty) ASC").limit(20)
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
" i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
@@ -1453,7 +1453,7 @@ end
query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
.order('receipt_date')
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("grand_total")
if !from_time.nil? && !to_time.nil?
query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time)
@@ -1471,7 +1471,7 @@ end
else
query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id)
end
- query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
+ query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date')
end
end
@@ -1480,20 +1480,20 @@ end
if current_user.nil?
query = Sale.select("grand_total")
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
- .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
+ .group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date')
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("grand_total")
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
- .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
+ .group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date')
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("grand_total")
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id)
- .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
+ .group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date')
end
end
@@ -1514,7 +1514,7 @@ end
query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name")
.order("e.name")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
if !from_time.nil? && !to_time.nil?
@@ -1547,7 +1547,7 @@ end
.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name")
.order("e.name")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
@@ -1576,7 +1576,7 @@ end
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to).sum("grand_total")
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).sum("grand_total")
else
@@ -1597,14 +1597,14 @@ end
end
else
if current_user.nil?
- total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
+ total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today).sum("grand_total")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
- total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
+ total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today).sum("grand_total")
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
- total = Sale.where('sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id)
+ total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id)
.sum("grand_total")
end
end
@@ -1621,7 +1621,7 @@ end
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',from,to).count
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).count
else
@@ -1640,14 +1640,14 @@ end
end
else
if current_user.nil?
- total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
+ total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',today,today).count
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
- total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
+ total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',today,today).count
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
- total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id = ?',today,shift.id).count
+ total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id = ?',today,today,shift.id).count
end
end
end
@@ -1667,7 +1667,7 @@ end
.sum("sp.payment_amount")
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
@@ -1694,18 +1694,18 @@ end
end
else
if current_user.nil?
- query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today)
+ query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
- query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today)
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
+ query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount")
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
- query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',today,shift.id)
+ query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',today,today,shift.id)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount")
end
@@ -1727,7 +1727,7 @@ end
.sum("payment_amount")
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
@@ -1754,18 +1754,18 @@ end
end
else
if current_user.nil?
- query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
+ query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
- query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
+ query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount")
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
- query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ? and s.shift_sale_id=?',today,shift.id)
+ query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and s.shift_sale_id=?',today,today,shift.id)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount")
end
@@ -1787,7 +1787,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
@@ -1815,18 +1815,18 @@ end
else
if current_user.nil?
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
- .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
+ .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
- .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
+ .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
- .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id)
+ .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id)
.first()
end
end
@@ -1847,7 +1847,7 @@ end
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
@@ -1875,18 +1875,18 @@ end
else
if current_user.nil?
query = Sale.select("distinct sp.payment_method")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("distinct sp.payment_method")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("distinct sp.payment_method")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
end
end
@@ -1919,7 +1919,7 @@ end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card'
@@ -1970,7 +1970,7 @@ end
end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card'
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today)
@@ -2022,7 +2022,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
@@ -2055,20 +2055,20 @@ end
if current_user.nil?
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
.first()
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
.first()
end
end
@@ -2091,7 +2091,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.select("count(sales.customer_id) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
@@ -2124,20 +2124,20 @@ end
if current_user.nil?
query = Sale.select("count(sales.customer_id) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(sales.customer_id) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
.first()
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("count(sales.customer_id) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
.first()
end
end
@@ -2160,7 +2160,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if !from_time.nil? && !to_time.nil?
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
@@ -2189,20 +2189,20 @@ end
if current_user.nil?
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
.first()
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null)) and sales.shift_sale_id=?',today,shift.id)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null)) and sales.shift_sale_id=?',today,shift.id)
.first()
end
end
@@ -2223,7 +2223,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
if !from_time.nil? && !to_time.nil?
@@ -2252,20 +2252,20 @@ end
if current_user.nil?
query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
.first()
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
.first()
end
end
@@ -2287,7 +2287,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id")
@@ -2319,14 +2319,14 @@ end
query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id")
- .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
+ .where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id")
- .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
+ .where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
else
shift = ShiftSale.current_open_shift(current_user.id)
@@ -2334,7 +2334,7 @@ end
query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id")
- .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
+ .where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
.first()
end
end
@@ -2354,7 +2354,7 @@ end
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
@@ -2382,20 +2382,20 @@ end
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
else
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
end
end
end
@@ -2415,7 +2415,7 @@ end
.first()
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
if !from_time.nil? && !to_time.nil?
@@ -2447,7 +2447,7 @@ end
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
@@ -2479,7 +2479,7 @@ end
.order("SUM(a.qty) DESC")
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
if !from_time.nil? && !to_time.nil?
@@ -2515,7 +2515,7 @@ end
.order("SUM(a.qty) DESC")
.first()
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
@@ -2549,7 +2549,7 @@ end
.sum("a.qty")
end
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
if !from_time.nil? && !to_time.nil?
query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
@@ -2578,7 +2578,7 @@ end
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.sum("a.qty")
else
- if current_user.role == 'administrator' || current_user.role == 'manager'
+ if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.sum("a.qty")
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index 865202b0..6131e656 100755
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -119,7 +119,7 @@
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'cashier' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'cashier' %>
<% if !@summ_sale.nil? %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %>
<% end %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% else %>
@@ -298,11 +298,11 @@
<% end %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% else %>
@@ -349,7 +349,7 @@
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %>
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %>
<% end %>
diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb
index b84bca54..e0eb7455 100644
--- a/config/initializers/action_controller.rb
+++ b/config/initializers/action_controller.rb
@@ -20,11 +20,11 @@ class ActionController::Base
end
else
#check for license file
- # if check_license
- # current_license(ENV["SX_PROVISION_URL"])
- # else
- # redirect_to activate_path
- # end
+ if check_license
+ current_license(ENV["SX_PROVISION_URL"])
+ else
+ redirect_to activate_path
+ end
end
end