tweak order_summary and receipt bill pdfs

This commit is contained in:
DevTeam
2025-07-28 17:07:10 +06:30
parent ca6bb56fc3
commit cfa73532db
2 changed files with 70 additions and 7 deletions

View File

@@ -121,39 +121,47 @@ class OrderSummaryPdf < Prawn::Document
# Add order items under order info # Add order items under order info
def add_order_items(order_item, alt_name, precision) def add_order_items(order_item, alt_name, precision)
y_position = cursor y_position = cursor
order = order_item.first.order
sale_orders = order.sale_orders
sale = Sale.find_by(sale_id: sale_orders.first.sale_id)
sale_items = sale.sale_items.order(:product_name)
move_down 5 move_down 5
order_item.each do|odi| sale_items.each do|sale_item|
# check for item not to show # check for item not to show
# if odi.price != 0 # if odi.price != 0
if sale_item.status == 'foc' || sale_item.status == 'Discount'
next
end
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left text "#{sale_item.product_code} - #{sale_item.product_name}", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_width,y_position], :width => self.qty_width) do bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left text "#{number_format(sale_item.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end end
bounding_box([0,y_position], :width => self.item_width) do bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left text "#{sale_item.product_code} - #{sale_item.product_name}", :size => self.item_font_size,:align => :left
end end
if alt_name if alt_name
if !(odi.alt_name).empty? if !(sale_item.alt_name).empty?
move_down 4 move_down 4
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do # font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true text "(#{sale_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end # end
end end
end end
# add option # add option
odi = OrderItem.where(item_instance_code: sale_item.item_instance_code).first
options = odi.options == "[]"? "" : odi.options options = odi.options == "[]"? "" : odi.options
if options != "" if options != ""
@@ -174,6 +182,57 @@ class OrderSummaryPdf < Prawn::Document
move_down 5 move_down 5
# end # end
end end
# order_item.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) 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_format(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 alt_name
# 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
# # add option
# options = odi.options == "[]"? "" : odi.options
# if options != ""
# move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width => self.item_width) do
# text "#{options}", :size => self.item_font_size,:align => :left
# end
# move_down 5
# end
# move_down 5
# dash(1, :space => 1, :phase => 1)
# stroke_horizontal_line 0, (self.page_width - self.margin)
# move_down 5
# # end
# end
end end
def get_booking_id(order_no) def get_booking_id(order_no)

View File

@@ -263,6 +263,10 @@ class ReceiptBillPdf < Prawn::Document
end end
end end
if item.qty < 0 && item.status == 'void'
total_qty += item.qty
end
product_name = item.product_name product_name = item.product_name
# if item.status = 'promotion' && (item.remark =='promotion nett price' || item.remark == 'promotion discount') # if item.status = 'promotion' && (item.remark =='promotion nett price' || item.remark == 'promotion discount')