update existin order
This commit is contained in:
@@ -1323,7 +1323,7 @@ end
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -1378,7 +1378,7 @@ end
|
||||
query = query.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -1422,7 +1422,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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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)
|
||||
@@ -1452,7 +1452,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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', '+06:30'), '%I %p')")
|
||||
@@ -1483,7 +1483,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' or sp.payment_method='giftvoucher') THEN 'card' ELSE sp.payment_method END)","e.name")
|
||||
.order("e.name")
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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?
|
||||
@@ -1516,7 +1516,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' or sp.payment_method='giftvoucher') THEN 'card' ELSE sp.payment_method END)","e.name")
|
||||
.order("e.name")
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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}'")
|
||||
@@ -1545,7 +1545,7 @@ end
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").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)
|
||||
else
|
||||
@@ -1566,7 +1566,7 @@ end
|
||||
if current_user.nil?
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@@ -1591,7 +1591,7 @@ end
|
||||
.sum("sp.payment_amount")
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -1622,7 +1622,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -1651,7 +1651,7 @@ end
|
||||
.sum("payment_amount")
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -1682,7 +1682,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -1711,7 +1711,7 @@ end
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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)
|
||||
@@ -1742,7 +1742,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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") = ?',today)
|
||||
.first()
|
||||
@@ -1771,7 +1771,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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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)
|
||||
@@ -1802,7 +1802,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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") = ?',today)
|
||||
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||
@@ -1843,7 +1843,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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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'
|
||||
@@ -1956,7 +1956,7 @@ end
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
@@ -2025,7 +2025,7 @@ end
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -2057,7 +2057,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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(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)
|
||||
@@ -2088,7 +2088,7 @@ end
|
||||
# .first()
|
||||
# end
|
||||
# else
|
||||
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
# 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?
|
||||
@@ -2120,7 +2120,7 @@ end
|
||||
# .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' || current_user.role == 'account'
|
||||
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
# 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(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)
|
||||
@@ -2152,7 +2152,7 @@ end
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -2187,7 +2187,7 @@ end
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -2219,7 +2219,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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -2249,7 +2249,7 @@ end
|
||||
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||
.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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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")
|
||||
@@ -2280,7 +2280,7 @@ end
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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?
|
||||
@@ -2312,7 +2312,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' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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)
|
||||
@@ -2344,7 +2344,7 @@ end
|
||||
.order("SUM(a.qty) DESC")
|
||||
.first()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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?
|
||||
@@ -2380,7 +2380,7 @@ end
|
||||
.order("SUM(a.qty) DESC")
|
||||
.first()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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)
|
||||
@@ -2414,7 +2414,7 @@ end
|
||||
.count()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
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.status='foc' and a.product_name 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)
|
||||
@@ -2443,7 +2443,7 @@ end
|
||||
.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
.count()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
.count()
|
||||
|
||||
Reference in New Issue
Block a user