add updated qty text in oqs

This commit is contained in:
phyusin
2018-02-05 15:29:31 +06:30
parent 0ef45bbc70
commit 2ebfdbe8bc
6 changed files with 62 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
class OrderItemSlimPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_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(print_settings,order_item_slim, print_status, options, alt_name)
def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
@@ -46,7 +46,7 @@ class OrderItemSlimPdf < Prawn::Document
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
# order items slim
order_items_slim(order_item_slim, options, alt_name, print_settings.precision)
order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -74,7 +74,7 @@ class OrderItemSlimPdf < Prawn::Document
end
# Write Order items to PDF
def order_items_slim(order_item_slim, options, alt_name, precision)
def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
y_position = cursor
#Add Order Item
@@ -82,6 +82,7 @@ class OrderItemSlimPdf < Prawn::Document
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
add_updated_qty_text(before_updated_qty, order_item_slim.qty, precision)
move_down 1
end
@@ -126,4 +127,17 @@ class OrderItemSlimPdf < Prawn::Document
end
#add updated qty text
def add_updated_qty_text(before_updated_qty, updated_qty, precision)
if !before_updated_qty.nil?
move_down 1
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
end