diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 2d3a819e..35cefe6f 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -13,7 +13,7 @@ class Transactions::OrdersController < ApplicationController end end - @orders = Kaminari.paginate_array(orders).page(params[:page]).per(2) + @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) respond_to do |format| format.html # index.html.erb format.json { render json: @orders } diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index c8ecb725..b1c28e98 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -10,12 +10,18 @@ class Transactions::SalesController < ApplicationController today = Date.today if receipt_no.nil? - @sales = Sale.order("sale_id") - #@products = Product.order("name").page(params[:page]).per(5) + sales = Sale.order("sale_id desc") else - @sales = Sale.search(receipt_no) - end - @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + order = Sale.search(receipt_no) + if order.count > 0 + sales = order + else + sales = Sale.order("sale_id desc") + + end + end + @sales = Kaminari.paginate_array(sales).page(params[:page]).per(50) + respond_to do |format| format.html # index.html.erb format.json { render json: @sales } diff --git a/app/models/order.rb b/app/models/order.rb index b250c073..83eb9418 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -231,7 +231,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,orders.status") + .group("bookings.booking_id,orders.status,sales.receipt_no,sales.sale_status,orders.order_id,sales.customer_id,sales.sale_id,dining_facilities.name") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -246,7 +246,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("sales.sale_id") + .group("sales.sale_id,orders.status,orders.order_id,bookings.booking_id,dining_facilities.name") # For PG #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end @@ -262,7 +262,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,orders.order_id,sales.customer_id,sales.sale_status,orders.customer_id,sales.sale_id,dining_facilities.name") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/models/sale.rb b/app/models/sale.rb index 67953c14..dee4c2f7 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -57,10 +57,9 @@ class Sale < ApplicationRecord self.tax_type = "exclusive" # set cashier by current login - # TODO: requested_by is string , can't cast to id. error occur. please fix - # self.cashier_id = requested_by.id - self.cashier_name = requested_by - self.requested_by = requested_by + self.cashier_id = requested_by.id + self.cashier_name = requested_by.name + self.requested_by = requested_by.name self.requested_at = DateTime.now.utc diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..1b4082f5 --- /dev/null +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -0,0 +1,211 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + + \ No newline at end of file diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb index a50bf56b..ee82eb8b 100644 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -57,7 +57,7 @@
- + <%= paginate @sales %> diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 26fcc62f..56887410 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -171,13 +171,7 @@ -