update receipt pdf for 0price
This commit is contained in:
@@ -186,57 +186,31 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_line_item_row(sale_items,precision,delimiter)
|
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) + 5
|
|
||||||
item_qty_end_width = self.qty_width + 4
|
|
||||||
item_total_front_width = item_name_width + 10
|
|
||||||
item_total_end_width = self.total_width + 9
|
|
||||||
else
|
|
||||||
item_name_width = (self.item_width+self.price_width)
|
|
||||||
item_qty_front_width = item_name_width + 8
|
|
||||||
item_qty_end_width = self.qty_width + 7
|
|
||||||
item_total_front_width = item_name_width + 5
|
|
||||||
item_total_end_width = self.total_width + 4
|
|
||||||
end
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
move_down line_move
|
move_down line_move
|
||||||
sub_total = 0.0
|
sub_total = 0.0
|
||||||
total_qty = 0.0
|
total_qty = 0.0
|
||||||
sale_items.each do |item|
|
sale_items.each do |item|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
if item.price != 0
|
|
||||||
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
|
||||||
if item.status != 'Discount' && item.qty > 0
|
|
||||||
total_qty += item.qty
|
|
||||||
end
|
|
||||||
qty = item.qty
|
|
||||||
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
|
||||||
price = item.unit_price
|
|
||||||
product_name = item.product_name
|
|
||||||
|
|
||||||
|
show_price = Lookup.find_by_lookup_type("show_price").value
|
||||||
|
|
||||||
y_position = cursor
|
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
||||||
|
if item.status != 'Discount' && item.qty > 0
|
||||||
|
total_qty += item.qty
|
||||||
|
end
|
||||||
|
qty = item.qty
|
||||||
|
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
||||||
|
price = item.unit_price
|
||||||
|
product_name = item.product_name
|
||||||
|
|
||||||
pad_top(15) {
|
if show_price.to_i>0
|
||||||
bounding_box([0,y_position], :width =>self.item_width) do
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
else
|
||||||
end
|
if item.price != 0
|
||||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
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
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -255,6 +229,45 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
end
|
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) + 5
|
||||||
|
item_qty_end_width = self.qty_width + 4
|
||||||
|
item_total_front_width = item_name_width + 10
|
||||||
|
item_total_end_width = self.total_width + 9
|
||||||
|
else
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = item_name_width + 8
|
||||||
|
item_qty_end_width = self.qty_width + 7
|
||||||
|
item_total_front_width = item_name_width + 5
|
||||||
|
item_total_end_width = self.total_width + 4
|
||||||
|
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)
|
def all_total(sale_data,precision,delimiter)
|
||||||
move_down line_move
|
move_down line_move
|
||||||
item_name_width = self.item_width
|
item_name_width = self.item_width
|
||||||
|
|||||||
@@ -180,58 +180,32 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_line_item_row(sale_items,precision,delimiter)
|
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) + 5
|
|
||||||
item_qty_end_width = self.qty_width + 4
|
|
||||||
item_total_front_width = item_name_width + 10
|
|
||||||
item_total_end_width = self.total_width + 9
|
|
||||||
else
|
|
||||||
item_name_width = (self.item_width+self.price_width)
|
|
||||||
item_qty_front_width = item_name_width + 8
|
|
||||||
item_qty_end_width = self.qty_width + 7
|
|
||||||
item_total_front_width = item_name_width + 5
|
|
||||||
item_total_end_width = self.total_width + 4
|
|
||||||
end
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
move_down line_move
|
move_down line_move
|
||||||
sub_total = 0.0
|
sub_total = 0.0
|
||||||
total_qty = 0.0
|
total_qty = 0.0
|
||||||
sale_items.each do |item|
|
sale_items.each do |item|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
if item.price != 0
|
show_price = Lookup.find_by_lookup_type("show_price").value
|
||||||
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
|
||||||
if item.status != 'Discount' && item.qty > 0
|
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
||||||
total_qty += item.qty
|
if item.status != 'Discount' && item.qty > 0
|
||||||
end
|
total_qty += item.qty
|
||||||
qty = item.qty
|
end
|
||||||
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
qty = item.qty
|
||||||
price = item.unit_price
|
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
||||||
product_name = item.product_name
|
price = item.unit_price
|
||||||
|
product_name = item.product_name
|
||||||
|
|
||||||
y_position = cursor
|
if show_price.to_i>0
|
||||||
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
pad_top(15) {
|
else
|
||||||
bounding_box([0,y_position], :width =>self.item_width) do
|
if item.price != 0
|
||||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
@@ -249,6 +223,45 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
end
|
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) + 5
|
||||||
|
item_qty_end_width = self.qty_width + 4
|
||||||
|
item_total_front_width = item_name_width + 10
|
||||||
|
item_total_end_width = self.total_width + 9
|
||||||
|
else
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = item_name_width + 8
|
||||||
|
item_qty_end_width = self.qty_width + 7
|
||||||
|
item_total_front_width = item_name_width + 5
|
||||||
|
item_total_end_width = self.total_width + 4
|
||||||
|
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)
|
def all_total(sale_data,precision,delimiter)
|
||||||
move_down line_move
|
move_down line_move
|
||||||
item_name_width = self.item_width
|
item_name_width = self.item_width
|
||||||
|
|||||||
Reference in New Issue
Block a user