Sale Item Pdf added
This commit is contained in:
@@ -273,6 +273,9 @@ For Online Order Receipt Setting
|
|||||||
1) settings/lookups => { type:order_reservation, name:ReceiptBill, value: {0 or 1} }
|
1) settings/lookups => { type:order_reservation, name:ReceiptBill, value: {0 or 1} }
|
||||||
2) settings/print_settings => {name: ReceiptBillOrder, unique_code: ReceiptBillOrderPdf, ....}
|
2) settings/print_settings => {name: ReceiptBillOrder, unique_code: ReceiptBillOrderPdf, ....}
|
||||||
|
|
||||||
|
For Close Cashier Print Settings
|
||||||
|
settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 or 1} }
|
||||||
|
|
||||||
* ToDo list
|
* ToDo list
|
||||||
|
|
||||||
1. Migration
|
1. Migration
|
||||||
@@ -369,5 +372,3 @@ For Online Order Receipt Setting
|
|||||||
2. Show/Detail Buttons => btn-info
|
2. Show/Detail Buttons => btn-info
|
||||||
3. Delete => btn-delete
|
3. Delete => btn-delete
|
||||||
4. Cancel/Back => btn-default
|
4. Cancel/Back => btn-default
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
|
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_shift
|
def update_shift
|
||||||
closing_balance = params[:closing_balance]
|
closing_balance = params[:closing_balance]
|
||||||
shift_id = params[:shift_id]
|
shift_id = params[:shift_id]
|
||||||
@@ -67,6 +69,11 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
|
|
||||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# if !close_cashier_print[0].nil?
|
||||||
|
# @close_cashier_print = close_cashier_print[0][1]
|
||||||
|
# end
|
||||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||||
unique_code = "CloseCashierPdf"
|
unique_code = "CloseCashierPdf"
|
||||||
|
|
||||||
@@ -104,14 +111,31 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||||
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||||
|
|
||||||
# close_cashier = Lookup.is_print_close_cashier
|
# <<<<<<< HEAD
|
||||||
# if close_cashier
|
# # close_cashier = Lookup.is_print_close_cashier
|
||||||
|
# # if close_cashier
|
||||||
|
# # get printer info
|
||||||
|
# print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
# printer = Printer::CashierStationPrinter.new(print_settings)
|
||||||
|
|
||||||
|
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||||
|
# # end
|
||||||
|
# =======
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||||
|
|
||||||
|
# print close cashier setting
|
||||||
|
close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||||
|
if close_cashier_print.empty?
|
||||||
|
@settings_lookup = Lookup.new(lookup_type: "close_cashier_print", name: "CloseCashierPrint", value: "1")
|
||||||
|
@settings_lookup.save
|
||||||
|
end
|
||||||
|
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||||
|
if find_close_cashier_print[0][1].to_i > 0
|
||||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||||
# end
|
end
|
||||||
|
# >>>>>>> 6c45e8f0a32a9e71992bde41d20ef993b668c42d
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Employee.logout(session[:session_token])
|
Employee.logout(session[:session_token])
|
||||||
|
|||||||
@@ -86,4 +86,76 @@ class Reports::SaleitemController < BaseReportController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def print_sale_items
|
||||||
|
type = params[:type]
|
||||||
|
account = params[:account]
|
||||||
|
from_date = to_date = '-'
|
||||||
|
if !params[:from].nil?
|
||||||
|
from_date = Date.parse(params[:from])
|
||||||
|
end
|
||||||
|
if !params[:to].nil?
|
||||||
|
to_date = Date.parse(params[:to])
|
||||||
|
end
|
||||||
|
|
||||||
|
shift = params[:shift_name]
|
||||||
|
shift_name = "All Shifts"
|
||||||
|
if shift.to_i > 0
|
||||||
|
shift_name = params[:shift_from].to_s+" - ".to_s+params[:shift_to].to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
period_name = get_period_name(params[:period])
|
||||||
|
|
||||||
|
shop_details = shop_detail
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
print_settings = PrintSetting.find_by_unique_code('CloseCashierPdf') # SaleItemsPdf
|
||||||
|
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||||
|
|
||||||
|
printer.print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, params[:sale_items], params[:menu_cate_count])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
|
||||||
|
format
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_period_name(period)
|
||||||
|
period_name = '-'
|
||||||
|
unless period.nil? or period.blank?
|
||||||
|
case period.to_i
|
||||||
|
when PERIOD["today"]
|
||||||
|
period_name = "Today"
|
||||||
|
|
||||||
|
when PERIOD["yesterday"]
|
||||||
|
period_name = "Yesterday"
|
||||||
|
|
||||||
|
when PERIOD["this_week"]
|
||||||
|
period_name = "This Week"
|
||||||
|
|
||||||
|
when PERIOD["last_week"]
|
||||||
|
period_name = "Last Week"
|
||||||
|
|
||||||
|
when PERIOD["last_7"]
|
||||||
|
period_name = "Last 7 days"
|
||||||
|
|
||||||
|
when PERIOD["this_month"]
|
||||||
|
period_name = "This Month"
|
||||||
|
|
||||||
|
when PERIOD["last_month"]
|
||||||
|
period_name = "Last Month"
|
||||||
|
|
||||||
|
when PERIOD["last_30"]
|
||||||
|
period_name = "Last 30 Days"
|
||||||
|
|
||||||
|
when PERIOD["this_year"]
|
||||||
|
period_name = "This Year"
|
||||||
|
|
||||||
|
when PERIOD["last_year"]
|
||||||
|
period_name = "Last Year"
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return period_name
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,5 +48,63 @@ class Reports::ShiftsaleController < BaseReportController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def print_close_receipt
|
||||||
|
shift_id = params[:id]
|
||||||
|
@shift = ShiftSale.find_by_id(shift_id)
|
||||||
|
shift_obj = ShiftSale.where('id =?',shift_id)
|
||||||
|
puts "shift obj!!!!!"
|
||||||
|
puts shift_obj.to_json
|
||||||
|
|
||||||
|
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
|
|
||||||
|
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||||
|
puts "close !!!!"
|
||||||
|
puts close_cashier_pdf
|
||||||
|
|
||||||
|
unique_code = "CloseCashierPdf"
|
||||||
|
|
||||||
|
if !close_cashier_pdf.empty?
|
||||||
|
close_cashier_pdf.each do |close_cashier|
|
||||||
|
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||||
|
if close_cashier[1] == '1'
|
||||||
|
unique_code="CloseCashierCustomisePdf"
|
||||||
|
else
|
||||||
|
unique_code="CloseCashierPdf"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
shop_details = shop_detail
|
||||||
|
cashier_terminal = @shift.cashier_terminal
|
||||||
|
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||||
|
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||||
|
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||||
|
#other payment details for mpu or visa like card
|
||||||
|
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||||
|
|
||||||
|
# Calculate price_by_accounts
|
||||||
|
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||||
|
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||||
|
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||||
|
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||||
|
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||||
|
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||||
|
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||||
|
|
||||||
|
printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
|
||||||
|
format
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
# pdf.render_file filename
|
# pdf.render_file filename
|
||||||
# self.print(filename, cashier_terminal.printer_name)
|
# self.print(filename, cashier_terminal.printer_name)
|
||||||
# end
|
# end
|
||||||
|
# <<<<<<< HEAD
|
||||||
|
|
||||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
|
|
||||||
@@ -46,12 +47,16 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
|
|
||||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||||
sale_items.each {|cate| @menu_cate_count[cate.account_id] += 1}
|
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
|
||||||
|
|
||||||
|
|
||||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||||
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||||
end
|
end
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
|
# >>>>>>> 6c45e8f0a32a9e71992bde41d20ef993b668c42d
|
||||||
|
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
@@ -68,7 +73,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
if close_cashier[1] == '1'
|
if close_cashier[1] == '1'
|
||||||
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
else
|
else
|
||||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -80,5 +85,18 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
self.print(filename, cashier_terminal.printer_name)
|
self.print(filename, cashier_terminal.printer_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, menu_cate_count)
|
||||||
|
filename = "tmp/reports_sale_items.pdf"
|
||||||
|
|
||||||
|
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, menu_cate_count, nil)
|
||||||
|
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
#no print in cloud server
|
||||||
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
|
self.print(filename, print_settings.printer_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
#sqa
|
#sqa
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -951,6 +951,7 @@ def self.get_by_shiftsales(from,to,shift)
|
|||||||
end
|
end
|
||||||
|
|
||||||
shift_sale_data[shift_sale.id] = {
|
shift_sale_data[shift_sale.id] = {
|
||||||
|
:shift_id => shift_sale.id,
|
||||||
:cashier_terminal_name => shift_sale.cashier_terminal.name,
|
:cashier_terminal_name => shift_sale.cashier_terminal.name,
|
||||||
:employee_name => shift_sale.employee.name,
|
:employee_name => shift_sale.employee.name,
|
||||||
:shift_started_at => shift_sale.shift_started_at,
|
:shift_started_at => shift_sale.shift_started_at,
|
||||||
|
|||||||
@@ -521,14 +521,15 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
total_items = 0
|
total_items = 0
|
||||||
total_amount = 0
|
total_amount = 0
|
||||||
|
|
||||||
if !acc_cate_count.nil?
|
if !menu_cate_count.nil?
|
||||||
acc_cate_count.each do |key, value|
|
menu_cate_count.each do |key, value|
|
||||||
|
|
||||||
account = Account.find(key)
|
# account = Account.find(key)
|
||||||
|
menu_category = MenuCategory.where('code=?', key).last
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
text "#{account.title}", :size => self.header_font_size, :align => :left
|
text "#{menu_category.name}", :size => self.header_font_size, :align => :left
|
||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
@@ -550,7 +551,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
|
|
||||||
sale_items.each do |item|
|
sale_items.each do |item|
|
||||||
|
|
||||||
if item.account_id == key
|
if item.menu_category_id == key
|
||||||
total_qty += item.total_item.to_i
|
total_qty += item.total_item.to_i
|
||||||
sub_total += item.grand_total.to_i
|
sub_total += item.grand_total.to_i
|
||||||
|
|
||||||
|
|||||||
505
app/pdf/close_cashier_pdf_v1.rb
Normal file
505
app/pdf/close_cashier_pdf_v1.rb
Normal file
@@ -0,0 +1,505 @@
|
|||||||
|
class CloseCashierPdf < 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,:text_width
|
||||||
|
|
||||||
|
def initialize(printer_settings, shift_sale, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.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 = 5
|
||||||
|
self.price_width = 60
|
||||||
|
self.qty_width = 20
|
||||||
|
self.total_width = 40
|
||||||
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
|
self.label_width = 100
|
||||||
|
|
||||||
|
self.text_width = (self.page_width - 80) - self.price_width / 3
|
||||||
|
# @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])
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
#precision checked
|
||||||
|
if printer_settings.precision.to_i > 2
|
||||||
|
printer_settings.precision = 2
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if printer_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
header( shop_details)
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (shop_details)
|
||||||
|
move_down 7
|
||||||
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down 5
|
||||||
|
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||||
|
move_down 7
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Cashier : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.employee.name}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Cashier Station : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.cashier_terminal.name}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Opening Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Closing Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Opening Float : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Closing Float : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||||
|
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
move_down 10
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "Shift Sale Summary", :size => self.header_font_size, :align => :center
|
||||||
|
end
|
||||||
|
move_down 10
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Received Amount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Cash In:", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Cash Out:", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
@total_foc = 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Credit Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
#start other payment details
|
||||||
|
if shift_sale.other_sales > 0
|
||||||
|
other_payment.each do |other|
|
||||||
|
@total_foc = other.foc_amount.round(2)
|
||||||
|
if other.mpu_amount && other.mpu_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.visa_amount && other.visa_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "VISA Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.master_amount && other.master_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Master Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.jcb_amount && other.jcb_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "JCB Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.unionpay_amount && other.unionpay_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.alipay_amount && other.alipay_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Alipay Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.junctionpay_amount && other.junctionpay_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.dinga_amount && other.dinga_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Dinga Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.paypar_amount && other.paypar_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Redeem Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.paymal_amount && other.paymal_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Paymal Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if other.giftvoucher_amount && other.giftvoucher_amount.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Other Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
# end other payment details
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
#start service charges and commercial tax
|
||||||
|
sale_taxes.each do |tax|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Taxes :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
if total_credit_payments && total_credit_payments.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end for service charges and commercial tax
|
||||||
|
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Total Sale :", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
# text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
total_discount_by_account.each do |amount|
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
|
if total_member_discount[0].member_discount.present?
|
||||||
|
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||||
|
@overall = shift_sale.total_discounts - @member_discount
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Member Discount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@overall = shift_sale.total_discounts
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Discount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total FOC :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Void :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Waste :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Spoile :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Grand Total :", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
total_amount_by_account.each do |amount|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Other Amount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Dine-in Count :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Takeaway Count :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Receipts :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
227
app/pdf/sale_items_pdf.rb
Normal file
227
app/pdf/sale_items_pdf.rb
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
class SaleItemsPdf < 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,:text_width
|
||||||
|
|
||||||
|
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc)
|
||||||
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.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 = 5
|
||||||
|
self.price_width = 60
|
||||||
|
self.qty_width = 20
|
||||||
|
self.total_width = 40
|
||||||
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
|
@label_name_width = 70
|
||||||
|
@label_item_width = self.page_width-@label_name_width
|
||||||
|
self.label_width = 100
|
||||||
|
|
||||||
|
self.text_width = (self.page_width - 80) - self.price_width / 3
|
||||||
|
# @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])
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
#precision checked
|
||||||
|
if printer_settings.precision.to_i > 2
|
||||||
|
printer_settings.precision = 2
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if printer_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
header( shop_details)
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
sale_details(period, type, account, from_date, to_date, shift)
|
||||||
|
|
||||||
|
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (shop_details)
|
||||||
|
move_down 7
|
||||||
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down 5
|
||||||
|
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
def sale_details(period, type, account, from_date, to_date, shift)
|
||||||
|
move_down 7
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||||
|
text "Period : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||||
|
text "#{period}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||||
|
text "Type : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||||
|
text "#{type}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||||
|
text "Account : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||||
|
text "#{account}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||||
|
text "From Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||||
|
text "#{ from_date}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||||
|
text "To Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||||
|
text "#{ to_date}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||||
|
text "Shift : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||||
|
text "#{shift}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 10
|
||||||
|
end
|
||||||
|
|
||||||
|
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
|
||||||
|
self.item_width = 73
|
||||||
|
self.price_width = 60
|
||||||
|
item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_label_qty_end_width = 32
|
||||||
|
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_label_total_end_width = 64
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
||||||
|
end
|
||||||
|
|
||||||
|
total_items = 0
|
||||||
|
total_amount = 0
|
||||||
|
total_qty = 0
|
||||||
|
sub_total = 0
|
||||||
|
|
||||||
|
arr = Array.new
|
||||||
|
|
||||||
|
unless sale_items.nil?
|
||||||
|
JSON.parse(sale_items).each do |item|
|
||||||
|
|
||||||
|
if !arr.include?(item['menu_category_id'])
|
||||||
|
|
||||||
|
unless total_qty == 0 and sub_total == 0
|
||||||
|
total_details('Sub Total', total_qty, sub_total)
|
||||||
|
end
|
||||||
|
|
||||||
|
total_qty = 0
|
||||||
|
sub_total = 0
|
||||||
|
|
||||||
|
move_down 10
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
# write_stroke_dash
|
||||||
|
# dash(1, :space => 1, :phase => 1)
|
||||||
|
# stroke_horizontal_rule
|
||||||
|
# move_down 2
|
||||||
|
y_position = cursor
|
||||||
|
pad_top(15) {
|
||||||
|
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 =>[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 2
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
move_down 3
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
pad_top(15) {
|
||||||
|
text_box "#{item['product_name']}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
|
text_box "#{item['unit_price'].to_i}", :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 "#{item['total_item'].to_i}", :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 "#{item['grand_total'].to_i}", :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
|
||||||
|
}
|
||||||
|
total_qty += item['total_item'].to_i
|
||||||
|
sub_total += item['grand_total'].to_i
|
||||||
|
total_items += item['total_item'].to_i
|
||||||
|
total_amount += item['grand_total'].to_i
|
||||||
|
arr.push(item['menu_category_id'])
|
||||||
|
end
|
||||||
|
|
||||||
|
# stroke_horizontal_rule
|
||||||
|
total_details('Sub Total', total_qty, sub_total)
|
||||||
|
move_down 5
|
||||||
|
total_details('Total Amount', total_items, total_amount)
|
||||||
|
move_down 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def total_details(col_name, total_qty, sub_total)
|
||||||
|
self.item_width = 73
|
||||||
|
self.price_width = 60
|
||||||
|
item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_label_qty_end_width = 32
|
||||||
|
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||||
|
item_label_total_end_width = 64
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
y_position = cursor
|
||||||
|
pad_top(15) {
|
||||||
|
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
|
text_box "#{total_qty.to_i}", :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 "#{sub_total.to_i}", :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
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
<%= link_to "Print", reports_print_sale_items_path(:type => params[:sale_type], :period => params[:period], :account => params[:account_type], :from => @from, :to => @to, :shift_name => params[:shift_name], :shift_from => @shift_from, :shift_to => @shift_to, :menu_cate_count => @menu_cate_count, :sale_items => @sale_data.to_json), :method => 'post', class:"btn btn-info wave-effects" %>
|
||||||
<a href="javascript:export_to('<%=reports_saleitem_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
<a href="javascript:export_to('<%=reports_saleitem_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
<br/>Rounding Adj</th> -->
|
<br/>Rounding Adj</th> -->
|
||||||
<!-- <th>Rounding Adj</th> -->
|
<!-- <th>Rounding Adj</th> -->
|
||||||
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
||||||
|
<th>Print</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -89,7 +90,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<%= result[:cashier_terminal_name] rescue '-'%>
|
<%= result[:cashier_terminal_name] rescue '-'%> <%= result[:shift_id].to_i %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= result[:employee_name] rescue '-'%>
|
<%= result[:employee_name] rescue '-'%>
|
||||||
@@ -108,7 +109,9 @@
|
|||||||
<%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
|
<%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
|
||||||
</td>
|
</td>
|
||||||
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td>
|
||||||
|
<%= link_to "Print", reports_get_shift_id_path(result[:shift_id].to_i), class:"btn btn-info wave-effects" %>
|
||||||
|
</td>
|
||||||
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
|
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
|
||||||
<% grand_total = result[:grand_total].to_f %>
|
<% grand_total = result[:grand_total].to_f %>
|
||||||
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
|
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
|
||||||
@@ -142,6 +145,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('#close_cashier').on('click',function(){
|
||||||
|
window.location.href = '/origami/shift/close';
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
||||||
var check_arr = [];
|
var check_arr = [];
|
||||||
@@ -243,5 +253,3 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -524,6 +524,8 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
||||||
get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation"
|
get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation"
|
||||||
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"
|
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"
|
||||||
|
get "shiftsale_print/:id" , to: "shiftsale#print_close_receipt", as: "get_shift_id"
|
||||||
|
post "print_sale_items", to: "saleitem#print_sale_items", as: "print_sale_items"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user