diff --git a/app/assets/javascripts/reports/shiftsale.coffee b/app/assets/javascripts/reports/shiftsale.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/shiftsale.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index 6f8d90f0..cf6782dd 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -13,7 +13,7 @@ .selected-item { color: #fff !important; - background-color: #54A5AF !important; + background-color: #7a62d3 !important; } .assign { @@ -23,6 +23,14 @@ .assign .text-muted{ color: #fff !important; } +.normal{ + color: #fff !important; + background-color: #54A5AF; +} +.cancel { + color: #fff !important; + background-color: #FF0000; +} .red{ color: #fff !important; background-color: red; @@ -39,9 +47,9 @@ } .card-columns { @include media-breakpoint-only(lg) { - column-count: 6; + column-count: 5; } @include media-breakpoint-only(xl) { - column-count: 6; + column-count: 5; } } \ No newline at end of file diff --git a/app/assets/stylesheets/reports/shiftsale.scss b/app/assets/stylesheets/reports/shiftsale.scss new file mode 100644 index 00000000..0e0a4c32 --- /dev/null +++ b/app/assets/stylesheets/reports/shiftsale.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/shiftsale controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index be4b4055..126b20b0 100644 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -7,7 +7,7 @@ class BaseOrigamiController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| flash[:warning] = exception.message - redirect_to root_path + redirect_to origami_root_path end def current_user diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index b4f902fc..9c5f8b73 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -96,6 +96,17 @@ class Crm::DiningQueuesController < BaseCrmController end end + def cancel_queue + queue = DiningQueue.find(params[:id]) + + status = queue.update_attributes(id: params[:id],status:"Cancel") + + if status == true + render json: JSON.generate({:status => true , notice: 'Dining queue was successfully canceled .'}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + end + end private # Use callbacks to share common setup or constraints between actions. diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 1d26438e..0d2d9082 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -9,7 +9,12 @@ class Origami::PaymentsController < BaseOrigamiController sale_data = Sale.find_by_sale_id(sale_id) sale_items = SaleItem.where("sale_id=?",sale_id) + new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + rounding_adj = sale_data.grand_total - new_total + + sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj) # Print for First Bill to Customer + unique_code = "ReceiptBillPdf" #shop detail shop_details = Shop.find(1) diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 975ae73f..d4fba302 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -1,5 +1,5 @@ class Origami::SaleEditController < BaseOrigamiController - + authorize_resource :class => false # Index for sale item void OR edit def edit sale_id = params[:sale_id] diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 3515b010..b8972cf2 100644 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -1,5 +1,5 @@ class Origami::VoidController < BaseOrigamiController - + authorize_resource :class => false def overall_void sale_id = params[:sale_id] diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb new file mode 100644 index 00000000..5f13857d --- /dev/null +++ b/app/controllers/reports/shiftsale_controller.rb @@ -0,0 +1,18 @@ +class Reports::ShiftsaleController < ApplicationController + # authorize_resource :class => false + + def index + + from, to, report_type = get_date_range_from_params + @sale_data = Sale.get_by_shiftsales(from,to) + respond_to do |format| + format.html + format.xls + end + end + + def show + + end +end + diff --git a/app/helpers/reports/shiftsale_helper.rb b/app/helpers/reports/shiftsale_helper.rb new file mode 100644 index 00000000..967a8c6b --- /dev/null +++ b/app/helpers/reports/shiftsale_helper.rb @@ -0,0 +1,2 @@ +module Reports::ShiftsaleHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 0d54d030..066311af 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -47,6 +47,7 @@ class Ability can :remove_discount_items, :discount can :remove_all_discount, :discount + can :first_bill, :payment can :show, :payment can :create, :payment can :reprint, :payment @@ -56,6 +57,14 @@ class Ability can :move_dining, :moveroom + can :edit, :sale_edit + can :item_void, :sale_edit + can :item_void_cancel, :sale_edit + can :cancel_all_void, :sale_edit + can :apply_void, :sale_edit + + can :overall_void, :void + elsif user.role == "cashier" can :read, Order diff --git a/app/models/sale.rb b/app/models/sale.rb index bf3bc216..9c3aea00 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -322,6 +322,41 @@ class Sale < ApplicationRecord end end + def self.get_rounding_adjustment(num) + ## 0 -- 25 -- 50 -- 75 -- 100 + # if get_rounded_amt == true + value = 0 + + num = num.to_f.round + get_last_no = num.to_s.last(2).to_f + if get_last_no.between?(0,25) + ## down to 0 + num -= get_last_no + else + if get_last_no.between?(26,50) + ## up to 50 + value = 50 - get_last_no.to_f + num += value + puts 'up to 50' + else + if get_last_no.between?(51, 75) + ## down to 50 + value = get_last_no.to_f - 50 + num -= value + puts 'down to 50' + else + ## up to 100 + value = 100 - get_last_no.to_f + num += value + puts 'up to 100' + end + end + end + # end + return num + end + + def self.daily_sales_list(from,to) payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, @@ -387,13 +422,13 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) .group('mi.id') .order("mi.menu_category_id") - query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code" + " JOIN menu_categories mc ON mc.id = mi.menu_category_id JOIN employees ea ON ea.id = sales.cashier_id") - query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) + query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) @@ -409,6 +444,10 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) end +def self.get_by_shiftsales(from,to) + return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) +end + private def generate_custom_id diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index 4adbead9..4f39147f 100644 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -18,19 +18,25 @@
<%= queue.id %>
<%= queue.status %>
- - <%= @i += 1 %> . Queue No - Seater : <%= queue.seater %> -- <%= queue.queue_no %> -
- + Queue No : <%= queue.queue_no %> + Seater : <%= queue.seater %>| From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%> | +||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Cashier Station | +Shift Name | +Void Amount | +Cash Payment | +Credit Charges | +Credit Payment | +FOC Payment | +Card Payment | +Grand Total +
+ Rounding Adj |
+ Rounding Adj | +Grand Total | +
| + <%= result[:cashier_station_name] rescue '-'%> + | +<%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> - + <%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %> + | + +<%= sprintf "%.2f",result[:cash_amount].to_f.to_d rescue '-'%> | +<%= sprintf "%.2f",result[:credit_amount].to_f.to_d rescue '-'%> | +<%= sprintf "%.2f",result[:accept_credit_amount].to_f.to_d rescue '-'%> | +<%= sprintf "%.2f",result[:foc_amount].to_f.to_d rescue '-'%> | +<%= sprintf "%.2f",result[:card_amount].to_f.to_d rescue '-'%> | +<%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%> | +<%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%> | + <% grand_total = result[:grand_total].to_f - result[:rounding_adj].to_f %> +<%= sprintf "%.2f",grand_total.to_f.to_d rescue '-'%> | +|
| + | (<%= sprintf("%.2f",void) rescue '-'%>) | +<%= sprintf("%.2f",cash) rescue '-'%> | +<%= sprintf("%.2f",credit) rescue '-'%> | +<%= sprintf("%.2f",accept_credit) rescue '-'%> | +<%= sprintf("%.2f",foc) rescue '-'%> | +<%= sprintf("%.2f",card) rescue '-'%> | +<%= sprintf("%.2f",total) rescue '-'%> | +<%= sprintf("%.2f",rounding_adj) rescue '-'%> | +<%= sprintf("%.2f",g_total) rescue '-'%> | +|