This commit is contained in:
Myat Zin Wai Maw
2019-05-28 10:36:54 +06:30
44 changed files with 2617 additions and 355 deletions

0
10
View File

View File

@@ -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

View File

@@ -17,7 +17,7 @@ class Crm::CustomersController < BaseCrmController
@crm_customers = Customer.all @crm_customers = Customer.all
else else
@crm_customers = Customer.search(filter) @crm_customers = Customer.search(filter)
paymal_customer = Customer.search_paypar_account_no(filter) # paymal_customer = Customer.search_paypar_account_no(filter)
# search account no from paypar # search account no from paypar
if type == "card" if type == "card"

View File

@@ -35,13 +35,24 @@ class Origami::PaymentsController < BaseOrigamiController
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
# Print for First Bill to Customer # Print for First Bill to Customer
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty? if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5| receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1' if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf" unique_code = "ReceiptBillA5Pdf"
else else
unique_code = "ReceiptBillPdf" unique_code = unique_code#{}"ReceiptBillPdf"
end end
end end
end end
@@ -169,13 +180,24 @@ class Origami::PaymentsController < BaseOrigamiController
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty? if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5| receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1' if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf" unique_code = "ReceiptBillA5Pdf"
else # else
unique_code = "ReceiptBillPdf"
end end
end end
end end
@@ -686,13 +708,23 @@ class Origami::PaymentsController < BaseOrigamiController
else else
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty? if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5| receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1' if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf" unique_code = "ReceiptBillA5Pdf"
else # else
unique_code = "ReceiptBillPdf" # unique_code = "ReceiptBillPdf"
end end
end end
end end

View File

@@ -11,6 +11,7 @@ class Origami::ShiftsController < BaseOrigamiController
if !bank_integration[0].nil? if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1] @bank_integration = bank_integration[0][1]
end end
end end
def new def new
@@ -38,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]
@@ -66,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"
@@ -83,6 +91,11 @@ class Origami::ShiftsController < BaseOrigamiController
shop_details = shop_detail shop_details = shop_detail
#get tax #get tax
shift_obj = ShiftSale.where('id =?',@shift.id) shift_obj = ShiftSale.where('id =?',@shift.id)
sale_items = ''
@lookup = Lookup.shift_sale_items_lookup_value
if @lookup.to_i == 1
@sale_items = Sale.get_shift_sale_items(@shift.id)
end
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @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_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
@@ -98,11 +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
# <<<<<<< HEAD
# # 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)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,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) # 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)
end
# >>>>>>> 6c45e8f0a32a9e71992bde41d20ef993b668c42d
end end
end end
Employee.logout(session[:session_token]) Employee.logout(session[:session_token])

View File

@@ -11,6 +11,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1 # GET /print_settings/1
# GET /print_settings/1.json # GET /print_settings/1.json
def show def show
@lookup = Lookup.shift_sale_items_lookup_value
end end
# GET /print_settings/new # GET /print_settings/new
@@ -21,6 +22,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1/edit # GET /print_settings/1/edit
def edit def edit
@lookup = Lookup.shift_sale_items_lookup_value
@server_mode = ENV["SERVER_MODE"] @server_mode = ENV["SERVER_MODE"]
end end
@@ -45,6 +47,10 @@ class PrintSettingsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @print_setting.update(print_setting_params) if @print_setting.update(print_setting_params)
if @print_setting.unique_code == 'CloseCashierPdf'
Lookup.save_shift_sale_items_settings(params[:shift_sale_items])
end
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }
format.json { render :show, status: :ok, location: @print_setting } format.json { render :show, status: :ok, location: @print_setting }
else else

View File

@@ -31,10 +31,9 @@ class Reports::SaleitemController < BaseReportController
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
@account_cate_count = Hash.new {|hash, key| hash[key] = 0} @account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0} @menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1} @sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
@@ -87,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

View File

@@ -48,5 +48,63 @@ class Reports::ShiftsaleController < BaseReportController
end 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
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

View File

