update receipt pdf for 0price
This commit is contained in:
@@ -186,6 +186,51 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_line_item_row(sale_items,precision,delimiter)
|
def add_line_item_row(sale_items,precision,delimiter)
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
move_down line_move
|
||||||
|
sub_total = 0.0
|
||||||
|
total_qty = 0.0
|
||||||
|
sale_items.each do |item|
|
||||||
|
# check for item not to show
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
if show_price.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
|
||||||
|
bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
|
||||||
|
end
|
||||||
|
bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
|
|
||||||
if precision.to_i > 0
|
if precision.to_i > 0
|
||||||
item_name_width = (self.item_width+self.price_width)
|
item_name_width = (self.item_width+self.price_width)
|
||||||
item_qty_front_width = (self.item_width+self.price_width) + 5
|
item_qty_front_width = (self.item_width+self.price_width) + 5
|
||||||
@@ -199,22 +244,6 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
item_total_front_width = item_name_width + 5
|
item_total_front_width = item_name_width + 5
|
||||||
item_total_end_width = self.total_width + 4
|
item_total_end_width = self.total_width + 4
|
||||||
end
|
end
|
||||||
y_position = cursor
|
|
||||||
move_down line_move
|
|
||||||
sub_total = 0.0
|
|
||||||
total_qty = 0.0
|
|
||||||
sale_items.each do |item|
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
@@ -238,22 +267,6 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
move_down line_move
|
move_down line_move
|
||||||
}
|
}
|
||||||
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
|
|
||||||
bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
|
|
||||||
text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
|
|
||||||
end
|
|
||||||
bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
|
|
||||||
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def all_total(sale_data,precision,delimiter)
|
def all_total(sale_data,precision,delimiter)
|
||||||
move_down line_move
|
move_down line_move
|
||||||
|
|||||||
@@ -180,6 +180,50 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_line_item_row(sale_items,precision,delimiter)
|
def add_line_item_row(sale_items,precision,delimiter)
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
move_down line_move
|
||||||
|
sub_total = 0.0
|
||||||
|
total_qty = 0.0
|
||||||
|
sale_items.each do |item|
|
||||||
|
# check for item not to show
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
if show_price.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
|
||||||
|
bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
|
||||||
|
end
|
||||||
|
bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
if precision.to_i > 0
|
if precision.to_i > 0
|
||||||
item_name_width = (self.item_width+self.price_width)
|
item_name_width = (self.item_width+self.price_width)
|
||||||
item_qty_front_width = (self.item_width+self.price_width) + 5
|
item_qty_front_width = (self.item_width+self.price_width) + 5
|
||||||
@@ -193,22 +237,6 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
item_total_front_width = item_name_width + 5
|
item_total_front_width = item_name_width + 5
|
||||||
item_total_end_width = self.total_width + 4
|
item_total_end_width = self.total_width + 4
|
||||||
end
|
end
|
||||||
y_position = cursor
|
|
||||||
move_down line_move
|
|
||||||
sub_total = 0.0
|
|
||||||
total_qty = 0.0
|
|
||||||
sale_items.each do |item|
|
|
||||||
# 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
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
pad_top(15) {
|
pad_top(15) {
|
||||||
@@ -231,22 +259,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
move_down line_move
|
move_down line_move
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
|
|
||||||
text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
|
|
||||||
end
|
|
||||||
bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
|
|
||||||
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_total(sale_data,precision,delimiter)
|
def all_total(sale_data,precision,delimiter)
|
||||||
|
|||||||
Reference in New Issue
Block a user