fixed star printer setting

This commit is contained in:
NyanLinHtut
2019-06-03 10:59:16 +06:30
parent bd55069c2d
commit 2e342d7859
7 changed files with 193 additions and 188 deletions

View File

@@ -2,19 +2,19 @@ class ReceiptBillStarPdf < 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, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
self.item_font_size = printer_settings.item_font_size.to_i
self.margin = 0
self.price_width = 50
self.qty_width = 23
self.total_width = 50
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.price_width = 60
self.qty_width = 20
self.total_width = 40
self.item_width = 73
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.item_description_width = (self.page_width-30) / 2
self.label_width = 90
self.description_width = 140
@@ -101,7 +101,7 @@ class ReceiptBillStarPdf < Prawn::Document
if shop_details.note && !shop_details.note.nil?
shop_note(shop_details)
end
footer(printed_status)
end
@@ -129,7 +129,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left
end
move_down line_move
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
@@ -146,7 +146,7 @@ class ReceiptBillStarPdf < Prawn::Document
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
end
end
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
end
@@ -164,7 +164,7 @@ class ReceiptBillStarPdf < Prawn::Document
end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
# :size => self.item_font_size,:align => :right
# end
@@ -201,7 +201,7 @@ class ReceiptBillStarPdf < Prawn::Document
end
def add_line_item_row(sale_items,precision,delimiter)
if precision.to_i > 0
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = (self.item_width+self.price_width) + 2
@@ -222,14 +222,14 @@ class ReceiptBillStarPdf < Prawn::Document
total_qty = 0.0
show_price = Lookup.find_by_lookup_type("show_price")
sale_items.each do |item|
# check for item not to show
# 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
total_qty += item.qty
else
if item.price != 0
total_qty += item.qty
total_qty += item.qty
end
end
end
@@ -246,9 +246,9 @@ class ReceiptBillStarPdf < Prawn::Document
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
# end
if !show_price.nil? && show_price.value.to_i>0
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
@@ -257,7 +257,7 @@ class ReceiptBillStarPdf < Prawn::Document
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
end
end
end
stroke_horizontal_rule
@@ -291,10 +291,10 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_width) do
text "#{product_name}", :size => self.item_font_size,:align => :left
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_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
# 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_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
if show_alt_name
if !(item.product_alt_name).empty?
@@ -367,7 +367,7 @@ class ReceiptBillStarPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
end
end
end
move_down line_move
@@ -380,11 +380,11 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
end
move_down line_move
sale_payment(sale_data,precision,delimiter)
sale_payment(sale_data,precision,delimiter)
end
def sale_payment(sale_data,precision,delimiter)
def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
#move_down line_move
sql = "SELECT SUM(payment_amount)
@@ -416,13 +416,13 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
end
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
if sale_data.amount_received > 0
if sale_data.amount_received > 0
y_position = cursor
move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -437,7 +437,7 @@ class ReceiptBillStarPdf < Prawn::Document
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
if rebate_amount != nil
if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
@@ -466,8 +466,8 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
# Total Rebate Amount if birthday
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
rebate_balance = rebate_balance + res["deposit"]
@@ -479,7 +479,7 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
#end Total rebate if birthday
end
@@ -502,7 +502,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
end
end
@@ -512,7 +512,7 @@ class ReceiptBillStarPdf < Prawn::Document
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
total_balance = total_balance + res["balance"]
end
end
move_down line_move
@@ -524,7 +524,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
def customer(customer_name)
@@ -554,7 +554,7 @@ class ReceiptBillStarPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
end
end
move_down line_move
end
end
@@ -571,7 +571,7 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
move_down line_move
end
end
@@ -583,7 +583,7 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
move_down line_move
end
#individual payment per person
@@ -623,17 +623,17 @@ class ReceiptBillStarPdf < Prawn::Document
JOIN sale_audits sa
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
where sa.sale_id='#{sale_data.sale_id}')) = 0
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
@@ -650,7 +650,7 @@ class ReceiptBillStarPdf < Prawn::Document
move_down 70
stroke_horizontal_rule
end
if sale_data.payment_status == "foc"
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
@@ -661,9 +661,9 @@ class ReceiptBillStarPdf < Prawn::Document
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
end
end
end
end
end
def shop_note(shop)
@@ -673,8 +673,8 @@ class ReceiptBillStarPdf < Prawn::Document
move_down line_move
y_position = cursor
text "#{shop.note}", :size => self.item_font_size, :align => :left
text "#{shop.note}", :size => self.item_font_size, :align => :left
move_down line_move
end
@@ -688,10 +688,10 @@ class ReceiptBillStarPdf < Prawn::Document
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
end
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width+20, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
end
end
move_down line_move
end
@@ -729,7 +729,7 @@ class ReceiptBillStarPdf < Prawn::Document
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
end
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
end
@@ -753,4 +753,4 @@ class ReceiptBillStarPdf < Prawn::Document
end
return status
end
end
end