Merge branch 'r-1902001-01' into customer_report
This commit is contained in:
@@ -58,9 +58,9 @@ class Booking < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
||||
scope :assign, -> { where(booking_status: 'assign')}
|
||||
scope :active, -> { where('booking_status != ?', 'moved') }
|
||||
scope :today, -> { where('created_at >= ?', Time.now) }
|
||||
scope :assign, -> { where(booking_status: 'assign') }
|
||||
|
||||
def self.sync_booking_records(bookings)
|
||||
if !bookings.nil?
|
||||
@@ -171,6 +171,15 @@ class Booking < ApplicationRecord
|
||||
return @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales
|
||||
end
|
||||
|
||||
def self.get_booking_id(order_no)
|
||||
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
|
||||
.joins(" JOIN orders o ON o.order_id=bo.order_id")
|
||||
.where("o.order_id='#{order_no}'")
|
||||
.first()
|
||||
|
||||
return booking.booking_id
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.booking_id.nil?
|
||||
|
||||
@@ -176,7 +176,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
end
|
||||
|
||||
def move_print_pdf(change_to,current_user,change_from,order_items,oqs)
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# get printer info
|
||||
@from = (DiningFacility.find(change_from)).name
|
||||
@to = (DiningFacility.find(change_to)).name
|
||||
@@ -197,6 +197,6 @@ class OrderQueueStation < ApplicationRecord
|
||||
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items,oqs)
|
||||
# end
|
||||
# end
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,66 +38,108 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
# self.print(filename, cashier_terminal.printer_name)
|
||||
# end
|
||||
|
||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
|
||||
def print_close_cashier(printer_settings, cashier_terminal, shift_sale, sale_items, total_other_charges_info, shop_details, sale_taxes, other_payment, amount, discount, member_discount, total_dinein, total_takeway, total_other_charges, total_waste, total_spoile, total_credit_payments, payment_methods)
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
if !sale_items.blank? or !sale_items.nil?
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
if !sale_items.blank? or !sale_items.nil?
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
end
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
cashier = shift_sale.employee.name
|
||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
pdf = CloseCashierPdf.new(printer_settings, shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details, sale_taxes, other_payment, amount, discount, member_discount, total_dinein, total_takeway, total_other_charges, total_waste, total_spoile, total_credit_payments, payment_methods)
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
end
|
||||
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
cashier = shift_sale.employee.name
|
||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
else
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
pdf = CloseCashierCustomisePdf.new(printer_settings, shift_sale, shop_details, sale_taxes, other_payment, amount, discount, member_discount, total_dinein, total_takeway, total_other_charges, total_waste, total_spoile, total_credit_payments)
|
||||
else
|
||||
pdf = CloseCashierPdf.new(printer_settings, shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details, sale_taxes, other_payment, amount,discount, member_discount, total_dinein, total_takeway, total_other_charges, total_waste, total_spoile, total_credit_payments, payment_methods)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, cashier_terminal.printer_name)
|
||||
pdf.render_file filename
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, cashier_terminal.printer_name)
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: cashier_terminal.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
shop_details: shop_details.as_json,
|
||||
shift_sale: shift_sale,
|
||||
cashier_terminal: cashier_terminal,
|
||||
shift_employee: shift_sale.employee,
|
||||
sale_items: sale_items,
|
||||
other_charges: total_other_charges_info,
|
||||
sale_taxes: sale_taxes,
|
||||
other_payment: other_payment,
|
||||
total_amount_by_account: amount,
|
||||
total_discount_by_account: discount,
|
||||
total_member_discount: member_discount,
|
||||
total_waste: total_waste,
|
||||
total_spoile: total_spoile,
|
||||
total_other_charges: total_other_charges,
|
||||
total_credit_payments: total_credit_payments
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
filename = "tmp/reports_sale_items.pdf"
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
filename = "tmp/reports_sale_items.pdf"
|
||||
|
||||
if print_settings.unique_code == "SaleItemsPdf"
|
||||
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
puts 'Printing!!!!'
|
||||
end
|
||||
if print_settings.unique_code == "SaleItemsStarPdf"
|
||||
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
puts 'PrintingStar!!!!'
|
||||
end
|
||||
if print_settings.unique_code == "SaleItemsPdf"
|
||||
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
end
|
||||
|
||||
pdf.render_file filename
|
||||
if print_settings.unique_code == "SaleItemsStarPdf"
|
||||
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
end
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: print_settings.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
sale_items: sale_items.as_json,
|
||||
total_other_charges: total_other_charges,
|
||||
shop_details:shop_details.as_json,
|
||||
sale_details: {
|
||||
period: period_name,
|
||||
type: type,
|
||||
account: account,
|
||||
from_date: from_date,
|
||||
to_date: to_date,
|
||||
shift: shift_name,
|
||||
},
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
#sqa
|
||||
|
||||
@@ -1,80 +1,66 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(print_settings, oqs, order_id, order_item_id, print_status, before_updated_qty="", options="")
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
booking_id = Booking.get_booking_id(order_id)
|
||||
order_item = print_query('order_item', order_item_id).first #OrderItem.find_by_item_code(item_code)
|
||||
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
end
|
||||
|
||||
options = order_item.options
|
||||
# check for item not to show
|
||||
pdf = print_settings.unique_code.constantize.new(print_settings, order_item, print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
|
||||
shop = Shop.current_shop
|
||||
directory_name = "public/orders_#{shop.shop_code}"
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
order_item: order_item.as_json(methods: :type),
|
||||
print_status: print_status.gsub(/[()]/, ""),
|
||||
booking_id: booking_id,
|
||||
precision: print_settings.precision
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
|
||||
options = order_item[0].options
|
||||
|
||||
# check for item not to show
|
||||
# if order_item[0].price != 0
|
||||
pdf = print_settings.unique_code.constantize.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
# end
|
||||
|
||||
shop = Shop.current_shop
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
end
|
||||
#For print copy
|
||||
# pdf.render_file filename.gsub(".","-copy.")
|
||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||
|
||||
return filename, order_id, oqs.printer_name
|
||||
end
|
||||
|
||||
# Query for per order
|
||||
def print_order_summary(print_settings, oqs, order_id, order_items, print_status, before_updated_qty="", options="")
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
end
|
||||
booking_id = Booking.get_booking_id(order_id) #order[0].order_id
|
||||
order = print_query('order_summary', order_id)
|
||||
|
||||
shop = Shop.current_shop
|
||||
directory_name = "public/orders_#{shop.shop_code}"
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
|
||||
order_items.each do |odi|
|
||||
odi_item = print_query('order_item', odi.order_items_id)
|
||||
|
||||
filename = directory_name + "/order_item_#{order_id}.pdf"
|
||||
# filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]" ? "" : odi.options
|
||||
|
||||
# check for item not to show
|
||||
#if odi.price != 0
|
||||
pdf = print_settings.unique_code.constantize.new(print_settings, odi_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
|
||||
# pdf.render_file "tmp/order_item.pdf"
|
||||
pdf.render_file filename
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||
end
|
||||
#end
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
order = print_query('order_summary', order_id)
|
||||
|
||||
shop = Shop.current_shop
|
||||
directory_name = "public/orders_#{shop.shop_code}"
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
filename = directory_name + "/order_summary_#{order_id}.pdf"
|
||||
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
@@ -85,15 +71,26 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
end
|
||||
#For print copy
|
||||
# pdf.render_file filename.gsub(".","-copy.")
|
||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
order_item: order_items,
|
||||
order: order.as_json(methods: :type),
|
||||
print_status: "",
|
||||
booking_id: booking_id,
|
||||
precision: print_settings.precision
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
return filename, order_id, oqs.printer_name
|
||||
end
|
||||
|
||||
# Print for orders in booking
|
||||
def print_booking_summary(print_settings, oqs, booking_id, print_status,before_updated_qty="")
|
||||
def print_booking_summary(print_settings, oqs, booking_id, print_status, before_updated_qty="")
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
@@ -173,37 +170,51 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
# Check in-out time
|
||||
def print_check_in_out(print_settings, cashier_terminal, booking, table)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
sale_id = booking.sale_id
|
||||
filename = "tmp/check_in_out_#{sale_id}" + ".pdf"
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
sale_id = booking.sale_id
|
||||
filename = "tmp/check_in_out_#{sale_id}" + ".pdf"
|
||||
|
||||
pdf = CheckInOutPdf.new(print_settings,booking, table)
|
||||
print_setting = PrintSetting.all
|
||||
pdf = CheckInOutPdf.new(print_settings,booking, table)
|
||||
|
||||
# if order_item[0].price != 0
|
||||
if !print_setting.empty?
|
||||
print_setting.each do |print_settings|
|
||||
if print_settings.unique_code == 'CheckInOutPdf'
|
||||
pdf = CheckInOutPdf.new(print_settings,booking, table)
|
||||
print_setting = PrintSetting.all
|
||||
|
||||
# if order_item[0].price != 0
|
||||
if !print_setting.empty?
|
||||
print_setting.each do |print_settings|
|
||||
if print_settings.unique_code == 'CheckInOutPdf'
|
||||
pdf = CheckInOutPdf.new(print_settings,booking, table)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pdf.render_file filename
|
||||
pdf.render_file filename
|
||||
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
end
|
||||
# print_settings.print_copies = 1
|
||||
# print_settings.save!
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
end
|
||||
# print_settings.print_copies = 1
|
||||
# print_settings.save!
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: cashier_terminal.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
booking: booking,
|
||||
table: table,
|
||||
table_type: table.type,
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -91,10 +91,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
if printer_settings
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
if !printer_settings.unique_code.match?(/receiptbillorder/i)
|
||||
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
@@ -109,48 +109,97 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
# print as print copies in printer setting
|
||||
count = printer_settings.print_copies
|
||||
|
||||
# override print copies for print worker loop
|
||||
# print_settings.print_copies = 1
|
||||
# print_settings.save!
|
||||
end
|
||||
directory_name = 'public/receipts'
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
Rails.logger.debug "############## dir::" + directory_name
|
||||
if count == 1
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file filename
|
||||
if printed_status != 'Paid' && printed_status != 'credit_payment'
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
elsif printed_status == 'credit_payment'
|
||||
filename = directory_name + "/receipt_bill_credit_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file filename
|
||||
self.print(directory_name + "/receipt_bill_credit_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
else
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
pdf.render_file filename
|
||||
if printed_status != 'Paid'
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
directory_name = 'public/receipts'
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
Rails.logger.debug "############## dir::" + directory_name
|
||||
|
||||
filename = "#{directory_name}/receipt_bill_#{sale_data.receipt_no}#{count != 1 ? "_#{count}" : ''}.pdf"
|
||||
pdf.render_file filename
|
||||
|
||||
if printed_status != 'Paid' || !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1')
|
||||
#no print in cloud server
|
||||
puts "SERVER_MODE #{ENV["SERVER_MODE"]}"
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, cashier_terminal.printer_name)
|
||||
end
|
||||
end
|
||||
Rails.logger.debug "############## filename::" + filename
|
||||
return filename, sale_data.receipt_no, cashier_terminal.printer_name
|
||||
|
||||
Rails.logger.debug "############## filename::" + filename
|
||||
else
|
||||
if printed_status != 'Paid' || !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1')
|
||||
sale_payments = SalePayment
|
||||
.select(:payment_method, 'SUM(`sale_payments`.`payment_amount`) AS `payment_amount`')
|
||||
.where(sale_id: sale_data.sale_id).group(:payment_method)
|
||||
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: cashier_terminal.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
shop_details: shop_details.as_json,
|
||||
body: { sale_data: sale_data,
|
||||
booking: sale_data.bookings,
|
||||
dining_facility: sale_data.booking.dining_facility.as_json(methods: :type),
|
||||
sale_taxes: sale_data.sale_taxes,
|
||||
latest_order_no: latest_order_no,
|
||||
sale_items: sale_items,
|
||||
precision: print_settings.precision,
|
||||
delimiter: print_settings.delimiter,
|
||||
member_info: member_info,
|
||||
customer_name: customer_name,
|
||||
rebate_amount: rebate_amount,
|
||||
current_balance: balance,
|
||||
card_data: card_data,
|
||||
card_balance_amount: card_balance_amount,
|
||||
discount_price_by_accounts: discount_price_by_accounts,
|
||||
item_price_by_accounts: item_price_by_accounts,
|
||||
sale_payments: sale_payments.as_json
|
||||
},
|
||||
footer: {
|
||||
printed_status: printed_status, footer_text: "Thank You! See you Again"
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return filename || '', sale_data.receipt_no, cashier_terminal.printer_name
|
||||
end
|
||||
|
||||
# stock check
|
||||
def print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
||||
pdf = StockResultPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
||||
pdf.render_file "tmp/print_stock_check_result.pdf"
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print("tmp/print_stock_check_result.pdf")
|
||||
def print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker_name, shop_details)
|
||||
stock_items= []
|
||||
if stockcheck_items.length > 0
|
||||
stockcheck_items.each do |sc|
|
||||
stock_item= {
|
||||
count: sc.stock_count.to_s,
|
||||
item_name: MenuItemInstance.get_item_name(sc.item_code)
|
||||
}
|
||||
stock_items.push(stock_item)
|
||||
end
|
||||
end
|
||||
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
pdf = StockCheckPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
||||
|
||||
pdf.render_file "tmp/print_stock_check_result.pdf"
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print("tmp/print_stock_check_result.pdf")
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: print_settings.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
stockcheck: stockcheck,
|
||||
stockcheck_items: stock_items,
|
||||
checker_name: checker_name,
|
||||
shop_details: shop_details,
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
#Queue No Print
|
||||
@@ -167,21 +216,40 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Move Table Print
|
||||
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items,oqs)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
def print_move_table(printer_settings, to, from, shop_detail, date, type, moved_by, order_items, oqs)
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = MoveTablePdf.new(printer_settings, to, from, shop_detail, date, type, moved_by, order_items)
|
||||
pdf.render_file "tmp/print_move_table.pdf"
|
||||
|
||||
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||
pdf.render_file "tmp/print_move_table.pdf"
|
||||
|
||||
if oqs.print_copy
|
||||
self.print("tmp/print_move_table.pdf",oqs.printer_name)
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
if oqs.print_copy
|
||||
self.print("tmp/print_move_table.pdf",oqs.printer_name)
|
||||
else
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
#no print in cloud server
|
||||
self.print("tmp/print_move_table.pdf", oqs.printer_name)
|
||||
end
|
||||
end
|
||||
else
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
#no print in cloud server
|
||||
self.print("tmp/print_move_table.pdf", oqs.printer_name)
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.station_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
type: type,
|
||||
body: {
|
||||
to: to,
|
||||
from: from,
|
||||
date: date,
|
||||
moved_by: moved_by,
|
||||
order_items: order_items.as_json,
|
||||
},
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -200,14 +268,29 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
#Queue No Print
|
||||
def print_call_waiter(printer_settings,table,time,shop_detail)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
|
||||
pdf.render_file "tmp/print_call_waiter.pdf"
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print("tmp/print_call_waiter.pdf")
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
|
||||
|
||||
pdf.render_file "tmp/print_call_waiter.pdf"
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print("tmp/print_call_waiter.pdf")
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: print_settings.printer_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
shop_name: shop_detail.name,
|
||||
name: print_settings.name,
|
||||
table: table.name,
|
||||
time: time,
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -217,18 +300,18 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
# if count == 0
|
||||
# self.print(filename, printer_name)
|
||||
# else
|
||||
if count == 1
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, printer_name)
|
||||
end
|
||||
else
|
||||
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
|
||||
# no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, printer_name)
|
||||
end
|
||||
end
|
||||
if count == 1
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, printer_name)
|
||||
end
|
||||
else
|
||||
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
|
||||
# no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, printer_name)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
@@ -764,7 +764,7 @@ class Sale < ApplicationRecord
|
||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||
.sale_payments_with_audit_except_void_between(from, to)
|
||||
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
|
||||
.group("sale_id").to_sql
|
||||
.group("sale_id")
|
||||
|
||||
sale_taxes = Sale.select('sales.sale_id, sale_taxes.tax_name')
|
||||
.joins(:sale_taxes)
|
||||
@@ -789,13 +789,13 @@ class Sale < ApplicationRecord
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
|
||||
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
#{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(`#{pm}`) as `#{pm}`"}.push('').join(', ')}
|
||||
SUM(cash_amount) as cash_amount,
|
||||
SUM(credit_amount) as credit_amount,
|
||||
SUM(foc_amount) as foc_amount
|
||||
SUM(`cash_amount`) as `cash_amount`,
|
||||
SUM(`credit_amount`) as `credit_amount`,
|
||||
SUM(`foc_amount`) as `foc_amount`
|
||||
FROM (
|
||||
#{sales}
|
||||
#{sales.to_sql}
|
||||
) as s
|
||||
JOIN (#{sale_taxes.to_sql}) AS st ON s.sale_id = st.sale_id
|
||||
LEFT JOIN (#{sale_taxes.to_sql}) AS st ON s.sale_id = st.sale_id
|
||||
GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
|
||||
return daily_total
|
||||
end
|
||||
@@ -974,7 +974,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
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 IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
sale_cash = select(Sale.column_names).select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -997,7 +997,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
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 IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
sale_cash = select(Sale.column_names).select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1021,7 +1021,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
|
||||
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 IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
sale_cash = select(Sale.column_names).select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1080,7 +1080,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
|
||||
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 IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
sale_cash = select(Sale.column_names).select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1103,7 +1103,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
|
||||
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 IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
sale_cash = select(Sale.column_names).select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1127,7 +1127,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
|
||||
|
||||
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 IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
sale_cash = select(Sale.column_names).select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
class SeedGenerator < ApplicationRecord
|
||||
# Generate ID for Tables
|
||||
def self.generate_id(model, prefix)
|
||||
model_name = self.get_model_name(model)
|
||||
|
||||
prefix ||= ''
|
||||
prefix << '-' if prefix.present?
|
||||
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
prefix << 'C'
|
||||
else
|
||||
# else
|
||||
prefix << 'L'
|
||||
end
|
||||
|
||||
@@ -16,14 +14,12 @@ class SeedGenerator < ApplicationRecord
|
||||
prefix << shop.shop_code
|
||||
end
|
||||
|
||||
seed = self.update_seed(model_name)
|
||||
seed = self.update_seed(model)
|
||||
length = 16 - prefix.length
|
||||
prefix + seed.to_s.rjust(length, '0')
|
||||
end
|
||||
|
||||
def self.generate_ids(model, prefix, count = 1)
|
||||
model_name = self.get_model_name(model)
|
||||
|
||||
prefix ||= ''
|
||||
prefix << '-' if prefix.present?
|
||||
|
||||
@@ -37,7 +33,7 @@ class SeedGenerator < ApplicationRecord
|
||||
prefix << shop.shop_code
|
||||
end
|
||||
|
||||
start = self.update_seed(model_name, count)
|
||||
start = self.update_seed(model, count)
|
||||
stop = start + count - 1
|
||||
length = 16 - prefix.length
|
||||
(start..stop).map { |c| prefix + c.to_s.rjust(length, '0') }
|
||||
@@ -127,7 +123,8 @@ class SeedGenerator < ApplicationRecord
|
||||
|
||||
def self.update_seed(model, count = 1)
|
||||
SeedGenerator.transaction do
|
||||
seed = SeedGenerator.lock.find_by_model(model)
|
||||
seed = SeedGenerator.lock.find_by_model(get_model_name(model)) ||
|
||||
SeedGenerator.lock.find_by_model(model)
|
||||
seed.next = seed.next + (count * seed.increase_by)
|
||||
seed.current = seed.next - seed.increase_by
|
||||
seed.save!
|
||||
|
||||
@@ -152,7 +152,7 @@ class ShiftSale < ApplicationRecord
|
||||
def self.get_by_shift_other_payment(shift)
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
shift_other_payments = Sale.select("sales.sale_id,sale_payments.payment_method as name")
|
||||
shift_other_payments = Sale.select("sales.sale_id, sale_payments.payment_method as name")
|
||||
if payment_methods.present?
|
||||
shift_other_payments = shift_other_payments.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as `#{method == 'paypar' ? 'redeem' : method}`"}.join(', ')}")
|
||||
end
|
||||
@@ -210,6 +210,11 @@ class ShiftSale < ApplicationRecord
|
||||
.first()
|
||||
end
|
||||
|
||||
def self.get_other_charges(shift)
|
||||
query = SaleItem.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
|
||||
end
|
||||
|
||||
def self.search(filter,from,to)
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
|
||||
@@ -8,7 +8,7 @@ class Shop < ApplicationRecord
|
||||
accepts_nested_attributes_for :display_images
|
||||
|
||||
def file_data=(input_data)
|
||||
self.data = input_data.read
|
||||
self.data = input_data.read
|
||||
end
|
||||
|
||||
def self.current_shop
|
||||
|
||||
Reference in New Issue
Block a user