to do req_bill_format and status changed after pay
This commit is contained in:
@@ -1,29 +1,46 @@
|
||||
class OrderItemPdf < Prawn::Document
|
||||
|
||||
attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:item_description_width
|
||||
def initialize(order_item, print_settings)
|
||||
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
self.page_width = 300
|
||||
self.page_height = 400
|
||||
self.margin = 10
|
||||
self.price_width = 50
|
||||
self.qty_width = 50
|
||||
self.item_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.receipt_width=130
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# 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 "#{order_item.dining}", :size => 15
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
text "#{order_item.dining}", :size => self.header_font_size,:align => :center
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
#order_info
|
||||
order_info(order_item.order_by,order_item.order_at, order_item.customer)
|
||||
order_info(order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_by, order_at, customer)
|
||||
def order_info(order_by, order_at)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 200, :height => 15) do
|
||||
text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width - 50, :height => self.item_height) do
|
||||
text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 50,y_position], :width => self.item_width + 50, :height => self.item_height) do
|
||||
text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -35,12 +52,12 @@ class OrderItemPdf < Prawn::Document
|
||||
def order_items(order_item)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 180, :height => 15) do
|
||||
text "Item", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Item", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 15) do
|
||||
text "Qty", :size => 7,:align => :right
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "Qty", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -56,12 +73,12 @@ class OrderItemPdf < Prawn::Document
|
||||
|
||||
move_down 5
|
||||
|
||||
bounding_box([0,y_position], :width => 180, :height => 20) do
|
||||
text "#{order_item.item_name}", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 20) do
|
||||
text "#{order_item.qty}", :size => 7,:align => :right
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "#{order_item.qty}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
class OrderSummaryPdf < Prawn::Document
|
||||
|
||||
attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:item_description_width
|
||||
def initialize(order, print_settings)
|
||||
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
self.page_width = 300
|
||||
self.page_height = 400
|
||||
self.margin = 10
|
||||
self.price_width = 60
|
||||
self.qty_width = 60
|
||||
self.item_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.receipt_width=130
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
font_size 9
|
||||
text "#{order[0].dining}", :size => 15
|
||||
text "#{order[0].dining}", :size => self.header_font_size,:align => :center
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
#order_info
|
||||
order_info(order[0].order_by,order[0].order_at, order[0].customer)
|
||||
order_info(order[0].order_by,order[0].order_at)
|
||||
|
||||
# order items
|
||||
order_items(order)
|
||||
@@ -21,11 +32,15 @@ class OrderSummaryPdf < Prawn::Document
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_by, order_at, customer)
|
||||
def order_info(order_by, order_at)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 200, :height => 15) do
|
||||
text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width - 20, :height => self.item_height) do
|
||||
text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 20,y_position], :width => self.item_width + 20, :height => self.item_height) do
|
||||
text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -37,12 +52,12 @@ class OrderSummaryPdf < Prawn::Document
|
||||
def order_items(order_item)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 180, :height => 15) do
|
||||
text "Item", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Item", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 15) do
|
||||
text "Qty", :size => 7,:align => :right
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "Qty", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -59,13 +74,13 @@ class OrderSummaryPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
order_item.each do|odi|
|
||||
bounding_box([0,y_position], :width => 180, :height => 20) do
|
||||
text "#{odi.item_name}", :size => 7,:align => :left
|
||||
end
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 20) do
|
||||
text "#{odi.qty}", :size => 7,:align => :right
|
||||
end
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "#{odi.qty}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
class ReceiptBillPdf < Prawn::Document
|
||||
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name)
|
||||
self.p_width = 200
|
||||
attr_accessor :receipt_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, sale_items, sale_data, customer_name, food_total, beverage_total)
|
||||
self.page_width = 300
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
# self.price_width = self.p_width / 2
|
||||
self.price_width=80
|
||||
self.item_width = self.p_width - self.price_width
|
||||
self.item_height = self.item_height
|
||||
self.qty_column_width = self.p_width / 2
|
||||
self.item_description_width=self.p_width - self.price_width
|
||||
self.receipt_width=130
|
||||
self.price_width = 50
|
||||
self.qty_width = 30
|
||||
self.total_width = 50
|
||||
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 - (self.price_width + self.qty_width + self.total_width)
|
||||
self.receipt_width=100
|
||||
|
||||
@item_width = self.p_width.to_i / 2
|
||||
@qty_width = @item_width.to_i / 3
|
||||
@double = @qty_width * 1.3
|
||||
@half_qty = @qty_width / 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.p_width, self.page_height])
|
||||
self.header_font_size = 10
|
||||
self.item_font_size = 9
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
header( printer_settings.printer_name, printer_settings.name)
|
||||
stroke_horizontal_rule
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name)
|
||||
line_items(sale_items)
|
||||
line_items(sale_items, food_total, beverage_total)
|
||||
all_total(sale_data)
|
||||
|
||||
|
||||
@@ -38,71 +44,66 @@ class ReceiptBillPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
end
|
||||
|
||||
def cashier_info(sale_data, customer_name)
|
||||
move_down 5
|
||||
move_down 2
|
||||
move_down 7
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
text "Receipt No:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.price_width, y_position], :width =>self.receipt_width) do
|
||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
||||
bounding_box([self.receipt_width, y_position], :width =>self.receipt_width) do
|
||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
text "Customer:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
|
||||
text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
text "Date:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
|
||||
text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# stroke_horizontal_rule
|
||||
move_down 5
|
||||
end
|
||||
|
||||
def line_items(sale_items)
|
||||
def line_items(sale_items, food_total, beverage_total)
|
||||
y_position = cursor
|
||||
qty_column_width = self.p_width * 0.2
|
||||
item_description_width = self.p_width * 0.5
|
||||
price_column_width = self.p_width * 0.3
|
||||
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "Items", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "Price", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "Qty", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "Total", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "Items", :at =>[0,y_position], :width => self.item_width - 20, :height =>self.item_height, :size => self.item_font_size
|
||||
text_box "Price", :at =>[self.item_width-20,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "Qty", :at =>[self.item_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "Total", :at =>[self.item_width+self.price_width+self.qty_width,y_position], :width => self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
|
||||
}
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
|
||||
add_line_item_row(sale_items)
|
||||
add_line_item_row(sale_items, food_total, beverage_total)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def add_line_item_row(sale_items)
|
||||
def add_line_item_row(sale_items, food_total, beverage_total)
|
||||
item_name_width = self.item_width-20
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
sub_total = 0.0
|
||||
@@ -119,53 +120,67 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "#{product_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{product_name}", :at =>[0,y_position], :width => item_name_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "#{price}", :at =>[item_name_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "#{qty.to_i}", :at =>[item_name_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "#{total_price}", :at =>[item_name_width+self.price_width+self.qty_width,y_position], :width =>self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
|
||||
}
|
||||
move_down 3
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "#{sub_total}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
# Food and Beverage
|
||||
food_beverage_total = food_total.to_s + '/' + beverage_total.to_s
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Food/Beverage Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
def all_total(sale_data)
|
||||
item_name_width = self.item_width-20
|
||||
move_down 5
|
||||
y_position =cursor
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Discount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position =cursor
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Grand Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
|
||||
Reference in New Issue
Block a user