This commit is contained in:
NyanLinHtut
2019-12-20 15:48:38 +06:30
parent 26edf23b46
commit 10c1ba12af
15 changed files with 709 additions and 100 deletions

View File

@@ -38,20 +38,20 @@ class Printer::PrinterWorker
end
def print(file_path,printer_destination = nil )
if printer_destination.nil?
printer_destination = self.printer_destination
end
puts printer_destination
puts '........Printer Destination..........'
copy = self.print_copies
#Print only when printer information is not null
if !self.printer_destination.nil?
(1..copy).each do
page = Cups::PrintJob.new(file_path, printer_destination)
page.print
end
end
# if printer_destination.nil?
# printer_destination = self.printer_destination
# end
#
# puts printer_destination
# puts '........Printer Destination..........'
#
# copy = self.print_copies
# #Print only when printer information is not null
# if !self.printer_destination.nil?
# (1..copy).each do
# page = Cups::PrintJob.new(file_path, printer_destination)
# page.print
# end
# end
end
end

View File

@@ -2118,7 +2118,7 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
end
# Start hourly sale item report
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type)
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type,filter,start_time,end_time)
# date_type_selection = get_sql_function_for_report_type(report_type)
if account_type.blank?
account_type = ''
@@ -2126,7 +2126,21 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
account_type = " and acc.title = '#{account_type}'"
end
query = self.get_hourly_item_query(type)
if start_time.blank? || end_time.blank?
receipt_date = "sales.receipt_date between '#{from}' and '#{to}'"
query = self.get_hourly_item_query(type,filter,true)
else
start_time = Time.parse(start_time).utc
end_time = Time.parse(end_time).utc
receipt_date = "sales.receipt_date between '#{start_time}' and '#{end_time}'"
query = self.get_hourly_item_query(type,filter,false)
end
puts "start time - end time >>>>>>>>>"
puts "#{start_time},#{end_time}"
# query = self.get_hourly_item_query(type,filter)
discount_query = 0
total_card_amount = 0
@@ -2187,7 +2201,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
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)
query = query.where("#{receipt_date} #{account_type} and sale_status='completed'")
if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end
@@ -2214,11 +2228,16 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
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)
def self.get_hourly_item_query(type,filter,status)
if status
group_by = "acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price,hour"
else
group_by = "acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price"
end
check_product = "i.menu_category_name != 'product'"
if type == "revenue"
sale_type = "i.qty > 0 and status IS NULL"
elsif type == "all" || type.nil?
elsif type == "all" || type.nil? || type.empty?
sale_type = "#{check_product}"
elsif type == "discount"
sale_type = "#{check_product} and i.status = 'Discount'"
@@ -2246,8 +2265,8 @@ def self.get_hourly_item_query(type)
" 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,hour")
query = query.where("#{sale_type} and i.product_name LIKE '%#{filter}%'" )
query = query.group("#{group_by}")
.order("hour asc")
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
end