fixed print serviceaction cable
This commit is contained in:
@@ -67,10 +67,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
@@ -126,34 +123,10 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||
if find_close_cashier_print[0][1].to_i > 0
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods)
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods,@other_charges)
|
||||
end
|
||||
end
|
||||
p "close cashier print<==============================="
|
||||
p @other_charges
|
||||
p @total_amount_by_account
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: "Cashier",
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
shop_details: shop_details.as_json,
|
||||
shift_sale: @shift,
|
||||
cashier_terminal: cashier_terminal,
|
||||
shift_employee: @shift.employee,
|
||||
sale_items: @sale_items,
|
||||
sale_taxes: @sale_taxes,
|
||||
other_payment: @other_payment,
|
||||
total_amount_by_account: @total_amount_by_account,
|
||||
total_discount_by_account: @total_discount_by_account,
|
||||
total_member_discount: @total_member_discount,
|
||||
total_waste: @total_waste,
|
||||
total_spoile: @total_spoile,
|
||||
other_charges: @other_charges,
|
||||
total_other_charges: @total_other_charges,
|
||||
total_credit_payments: @total_credit_payments
|
||||
}
|
||||
)
|
||||
# end
|
||||
|
||||
end
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = 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,7 +38,7 @@ 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,other_charges)
|
||||
|
||||
if !sale_items.blank? or !sale_items.nil?
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@@ -74,10 +74,32 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, cashier_terminal.printer_name)
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: "Cashier",
|
||||
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,
|
||||
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,
|
||||
other_charges: other_charges,
|
||||
total_other_charges: total_other_charges,
|
||||
total_credit_payments: total_credit_payments
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,7 +108,18 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: 'Cashier',
|
||||
unique_code: print_settings.unique_code,
|
||||
@@ -105,18 +138,6 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
},
|
||||
}
|
||||
)
|
||||
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
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
end
|
||||
end
|
||||
#sqa
|
||||
|
||||
@@ -15,18 +15,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
pdf = print_settings.unique_code.constantize.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
booking_id = Booking.get_booking_id(order_id)
|
||||
# end
|
||||
puts "print_channel_#{Shop.current_shop.shop_code}"
|
||||
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: {
|
||||
order_item: order_item[0].as_json(methods: :type),
|
||||
print_status: print_status.gsub(/[()]/, ""),
|
||||
booking_id: booking_id,
|
||||
precision: print_settings.precision
|
||||
}
|
||||
)
|
||||
|
||||
shop = Shop.current_shop
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
@@ -38,6 +26,18 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
else
|
||||
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: {
|
||||
order_item: order_item[0].as_json(methods: :type),
|
||||
print_status: print_status.gsub(/[()]/, ""),
|
||||
booking_id: booking_id,
|
||||
precision: print_settings.precision
|
||||
}
|
||||
)
|
||||
end
|
||||
#For print copy
|
||||
# pdf.render_file filename.gsub(".","-copy.")
|
||||
@@ -87,6 +87,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
booking_id = Booking.get_booking_id(order_id) #order[0].order_id
|
||||
order = print_query('order_summary', order_id)
|
||||
|
||||
filename = directory_name + "/order_summary_#{order_id}.pdf"
|
||||
@@ -97,10 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
end
|
||||
booking_id = Booking.get_booking_id(order_id) #order[0].order_id
|
||||
puts "printing>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||
puts "print_channel_#{Shop.current_shop.shop_code}"
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.station_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
@@ -112,6 +110,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
booking_id: booking_id,
|
||||
precision: print_settings.precision}
|
||||
)
|
||||
end
|
||||
|
||||
#For print copy
|
||||
# pdf.render_file filename.gsub(".","-copy.")
|
||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||
|
||||
@@ -106,6 +106,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
pdf = ReceiptBillOrderPdf.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,order_reservation)
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: "Cashier",
|
||||
unique_code: print_settings.unique_code,
|
||||
@@ -133,6 +134,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
footer: { printed_status: printed_status, footer_text: "Thank You! See you Again" }
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
# print as print copies in printer setting
|
||||
count = printer_settings.print_copies
|
||||
@@ -199,10 +201,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
#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"
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
if oqs.print_copy
|
||||
self.print("tmp/print_move_table.pdf",oqs.printer_name)
|
||||
else
|
||||
@@ -211,6 +213,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
#no print in cloud server
|
||||
self.print("tmp/print_move_table.pdf", oqs.printer_name)
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.station_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
@@ -227,6 +230,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_crm_order(booking,order_items,setting)
|
||||
|
||||
@@ -755,7 +755,7 @@ class Sale < ApplicationRecord
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
sales = select(Sale.column_names)
|
||||
.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}"}.push('').join(', ')}
|
||||
.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}`"}.push('').join(', ')}
|
||||
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) -
|
||||
SUM(case when (sale_payments.payment_method not in('creditnote') and sale_audits.sale_audit_id IS NOT NULL) then sale_payments.payment_amount else 0 end) as credit_amount,
|
||||
@@ -776,7 +776,7 @@ 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 grand_total else 0 end),0) / 21) as net_sale,
|
||||
(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(', ')}
|
||||
#{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
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
class SeedGenerator < ApplicationRecord
|
||||
# Generate ID for Tables
|
||||
def self.generate_id(model, prefix)
|
||||
model_name = self.get_model_name(model)
|
||||
# model_name = self.get_model_name(model)
|
||||
model_name = model
|
||||
|
||||
prefix ||= ''
|
||||
prefix << '-' if prefix.present?
|
||||
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
prefix << 'C'
|
||||
else
|
||||
# else
|
||||
prefix << 'L'
|
||||
end
|
||||
|
||||
@@ -22,7 +23,8 @@ class SeedGenerator < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.generate_ids(model, prefix, count = 1)
|
||||
model_name = self.get_model_name(model)
|
||||
# model_name = self.get_model_name(model)
|
||||
model_name = model
|
||||
|
||||
prefix ||= ''
|
||||
prefix << '-' if prefix.present?
|
||||
|
||||
@@ -152,9 +152,9 @@ 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(', ')}")
|
||||
shift_other_payments = Sale.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
|
||||
shift_other_payments.select("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")
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
development:
|
||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||
sx_provision_url: connect.smartsales.asia/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||
server_mode: application
|
||||
server_mode: cloud
|
||||
cipher_type: AES-256-CBC
|
||||
sx_key: Wh@t1$C2L
|
||||
|
||||
|
||||
Reference in New Issue
Block a user