waste and spoil report

This commit is contained in:
NyanLinHtut
2019-08-09 14:21:24 +06:30
parent 3f08f99bf4
commit 5e344dc4a6
12 changed files with 1044 additions and 189 deletions

View File

@@ -1,83 +1,82 @@
GIT
remote: https://github.com/capistrano/rbenv.git
revision: c029e4128e4a8f25adda35795f5729bd4f62e51f
revision: b8807f3bbb3f424ac42cc8838a38822e028d0aa3
specs:
capistrano-rbenv (2.1.3)
capistrano-rbenv (2.1.4)
capistrano (~> 3.1)
sshkit (~> 1.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.4)
actionpack (= 5.1.4)
actioncable (5.1.7)
actionpack (= 5.1.7)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.4)
activesupport (= 5.1.4)
actionview (5.1.7)
activesupport (= 5.1.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.4)
activesupport (= 5.1.4)
activejob (5.1.7)
activesupport (= 5.1.7)
globalid (>= 0.3.6)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
activemodel (5.1.7)
activesupport (= 5.1.7)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.4)
activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
aescrypt (1.0.0)
airbrussh (1.3.0)
airbrussh (1.3.2)
sshkit (>= 1.6.1, != 1.7.0)
arel (8.0.0)
axlsx (2.0.1)
htmlentities (~> 4.3.1)
nokogiri (>= 1.4.1)
rubyzip (~> 1.0.0)
axlsx_rails (0.5.1)
axlsx_rails (0.5.2)
actionpack (>= 3.1)
axlsx (>= 2.0.1)
bcrypt (3.1.11)
bindex (0.5.0)
bcrypt (3.1.13)
bindex (0.8.1)
builder (3.2.3)
byebug (9.1.0)
byebug (11.0.1)
cancancan (1.17.0)
capistrano (3.10.1)
capistrano (3.11.0)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.3.0)
capistrano-bundler (1.6.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.3.1)
capistrano-rails (1.4.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
carrierwave (1.2.1)
carrierwave (1.3.1)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
chartkick (2.2.5)
chartkick (3.2.1)
chronic (0.10.2)
chunky_png (1.3.11)
coffee-rails (4.2.2)
@@ -87,46 +86,45 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
crass (1.0.2)
concurrent-ruby (1.1.5)
connection_pool (2.2.2)
crass (1.0.4)
cups (0.1.10)
database_cleaner (1.6.2)
database_cleaner (1.7.0)
diff-lcs (1.3)
erubi (1.7.0)
erubi (1.8.0)
execjs (2.7.0)
factory_girl (4.9.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.9.0)
factory_girl (~> 4.9.0)
railties (>= 3.0.0)
faker (1.8.4)
i18n (~> 0.5)
ffi (1.9.18)
filterrific (2.1.2)
font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2)
globalid (0.4.1)
faker (2.1.0)
i18n (>= 0.7)
ffi (1.11.1)
filterrific (5.2.1)
font-awesome-rails (4.7.0.5)
railties (>= 3.2, < 6.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
htmlentities (4.3.4)
httparty (0.15.6)
httparty (0.15.7)
multi_xml (>= 0.5.2)
i18n (0.9.1)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-fileupload-rails (0.4.7)
jquery-fileupload-rails (1.0.0)
actionpack (>= 3.1)
railties (>= 3.1)
sass (>= 3.2)
jquery-rails (4.3.1)
sassc
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (2.1.0)
json (2.2.0)
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
@@ -142,39 +140,38 @@ GEM
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.1.1)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
material_icons (2.2.1)
railties (>= 3.2)
method_source (0.9.0)
mime-types (3.1)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.8.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
momentjs-rails (2.17.1)
mime-types-data (3.2019.0331)
mini_magick (4.9.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
momentjs-rails (2.20.1)
railties (>= 3.1)
multi_json (1.12.2)
multi_xml (0.6.0)
mysql2 (0.4.10)
nested_form (0.3.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.2.0)
nio4r (2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0)
nio4r (2.4.0)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
pdf-core (0.7.0)
pdfjs_viewer-rails (0.2.0)
pdfjs_viewer-rails (0.3.1)
json (> 1.8.4)
rails (> 4.2.0)
sass-rails (~> 5.0)
pg (0.21.0)
pg (1.1.4)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -183,40 +180,40 @@ GEM
rqrcode (>= 0.4.1)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
puma (3.10.0)
rack (2.0.3)
rack-cors (1.0.2)
rack-protection (2.0.0)
puma (3.12.1)
rack (2.0.7)
rack-cors (1.0.3)
rack-protection (2.0.5)
rack
rack-test (0.7.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
bundler (>= 1.3.0)
railties (= 5.1.4)
railties (= 5.1.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
rails-html-sanitizer (1.1.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.2.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rake (12.3.3)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
redis (3.3.5)
roo (1.13.2)
nokogiri
@@ -224,89 +221,91 @@ GEM
spreadsheet (> 0.6.4)
rqrcode (0.10.1)
chunky_png (~> 1.0)
rspec-core (3.7.0)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.1)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
ruby-ole (1.2.12.1)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
ruby-ole (1.2.12.2)
rubyzip (1.0.0)
sass (3.5.3)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sassc (2.0.1)
ffi (~> 1.9)
rake
schema_to_scaffold (0.8.0)
activesupport (>= 3.2.1)
shoulda-matchers (3.1.2)
shoulda-matchers (3.1.3)
activesupport (>= 4.0.0)
sidekiq (5.0.5)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
sidekiq (5.2.7)
connection_pool (~> 2.2, >= 2.2.2)
rack (>= 1.5.0)
rack-protection (>= 1.5.0)
redis (>= 3.3.4, < 5)
simple_form (3.5.0)
actionpack (> 4, < 5.2)
activemodel (> 4, < 5.2)
spreadsheet (1.1.4)
redis (>= 3.3.5, < 5)
simple_form (4.1.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
spreadsheet (1.2.4)
ruby-ole (>= 1.0)
spring (2.0.2)
activesupport (>= 4.2)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.15.1)
sshkit (1.20.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
tether-rails (1.4.0)
rails (>= 3.1)
thor (0.20.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.8)
tilt (2.0.9)
to_xls-rails (1.3.1)
spreadsheet (>= 0.8.5)
ttfunk (1.5.1)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
tzinfo (1.2.4)
turbolinks (5.2.0)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (3.2.0)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
web-console (3.5.1)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.7)
websocket-extensions (0.1.4)
whenever (1.0.0)
chronic (>= 0.6.3)
PLATFORMS
@@ -375,4 +374,4 @@ RUBY VERSION
ruby 2.4.1p111
BUNDLED WITH
2.0.1
2.0.2

View File

@@ -1,11 +1,11 @@
class HomeController < ApplicationController
class HomeController < ApplicationController
# layout "application", except: [:index, :show]
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
before_action :check_user, only: :dashboard
# Special check for only dashboard
def check_user
def check_user
if current_user.nil?
redirect_to root_path
end
@@ -42,8 +42,8 @@ class HomeController < ApplicationController
route_by_role(@employee)
else
flash[:notice] ="Invalid PIN for Employee. Please try again!"
render :show
end
render :show
end
end
def create
@@ -117,7 +117,8 @@ class HomeController < ApplicationController
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><'
logger.debug @hourly_sales.to_json
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
@employee_sales = []
@@ -145,7 +146,7 @@ class HomeController < ApplicationController
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time)
@sale_data.push({'card' => pay.payment_amount})
else
else
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
@@ -154,7 +155,7 @@ class HomeController < ApplicationController
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
@account_data = Array.new
@@ -168,7 +169,7 @@ class HomeController < ApplicationController
end
@top_items = Sale.top_items(today,current_user,@from,@to,@from_time,@to_time)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@@ -231,7 +232,7 @@ class HomeController < ApplicationController
def get_date_range_from_params
from = params[:from]
to = params[:to]
to = params[:to]
from_time = params[:from_time]
to_time = params[:to_time]
@@ -243,8 +244,8 @@ class HomeController < ApplicationController
# from = f_time.beginning_of_day.utc.getlocal
# to = t_time.end_of_day.utc.getlocal
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
end
return from, to, from_time, to_time

View File

@@ -0,0 +1,197 @@
class Reports::HourlySaleitemController < BaseReportController
authorize_resource :class => false
def index
@account = Account.all
from, to = get_date_range_from_params
shift_sale_range = ''
shift = ''
if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
else
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
end
account_type = params[:account_type]
@type = params[:sale_type]
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
logger.debug 'product>>>>>>>>>>>>>>>>>>>>>>>>>>'
logger.debug @sale_data.group(:date_format)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if shift.present?
shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
sale_data = @sale_data
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
logger.debug 'show date arr####################'
logger.debug date_arr
end
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
def print_sale_items
from, to = get_date_range_from_params
shift_sale_range = ''
shift = ''
shift_name = 'All Shift'
if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
else
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
sh_name = "#{shift_sale.shift_started_at.utc.getlocal.strftime('%d %B %l:%M%p')} - #{shift_sale.shift_closed_at.utc.getlocal.strftime('%d %B %l:%M%p')}"
employee = Employee.find(shift_sale.employee_id)
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
end
shop_details = shop_detail
account_type = params[:account_type]
@type = params[:period_type]
period_name = get_period_name(params[:period])
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
other_charges = Sale.get_other_charges()
if shift.present?
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
else
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end
# get printer info
print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
# if print_settings.nil? && print_settings_star.nil?
# @print_setting = PrintSetting.new(name: "SaleItemsPdf", unique_code: "SaleItemsPdf", template: "",font: "Zawgyi-One", header_font_size: "10", item_font_size: "8", printer_name: "", api_settings: "", brand_name: nil, printer_type: nil, page_width: "210", page_height: "1450", print_copies: "1", precision: "0", delimiter: "0", heading_space: "5" )
# @print_setting.save
# end
if print_settings.nil?
if !print_settings_star.nil?
printer = Printer::CashierStationPrinter.new(print_settings_star)
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
end
else
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
end
respond_to do |format|
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
format
end
end
def get_period_name(period)
period_name = '-'
unless period.nil? or period.blank?
case period.to_i
when PERIOD["today"]
period_name = "Today"
when PERIOD["yesterday"]
period_name = "Yesterday"
when PERIOD["this_week"]
period_name = "This Week"
when PERIOD["last_week"]
period_name = "Last Week"
when PERIOD["last_7"]
period_name = "Last 7 days"
when PERIOD["this_month"]
period_name = "This Month"
when PERIOD["last_month"]
period_name = "Last Month"
when PERIOD["last_30"]
period_name = "Last 30 Days"
when PERIOD["this_year"]
period_name = "This Year"
when PERIOD["last_year"]
period_name = "Last Year"
end
end
return period_name
end
end

View File

@@ -64,7 +64,7 @@ class Reports::SaleitemController < BaseReportController
def show
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
sale_data = @sale_data
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")

View File

@@ -86,7 +86,7 @@ class Sale < ApplicationRecord
# InventoryJob.perform_now(self.id)
InventoryDefinition.calculate_product_count(saleObj)
# dining charges
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
@@ -1084,13 +1084,15 @@ def self.get_item_query(type)
elsif type == "promotion"
sale_type = "#{check_product} and i.status = 'promotion'"
end
query = Sale.select("acc.title as account_name,
query = Sale.select("sales.sale_id,acc.title as account_name,
i.item_instance_code as item_code,i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,
SUM(i.qty) as total_item,i.qty as qty," +
"i.status as status_type,i.remark as remark,"+
"i.unit_price,i.price as price,i.product_name as product_name, " +
"i.menu_category_name,i.menu_category_code as menu_category_id ")
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
"date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')
as date_format")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
@@ -1182,7 +1184,8 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
else
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
logger.debug 'get_by_shift_items??????????????????????????????????????'
logger.debug query.to_json
if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end
@@ -1639,6 +1642,13 @@ end
end
def self.hourly_sales(today,current_user,from,to,from_time,to_time)
logger.debug 'hourly_sales<<<<<<<<<<<<<<<<<<<<<<<<'
logger.debug today
logger.debug current_user.to_json
logger.debug from
logger.debug to
logger.debug from_time
logger.debug to_time
if (!from.nil? && !to.nil?) && (from != "" && to!="")
if current_user.nil?
query = Sale.hourly_sale_data(today,nil,from,to,from_time,to_time)
@@ -2775,6 +2785,8 @@ def self.hourly_sale_data(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=
end
query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date')
logger.debug 'sales data>>>>>>>>>>>>>>>>>>>>>>>'
logger.debug query.to_json
end
return query

View File

@@ -0,0 +1,146 @@
<div class="p-l-15">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<label class="font-14 mbl_lbl">Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="">Select Type</option>
<option value="revenue" selected>Revenue Only</option>
<option value="all">All Type</option>
<option value="discount">Discount Only</option>
<option value="void">Void Only</option>
<option value="foc">Foc Only</option>
<option value="promotion">Promotion Only</option>
<option value="other">Other Amount Only</option>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_account") %></label>
<select name="account_type" id="account_type" class="form-control">
<option value = "">Select Account</option>
<% @account.each do |acc| %>
<option value="<%=acc.title%>" class="<%=acc.title%>" > <%=acc.title%></option>
<%end %>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
<label class="font-14 mbl_lbl">All Shift</label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 margin-top-20 mbl-right-btn">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary float_right'>
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
$("#account_type").val("<%=params[:account_type]%>");
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
var sale_type = "<%=params[:sale_type]%>";
$("#sel_sale_type").val(sale_type);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -0,0 +1,114 @@
<div class="container-fluid">
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.waste_spoilage_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_waste_and_spoilage_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<% time_arr = Array.new %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% total_qty = 0 %>
<% time_count = 0 %>
<% @sale_data.each do |sale| %>
<% if !time_arr.include?(sale.date_format) %>
<% time_count = time_count + 1 %>
<thead>
<td>&nbsp;</td>
<tr>
<td >
<strong>Time :<%= sale.date_format %></strong>
</td>
<td></td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : </strong></td>
</tr>
<tr>
<td><strong>Menu Category</strong></td>
<td><strong>Item Code</strong></td>
<td><strong>Item Name</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
</thead>
<% time_arr.push(sale.date_format) %>
<% menu_cat_arr.clear %>
<% count = 0 %>
<% end %>
<tbody>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.status_type =="promotion" && @type == "promotion"
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if !sale.item_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %>
<tr>
<% if !menu_cat_arr.include?(sale.menu_category_name) %>
<td><%= sale.menu_category_name %></td>
<% menu_cat_arr.push(sale.menu_category_name) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code %></td>
<td><%= sale.product_name %></td>
<td><%= sale.total_item.to_i %></td>
<td><%= sale.unit_price %></td>
<td><%= sale.price %></td>
<td><%= sale.date_format %></td>
</tr>
<% end %>
<!-- new tr -->
<% count = count + 1 %>
<% logger.debug ' normal count+++++++++++++++++++++++++' %>
<% logger.debug sale.sale_items.count %>
<% logger.debug 'time_count count------------------------------------' %>
<% logger.debug time_count %>
<% if sale.sale_items.count == count %>
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<td>Total Qty:</td>
<td><span><%= total_qty%></span></td>
<td style="border-bottom:2px solid grey;">Grand Total:</td>
<td style="border-bottom:2px solid grey;"><span></span></td>
</tr>
<% footer_arr.push(sale.sale_id) %>
<% end %>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,282 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<div class="table-responsive">
<table class="table table-striped" id="items_table" border="0">
<thead>
<tr>
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th>&nbsp;</th>
<th><%= t("views.right_panel.header.menu_category") %></th>
<th><%= t("views.right_panel.detail.code") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<th><%= t("views.right_panel.detail.revenue") %></th>
</tr>
</thead>
<tbody>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% p_qty = 0 %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% product_sub_total = 0 %>
<% count = 0 %>
<% total_price = 0 %>
<% cate_count = 0 %>
<% acc_count = 0 %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% total_amount = 0 %>
<% discount = 0 %>
<% total_item_foc = 0 %>
<% total_item_dis = 0.0 %>
<% total_tax = 0 %>
<% unless @sale_data.blank? %>
<% @sale_data.each do |sale| %>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.remark =="promotion"
total_qty += sale.total_item
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
<td colspan="4">&nbsp;</td>
<td><%= t("views.right_panel.detail.total_price_by") %> <%= sale.account_name %></td>
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
</td>
</tr>
<% acc_arr.push(sale.account_id) %>
<% end %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<% if sale.status_type != "Discount" %>
<td><%= sale.total_item rescue '-' %></td>
<%else%>
<td><%= sale.total_item*(-1) rescue '-' %></td>
<% end %>
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
sub_qty += sale.total_item
end %>
<% if sale.status_type =="Discount"
sub_qty += sale.total_item*(-1)
end %>
<% if sale.remark == "promotion"
sub_qty += sale.total_item
end %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total <%= sale.account_name %> Qty </b> </td>
<td><b><%= sub_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% end %>
<!--Product Sale -->
<% if @product.present?%>
<tr>
<td><b>Product</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @product.each do |product| %>
<% if product.total_item > 0
total_qty += product.total_item
end %>
<% grand_total +=product.grand_total
p_qty += product.total_item%>
<tr>
<td>&nbsp;</td>
<td>Product</td>
<td><%= product.product_code rescue '-' %></td>
<td><%= product.product_name rescue '-' %></td>
<td><%= product.total_item rescue '-' %></td>
<td> <%= number_with_precision(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% product_sub_total += product.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total Product Qty </b> </td>
<td><b><%= p_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Product Sale -->
<!--Other Charges -->
<% if @type == "other" || @other_charges.present?%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item rescue '-' %></td>
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<% end %>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item rescue '-' %></td>
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,99 @@
<div class="container-fluid">
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.waste_spoilage_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_waste_and_spoilage_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<h5 class="p-l-10 p-t-10">Report For <%= @sale_type? @sale_type : 'Waste' %></h5>
<% receipt_arr = Array.new %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% @sale_data.each do |sale| %>
<% if !receipt_arr.include?(sale.receipt_no) %>
<thead>
<td>&nbsp;</td>
<tr>
<td >
<strong>Receipt No :<%= sale.receipt_no %></strong>
</td>
<td></td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %></strong></td>
</tr>
<tr>
<td><strong>Menu Category</strong></td>
<td><strong>Item Name</strong></td>
<td><strong>Item Code</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
</thead>
<% receipt_arr.push(sale.receipt_no) %>
<% menu_cat_arr.clear %>
<% count = 0 %>
<% end %>
<tbody>
<% if !sale.item_instance_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %>
<tr>
<% if !menu_cat_arr.include?(sale.name) %>
<td><%= sale.name %></td>
<% menu_cat_arr.push(sale.name) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.product_name %></td>
<td><%= sale.product_code %></td>
<td><%= sale.qty.to_i %></td>
<td><%= sale.unit_price %></td>
<td><%= sale.price %></td>
</tr>
<% end %>
<% count = count + 1 %>
<% if sale.sale_items.count == count %>
<tr>
<td></td>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td>
<span class="underline" style="text-align:right">
<strong><%= waste_and_spoil_item_count %></strong>
<% waste_and_spoil_item_count = 0%>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= sale.grand_total %></strong>
</span>
</td>
</tr>
<% footer_arr.push(sale.sale_id) %>
<% end %>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -18,46 +18,47 @@
</div>
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<h5 class="p-l-10 p-t-10">Report For <%= @sale_type? @sale_type : 'Waste' %></h5>
<% receipt_arr = Array.new %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% @sale_data.each do |sale| %>
<% if !receipt_arr.include?(sale.receipt_no) %>
<thead>
<td>&nbsp;</td>
<thead>
<!-- <td>&nbsp;</td>
<tr>
<td >
<strong>Receipt No :<%= sale.receipt_no %></strong>
</td>
<strong>Receipt No :</strong>
</td>
<td></td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %></strong></td>
</tr>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : </strong></td>
</tr> -->
<tr>
<td><strong>Menu Category</strong></td>
<td><strong>Item Name</strong></td>
<td><strong>Item Code</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
</thead>
<% receipt_arr.push(sale.receipt_no) %>
<% menu_cat_arr.clear %>
<% count = 0 %>
<% end %>
<tbody>
<% if !sale.item_instance_code.nil?%>
<% receipt_arr = Array.new %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% grand_total = 0%>
<% unless @sale_data.blank? %>
<% @sale_data.each do |sale| %>
<% if !sale.item_instance_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %>
<% grand_total += sale.grand_total.to_i %>
<% end %>
<tr>
<% if !menu_cat_arr.include?(sale.name) %>
<% if !menu_cat_arr.include?(sale.name) %>
<td><%= sale.name %></td>
<% menu_cat_arr.push(sale.name) %>
<% else %>
@@ -68,33 +69,35 @@
<td><%= sale.qty.to_i %></td>
<td><%= sale.unit_price %></td>
<td><%= sale.price %></td>
</tr>
<% end %>
</tr>
<% count = count + 1 %>
<% if sale.sale_items.count == count %>
<% if @sale_data.length == count %>
<tr>
<td></td>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td>
<span class="underline" style="text-align:right">
<strong><%= waste_and_spoil_item_count %></strong>
<% waste_and_spoil_item_count = 0%>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<td >
<span class="underline" style="text-align:right">
<strong><%= sale.grand_total %></strong>
<strong><%= grand_total %></strong>
</span>
</td>
</tr>
</tr>
<% footer_arr.push(sale.sale_id) %>
<% end %>
</tbody>
<% end %>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -4,13 +4,13 @@ default: &default
pool: 5
timeout: 5000
encoding: unicode
username: wunna
password: admin123
username: nlh
password: 7812co2Y
port: 5432
development:
<<: *default
database: SXDatabase
database: sxdemo
production:
<<: *default
database: paymal

View File

@@ -523,6 +523,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :receipt_no_detail
resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show]
resources :hourly_saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]
resources :credit_payment, :only => [:index, :show]
resources :void_sale, :only => [:index, :show]
@@ -537,6 +538,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :card_settle_tran
get "saleitem/get_shift_by_date", to: "saleitem#show", as: "get_shift_by_sale_item"
get "hourly_saleitem/get_shift_by_date", to: "hourly_saleitem#show", as: "get_shift_by_hourly_saleitem"
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation"
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"