Add MoveTablePdf and FOC update error

This commit is contained in:
San Wai Lwin
2018-04-05 18:23:29 +06:30
parent 39e887c7a5
commit 769698e09e
6 changed files with 93 additions and 23 deletions

View File

@@ -1,18 +1,19 @@
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
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by)
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
self.item_font_size = printer_settings.item_font_size
self.margin = 5
self.price_width = 35
self.qty_width = 20
self.total_width = 35
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
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])
@@ -37,6 +38,12 @@ class MoveTablePdf < Prawn::Document
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)
@@ -54,5 +61,57 @@ class MoveTablePdf < Prawn::Document
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