Add MoveTablePdf and FOC update error
This commit is contained in:
@@ -62,9 +62,19 @@ class Origami::MovetableController < BaseOrigamiController
|
|||||||
bookings = Booking.where('dining_facility_id=?',change_from)
|
bookings = Booking.where('dining_facility_id=?',change_from)
|
||||||
|
|
||||||
booking_array = Array.new
|
booking_array = Array.new
|
||||||
bookings.each do | booking |
|
order_items = Array.new
|
||||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
if !bookings.nil?
|
||||||
booking_array.push(booking)
|
bookings.each do | booking |
|
||||||
|
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||||
|
booking_array.push(booking)
|
||||||
|
end
|
||||||
|
|
||||||
|
booking.booking_orders.each do |booking_order|
|
||||||
|
order = Order.find(booking_order.order_id)
|
||||||
|
order.order_items.each do |order_item|
|
||||||
|
order_items.push(order_item)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,12 +92,13 @@ class Origami::MovetableController < BaseOrigamiController
|
|||||||
#print_settings = PrintSetting.find_by_unique_code(unique_code)
|
#print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
printer_array = []
|
printer_array = []
|
||||||
printer_array = PrintSetting.where(:unique_code => unique_code)
|
printer_array = PrintSetting.where(:unique_code => unique_code)
|
||||||
|
|
||||||
for i in 0..pdf_no
|
for i in 0..pdf_no
|
||||||
if i != pdf_no
|
if i != pdf_no
|
||||||
print_settings = printer_array[i]
|
print_settings = printer_array[i]
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by)
|
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -239,11 +239,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Move Table Print
|
#Move Table Print
|
||||||
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by)
|
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by)
|
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||||
pdf.render_file "tmp/print_move_table.pdf"
|
pdf.render_file "tmp/print_move_table.pdf"
|
||||||
self.print("tmp/print_move_table.pdf")
|
self.print("tmp/print_move_table.pdf")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
# add to sale item with foc
|
# add to sale item with foc
|
||||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and status is null")
|
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
||||||
|
|
||||||
sale_items.each do|item|
|
sale_items.each do|item|
|
||||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
class MoveTablePdf < Prawn::Document
|
class MoveTablePdf < Prawn::Document
|
||||||
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
|
include ActionView::Helpers::NumberHelper
|
||||||
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by)
|
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_width = printer_settings.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size
|
self.header_font_size = printer_settings.header_font_size
|
||||||
self.item_font_size = printer_settings.item_font_size
|
self.item_font_size = printer_settings.item_font_size
|
||||||
self.margin = 5
|
self.margin = 0
|
||||||
self.price_width = 35
|
self.price_width = 40 # No Need for item
|
||||||
self.qty_width = 20
|
self.qty_width = 40
|
||||||
self.total_width = 35
|
self.total_width = 40 # No Need for item
|
||||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||||
self.item_height = 15
|
self.item_height = 15
|
||||||
self.item_description_width = (self.page_width-20) / 2
|
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||||
self.label_width = 100
|
self.label_width=90
|
||||||
|
|
||||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
@@ -37,6 +38,12 @@ class MoveTablePdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
|
add_lining_item(order_items, printer_settings.precision)
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def header (name,type)
|
def header (name,type)
|
||||||
@@ -54,5 +61,57 @@ class MoveTablePdf < Prawn::Document
|
|||||||
text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size
|
text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ class OrderItemPdf < Prawn::Document
|
|||||||
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
||||||
self.page_width = print_settings.page_width
|
self.page_width = print_settings.page_width
|
||||||
self.page_height = print_settings.page_height
|
self.page_height = print_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size
|
self.header_font_size = print_settings.header_font_size
|
||||||
self.item_font_size = printer_settings.item_font_size
|
self.item_font_size = print_settings.item_font_size
|
||||||
self.margin = 0
|
self.margin = 0
|
||||||
self.price_width = 40 # No Need for item
|
self.price_width = 40 # No Need for item
|
||||||
self.qty_width = 40
|
self.qty_width = 40
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ class OrderSummaryPdf < Prawn::Document
|
|||||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||||
self.page_width = print_settings.page_width
|
self.page_width = print_settings.page_width
|
||||||
self.page_height = print_settings.page_height
|
self.page_height = print_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size
|
self.header_font_size = print_settings.header_font_size
|
||||||
self.item_font_size = printer_settings.item_font_size
|
self.item_font_size = print_settings.item_font_size
|
||||||
self.margin = 0
|
self.margin = 0
|
||||||
self.price_width = 40 # No Need for item
|
self.price_width = 40 # No Need for item
|
||||||
self.qty_width = 40
|
self.qty_width = 40
|
||||||
|
|||||||
Reference in New Issue
Block a user