check bill
This commit is contained in:
@@ -1,111 +1,113 @@
|
|||||||
class ReceiptBillPdf < Prawn::Document
|
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
|
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
|
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.price_num_width = 50
|
self.page_width = printer_settings.page_width
|
||||||
self.line_move = 2
|
self.page_height = printer_settings.page_height
|
||||||
# @item_width = self.page_width.to_i / 2
|
self.margin = 0
|
||||||
# @qty_width = @item_width.to_i / 3
|
self.price_width = 60
|
||||||
# @double = @qty_width * 1.3
|
self.qty_width = 25
|
||||||
# @half_qty = @qty_width / 2
|
self.total_width = 60
|
||||||
#setting page margin and width
|
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
|
||||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-5) / 2
|
||||||
|
self.label_width = 100
|
||||||
|
|
||||||
#precision checked
|
self.description_width = 150
|
||||||
if printer_settings.precision.to_i > 2
|
self.price_num_width = 50
|
||||||
printer_settings.precision = 2
|
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
|
||||||
|
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
|
end
|
||||||
|
|
||||||
# db font setup
|
def header (shop_details)
|
||||||
if printer_settings.font != ""
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
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)
|
|
||||||
move_down line_move
|
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
|
# move_down 2
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
|
||||||
@@ -146,7 +148,6 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
text "Date : #{ time }",:size => self.item_font_size,:align => :left
|
text "Date : #{ time }",:size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
|
# 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') })" ,
|
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
|
||||||
@@ -155,7 +156,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
move_down line_move
|
move_down line_move
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
def line_items(sale_items,precision,delimiter)
|
def line_items(sale_items,precision,delimiter)
|
||||||
if precision.to_i > 0
|
if precision.to_i > 0
|
||||||
@@ -250,7 +251,6 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def all_total(sale_data,precision,delimiter)
|
def all_total(sale_data,precision,delimiter)
|
||||||
|
|
||||||
move_down line_move
|
move_down line_move
|
||||||
item_name_width = self.item_width
|
item_name_width = self.item_width
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
@@ -317,7 +317,6 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
move_down line_move
|
move_down line_move
|
||||||
|
|
||||||
sale_payment(sale_data,precision,delimiter)
|
sale_payment(sale_data,precision,delimiter)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
@@ -549,7 +548,6 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def footer(printed_status)
|
def footer(printed_status)
|
||||||
|
|||||||
Reference in New Issue
Block a user