From 978e7b7e07a5d695255c2462fa6f5417bf1cf5c3 Mon Sep 17 00:00:00 2001
From: Myat Zin Wai Maw
Date: Tue, 4 Feb 2020 17:47:06 +0630
Subject: [PATCH] transaction sales
---
Gemfile | 2 +-
app/assets/stylesheets/application.scss | 51 +++++++++++++++++++
.../transactions/sales_controller.rb | 37 +++++++-------
app/models/ability.rb | 3 +-
app/models/sale.rb | 4 +-
app/views/layouts/_header.html.erb | 2 +-
app/views/shared/_breadcrumb.html.erb | 2 +-
.../transactions/bookings/index.html.erb | 2 +-
app/views/transactions/orders/index.html.erb | 3 +-
app/views/transactions/sales/index.html.erb | 3 +-
app/views/transactions/sales/show.html.erb | 4 +-
11 files changed, 80 insertions(+), 33 deletions(-)
diff --git a/Gemfile b/Gemfile
index 3c72eab1..0f13a68e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
-ruby '2.4.1'
+ruby '2.6.5'
#ruby '2.5.7'
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index ee797cf8..864c548e 100755
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -236,3 +236,54 @@ i.logout_icon{
.input-group-addon {
margin-bottom: 20px;
}
+.access_number{
+ width: 33%;
+ height:58px;
+ line-height:58px;
+ text-align:center;
+ background:#54A5AF;
+ // float:left;
+ // margin:2px;
+ font-size:20px;
+ color:white;
+ // cursor:pointer;
+}
+.border-top{
+ border-top:1px solid #fff;
+}
+
+.border-right{
+ border-right:1px solid #fff;
+}
+
+.border-left{
+ border-left:1px solid #fff;
+}
+.bottom{
+ margin-bottom:1px;
+}
+
+/* Colors */
+.purple {
+ background-color:#7a62d3;
+}
+
+.orange{
+ background-color:#FF7F50;
+}
+
+.red {
+ background-color:#F44336;
+}
+
+.green{
+ background-color: #009900;
+}
+
+.orange{
+ background-color: #FF8C00;
+}
+
+.blue{
+ background-color: blue;
+}
diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb
index 1326e6bf..6c8cb07f 100755
--- a/app/controllers/transactions/sales_controller.rb
+++ b/app/controllers/transactions/sales_controller.rb
@@ -6,31 +6,30 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales
# GET /transactions/sales.json
def index
-
+ sale =nil
receipt_no = params[:receipt_no]
- # from = params[:from]
- # to = params[:to]
- from, to = get_date_range_from_params
- @shift = ''
+ from = params[:from]
+ to = params[:to]
if params[:shift_name].to_i != 0
- @shift = ShiftSale.find(params[:shift_name])
+ @shift = ShiftSale.find(params[:shift_name])
end
-
- if receipt_no.nil? && from.nil? && to.nil?
+ if params[:period].blank? && from.blank? && to.blank?
if @shift.blank?
- @sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
- else
- @sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
+ if current_user.role =="cashier"
+ @shift =ShiftSale.current_open_shift(current_user)
+ end
end
- @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
else
- sale = Sale.search(receipt_no,from,to,@shift)
- if sale.count > 0
- @sales = sale
- @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
- else
- @sales = 0
- end
+ from, to = get_date_range_from_params
+ end
+ sale = Sale.search(receipt_no,from,to,@shift)
+ if !sale.nil?
+ if sale.count > 0
+ @sales = sale
+ @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
+ else
+ @sales = 0
+ end
end
@receipt_no = receipt_no
@from = from
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 5b74c312..a22a68f0 100755
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -153,7 +153,7 @@ class Ability
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
- can :member_discount, :discount
+ can :member_discount, :discount
can :first_bill, :payment
can :show, :payment
@@ -205,6 +205,7 @@ class Ability
can :overall_void, :void
can :manage, Sale
+ can :show, :receipt_no
elsif user.role == "account"
diff --git a/app/models/sale.rb b/app/models/sale.rb
index f1d13222..385700ac 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -704,14 +704,14 @@ class Sale < ApplicationRecord
if shift.blank?
sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(receipt_date,'%Y-%m-%d') <= ? and NOT sale_status = 'new' ", from,to)
else
- sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(receipt_date,'%Y-%m-%d') <= ? and NOT sale_status = 'new' and shift_sale_id = '#{shift.id}'", from,to)
+ sale = Sale.where("(DATE_FORMAT(receipt_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(receipt_date,'%Y-%m-%d') <= ? and NOT sale_status = 'new') and shift_sale_id = '#{shift.id}'", from,to)
end
query = sale.where(keyword)
else
if shift.blank?
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%")
else
- where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}' and shift_sale_id = ?","%#{filter}%","%#{filter}%",shift.id)
+ where("(receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}') and shift_sale_id = ?","%#{filter}%","%#{filter}%",shift.id)
end
end
.order("sale_id DESC")
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index 49cbd58f..8fbe48b5 100755
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -162,7 +162,7 @@
<%food_court = Lookup.find_by_lookup_type_and_value("food_court", "1")%>
- <% if food_court %>
+ <% if food_court && ShiftSale.current_open_shift(current_user)%>
close
diff --git a/app/views/shared/_breadcrumb.html.erb b/app/views/shared/_breadcrumb.html.erb
index e6077dcf..ca178e57 100644
--- a/app/views/shared/_breadcrumb.html.erb
+++ b/app/views/shared/_breadcrumb.html.erb
@@ -21,4 +21,4 @@
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/transactions/bookings/index.html.erb b/app/views/transactions/bookings/index.html.erb
index 76956d97..d8de6e81 100755
--- a/app/views/transactions/bookings/index.html.erb
+++ b/app/views/transactions/bookings/index.html.erb
@@ -1,4 +1,4 @@
-<% breadcrumb_add t(:bookings), "", @food_court ? foodcourt_food_court_path : dashboard_path %>
+<% breadcrumb_add t(:bookings), "", (@food_court && current_user.role=='cashier') ? foodcourt_food_court_path : dashboard_path %>