@@ -55,7 +55,26 @@ class Settings::MenuItemAttributesController < ApplicationController
# DELETE /settings/menu_item_attributes/1 # DELETE /settings/menu_item_attributes/1
# DELETE /settings/menu_item_attributes/1.json # DELETE /settings/menu_item_attributes/1.json
def destroy def destroy
@settings_menu_item_attribute.destroy item_attribute_id =@settings_menu_item_attribute.id
item_attribute_id_string=""+item_attribute_id.to_s+""
if @settings_menu_item_attribute.destroy
menu_items =MenuItem.all
menu_items.each do |item|
if item.item_attributes.include?(item_attribute_id)
item_update =item.item_attributes.reject { |i| i == item_attribute_id }
item.item_code =item.item_code
item.item_attributes =item_update
item.save
end
if item.item_attributes.include?(item_attribute_id_string)
item_update =item.item_attributes.reject { |i| i == item_attribute_id_string }
item.item_code =item.item_code
item.item_attributes =item_update
item.save
end
end
end
# @settings_menu_item_attribute.destroy
flash[:notice] = 'Menu item attribute was successfully destroyed.' flash[:notice] = 'Menu item attribute was successfully destroyed.'
render :json => {:status=> "Success", :url => settings_menu_item_attributes_path }.to_json render :json => {:status=> "Success", :url => settings_menu_item_attributes_path }.to_json
# respond_to do |format| # respond_to do |format|

View File

@@ -18,36 +18,39 @@ class Customer < ApplicationRecord
paginates_per 50 paginates_per 50
def self.get_member_account(customer) def self.get_member_account(customer)
membership = MembershipSetting.find_by_membership_type("paypar_url") membership = MembershipSetting.active.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_account") memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# urltest =self.url_exist?(url) # urltest =self.url_exist?(url)
if !membership.nil? && !memberaction.nil?
begin
response = HTTParty.get(url, :body => {
membership_id: customer.membership_id,
merchant_uid:merchant_uid,
type: "summary",
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
},
:timeout => 10)
rescue HTTParty::Error
response = {status: false, message: "Server Error"}
begin rescue Net::OpenTimeout
response = HTTParty.get(url, :body => { response = { status: false , message: "Server Time out"}
membership_id: customer.membership_id,
merchant_uid:merchant_uid,
type: "summary",
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
},
:timeout => 10)
rescue HTTParty::Error
response = {status: false, message: "Server Error"}
rescue Net::OpenTimeout rescue OpenURI::HTTPError
response = { status: false , message: "Server Time out"} response = { status: false, message: "Can't connect server"}
rescue OpenURI::HTTPError rescue SocketError
response = { status: false, message: "Can't connect server"} response = { status: false, message: "Can't connect server"}
end
rescue SocketError else
response = { status: false, message: "Can't connect server"} response = {status: false, message: "There is no membership setting."}
end end
Rails.logger.debug "--------Get Member Account response -------" Rails.logger.debug "--------Get Member Account response -------"
Rails.logger.debug response.to_json Rails.logger.debug response.to_json

View File

@@ -25,4 +25,31 @@ class Lookup < ApplicationRecord
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] } Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
end end
def self.create_shift_sale_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'shift_sale_items'
@lookup.name = 'Shift Sale Items'
@lookup.value = 0
@lookup.save
return @lookup
end
def self.save_shift_sale_items_settings(val)
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup
end
@lookup.value = val
@lookup.save
end
def self.shift_sale_items_lookup_value
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup
end
return @lookup.value
end
end end

View File

@@ -256,6 +256,8 @@ class OrderQueueStation < ApplicationRecord
printer.each do |printer_setting| printer.each do |printer_setting|
if printer_setting.unique_code == 'OrderItemPdf' if printer_setting.unique_code == 'OrderItemPdf'
unique_code="OrderItemPdf" unique_code="OrderItemPdf"
elsif printer_setting.unique_code == 'OrderItemStarPdf'
unique_code="OrderItemStarPdf"
elsif printer_setting.unique_code == 'OrderItemSlimPdf' elsif printer_setting.unique_code == 'OrderItemSlimPdf'
unique_code="OrderItemSlimPdf" unique_code="OrderItemSlimPdf"
elsif printer_setting.unique_code == 'OrderSetItemPdf' elsif printer_setting.unique_code == 'OrderSetItemPdf'

View File

@@ -37,8 +37,26 @@ 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,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)
if !sale_items.blank? or !sale_items.nil?
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
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
@@ -46,7 +64,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf = CloseCashierPdf.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 = 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)
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty? if !close_cashier_pdf.empty?
@@ -55,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,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
@@ -67,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

