change receipt bill format

This commit is contained in:
phyusin
2017-12-22 16:33:10 +06:30
parent 7d8fddbdeb
commit dad83a1f83
2 changed files with 35 additions and 15 deletions

View File

@@ -5,10 +5,10 @@ class ReceiptBillPdf < Prawn::Document
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
self.price_width = 50
self.qty_width = 35
self.total_width = 50
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.price_width = 60
self.qty_width = 25
self.total_width = 60
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-5) / 2
self.label_width = 100
@@ -129,16 +129,26 @@ class ReceiptBillPdf < Prawn::Document
end
def line_items(sale_items,precision,delimiter)
item_label_total_front_width = (self.item_width+self.price_width) + 15
item_label_total_end_width = self.total_width + 14
if precision.to_i > 0
item_label_qty_front_width = (self.item_width+self.price_width) + 5
item_label_qty_end_width = self.qty_width + 4
item_label_total_front_width = (self.item_width+self.price_width) + 10
item_label_total_end_width = self.total_width + 9
else
self.item_width = self.item_width.to_i + 8
item_label_qty_front_width = (self.item_width+self.price_width) + 8
item_label_qty_end_width = self.qty_width + 7
item_label_total_front_width = (self.item_width+self.price_width) + 5
item_label_total_end_width = self.total_width + 4
end
move_down 5
y_position = cursor
move_down 5
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down -5
@@ -147,9 +157,19 @@ class ReceiptBillPdf < Prawn::Document
end
def add_line_item_row(sale_items,precision,delimiter)
item_name_width = (self.item_width+self.price_width)
item_total_front_width = item_name_width + 15
item_total_end_width = self.total_width + 14
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
move_down 5
sub_total = 0.0
@@ -171,7 +191,7 @@ class ReceiptBillPdf < Prawn::Document
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_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :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
}
move_down 5
@@ -478,7 +498,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
end
move_down 5

View File

@@ -16,7 +16,7 @@
<%= f.input :page_width %>
<%= f.input :page_height %>
<%= f.input :print_copies, input_html: { min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %>
<%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanThree(this.value);" } %>
<%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %>
<%= f.input :delimiter %>
<%= f.input :heading_space %>
</div>
@@ -74,7 +74,7 @@
if(parseInt(val)==0) $("#print_setting_print_copies").val(1);
}
function greaterThanThree(val){
function greaterThanTwo(val){
if(parseInt(val)>2) $("#print_setting_precision").val(2);
}
</script>