sx star printer setting rearrangement
This commit is contained in:
@@ -35,13 +35,24 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
# Print for First Bill to Customer
|
# Print for First Bill to Customer
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
|
print_settings = PrintSetting.all
|
||||||
|
if !print_settings.nil?
|
||||||
|
print_settings.each do |setting|
|
||||||
|
if setting.unique_code == 'ReceiptBillPdf'
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||||
|
unique_code = "ReceiptBillStarPdf"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
if !receipt_bill_a5_pdf.empty?
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||||
if receipt_bilA5[1] == '1'
|
if receipt_bilA5[1] == '1'
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
else
|
else
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = unique_code#{}"ReceiptBillPdf"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -169,13 +180,24 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
|
print_settings = PrintSetting.all
|
||||||
|
if !print_settings.nil?
|
||||||
|
print_settings.each do |setting|
|
||||||
|
if setting.unique_code == 'ReceiptBillPdf'
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||||
|
unique_code = "ReceiptBillStarPdf"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
if !receipt_bill_a5_pdf.empty?
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||||
if receipt_bilA5[1] == '1'
|
if receipt_bilA5[1] == '1'
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
else
|
# else
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -686,13 +708,23 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
else
|
else
|
||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
|
print_settings = PrintSetting.all
|
||||||
|
if !print_settings.nil?
|
||||||
|
print_settings.each do |setting|
|
||||||
|
if setting.unique_code == 'ReceiptBillPdf'
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||||
|
unique_code = "ReceiptBillStarPdf"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if !receipt_bill_a5_pdf.empty?
|
if !receipt_bill_a5_pdf.empty?
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||||
if receipt_bilA5[1] == '1'
|
if receipt_bilA5[1] == '1'
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
else
|
# else
|
||||||
unique_code = "ReceiptBillPdf"
|
# unique_code = "ReceiptBillPdf"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -256,6 +256,8 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
printer.each do |printer_setting|
|
printer.each do |printer_setting|
|
||||||
if printer_setting.unique_code == 'OrderItemPdf'
|
if printer_setting.unique_code == 'OrderItemPdf'
|
||||||
unique_code="OrderItemPdf"
|
unique_code="OrderItemPdf"
|
||||||
|
elsif printer_setting.unique_code == 'OrderItemStarPdf'
|
||||||
|
unique_code="OrderItemStarPdf"
|
||||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
||||||
unique_code="OrderItemSlimPdf"
|
unique_code="OrderItemSlimPdf"
|
||||||
elsif printer_setting.unique_code == 'OrderSetItemPdf'
|
elsif printer_setting.unique_code == 'OrderSetItemPdf'
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
print_setting.each do |print_settings|
|
print_setting.each do |print_settings|
|
||||||
if print_settings.unique_code == 'OrderItemPdf'
|
if print_settings.unique_code == 'OrderItemPdf'
|
||||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
||||||
|
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
||||||
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
||||||
@@ -100,6 +102,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
print_setting.each do |print_settings|
|
print_setting.each do |print_settings|
|
||||||
if print_settings.unique_code == 'OrderItemPdf'
|
if print_settings.unique_code == 'OrderItemPdf'
|
||||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||||
|
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
||||||
|
pdf = OrderItemStarPdfnew(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
||||||
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
||||||
@@ -207,6 +211,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
print_setting.each do |print_settings|
|
print_setting.each do |print_settings|
|
||||||
if print_settings.unique_code == 'OrderItemPdf'
|
if print_settings.unique_code == 'OrderItemPdf'
|
||||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||||
|
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
||||||
|
pdf = OrderItemStarPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
||||||
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
||||||
|
|||||||
@@ -195,14 +195,25 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
if !printer_settings.nil?
|
if !printer_settings.nil?
|
||||||
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
||||||
pdf = ReceiptBillPdf.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)
|
pdf = ReceiptBillPdf.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)
|
||||||
|
settings = PrintSetting.all
|
||||||
|
if !settings.nil?
|
||||||
|
settings.each do |setting|
|
||||||
|
if setting.unique_code == 'ReceiptBillPdf'
|
||||||
|
pdf = ReceiptBillPdf.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)
|
||||||
|
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||||
|
pdf = ReceiptBillStarPdf.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)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
if !receipt_bill_a5_pdf.empty?
|
if !receipt_bill_a5_pdf.empty?
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||||
if receipt_bilA5[1] == '1'
|
if receipt_bilA5[1] == '1'
|
||||||
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)
|
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)
|
||||||
else
|
# else
|
||||||
pdf = ReceiptBillPdf.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)
|
# pdf = ReceiptBillPdf.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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
117
app/pdf/move_table_star_pdf.rb
Normal file
117
app/pdf/move_table_star_pdf.rb
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
class MoveTableStarPdf < Prawn::Document
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||||
|
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||||
|
self.page_width = printer_settings.page_width
|
||||||
|
self.page_height = printer_settings.page_height
|
||||||
|
self.header_font_size = printer_settings.header_font_size.to_i
|
||||||
|
self.item_font_size = printer_settings.item_font_size.to_i
|
||||||
|
self.margin = 0
|
||||||
|
self.price_width = 40 # No Need for item
|
||||||
|
self.qty_width = 40
|
||||||
|
self.total_width = 40 # No Need for item
|
||||||
|
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||||
|
self.label_width=90
|
||||||
|
|
||||||
|
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if printer_settings.font != ""
|
||||||
|
font_families.update("#{printer_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{printer_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
end
|
||||||
|
|
||||||
|
header(printer_settings.name,type)
|
||||||
|
|
||||||
|
call_move_table(to,from,date,type,moved_by)
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
add_lining_item(order_items, printer_settings.precision)
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (name,type)
|
||||||
|
text "Move #{type}", :left_margin => -10, :size => self.header_font_size.to_i + 3,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
|
|
||||||
|
def call_move_table (to,from,date,type,moved_by)
|
||||||
|
move_down 3
|
||||||
|
text "Date Time : #{date.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :left_margin => -10, :size => self.header_font_size
|
||||||
|
text "Change [#{from}] To [#{to}]", :left_margin => -10, :size => self.header_font_size
|
||||||
|
text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_lining_item(order_items, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "Item", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||||
|
text "Qty", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
add_item(order_items, precision)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add order items under order info
|
||||||
|
def add_item(order_items, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
order_items.each do|odi|
|
||||||
|
# check for item not to show
|
||||||
|
# if odi.price != 0
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
# bounding_box([0,y_position], :width => self.item_width + 60, :height => self.item_height) do
|
||||||
|
# text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||||
|
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(odi.alt_name).empty?
|
||||||
|
move_down 4
|
||||||
|
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||||
|
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
162
app/pdf/order_item_star_pdf.rb
Normal file
162
app/pdf/order_item_star_pdf.rb
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
class OrderItemStarPdf < Prawn::Document
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||||
|
|
||||||
|
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
||||||
|
self.page_width = print_settings.page_width
|
||||||
|
self.page_height = print_settings.page_height
|
||||||
|
self.header_font_size = print_settings.header_font_size.to_i
|
||||||
|
self.item_font_size = print_settings.item_font_size.to_i
|
||||||
|
self.margin = 0
|
||||||
|
self.price_width = 40 # No Need for item
|
||||||
|
self.qty_width = 38
|
||||||
|
self.total_width = 40 # No Need for item
|
||||||
|
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||||
|
self.label_width=90
|
||||||
|
|
||||||
|
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if print_settings.font != ""
|
||||||
|
font_families.update("#{print_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{print_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
end
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
#font "public/fonts/Chinese.ttf"
|
||||||
|
if !order_item.dining.nil?
|
||||||
|
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||||
|
else
|
||||||
|
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 3
|
||||||
|
|
||||||
|
#order_info
|
||||||
|
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||||
|
|
||||||
|
# order items
|
||||||
|
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Write Order Information to PDF
|
||||||
|
def order_info(order_no, order_by, order_at)
|
||||||
|
#booking ID
|
||||||
|
booking_id = get_booking_id(order_no)
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 2
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 2
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 2
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
move_down 10
|
||||||
|
end
|
||||||
|
|
||||||
|
# Write Order items to PDF
|
||||||
|
def order_items(order_item, options, alt_name, precision, before_updated_qty)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
#Add Order Item
|
||||||
|
add_order_items(order_item, options, alt_name, precision)
|
||||||
|
|
||||||
|
dash(1, :space => 1, :phase => 1)
|
||||||
|
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||||
|
add_updated_qty_text(before_updated_qty, order_item.qty, precision)
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add order items under order info
|
||||||
|
def add_order_items(order_item, options, alt_name, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||||
|
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if alt_name
|
||||||
|
if order_item.alt_name
|
||||||
|
move_down 4
|
||||||
|
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||||
|
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !options.empty?
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
# add option
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
#add updated qty text
|
||||||
|
def add_updated_qty_text(before_updated_qty, updated_qty, precision)
|
||||||
|
if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
# add option
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_booking_id(order_no)
|
||||||
|
booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id")
|
||||||
|
.joins(" JOIN bookings b ON b.booking_id=bo.booking_id")
|
||||||
|
.where("orders.order_id='#{order_no}'")
|
||||||
|
.first()
|
||||||
|
|
||||||
|
return booking.booking_id
|
||||||
|
end
|
||||||
|
end
|
||||||
756
app/pdf/receipt_bill_star_pdf.rb
Normal file
756
app/pdf/receipt_bill_star_pdf.rb
Normal file
@@ -0,0 +1,756 @@
|
|||||||
|
class ReceiptBillStarPdf < Prawn::Document
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||||
|
|
||||||
|
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
|
||||||
|
self.page_width = printer_settings.page_width
|
||||||
|
self.page_height = printer_settings.page_height
|
||||||
|
self.header_font_size = printer_settings.header_font_size.to_i
|
||||||
|
self.item_font_size = printer_settings.item_font_size.to_i
|
||||||
|
self.margin = 0
|
||||||
|
self.price_width = 50
|
||||||
|
self.qty_width = 23
|
||||||
|
self.total_width = 50
|
||||||
|
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
|
self.label_width = 90
|
||||||
|
|
||||||
|
self.description_width = 140
|
||||||
|
self.price_num_width = 40
|
||||||
|
self.line_move = 2
|
||||||
|
# @item_width = self.page_width.to_i / 2
|
||||||
|
# @qty_width = @item_width.to_i / 3
|
||||||
|
# @double = @qty_width * 1.3
|
||||||
|
# @half_qty = @qty_width / 2
|
||||||
|
#setting page margin and width
|
||||||
|
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
|
#precision checked
|
||||||
|
if printer_settings.precision.to_i > 2
|
||||||
|
printer_settings.precision = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if printer_settings.font != ""
|
||||||
|
font_families.update("#{printer_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{printer_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
end
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
|
||||||
|
if printer_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
header(shop_details)
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
cashier_info(sale_data, customer_name, latest_order_no)
|
||||||
|
line_items(sale_items,printer_settings.precision,delimiter)
|
||||||
|
all_total(sale_data,printer_settings.precision,delimiter)
|
||||||
|
|
||||||
|
|
||||||
|
if member_info != nil
|
||||||
|
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
|
||||||
|
end
|
||||||
|
|
||||||
|
customer(customer_name)
|
||||||
|
|
||||||
|
#start card sale trans data
|
||||||
|
if card_data != nil
|
||||||
|
card_sale_data(card_data)
|
||||||
|
end
|
||||||
|
#end card sale trans data
|
||||||
|
#start card blanace amount
|
||||||
|
if !card_balance_amount.nil?
|
||||||
|
card_balance_data(card_balance_amount)
|
||||||
|
end
|
||||||
|
#end card blanace amount
|
||||||
|
|
||||||
|
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
|
||||||
|
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
|
||||||
|
end
|
||||||
|
|
||||||
|
if shop_details.show_account_info
|
||||||
|
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
|
||||||
|
if other_charges_amount
|
||||||
|
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#start for individual payment
|
||||||
|
if !sale_data.equal_persons.nil?
|
||||||
|
individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
|
||||||
|
end
|
||||||
|
#end for individual payment
|
||||||
|
|
||||||
|
sign(sale_data)
|
||||||
|
|
||||||
|
if shop_details.note && !shop_details.note.nil?
|
||||||
|
shop_note(shop_details)
|
||||||
|
end
|
||||||
|
|
||||||
|
footer(printed_status)
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (shop_details)
|
||||||
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
|
move_down line_move
|
||||||
|
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down line_move
|
||||||
|
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
def cashier_info(sale_data, customer_name, latest_order_no)
|
||||||
|
if latest_order_no.nil?
|
||||||
|
move_down line_move
|
||||||
|
text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
if !latest_order_no.nil?
|
||||||
|
move_down line_move
|
||||||
|
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
# move_down 2
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
|
||||||
|
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
if sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||||
|
bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do
|
||||||
|
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
if sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||||
|
time = sale_data.receipt_date.strftime('%d-%m-%Y') +"("+ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') +"-"+ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p')+")"
|
||||||
|
else
|
||||||
|
time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
|
||||||
|
text "Date : #{ time }",:size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
|
||||||
|
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
|
||||||
|
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
|
||||||
|
# :size => self.item_font_size,:align => :right
|
||||||
|
# end
|
||||||
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
def line_items(sale_items,precision,delimiter)
|
||||||
|
if precision.to_i > 0
|
||||||
|
item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_label_qty_end_width = self.qty_width + 1
|
||||||
|
item_label_total_front_width = (self.item_width+self.price_width) + 3
|
||||||
|
item_label_total_end_width = self.total_width + 3
|
||||||
|
else
|
||||||
|
# self.item_width = self.item_width.to_i + 3
|
||||||
|
item_label_qty_front_width = (self.item_width+self.price_width) + 3
|
||||||
|
item_label_qty_end_width = self.qty_width + 2
|
||||||
|
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_label_total_end_width = self.total_width + 1
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
move_down line_move
|
||||||
|
pad_top(15) {
|
||||||
|
# @item_width.to_i + @half_qty.to_i
|
||||||
|
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
|
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
|
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
|
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
|
}
|
||||||
|
# move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
add_line_item_row(sale_items,precision,delimiter)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_line_item_row(sale_items,precision,delimiter)
|
||||||
|
|
||||||
|
if precision.to_i > 0
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_qty_end_width = self.qty_width + 1
|
||||||
|
item_total_front_width = item_name_width + 3
|
||||||
|
item_total_end_width = self.total_width + 3
|
||||||
|
else
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = item_name_width + 3
|
||||||
|
item_qty_end_width = self.qty_width + 2
|
||||||
|
item_total_front_width = item_name_width + 2
|
||||||
|
item_total_end_width = self.total_width + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
move_down line_move
|
||||||
|
sub_total = 0.0
|
||||||
|
total_qty = 0.0
|
||||||
|
show_price = Lookup.find_by_lookup_type("show_price")
|
||||||
|
sale_items.each do |item|
|
||||||
|
# check for item not to show
|
||||||
|
|
||||||
|
if item.status != 'Discount' && item.qty > 0
|
||||||
|
if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0
|
||||||
|
total_qty += item.qty
|
||||||
|
else
|
||||||
|
if item.price != 0
|
||||||
|
total_qty += item.qty
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
product_name = item.product_name
|
||||||
|
|
||||||
|
# if item.status = 'promotion' && (item.remark =='promotion nett price' || item.remark == 'promotion discount')
|
||||||
|
# sub_total += -item.price #(item.qty*item.unit_price) - comment for room charges
|
||||||
|
# qty = -item.qty
|
||||||
|
# total_price = -item.price #item.qty*item.unit_price - comment for room charges
|
||||||
|
# price = -item.unit_price
|
||||||
|
# else
|
||||||
|
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
||||||
|
qty = item.qty
|
||||||
|
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
||||||
|
price = item.unit_price
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
if !show_price.nil? && show_price.value.to_i>0
|
||||||
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
|
else
|
||||||
|
if item.price != 0
|
||||||
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
|
||||||
|
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
|
text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
|
end
|
||||||
|
|
||||||
|
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
|
if precision.to_i > 0
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_qty_end_width = self.qty_width + 1
|
||||||
|
item_total_front_width = item_name_width + 3
|
||||||
|
item_total_end_width = self.total_width + 3
|
||||||
|
else
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = item_name_width + 3
|
||||||
|
item_qty_end_width = self.qty_width + 2
|
||||||
|
item_total_front_width = item_name_width + 2
|
||||||
|
item_total_end_width = self.total_width + 1
|
||||||
|
end
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
pad_top(15) {
|
||||||
|
bounding_box([0,y_position], :width =>self.item_width) do
|
||||||
|
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||||
|
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
|
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
|
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
|
|
||||||
|
if show_alt_name
|
||||||
|
if !(item.product_alt_name).empty?
|
||||||
|
move_down 2
|
||||||
|
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||||
|
text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def all_total(sale_data,precision,delimiter)
|
||||||
|
move_down line_move
|
||||||
|
item_name_width = self.item_width
|
||||||
|
y_position = cursor
|
||||||
|
if sale_data.discount_type == 'member_discount'
|
||||||
|
dis_type = "Member Discount:"
|
||||||
|
else
|
||||||
|
dis_type = "Overall Discount:"
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "#{ dis_type }", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
if sale_data.sale_taxes.length > 0
|
||||||
|
incl_tax = ""
|
||||||
|
if sale_data.tax_type == "inclusive"
|
||||||
|
incl_tax = "Incl."
|
||||||
|
end
|
||||||
|
|
||||||
|
sale_data.sale_taxes.each do |st|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# move_down 5
|
||||||
|
# y_position = cursor
|
||||||
|
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
# text "Total Tax", :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
|
if sale_data.rounding_adjustment != 0.0
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Rounding Adjustment", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
move_down line_move
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width) do
|
||||||
|
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
sale_payment(sale_data,precision,delimiter)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
|
stroke_horizontal_rule
|
||||||
|
#move_down line_move
|
||||||
|
sql = "SELECT SUM(payment_amount)
|
||||||
|
FROM sale_payments where payment_method='creditnote'
|
||||||
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
|
FROM sale_payments where payment_method='creditnote'
|
||||||
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||||
|
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
|
ELSE SUM(payment_amount) END
|
||||||
|
FROM sale_payments
|
||||||
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
|
JOIN sale_audits sa
|
||||||
|
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
||||||
|
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
||||||
|
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id)
|
||||||
|
.group("payment_method")
|
||||||
|
|
||||||
|
sale_payments.each do |payment|
|
||||||
|
y_position = cursor
|
||||||
|
if payment.payment_method == "paypar"
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Redeem Payment", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
else
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
if sale_data.amount_received > 0
|
||||||
|
y_position = cursor
|
||||||
|
move_down line_move
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
# move_down line_move
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# show member information
|
||||||
|
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||||
|
if rebate_amount != nil
|
||||||
|
if rebate_amount["status"] == true
|
||||||
|
stroke_horizontal_rule
|
||||||
|
total = 0
|
||||||
|
balance = 0
|
||||||
|
rebate_balance =0
|
||||||
|
redeem = 0
|
||||||
|
redeem_count = 0
|
||||||
|
rebate_amount["data"].each do |res|
|
||||||
|
total = total + res["balance"]
|
||||||
|
#total redeem amount
|
||||||
|
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
|
||||||
|
redeem = redeem + res["withdraw"]
|
||||||
|
balance = balance + res["balance"]
|
||||||
|
end
|
||||||
|
#end Total redem
|
||||||
|
#total Rebate Earn
|
||||||
|
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
|
||||||
|
|
||||||
|
rebate_balance = rebate_balance + res["deposit"]
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Rebate Earn", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
# Total Rebate Amount if birthday
|
||||||
|
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
|
||||||
|
rebate_balance = rebate_balance + res["deposit"]
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end Total rebate if birthday
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Redeem Amount", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
if current_balance != nil
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Old Balance", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if member_info["status"] == true && member_info["data"].present?
|
||||||
|
total_balance = 0
|
||||||
|
member_info["data"].each do |res|
|
||||||
|
|
||||||
|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||||
|
total_balance = total_balance + res["balance"]
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Total Balance", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def customer(customer_name)
|
||||||
|
# move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
#move_down line_move
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Customer Name", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def discount_account(discount_price_by_accounts,precision,delimiter)
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
discount_price_by_accounts.each do |ipa|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def items_account(item_price_by_accounts,precision,delimiter)
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
item_price_by_accounts.each do |ipa|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_other_charges_amount(other_amount,precision,delimiter)
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width) do
|
||||||
|
text "Other Charges", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
|
||||||
|
#individual payment per person
|
||||||
|
def individual_payment(sale_data, survey, precision, delimiter)
|
||||||
|
# per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
|
||||||
|
per_person = sale_data.grand_total.to_f / survey.to_i
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width+50) do
|
||||||
|
text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width) do
|
||||||
|
move_down 15
|
||||||
|
text "Amount Due (per person)", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
move_down 15
|
||||||
|
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sign(sale_data)
|
||||||
|
sql = "SELECT SUM(payment_amount)
|
||||||
|
FROM sale_payments where payment_method='creditnote'
|
||||||
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
|
FROM sale_payments where payment_method='creditnote'
|
||||||
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
|
ELSE SUM(payment_amount) END
|
||||||
|
FROM sale_payments
|
||||||
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
|
JOIN sale_audits sa
|
||||||
|
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
||||||
|
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
||||||
|
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
||||||
|
if payment.payment_method == "creditnote"
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
move_down 70
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
move_down 73
|
||||||
|
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||||
|
end
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if sale_data.payment_status == "foc" || sale_data.payment_status == "waste" || sale_data.payment_status == "spoile"
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
move_down 70
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
if sale_data.payment_status == "foc"
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
move_down 73
|
||||||
|
text "Acknowledged By" , :size => self.item_font_size,:align => :center
|
||||||
|
end
|
||||||
|
elsif sale_data.payment_status == "waste" || sale_data.payment_status == "spoile"
|
||||||
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
move_down 73
|
||||||
|
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def shop_note(shop)
|
||||||
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
text "#{shop.note}", :size => self.item_font_size, :align => :left
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
|
||||||
|
def footer(printed_status)
|
||||||
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.label_width) do
|
||||||
|
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width+20, :height => self.item_height) do
|
||||||
|
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down line_move
|
||||||
|
end
|
||||||
|
|
||||||
|
#start card sale trans data
|
||||||
|
def card_sale_data(card_data)
|
||||||
|
if card_data != nil && !card_data.empty?
|
||||||
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
card_data.each do |data|
|
||||||
|
if data['app'] == 'CUP'
|
||||||
|
data['app'] = 'UNIONPAY'
|
||||||
|
elsif data['app'] == 'MASTERCARD'
|
||||||
|
data['app'] = 'MASTER'
|
||||||
|
end
|
||||||
|
text "DATE/TIME: #{data['res_date']} #{data['res_time']} ", :size => @item_font_size, :align => :left
|
||||||
|
text "BATCH NUM: #{data['batch_no']} TRACE#: #{data['trace']}",:size => @item_font_size, :align => :left
|
||||||
|
text "RREF NUM: #{data['ref_no']} APPR CODE: #{data['app_code']} ",:size => @item_font_size, :align => :left
|
||||||
|
text "TID: #{data['tid']} ",:size => @item_font_size, :align => :left
|
||||||
|
text "#{data['app']} #{data['pan']} ",:size => @item_font_size, :align => :left
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#start card balance data
|
||||||
|
def card_balance_data(card_balance_amount)
|
||||||
|
if card_balance_amount > 0
|
||||||
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down line_move
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.label_width) do
|
||||||
|
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#check ReceiptBillAltName included
|
||||||
|
def show_alt_name
|
||||||
|
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
|
status = false
|
||||||
|
if !bill_alt_name.empty?
|
||||||
|
bill_alt_name.each do |alt_name|
|
||||||
|
if alt_name[0] == 'ReceiptBillAltName'
|
||||||
|
if alt_name[1] == '1'
|
||||||
|
status = true
|
||||||
|
else
|
||||||
|
status = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return status
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user