View File

@@ -21,6 +21,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting.each do |print_settings| print_setting.each do |print_settings|
if print_settings.unique_code == 'OrderItemPdf' if print_settings.unique_code == 'OrderItemPdf'
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty) pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderItemStarPdf'
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderItemSlimPdf' elsif print_settings.unique_code == 'OrderItemSlimPdf'
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty) pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderSetItemPdf' elsif print_settings.unique_code == 'OrderSetItemPdf'
@@ -100,6 +102,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting.each do |print_settings| print_setting.each do |print_settings|
if print_settings.unique_code == 'OrderItemPdf' if print_settings.unique_code == 'OrderItemPdf'
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty) pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderItemStarPdf'
pdf = OrderItemStarPdfnew(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderItemSlimPdf' elsif print_settings.unique_code == 'OrderItemSlimPdf'
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty) pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderSetItemPdf' elsif print_settings.unique_code == 'OrderSetItemPdf'
@@ -207,6 +211,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting.each do |print_settings| print_setting.each do |print_settings|
if print_settings.unique_code == 'OrderItemPdf' if print_settings.unique_code == 'OrderItemPdf'
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty) pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderItemStarPdf'
pdf = OrderItemStarPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderItemSlimPdf' elsif print_settings.unique_code == 'OrderItemSlimPdf'
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty) pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderSetItemPdf' elsif print_settings.unique_code == 'OrderSetItemPdf'

View File

@@ -195,14 +195,25 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
if !printer_settings.nil? if !printer_settings.nil?
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder") if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
settings = PrintSetting.all
if !settings.nil?
settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
elsif setting.unique_code == 'ReceiptBillStarPdf'
pdf = ReceiptBillStarPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
end
end
end
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty? if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5| receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1' if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
else # else
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) # pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
end end
end end
end end

View File

