receipt update
This commit is contained in:
25
app/models/printer/cashier_station_printer.rb
Normal file
25
app/models/printer/cashier_station_printer.rb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||||
|
|
||||||
|
def print_open_cashier(receipt_no)
|
||||||
|
time = DateTime.now
|
||||||
|
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
pdf = CashierStationOpening.new
|
||||||
|
pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
|
||||||
|
self.print("tmp/cashier_station_#{order_id}_closing_#{time}.pdf")
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_close_cashier(receipt_no)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
time = DateTime.now
|
||||||
|
#Print
|
||||||
|
pdf = CashierStationClosing.new
|
||||||
|
pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
|
||||||
|
self.print("tmp/receipt.pdf")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
22
app/models/printer/order_queue_printer.rb
Normal file
22
app/models/printer/order_queue_printer.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||||
|
|
||||||
|
def print_order_item(order_queue_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
pdf = OrderItemPdf.new
|
||||||
|
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
|
||||||
|
self.print("tmp/receipt.pdf")
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_order_summary(booking_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
self.print(filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
50
app/models/printer/printer_worker.rb
Normal file
50
app/models/printer/printer_worker.rb
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
require 'net/http'
|
||||||
|
require 'cups'
|
||||||
|
|
||||||
|
class Printer::PrinterWorker
|
||||||
|
attr_accessor :print_settings
|
||||||
|
|
||||||
|
def initialize(print_settings)
|
||||||
|
self.print_settings = print_settings
|
||||||
|
end
|
||||||
|
|
||||||
|
def printer_destination()
|
||||||
|
if self.print_settings
|
||||||
|
self.print_settings.printer_name
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_copies()
|
||||||
|
if self.print_settings
|
||||||
|
self.print_settings.print_copies.to_i
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def printers()
|
||||||
|
Cups.show_destinations
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_printer()
|
||||||
|
Cups.default_printer
|
||||||
|
end
|
||||||
|
|
||||||
|
def print(file_path,printer_destination = nil )
|
||||||
|
|
||||||
|
if printer_destination.nil?
|
||||||
|
printer_destination = self.printer_destination
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
66
app/models/printer/receipt_printer.rb
Normal file
66
app/models/printer/receipt_printer.rb
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||||
|
|
||||||
|
def print_receipt(receipt_no)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
pdf = OrderItemPdf.new
|
||||||
|
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
|
||||||
|
self.print("tmp/receipt.pdf")
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_receipt_payment_by_card(booking_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
self.print(filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_receipt_payment_by_account(sale_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
self.print(filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_receipt_payment_by_vochure(sale_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
self.print(filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_receipt_payment_by_giftcard(sale_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
self.print(filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_receipt_payment_by_foc(sale_id)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
self.print(filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
18
app/pdf/order_item_pdf.rb
Normal file
18
app/pdf/order_item_pdf.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
class OrderItemPdf < Prawn::Document
|
||||||
|
|
||||||
|
def initialize(order_item, print_settings)
|
||||||
|
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||||
|
|
||||||
|
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
|
||||||
|
|
||||||
|
font_size 9
|
||||||
|
text "#{"table_name"}", :size => 15
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
17
app/pdf/order_summary_pdf.rb
Normal file
17
app/pdf/order_summary_pdf.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
class OrderSummaryPdf < Prawn::Document
|
||||||
|
|
||||||
|
def initialize(order, print_settings)
|
||||||
|
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||||
|
|
||||||
|
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
|
||||||
|
|
||||||
|
font_size 9
|
||||||
|
text "#{"table_name"}", :size => 15
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
4
db/migrate/20170421171849_add_company_address_email.rb
Normal file
4
db/migrate/20170421171849_add_company_address_email.rb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
class AddCompanyAddressEmail < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user