check bill

This commit is contained in:
Yan
2018-03-15 11:16:31 +06:30
parent 95eff6f733
commit 28c23bb50d

View File

@@ -1,111 +1,113 @@
class ReceiptBillPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
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)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
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
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)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
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
self.description_width = 150
self.price_num_width = 50
self.line_move = 2
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
self.description_width = 150
self.price_num_width = 50
self.line_move = 2
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 10
self.item_font_size = 8
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name)
line_items(sale_items,printer_settings.precision,delimiter)
all_total(sale_data,printer_settings.precision,delimiter)
if member_info != nil
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
end
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 10
self.item_font_size = 8
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name)
line_items(sale_items,printer_settings.precision,delimiter)
all_total(sale_data,printer_settings.precision,delimiter)
if member_info != nil
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
end
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
end
def header (shop_details)
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down line_move
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down line_move
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down line_move
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
def header (shop_details)
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down line_move
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down line_move
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down line_move
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
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
@@ -117,7 +119,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
end
end
move_down line_move
y_position = cursor
@@ -141,12 +143,11 @@ class ReceiptBillPdf < Prawn::Document
else
time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
end
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
text "Date : #{ time }",:size => self.item_font_size,:align => :left
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') }
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
@@ -155,7 +156,7 @@ class ReceiptBillPdf < Prawn::Document
move_down line_move
stroke_horizontal_rule
end
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
@@ -250,7 +251,6 @@ class ReceiptBillPdf < Prawn::Document
end
def all_total(sale_data,precision,delimiter)
move_down line_move
item_name_width = self.item_width
y_position = cursor
@@ -316,8 +316,7 @@ class ReceiptBillPdf < Prawn::Document
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)
@@ -548,8 +547,7 @@ class ReceiptBillPdf < Prawn::Document
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
end
end
def footer(printed_status)