@@ -259,7 +259,6 @@ class Sale < ApplicationRecord
sale_item.menu_category_code = menu_category.code sale_item.menu_category_code = menu_category.code
sale_item.menu_category_name = menu_category.name sale_item.menu_category_name = menu_category.name
else else
sale_item.menu_category_code = '0'
sale_item.menu_category_name = "Product" sale_item.menu_category_name = "Product"
end end
sale_item.product_code = item.item_code sale_item.product_code = item.item_code
@@ -880,6 +879,7 @@ def self.daily_sales_list(from,to)
total_sale.each do |sale| total_sale.each do |sale|
grand_total = sale.grand_total grand_total = sale.grand_total
amount_received = sale.amount_received
old_grand_total = sale.old_grand_total old_grand_total = sale.old_grand_total
total_discount = sale.total_discount total_discount = sale.total_discount
void_amount = sale.void_amount void_amount = sale.void_amount
@@ -952,6 +952,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,
@@ -1126,6 +1127,15 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end end
def self.get_shift_sale_items(sh_id)
query = Sale.select("sales.shift_sale_id as shift_sale_id, i.account_id as account_id, acc.title as account_name, i.item_instance_code as item_code, i.menu_category_name, i.menu_category_code as menu_category_id, i.product_name as product_name, i.unit_price, i.price as price, i.qty as qty, SUM(i.qty) as total_item, SUM(i.qty * i.unit_price) as grand_total, i.status as status_type, i.remark as remark")
.joins("JOIN sale_items i on i.sale_id = sales.sale_id")
.joins("JOIN accounts acc on acc.id = i.account_id")
.where("sales.shift_sale_id=?", sh_id)
.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
end
def self.get_product_sale() def self.get_product_sale()
query = Sale.select("i.account_id as account_id, " + query = Sale.select("i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," + "SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +

View File

@@ -180,10 +180,10 @@ class SaleItem < ApplicationRecord
def self.get_all_sale_items(sale_id) def self.get_all_sale_items(sale_id)
sale_items = SaleItem.select("sale_id,product_code,item_instance_code, sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
product_name,product_alt_name,account_id,status,remark, product_name,product_alt_name,account_id,status,remark,
(CASE WHEN (qty > 0 AND remark IS NULL) OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty, (CASE WHEN (qty > 0 AND remark IS NULL) OR (qty > 0 AND status='foc') OR (qty < 0 AND status = 'foc') OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty,
unit_price, unit_price,
taxable_price, taxable_price,
(CASE WHEN (price > 0 AND remark IS NULL) OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price, (CASE WHEN (price > 0 AND remark IS NULL) OR (qty > 0 AND status='foc') OR (qty < 0 AND status = 'foc') OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price,
is_taxable") is_taxable")
.where("sale_id = ?",sale_id) .where("sale_id = ?",sale_id)
.order("product_name asc") .order("product_name asc")

View File

@@ -178,7 +178,8 @@ class SalePayment < ApplicationRecord
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("redeem"); # membership_actions_data = MembershipAction.find_by_membership_type("redeem");
membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem") membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
puts "This is membership_actions_data"
puts membership_actions_data.to_json
if !membership_actions_data.nil? if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s url = paypar_url.to_s + membership_actions_data.gateway_url.to_s

View File

@@ -2,7 +2,7 @@ class CloseCashierPdf < 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,:text_width 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,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) def initialize(printer_settings, shift_sale, sale_items, acc_cate_count, menu_cate_count, 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_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -55,6 +55,10 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule 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) 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)
if !sale_items.nil? or !sale_items.blank?
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
end
end end
def header (shop_details) def header (shop_details)
@@ -175,6 +179,7 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do 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 text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end end
#start other payment details #start other payment details
if shift_sale.other_sales > 0 if shift_sale.other_sales > 0
other_payment.each do |other| other_payment.each do |other|
@@ -496,6 +501,108 @@ class CloseCashierPdf < Prawn::Document
move_down 5 move_down 5
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
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
move_down 5 move_down 5
total_items = 0
total_amount = 0
if !menu_cate_count.nil?
menu_cate_count.each do |key, value|
# account = Account.find(key)
menu_category = MenuCategory.where('code=?', key).last
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "#{menu_category.name}", :size => self.header_font_size, :align => :left
end
move_down 5
stroke_horizontal_rule
move_down 2
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[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
total_qty = 0
sub_total = 0
sale_items.each do |item|
if item.menu_category_id == key
total_qty += item.total_item.to_i
sub_total += item.grand_total.to_i
move_down 5
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
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
}
# move_down 3
end
end
stroke_horizontal_rule
move_down 5
# 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
total_items += total_qty
total_amount += sub_total
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Sub Total", :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 "#{total_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 "#{sub_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 10
end
stroke_horizontal_rule
move_down 5
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Total Amount", :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 "#{total_items}", :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_amount}", :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 10
end
end end
end end

View 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

View File

@@ -35,7 +35,7 @@ class CrmOrderPdf < Prawn::Document
end end
header( printer_settings.printer_name, printer_settings.name) header( printer_settings.printer_name, printer_settings.name)
stroke_horizontal_rule stroke_horizontal_rule
cashier_info(booking) cashier_info(booking)
line_items(order_items) line_items(order_items)

View File

@@ -0,0 +1,117 @@
class MoveTableStarPdf < 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
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
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 = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [self.margin, 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
header(printer_settings.name,type)
call_move_table(to,from,date,type,moved_by)
move_down 5
stroke_horizontal_rule
move_down 5
add_lining_item(order_items, printer_settings.precision)
move_down 5
stroke_horizontal_rule
move_down 5
end
def header (name,type)
text "Move #{type}", :left_margin => -10, :size => self.header_font_size.to_i + 3,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
move_down 5
end
def call_move_table (to,from,date,type,moved_by)
move_down 3
text "Date Time : #{date.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :left_margin => -10, :size => self.header_font_size
text "Change [#{from}] To [#{to}]", :left_margin => -10, :size => self.header_font_size
text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size
end
def add_lining_item(order_items, precision)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "Item", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "Qty", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 5
add_item(order_items, precision)
end
# Add order items under order info
def add_item(order_items, precision)
y_position = cursor
move_down 5
order_items.each do|odi|
# check for item not to show
# if odi.price != 0
y_position = cursor
# bounding_box([0,y_position], :width => self.item_width + 60, :height => self.item_height) do
# text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
# end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
if !(odi.alt_name).empty?
move_down 4
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
end
end

View File

@@ -1,6 +1,7 @@
class OrderItemPdf < Prawn::Document class OrderItemPdf < 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 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
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width self.page_width = print_settings.page_width
self.page_height = print_settings.page_height self.page_height = print_settings.page_height

View File

@@ -1,6 +1,7 @@
class OrderItemSlimPdf < Prawn::Document class OrderItemSlimPdf < 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 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
def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty) def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width self.page_width = print_settings.page_width
self.page_height = print_settings.page_height self.page_height = print_settings.page_height

View File

@@ -0,0 +1,162 @@
class OrderItemStarPdf < 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
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.header_font_size = print_settings.header_font_size.to_i
self.item_font_size = print_settings.item_font_size.to_i
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 38
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
if !order_item.dining.nil?
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 3
#order_info
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 10
end
# Write Order items to PDF
def order_items(order_item, options, alt_name, precision, before_updated_qty)
y_position = cursor
#Add Order Item
add_order_items(order_item, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
add_updated_qty_text(before_updated_qty, order_item.qty, precision)
move_down 5
end
# Add order items under order info
def add_order_items(order_item, options, alt_name, precision)
y_position = cursor
move_down 5
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
if order_item.alt_name
move_down 4
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
if !options.empty?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
end
move_down 5
end
#add updated qty text
def add_updated_qty_text(before_updated_qty, updated_qty, precision)
if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
def get_booking_id(order_no)
booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id")
.joins(" JOIN bookings b ON b.booking_id=bo.booking_id")
.where("orders.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -66,7 +66,7 @@ class OrderSummaryPdf < Prawn::Document
move_down 5 move_down 5
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
end end
move_down 5 move_down 5

View File

@@ -408,13 +408,13 @@ class ReceiptBillPdf < Prawn::Document
sale_payments.each do |payment| sale_payments.each do |payment|
y_position = cursor y_position = cursor
if payment.payment_method == "paypar" if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Payment", :size => self.item_font_size,:align => :left text "Redeem Payment", :size => self.item_font_size,:align => :left
end end
else else
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
end end
end end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
@@ -538,6 +538,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ customer_name }" , :size => self.item_font_size,:align => :right text "#{ customer_name }" , :size => self.item_font_size,:align => :right
end end
move_down line_move move_down line_move
stroke_horizontal_rule
end end

View File

@@ -0,0 +1,756 @@
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.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 90
self.description_width = 140
self.price_num_width = 40
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 => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
#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"
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name, latest_order_no)
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
#start card blanace amount
if !card_balance_amount.nil?
card_balance_data(card_balance_amount)
end
#end card blanace amount
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)
if other_charges_amount
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
end
end
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
if shop_details.note && !shop_details.note.nil?
shop_note(shop_details)
end
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, latest_order_no)
if latest_order_no.nil?
move_down line_move
text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left
move_down line_move
end
move_down line_move
if !latest_order_no.nil?
move_down line_move
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
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end
if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do
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
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
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
move_down line_move
y_position = cursor
if sale_data.bookings[0].dining_facility_id.to_i > 0
time = sale_data.receipt_date.strftime('%d-%m-%Y') +"("+ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') +"-"+ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p')+")"
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') })" ,
# :size => self.item_font_size,:align => :right
# end
move_down line_move
stroke_horizontal_rule
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = self.qty_width + 1
item_label_total_front_width = (self.item_width+self.price_width) + 3
item_label_total_end_width = self.total_width + 3
else
# self.item_width = self.item_width.to_i + 3
item_label_qty_front_width = (self.item_width+self.price_width) + 3
item_label_qty_end_width = self.qty_width + 2
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = self.total_width + 1
end
move_down line_move
y_position = cursor
move_down line_move
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[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 line_move
stroke_horizontal_rule
add_line_item_row(sale_items,precision,delimiter)
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
item_qty_end_width = self.qty_width + 1
item_total_front_width = item_name_width + 3
item_total_end_width = self.total_width + 3
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 3
item_qty_end_width = self.qty_width + 2
item_total_front_width = item_name_width + 2
item_total_end_width = self.total_width + 1
end
y_position = cursor
move_down line_move
sub_total = 0.0
total_qty = 0.0
show_price = Lookup.find_by_lookup_type("show_price")
sale_items.each do |item|
# 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
else
if item.price != 0
total_qty += item.qty
end
end
end
product_name = item.product_name
# if item.status = 'promotion' && (item.remark =='promotion nett price' || item.remark == 'promotion discount')
# sub_total += -item.price #(item.qty*item.unit_price) - comment for room charges
# qty = -item.qty
# total_price = -item.price #item.qty*item.unit_price - comment for room charges
# price = -item.unit_price
# else
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
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)
else
if item.price != 0
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
end
end
end
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
text_box "#{number_with_precision(total_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(sub_total, :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
end
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
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
item_qty_end_width = self.qty_width + 1
item_total_front_width = item_name_width + 3
item_total_end_width = self.total_width + 3
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 3
item_qty_end_width = self.qty_width + 2
item_total_front_width = item_name_width + 2
item_total_end_width = self.total_width + 1
end
y_position = cursor
pad_top(15) {
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
if show_alt_name
if !(item.product_alt_name).empty?
move_down 2
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
move_down line_move
}
end
def all_total(sale_data,precision,delimiter)
move_down line_move
item_name_width = self.item_width
y_position = cursor
if sale_data.discount_type == 'member_discount'
dis_type = "Member Discount:"
else
dis_type = "Overall Discount:"
end
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ dis_type }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end
if sale_data.sale_taxes.length > 0
incl_tax = ""
if sale_data.tax_type == "inclusive"
incl_tax = "Incl."
end
sale_data.sale_taxes.each do |st|
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
else
end
# move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
# text "Total Tax", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
# end
if sale_data.rounding_adjustment != 0.0
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rounding Adjustment", :size => self.item_font_size,:align => :left
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
move_down line_move
y_position = cursor
move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width) do
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
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)
end
def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
#move_down line_move
sql = "SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
.where("(CASE WHEN ((#{sql}) - (#{sql1})
ELSE SUM(payment_amount) END
FROM sale_payments
JOIN sales s ON s.sale_id=sale_payments.sale_id
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)
.group("payment_method")
sale_payments.each do |payment|
y_position = cursor
if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Payment", :size => self.item_font_size,:align => :left
end
else
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
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
y_position = cursor
move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
# move_down line_move
end
end
# 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["status"] == true
stroke_horizontal_rule
total = 0
balance = 0
rebate_balance =0
redeem = 0
redeem_count = 0
rebate_amount["data"].each do |res|
total = total + res["balance"]
#total redeem amount
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
redeem = redeem + res["withdraw"]
balance = balance + res["balance"]
end
#end Total redem
#total Rebate Earn
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
rebate_balance = rebate_balance + res["deposit"]
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
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
# 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"]
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
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 if birthday
end
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if current_balance != nil
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
end
end
if member_info["status"] == true && member_info["data"].present?
total_balance = 0
member_info["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
total_balance = total_balance + res["balance"]
end
end
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
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)
# move_down line_move
y_position = cursor
#move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Customer Name", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
end
move_down line_move
stroke_horizontal_rule
end
def discount_account(discount_price_by_accounts,precision,delimiter)
stroke_horizontal_rule
move_down line_move
y_position = cursor
discount_price_by_accounts.each do |ipa|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
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
move_down line_move
end
end
def items_account(item_price_by_accounts,precision,delimiter)
stroke_horizontal_rule
move_down line_move
y_position = cursor
item_price_by_accounts.each do |ipa|
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end
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
end
end
def show_other_charges_amount(other_amount,precision,delimiter)
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "Other Charges", :size => self.item_font_size,:align => :left
end
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
end
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
# per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
per_person = sale_data.grand_total.to_f / survey.to_i
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do
text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
end
bounding_box([0,y_position], :width =>self.label_width) do
move_down 15
text "Amount Due (per person)", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
def sign(sale_data)
sql = "SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
ELSE SUM(payment_amount) END
FROM sale_payments
JOIN sales s ON s.sale_id=sale_payments.sale_id
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|
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
end
break;
end
end
if sale_data.payment_status == "foc" || sale_data.payment_status == "waste" || sale_data.payment_status == "spoile"
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
if sale_data.payment_status == "foc"
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
elsif sale_data.payment_status == "waste" || sale_data.payment_status == "spoile"
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
end
end
end
end
def shop_note(shop)
move_down line_move
stroke_horizontal_rule
move_down line_move
move_down line_move
y_position = cursor
text "#{shop.note}", :size => self.item_font_size, :align => :left
move_down line_move
end
def footer(printed_status)
move_down line_move
stroke_horizontal_rule
move_down line_move
move_down line_move
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
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
move_down line_move
end
#start card sale trans data
def card_sale_data(card_data)
if card_data != nil && !card_data.empty?
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
card_data.each do |data|
if data['app'] == 'CUP'
data['app'] = 'UNIONPAY'
elsif data['app'] == 'MASTERCARD'
data['app'] = 'MASTER'
end
text "DATE/TIME: #{data['res_date']} #{data['res_time']} ", :size => @item_font_size, :align => :left
text "BATCH NUM: #{data['batch_no']} TRACE#: #{data['trace']}",:size => @item_font_size, :align => :left
text "RREF NUM: #{data['ref_no']} APPR CODE: #{data['app_code']} ",:size => @item_font_size, :align => :left
text "TID: #{data['tid']} ",:size => @item_font_size, :align => :left
text "#{data['app']} #{data['pan']} ",:size => @item_font_size, :align => :left
end
end
end
#start card balance data
def card_balance_data(card_balance_amount)
if card_balance_amount > 0
move_down line_move
stroke_horizontal_rule
move_down line_move
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
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
end
end
#check ReceiptBillAltName included
def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
status = false
if !bill_alt_name.empty?
bill_alt_name.each do |alt_name|
if alt_name[0] == 'ReceiptBillAltName'
if alt_name[1] == '1'
status = true
else
status = false
end
end
end
end
return status
end
end

