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 @@
- <% @i =0 %> + <% @dining_queues.each do |queue| %> -
" data-id="<%= queue.id %>" style="width: 17.5rem;"> + <% if queue.status == "Assign" + @bg_color = "assign" + elsif queue.status == "Cancel" + @bg_color = "cancel" + else + @bg_color = "normal" + end + %> +
- - <%= @i += 1 %> . Queue No - Seater : <%= queue.seater %> -

- <%= queue.queue_no %> -

- + Queue No : <%= queue.queue_no %> + Seater : <%= queue.seater %>
+ Name : <%= queue.name %>
+ Contact No : <%= queue.contact_no %> + Remark : <%= queue.remark %>
@@ -43,7 +49,7 @@
- +
\ No newline at end of file diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 345ca63f..558d35dd 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -42,6 +42,7 @@
  • <%= link_to "Daily Sale Report", reports_dailysale_index_path, :tabindex =>"-1" %>
  • <%= link_to "Sales Item Report", reports_saleitem_index_path, :tabindex =>"-1" %>
  • <%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %>
  • + diff --git a/app/views/layouts/origami.html.erb b/app/views/layouts/origami.html.erb index 1f519d2b..d6bbf436 100644 --- a/app/views/layouts/origami.html.erb +++ b/app/views/layouts/origami.html.erb @@ -19,14 +19,14 @@ <%= render 'layouts/header_orgiami' %>
    <% flash.each do |type, message| %> - <% if !flash["errors"]%> -
    - - <%=message%> -
    - <% end %> + <% if !flash["errors"]%> +
    + + <%=message%> +
    + <% end %> - <% end %> + <% end %> <%= yield %>
    diff --git a/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb b/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..34173d99 --- /dev/null +++ b/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb @@ -0,0 +1,127 @@ +
    +
    + <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
    +
    + + +
    + + +
    + + + +
    +
    + + +
    +
    + +
    +
    + <% end %> + + <% end %> +
    +
    + + \ No newline at end of file diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb new file mode 100644 index 00000000..8582a578 --- /dev/null +++ b/app/views/reports/shiftsale/index.html.erb @@ -0,0 +1,160 @@ + + +
    + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_shiftsale_index_path} %> +
    +
    + +
    +
    + +
    +
    + +
    + +
    +
    + + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + <% void = 0%> + <% cash = 0%> + <% credit = 0%> + <% accept_credit = 0%> + <% foc = 0%> + <% card = 0%> + <% total = 0%> + <% rounding_adj = 0%> + <% g_total = 0 %> + + <% @sale_data.each do |result| %> + + + + + + + + + + + + <% grand_total = result[:grand_total].to_f - result[:rounding_adj].to_f %> + + + <% void += result[:void_amount].to_f %> + <% cash += result[:cash_amount].to_f %> + <% credit += result[:credit_amount].to_f %> + <% accept_credit += result[:accept_credit_amount].to_f %> + <% foc += result[:foc_amount].to_f %> + <% card += result[:card_amount].to_f %> + <% total += result[:grand_total].to_f %> + <% rounding_adj += result[:rounding_adj].to_f %> + <% g_total += grand_total.to_f %> + + <% end %> + + + + + + + + + + + + + + +
    From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%>
    Cashier StationShift NameVoid AmountCash PaymentCredit ChargesCredit PaymentFOC PaymentCard PaymentGrand Total + +
    Rounding Adj
    Rounding AdjGrand 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 '-'%><%= 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 '-'%>
    +
    +
    +
    + + + \ No newline at end of file diff --git a/app/views/reports/daily_sale/index.html.erb b/app/views/reports/shiftsale/index.xls.erb similarity index 79% rename from app/views/reports/daily_sale/index.html.erb rename to app/views/reports/shiftsale/index.xls.erb index 7b790148..67e76e3c 100644 --- a/app/views/reports/daily_sale/index.html.erb +++ b/app/views/reports/shiftsale/index.xls.erb @@ -1,26 +1,4 @@ - - -
    - <%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %> -
    -
    - -
    -
    - -
    -
    - -
    -
    +
    @@ -135,56 +113,4 @@ <% end %>
    -
    -
    - - - \ No newline at end of file +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 10ee5a05..35669703 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -173,6 +173,7 @@ Rails.application.routes.draw do get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign" post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table" + post "/dining_queues/cancel_queue" =>"dining_queues#cancel_queue", :as => "cancel_queue" end @@ -268,6 +269,7 @@ Rails.application.routes.draw do resources :receipt_no, :only => [:index, :show] resources :dailysale, :only => [:index, :show] resources :saleitem, :only => [:index, :show] + resources :shiftsale, :only => [:index, :show] # resources :sales, :only => [:index, :show] # resources :orders, :only => [:index, :show] # resources :customers, :only => [:index, :show] diff --git a/spec/controllers/reports/shiftsale_controller_spec.rb b/spec/controllers/reports/shiftsale_controller_spec.rb new file mode 100644 index 00000000..ed90f941 --- /dev/null +++ b/spec/controllers/reports/shiftsale_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Reports::ShiftsaleController, type: :controller do + +end diff --git a/spec/helpers/reports/shiftsale_helper_spec.rb b/spec/helpers/reports/shiftsale_helper_spec.rb new file mode 100644 index 00000000..3555ce0c --- /dev/null +++ b/spec/helpers/reports/shiftsale_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::ShiftsaleHelper. For example: +# +# describe Reports::ShiftsaleHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Reports::ShiftsaleHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end