diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 9a1c8b7b..9071f666 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -121,39 +121,47 @@ class OrderSummaryPdf < Prawn::Document # Add order items under order info def add_order_items(order_item, alt_name, precision) 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 - order_item.each do|odi| + sale_items.each do|sale_item| # check for item not to show # if odi.price != 0 + if sale_item.status == 'foc' || sale_item.status == 'Discount' + next + end 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 + text "#{sale_item.product_code} - #{sale_item.product_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 + text "#{number_format(sale_item.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 + text "#{sale_item.product_code} - #{sale_item.product_name}", :size => self.item_font_size,:align => :left end if alt_name - if !(odi.alt_name).empty? + if !(sale_item.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 + text "(#{sale_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true # end end end # add option + odi = OrderItem.where(item_instance_code: sale_item.item_instance_code).first options = odi.options == "[]"? "" : odi.options if options != "" @@ -174,6 +182,57 @@ class OrderSummaryPdf < Prawn::Document move_down 5 # 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 def get_booking_id(order_no) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index a760db23..c3e5feac 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -252,7 +252,7 @@ class ReceiptBillPdf < Prawn::Document show_price = Lookup.find_by_lookup_type("show_price") sale_items.each do |item| # check for item not to show - + if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 total_qty += item.qty @@ -263,6 +263,10 @@ class ReceiptBillPdf < Prawn::Document end end + if item.qty < 0 && item.status == 'void' + total_qty += item.qty + end + product_name = item.product_name # if item.status = 'promotion' && (item.remark =='promotion nett price' || item.remark == 'promotion discount')