227
app/pdf/sale_items_pdf.rb Normal file
View 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

View File

@@ -721,7 +721,6 @@ $(document).ready(function(){
var sale_id = $('#sale_id').text(); var sale_id = $('#sale_id').text();
window.location.replace('/origami/sale/'+sale_id+'/cashier/payment'); window.location.replace('/origami/sale/'+sale_id+'/cashier/payment');
} }
/* replace url type*/ /* replace url type*/
/* start check first bill or not*/ /* start check first bill or not*/
var member_id = $('#membership_id').text(); var member_id = $('#membership_id').text();
@@ -1125,6 +1124,8 @@ $(document).ready(function(){
<% else %> <% else %>
$('#balance').text(parseFloat(result)); $('#balance').text(parseFloat(result));
<% end %> <% end %>
show_hide_btn($('#balance').text());
} }
function customer_display_view(data,status) { function customer_display_view(data,status) {
@@ -1831,4 +1832,15 @@ $(document).ready(function(){
} }
},100); },100);
}); });
function show_hide_btn(balance) {
// show discount when balance is greater than 0
// if(parseFloat(balance) > 0){
// $("#discount").show();
// $("#edit").show();
// }else{
// $("#discount").hide();
// $("#edit").hide();
// }
}
</script> </script>

View File

