fix conflict
This commit is contained in:
200
app/controllers/reports/hourly_saleitem_controller.bk.rb
Normal file
200
app/controllers/reports/hourly_saleitem_controller.bk.rb
Normal file
@@ -0,0 +1,200 @@
|
||||
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_by {|s| s.date_format }.collect{|key,qty| {"Date" =>key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
|
||||
@hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
logger.debug @hourly_total_qty
|
||||
|
||||
@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
|
||||
@@ -26,9 +26,9 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
|
||||
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_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_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)
|
||||
|
||||
@@ -79,8 +79,6 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
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}
|
||||
@@ -125,7 +123,7 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
@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)
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_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)
|
||||
|
||||
@@ -1184,8 +1184,6 @@ 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
|
||||
@@ -2785,8 +2783,6 @@ 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
|
||||
@@ -2816,6 +2812,142 @@ def self.employee_sale(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil
|
||||
return query
|
||||
end
|
||||
|
||||
# Start hourly sale item report
|
||||
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
else
|
||||
account_type = " and acc.title = '#{account_type}'"
|
||||
end
|
||||
|
||||
query = self.get_hourly_item_query(type)
|
||||
|
||||
discount_query = 0
|
||||
total_card_amount = 0
|
||||
total_cash_amount = 0
|
||||
total_credit_amount = 0
|
||||
total_foc_amount = 0
|
||||
total_grand_total = 0
|
||||
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
end
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
total_credit_amount += s_c.credit_amount.to_f
|
||||
total_foc_amount += s_c.foc_amount.to_f
|
||||
end
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
total_credit_amount += s_c.credit_amount.to_f
|
||||
total_foc_amount += s_c.foc_amount.to_f
|
||||
end
|
||||
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
total_credit_amount += s_c.credit_amount.to_f
|
||||
total_foc_amount += s_c.foc_amount.to_f
|
||||
end
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
end
|
||||
|
||||
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||
end
|
||||
|
||||
def self.get_hourly_item_query(type)
|
||||
check_product = "i.menu_category_name != 'product'"
|
||||
if type == "revenue"
|
||||
sale_type = "i.qty > 0 and status IS NULL"
|
||||
elsif type == "all" || type.nil?
|
||||
sale_type = "#{check_product}"
|
||||
elsif type == "discount"
|
||||
sale_type = "#{check_product} and i.status = 'Discount'"
|
||||
elsif type == "foc"
|
||||
sale_type = "#{check_product} and i.status = 'foc' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "void"
|
||||
sale_type = "#{check_product} and i.status = 'void' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "other"
|
||||
sale_type = "#{check_product} and i.item_instance_code IS NULL"
|
||||
elsif type == "promotion"
|
||||
sale_type = "#{check_product} and i.status = 'promotion'"
|
||||
end
|
||||
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, " +
|
||||
"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")
|
||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
||||
query = query.where("#{sale_type}")
|
||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
||||
.order("date_format asc")
|
||||
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
||||
end
|
||||
|
||||
# End hourly sale item report
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
@@ -285,6 +285,9 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_hourly_saleitem_index_path %>">Hourly Sale Items</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<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">
|
||||
<!-- <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">
|
||||
@@ -41,7 +41,7 @@
|
||||
<option value="<%=acc.title%>" class="<%=acc.title%>" > <%=acc.title%></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
121
app/views/reports/hourly_saleitem/index.bk.html.erb
Normal file
121
app/views/reports/hourly_saleitem/index.bk.html.erb
Normal file
@@ -0,0 +1,121 @@
|
||||
<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> </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> </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 -->
|
||||
|
||||
<% @hourly_total_qty.each do |qty| %>
|
||||
<% qty_count = qty["total_qty"] %>
|
||||
<% logger.debug ' qty count+++++++++++++++++++++++++' %>
|
||||
<% logger.debug qty_count %>
|
||||
<% #logger.debug ' normal count+++++++++++++++++++++++++' %>
|
||||
<% #logger.debug sale.sale_items.count %>
|
||||
<% end %>
|
||||
|
||||
<% count = count + 1 %>
|
||||
<% logger.debug 'count ------------------------------------' %>
|
||||
<% logger.debug count %>
|
||||
<% if sale.sale_items.count == count %>
|
||||
<tr style="border-top:2px solid grey;">
|
||||
<td colspan="3"> </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>
|
||||
@@ -2,7 +2,7 @@
|
||||
<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>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.hourly_saleitem_report") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
@@ -14,13 +14,14 @@
|
||||
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_hourly_saleitem_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>
|
||||
<a href="javascript:export_to('<%=reports_hourly_saleitem_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 %>
|
||||
<% acc_arr = Array.new %>
|
||||
<% sale_item_count =0 %>
|
||||
<% menu_cat_arr = Array.new %>
|
||||
<% footer_arr = Array.new %>
|
||||
@@ -28,6 +29,7 @@
|
||||
<% waste_and_spoil_item_count = 0%>
|
||||
<% total_qty = 0 %>
|
||||
<% time_count = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% if !time_arr.include?(sale.date_format) %>
|
||||
<% sale_item_count =1 %>
|
||||
@@ -35,12 +37,12 @@
|
||||
<thead>
|
||||
<td> </td>
|
||||
<tr>
|
||||
<td >
|
||||
<td>
|
||||
<strong>Time :<%= sale.date_format %></strong>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3" style="text-align:right"><strong>Date : </strong></td>
|
||||
<td colspan="3" style="text-align:right"><strong></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Menu Category</strong></td>
|
||||
@@ -55,10 +57,21 @@
|
||||
<% menu_cat_arr.clear %>
|
||||
<% count = 0 %>
|
||||
<% else %>
|
||||
<%= time_arr %>
|
||||
<% sale_item_count =sale_item_count +1 %>
|
||||
<% end %>
|
||||
<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
|
||||
%>
|
||||
<!-- all total qty sum -->
|
||||
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||
total_qty += sale.total_item
|
||||
@@ -72,7 +85,22 @@
|
||||
<% if sale.status_type =="promotion" && @type == "promotion"
|
||||
total_qty += sale.total_item*(-1)
|
||||
end %>
|
||||
|
||||
<!-- end all total qty -->
|
||||
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "promotion" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% grand_total += sale.grand_total %>
|
||||
|
||||
<% if !sale.item_code.nil?%>
|
||||
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
||||
<tr>
|
||||
@@ -85,32 +113,181 @@
|
||||
<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>
|
||||
<td><%= sale.unit_price.to_i %></td>
|
||||
<td><%= sale.grand_total.to_i %></td>
|
||||
<td><%= sale.date_format %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- new tr -->
|
||||
<% count = count + 1 %>
|
||||
<% @hourly_total_qty.each do |hr| %>
|
||||
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
|
||||
<tr style="border-top:2px solid grey;">
|
||||
<td colspan="2"> </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>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
|
||||
<td>
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= total_qty.to_i %></strong>
|
||||
<% total_qty = 0%>
|
||||
</span></td>
|
||||
<td style="text-align:right"> <strong>Grand Total: </strong></td>
|
||||
<td >
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= grand_total.to_i %></strong>
|
||||
<% grand_total = 0 %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<% footer_arr.push(sale.sale_id) %>
|
||||
<% total_qty =0%>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
var check_arr = [];
|
||||
var search = '<%= params[:period_type] %>';
|
||||
|
||||
if(search){
|
||||
|
||||
if(parseInt(search) == 0){
|
||||
search_by_period();
|
||||
}
|
||||
else{
|
||||
search_by_date();
|
||||
}
|
||||
}else{
|
||||
search_by_period();
|
||||
}
|
||||
|
||||
$('#sel_period').change(function(){
|
||||
search_by_period();
|
||||
});
|
||||
|
||||
function search_by_period(){
|
||||
var period = $('#sel_period').val();
|
||||
var period_type = 0;
|
||||
var from = "";
|
||||
var to = "";
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
// OK button is clicked
|
||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
month = parseInt(new_date.getMonth()+1)
|
||||
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#from').val(from)
|
||||
search_by_date();
|
||||
});
|
||||
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
month = parseInt(new_date.getMonth()+1)
|
||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#to').val(to)
|
||||
search_by_date();
|
||||
});
|
||||
|
||||
function search_by_date(){
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
|
||||
check_arr.push(to);
|
||||
|
||||
console.log(check_arr.length)
|
||||
if(check_arr.length == 1){
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function show_shift_name(period,period_type,from,to,shift_item){
|
||||
var shift = $('#shift_name');
|
||||
if (from == '' && to == '') {
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
}
|
||||
shift.empty();
|
||||
var selected = '';
|
||||
var str = '';
|
||||
var param_shift = '<%= params[:shift_name]%>';
|
||||
|
||||
url = '<%= reports_get_shift_by_sale_item_path %>';
|
||||
console.log(url)
|
||||
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
|
||||
console.log(data)
|
||||
|
||||
str = '<option value="0">--- All Shift ---</option>';
|
||||
$(data.message).each(function(index){
|
||||
|
||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
||||
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||
var shift_id = data.message[index].shift_id ;
|
||||
|
||||
if(param_shift != ''){
|
||||
if(shift_id == param_shift){
|
||||
selected = 'selected = "selected"';
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
|
||||
|
||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||
|
||||
// console.log(sh_date)
|
||||
})
|
||||
shift.append(str);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function print_sale_items(){
|
||||
var period = $('#sel_period').val();
|
||||
var type = $('#sel_sale_type').val();
|
||||
var account = $('#account_type').val();
|
||||
var from = $('#from').val();
|
||||
var to = $('#to').val();
|
||||
var shift = $('#shift_name').val();
|
||||
// var flag = false;
|
||||
// alert($('#row_count').val())
|
||||
|
||||
// if (flag == true) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%= reports_print_sale_items_path %>",
|
||||
data: "period="+period+"&period_type="+type+"&account_type="+account+"&from="+from+"&to="+to+"&shift_name="+shift,
|
||||
success: function(data){
|
||||
if (data != null){
|
||||
location.reload();
|
||||
}
|
||||
$("#loader").hide();
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -9,274 +9,138 @@
|
||||
<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> </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 %>
|
||||
<div class="table-responsive">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
|
||||
<% 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"> </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> </td>
|
||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||
<td><%= sale.menu_category_name %></td>
|
||||
<% cate_arr.push(sale.menu_category_id) %>
|
||||
<% else %>
|
||||
<td> </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 -->
|
||||
<table class="table table-striped" border="0">
|
||||
<% time_arr = Array.new %>
|
||||
<% acc_arr = Array.new %>
|
||||
<% sale_item_count =0 %>
|
||||
<% menu_cat_arr = Array.new %>
|
||||
<% footer_arr = Array.new %>
|
||||
<% count = 0 %>
|
||||
<% waste_and_spoil_item_count = 0%>
|
||||
<% total_qty = 0 %>
|
||||
<% time_count = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% if !time_arr.include?(sale.date_format) %>
|
||||
<% sale_item_count =1 %>
|
||||
<% time_count = time_count + 1 %>
|
||||
<thead>
|
||||
<td> </td>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Time :<%= sale.date_format %></strong>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3" style="text-align:right"><strong></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 %>
|
||||
<% else %>
|
||||
<% sale_item_count =sale_item_count +1 %>
|
||||
<% end %>
|
||||
<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
|
||||
%>
|
||||
<!-- 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 %>
|
||||
|
||||
<% @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 %>
|
||||
<!-- end all total qty -->
|
||||
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.remark == "promotion"
|
||||
sub_qty += sale.total_item
|
||||
end %>
|
||||
<% if count == value %>
|
||||
<tr>
|
||||
<td colspan="3"> </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"> </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> </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"> </td>
|
||||
<td><b>Total Product Qty </b> </td>
|
||||
<td><b><%= p_qty %></b></td>
|
||||
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<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 -->
|
||||
<% if sale.status_type == "promotion" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<!--Other Charges -->
|
||||
<% if @type == "other" || @other_charges.present?%>
|
||||
|
||||
<tr>
|
||||
<td><b>Other Charges</b></td>
|
||||
<td colspan="4"> </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> </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"> </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"> </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"> </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> </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"> </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>
|
||||
<% grand_total += sale.grand_total %>
|
||||
|
||||
<% 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> </td>
|
||||
<% end %>
|
||||
<td><%= sale.item_code %></td>
|
||||
<td><%= sale.product_name %></td>
|
||||
<td><%= sale.total_item.to_i %></td>
|
||||
<td><%= sale.unit_price.to_i %></td>
|
||||
<td><%= sale.grand_total.to_i %></td>
|
||||
<td><%= sale.date_format %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- new tr -->
|
||||
<% count = count + 1 %>
|
||||
<% @hourly_total_qty.each do |hr| %>
|
||||
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_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><%= total_qty.to_i %></strong>
|
||||
<% total_qty = 0%>
|
||||
</span></td>
|
||||
<td style="text-align:right"> <strong>Grand Total: </strong></td>
|
||||
<td >
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= grand_total.to_i %></strong>
|
||||
<% grand_total = 0 %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<% footer_arr.push(sale.sale_id) %>
|
||||
<% else %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -8,3 +8,4 @@ stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/
|
||||
port ENV.fetch("PORT") { 62158 }
|
||||
workers 2
|
||||
preload_app!
|
||||
threads 1,1
|
||||
Reference in New Issue
Block a user