@@ -26,7 +26,7 @@
<div class='col-md-6'> <div class='col-md-6'>
<span style='font-size:20px;'><b><input type='number' class="form-control" id='closing_balance_amount' value='' onkeypress="return isNumberKey(event);" onkeyup="closeCashier(this.value);"></b></span> <span style='font-size:20px;'><b><input type='number' class="form-control" id='closing_balance_amount' value='' onkeypress="return isNumberKey(event);" onkeyup="closeCashier(this.value);"></b></span>
</div> </div>
</div> </div><br>
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button> <button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
@@ -59,6 +59,13 @@
</div> </div>
<script> <script>
// $(document).ready(function(){
// var val = $('#sale_items').val()
// if (val == 1) {
// $('#sale_items').prop( "checked", true );
// }
// })
function closeCashier(val){ function closeCashier(val){
var aa = parseInt(val); var aa = parseInt(val);
if(isNaN(aa)) $("#closing_balance_amount").val(""); if(isNaN(aa)) $("#closing_balance_amount").val("");
@@ -81,9 +88,10 @@
$('#close_cashier').on('click',function(){ $('#close_cashier').on('click',function(){
var amount = $('#closing_balance_amount').val(); var amount = $('#closing_balance_amount').val();
var shift_id = "<%= @shift.id rescue ""%>" var shift_id = "<%= @shift.id rescue ""%>"
$.ajax({type: "POST", $.ajax({type: "POST",
url: "<%= origami_close_shift_path %>", url: "<%= origami_close_shift_path %>",
data: "closing_balance="+ amount + "&shift_id="+ shift_id, data: "closing_balance="+ amount + "&shift_id="+ shift_id ,
success:function(result){ success:function(result){
console.log(result) console.log(result)
window.location.href = '/'; window.location.href = '/';

View File

@@ -27,6 +27,22 @@
<%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %> <%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %>
<%= f.input :delimiter %> <%= f.input :delimiter %>
<%= f.input :heading_space %> <%= f.input :heading_space %>
<% if !@print_setting.new_record? and @print_setting.unique_code == 'CloseCashierPdf' %>
<div class="form-group boolean optional sale_items bmd-form-group is-filled">
<div class="checkbox">
<input value="0" type="hidden" name="shift_sale_items">
<label class="boolean optional" for="sale_items">
<input class="boolean optional" type="checkbox" value="<%= @lookup %>" name="shift_sale_items" id="sale_items" onchange="set_value(this)">
<span class="checkbox-decorator">
<span class="check"></span>
<div class="ripple-container"></div>
</span>Shift Sale Items
</label>
</div>
</div>
<% end %>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@@ -84,6 +100,10 @@
}); });
} }
if ($('#sale_items').val() == '1') {
$('#sale_items').prop('checked', true);
}
// if selected printer change call and bind // if selected printer change call and bind
$("#print_setting_printer_name").on("change", function(){ $("#print_setting_printer_name").on("change", function(){
if(serverMode != 'cloud'){ if(serverMode != 'cloud'){
@@ -119,4 +139,12 @@
function greaterThanTwo(val){ function greaterThanTwo(val){
if(parseInt(val)>2) $("#print_setting_precision").val(2); if(parseInt(val)>2) $("#print_setting_precision").val(2);
} }
function set_value(ele){
if ($(ele).val() == '1'){
$(ele).val(0)
}else{
$(ele).val(1)
}
}
</script> </script>

View File

@@ -58,6 +58,16 @@
<th><%= t("views.right_panel.detail.print_copies") %></th> <th><%= t("views.right_panel.detail.print_copies") %></th>
<td><%= @print_setting.print_copies %></td> <td><%= @print_setting.print_copies %></td>
</tr> </tr>
<tr>
<th>Include Shift Sale Items</th>
<td>
<% if @lookup == '1' %>
<%= 'True' %>
<% else %>
<%= 'False' %>
<% end %>
</td>
</tr>
<tr> <tr>
<td colspan="2" align="right"> <td colspan="2" align="right">
<%= link_to t("views.btn.edit"), edit_print_setting_path(@print_setting),:class => 'btn btn-info btn-sm waves-effect' %> <%= link_to t("views.btn.edit"), edit_print_setting_path(@print_setting),:class => 'btn btn-info btn-sm waves-effect' %>

View File

@@ -47,8 +47,8 @@
<select class="form-control select" name="shift_name" id="shift_name" > <select class="form-control select" name="shift_name" id="shift_name" >
</select> </select>
</div> </div>
<div class="col-lg-12 col-md-12 col-sm-12 margin-top-20 text-right"> <div class="col-lg-2 col-md-2 col-sm-2 margin-top-20" style="margin-top: 20px;">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary'> <input type="submit" value="Generate Report" class='btn btn-primary'>
</div> </div>
</div> </div>

View File

@@ -158,7 +158,11 @@
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %> <% end %>
<%end%> <%end%>
<td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td> <td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td> <td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>

View File

@@ -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>

View File

@@ -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>
@@ -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>

View File

@@ -17,15 +17,17 @@ class ActionController::Base
logger.info 'License is nil' logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error" # redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}] render :json => [{ status: false, message: 'Invalid Access!'}]
end end
else else
check for license file # check for license file
if check_license if check_license
current_license(ENV["SX_PROVISION_URL"]) current_license(ENV["SX_PROVISION_URL"])
else else
redirect_to activate_path redirect_to activate_path
end end
end end
end end
def current_license(url) def current_license(url)
@@ -146,4 +148,3 @@ class ActionController::API
end end
end end

View File

@@ -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

BIN
dump.rdb Executable file → Normal file

Binary file not shown.

0
false,
View File

View File

0
{
View File