order reservation receipt bill"
This commit is contained in:
@@ -199,6 +199,16 @@ $(function() {
|
|||||||
// $('body').addClass('modal-open').removeClass('modal-open-fix, modal-open-fix-pad');
|
// $('body').addClass('modal-open').removeClass('modal-open-fix, modal-open-fix-pad');
|
||||||
// }, 1000);
|
// }, 1000);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
//print pdf function
|
||||||
|
$("#print_receipt_pdf").on('click touchstart', function(event){
|
||||||
|
$(this).off("click touchstart touchend");
|
||||||
|
print_receipt();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".btn_pdf_close").on('click',function(){
|
||||||
|
window.location.href = '/origami/order_reservation';
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function warnBeforeRedirect(linkURL) {
|
function warnBeforeRedirect(linkURL) {
|
||||||
@@ -517,17 +527,17 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
|
|||||||
window.location.href = '/origami/order_reservation';
|
window.location.href = '/origami/order_reservation';
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
if(result.filename){
|
if(data.filepath){
|
||||||
//PDF lightbox data
|
//PDF lightbox data
|
||||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
var pdfPath = "/en/pdfjs/minimal?file=" + data.filepath.substring(6);
|
||||||
$("#sale_id").val(result.sale_id);
|
$("#sale_id").val(data.sale_id);
|
||||||
$("#sale_receipt_no").val(result.receipt_no);
|
$("#sale_receipt_no").val(data.receipt_no);
|
||||||
$("#filename").val(result.filename);
|
$("#filename").val(data.filepath);
|
||||||
$("#printer_name").val(result.printer_name);
|
$("#printer_name").val(data.printer_name);
|
||||||
$("#receipt_pdf").attr("src", pdfPath);
|
$("#receipt_pdf").attr("src", pdfPath);
|
||||||
|
|
||||||
$("#receiptpdfModal").modal({show : true, backdrop : false, keyboard : false});
|
$("#receiptpdfModal").modal({show : true, backdrop : false, keyboard : false});
|
||||||
$("#receiptpdfModalLabel").text("Receipt: " + result.receipt_no);
|
$("#receiptpdfModalLabel").text("Receipt: " + data.receipt_no);
|
||||||
}else{
|
}else{
|
||||||
swal({
|
swal({
|
||||||
title: 'Information',
|
title: 'Information',
|
||||||
@@ -701,31 +711,26 @@ function getOnlineOrderCount(){
|
|||||||
}
|
}
|
||||||
/* online order count*/
|
/* online order count*/
|
||||||
|
|
||||||
//print pdf function
|
|
||||||
$("#print_receipt_pdf").on('click touchstart', function(event){
|
|
||||||
$(this).off("click touchstart touchend");
|
|
||||||
print_receipt();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* pdf print out */
|
/* pdf print out */
|
||||||
function print_receipt(){
|
function print_receipt(){
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').val();
|
||||||
var filename = $("#filename").val();
|
var filename = $("#filename").val();
|
||||||
var printer_name = $("#printer_name").val();
|
var printer_name = $("#printer_name").val();
|
||||||
var receipt_no = $("#sale_receipt_no").val();
|
var receipt_no = $("#sale_receipt_no").val();
|
||||||
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
|
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
|
||||||
|
console.log(params);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/sale/"+sale_id+"/doemal_order/payment/print",
|
url: "/origami/sale/"+sale_id+"/doemal_order/payment/print",
|
||||||
data: params,
|
data: params,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
// For Server Print - from jade
|
// For Server Print - from jade
|
||||||
if ($("#server_mode").val() == "cloud") {
|
// if ($("#server_mode").val() == "cloud") {
|
||||||
if(typeof code2lab != 'undefined'){
|
// if(typeof code2lab != 'undefined'){
|
||||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
// code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
swal({
|
swal({
|
||||||
title: "Print Success",
|
title: "Print Success",
|
||||||
text: "Complete Order",
|
text: "Complete Order",
|
||||||
@@ -737,7 +742,7 @@ function print_receipt(){
|
|||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/order_reservation';
|
window.location.href = '/origami/order_reservation';
|
||||||
});
|
});
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
|||||||
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
|
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
|
||||||
order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id)
|
order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id)
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
from = request.subdomain + "." + request.domain
|
from = "" #request.subdomain + "." + request.domain
|
||||||
else
|
else
|
||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil)
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
@@ -246,7 +246,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||||
|
|
||||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
:status => true,
|
:status => true,
|
||||||
@@ -629,7 +629,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:status => true,
|
:status => true,
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
@@ -681,7 +681,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
printer_name = params[:printer_name]
|
printer_name = params[:printer_name]
|
||||||
cashier_type = params[:type]
|
cashier_type = params[:type]
|
||||||
|
|
||||||
if cashier_type == "doemal_order"
|
if cashier_type.strip.downcase == "doemal_order"
|
||||||
unique_code = "ReceiptBillOrderPdf"
|
unique_code = "ReceiptBillOrderPdf"
|
||||||
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
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
:printer_model => print_settings.brand_name,
|
:printer_model => print_settings.brand_name,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
|||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
:printer_model => print_settings.brand_name,
|
:printer_model => print_settings.brand_name,
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController
|
|||||||
|
|
||||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
|
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
:printer_model => print_settings.brand_name,
|
:printer_model => print_settings.brand_name,
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ class OrderReservation < ApplicationRecord
|
|||||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
shop_detail = Shop.first
|
shop_detail = Shop.first
|
||||||
|
order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id)
|
||||||
if !cashier_terminal.nil?
|
if !cashier_terminal.nil?
|
||||||
# Calculate Food and Beverage Total
|
# Calculate Food and Beverage Total
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
@@ -191,13 +192,14 @@ class OrderReservation < ApplicationRecord
|
|||||||
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
|
||||||
#receipt bill pdf setting
|
#receipt bill pdf setting
|
||||||
|
|
||||||
result = {:status=> true,
|
result = {:status=> true,
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
:sale_id => saleObj.sale_id,
|
:sale_id => saleObj.sale_id,
|
||||||
:receipt_no => sale_receipt_no,
|
:receipt_no => sale_receipt_no,
|
||||||
|
:printer_name => printer_name,
|
||||||
:printer_model => print_settings.brand_name,
|
:printer_model => print_settings.brand_name,
|
||||||
:printer_url => print_settings.api_settings ,
|
:printer_url => print_settings.api_settings ,
|
||||||
:message => DELIVERED }
|
:message => DELIVERED }
|
||||||
@@ -494,6 +496,14 @@ class OrderReservation < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#Create get_data for order_reservation
|
||||||
|
def self.get_order_reservation_info(sale_id)
|
||||||
|
query=OrderReservation.select("order_reservations.* ,deliveries.delivery_type,deliveries.delivery_fee")
|
||||||
|
.joins("join deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||||
|
.where("order_reservations.sale_id = '#{sale_id}'").first()
|
||||||
|
return query
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "ODRS")
|
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "ODRS")
|
||||||
|
|||||||
@@ -188,12 +188,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#Bill Receipt Print
|
||||||
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
|
if !printer_settings.nil?
|
||||||
|
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)
|
||||||
if printer_settings.name.strip.downcase != "receiptbillorder"
|
|
||||||
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|
|
||||||
@@ -208,15 +209,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
#doemal online order pdf template
|
#doemal online order pdf template
|
||||||
pdf = ReceiptBillOrderPdf.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 = ReceiptBillOrderPdf.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,order_reservation)
|
||||||
end
|
end
|
||||||
|
|
||||||
# print as print copies in printer setting
|
# print as print copies in printer setting
|
||||||
count = printer_settings.print_copies
|
count = printer_settings.print_copies
|
||||||
|
|
||||||
# override print copies for print worker loop
|
# override print copies for print worker loop
|
||||||
print_settings.print_copies = 1
|
print_settings.print_copies = 1
|
||||||
print_settings.save!
|
print_settings.save!
|
||||||
|
end
|
||||||
directory_name = 'public/receipts'
|
directory_name = 'public/receipts'
|
||||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||||
|
|
||||||
@@ -324,15 +326,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
begin
|
begin
|
||||||
if count == 1
|
if count == 1
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
# if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, printer_name)
|
self.print(filename, printer_name)
|
||||||
end
|
# end
|
||||||
else
|
else
|
||||||
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
|
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
# if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, printer_name)
|
self.print(filename, printer_name)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
count -= 1
|
count -= 1
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
|
|
||||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||||
|
|
||||||
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
|
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,order_reservation)
|
||||||
self.page_width = printer_settings.page_width
|
self.page_width = printer_settings.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
|
||||||
@@ -57,50 +57,9 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
cashier_info(sale_data, customer_name, latest_order_no)
|
cashier_info(sale_data, customer_name, latest_order_no,order_reservation)
|
||||||
line_items(sale_items,printer_settings.precision,delimiter)
|
line_items(sale_items,printer_settings.precision,delimiter,order_reservation)
|
||||||
all_total(sale_data,printer_settings.precision,delimiter)
|
all_total(sale_data,printer_settings.precision,delimiter,order_reservation)
|
||||||
|
|
||||||
|
|
||||||
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)
|
footer(printed_status)
|
||||||
end
|
end
|
||||||
@@ -117,62 +76,47 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
def cashier_info(sale_data, customer_name, latest_order_no)
|
def cashier_info(sale_data, customer_name, latest_order_no,order_reservation)
|
||||||
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 line_move
|
||||||
|
|
||||||
# move_down 2
|
# 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
|
y_position = cursor
|
||||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
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
|
text "Order Date " , :size => self.item_font_size, :align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
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
|
text "#{order_reservation.created_at.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right
|
||||||
end
|
end
|
||||||
move_down line_move
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
if sale_data.bookings[0].dining_facility_id.to_i > 0
|
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||||
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')+")"
|
text "Requested Date Time " , :size => self.item_font_size, :align => :left
|
||||||
else
|
end
|
||||||
time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
|
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "#{order_reservation.requested_time.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
|
y_position = cursor
|
||||||
text "Date : #{ time }",:size => self.item_font_size,:align => :left
|
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||||
|
text "Payment Type" , :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 "#{order_reservation.payment_type}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||||
|
text "#{customer_name} " , :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 "Online Order", :size => self.item_font_size,:align => :right
|
||||||
end
|
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
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
def line_items(sale_items,precision,delimiter)
|
def line_items(sale_items,precision,delimiter,order_reservation)
|
||||||
if precision.to_i > 0
|
if precision.to_i > 0
|
||||||
item_label_qty_front_width = (self.item_width+self.price_width) + 5
|
item_label_qty_front_width = (self.item_width+self.price_width) + 5
|
||||||
item_label_qty_end_width = self.qty_width + 4
|
item_label_qty_end_width = self.qty_width + 4
|
||||||
@@ -197,10 +141,11 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
}
|
}
|
||||||
# move_down line_move
|
# move_down line_move
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
add_line_item_row(sale_items,precision,delimiter)
|
add_line_item_row(sale_items,precision,delimiter,order_reservation)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_line_item_row(sale_items,precision,delimiter)
|
#Change Sub_Total and others...........
|
||||||
|
def add_line_item_row(sale_items,precision,delimiter,order_reservation)
|
||||||
|
|
||||||
if precision.to_i > 0
|
if precision.to_i > 0
|
||||||
item_name_width = (self.item_width+self.price_width)
|
item_name_width = (self.item_width+self.price_width)
|
||||||
@@ -248,8 +193,6 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
price = item.unit_price
|
price = item.unit_price
|
||||||
|
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
||||||
if !show_price.nil? && show_price.value.to_i>0
|
if !show_price.nil? && show_price.value.to_i>0
|
||||||
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
else
|
else
|
||||||
@@ -257,7 +200,6 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
@@ -268,22 +210,66 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||||
end
|
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(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
|
text_box "#{number_with_precision(order_reservation.total_amount, :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 !order_reservation.delivery_type.nil? && order_reservation.delivery_fee > '0'
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||||
|
text "Delivery Charges(#{order_reservation.delivery_type}) " , :size => self.item_font_size, :align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if order_reservation.total_tax > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||||
|
text "Tax " , :size => self.item_font_size, :align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(order_reservation.total_tax, :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 => self.item_height) do
|
||||||
|
text "Convenience Charges " , :size => self.item_font_size, :align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
if order_reservation.discount_amount > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||||
|
text "Promotion " , :size => self.item_font_size, :align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "#{number_with_precision(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#Change items rows
|
||||||
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||||
if precision.to_i > 0
|
if precision.to_i > 0
|
||||||
item_name_width = (self.item_width+self.price_width)
|
item_name_width = (self.item_width+self.price_width)
|
||||||
item_qty_front_width = (self.item_width+self.price_width) + 5
|
item_qty_front_width = (self.item_width+self.price_width) + 5
|
||||||
item_qty_end_width = self.qty_width + 4
|
item_qty_end_width = self.qty_width + 4
|
||||||
item_total_front_width = item_name_width + 10
|
item_total_front_width = item_name_width + 10
|
||||||
item_total_end_width = self.total_width + 9
|
#Change item_total_end_width
|
||||||
|
item_total_end_width = self.total_width + 3
|
||||||
else
|
else
|
||||||
item_name_width = (self.item_width+self.price_width)
|
item_name_width = (self.item_width+self.price_width)
|
||||||
item_qty_front_width = item_name_width + 8
|
item_qty_front_width = item_name_width + 8
|
||||||
item_qty_end_width = self.qty_width + 7
|
item_qty_end_width = self.qty_width + 7
|
||||||
item_total_front_width = item_name_width + 5
|
item_total_front_width = item_name_width + 5
|
||||||
item_total_end_width = self.total_width + 4
|
#Change item_total_end_width
|
||||||
|
item_total_end_width = self.total_width + 3
|
||||||
end
|
end
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
@@ -306,378 +292,31 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
move_down line_move
|
move_down line_move
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_total(sale_data,precision,delimiter)
|
#Change Grand Total
|
||||||
|
def all_total(sale_data,precision,delimiter,order_reservation)
|
||||||
move_down line_move
|
move_down line_move
|
||||||
item_name_width = self.item_width
|
item_name_width = self.item_width
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
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
|
move_down line_move
|
||||||
|
stroke_horizontal_rule
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
move_down line_move
|
move_down line_move
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width) do
|
bounding_box([0,y_position], :width =>self.item_description_width) do
|
||||||
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
||||||
end
|
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
|
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
|
text "#{number_with_precision(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||||
end
|
end
|
||||||
move_down line_move
|
move_down line_move
|
||||||
end
|
|
||||||
if sale_data.amount_received > 0
|
# sale_payment(sale_data,precision,delimiter)
|
||||||
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
|
|
||||||
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
|
end
|
||||||
|
|
||||||
|
#Change Footer
|
||||||
def footer(printed_status)
|
def footer(printed_status)
|
||||||
move_down line_move
|
move_down line_move
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
@@ -688,53 +327,13 @@ class ReceiptBillOrderPdf < Prawn::Document
|
|||||||
bounding_box([0, y_position], :width =>self.label_width) do
|
bounding_box([0, y_position], :width =>self.label_width) do
|
||||||
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
|
text "Thank You! See you Again", :left_margin => -3, :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down line_move
|
move_down line_move
|
||||||
end
|
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
|
#check ReceiptBillAltName included
|
||||||
def show_alt_name
|
def show_alt_name
|
||||||
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<!-- end count function -->
|
<!-- end count function -->
|
||||||
|
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
|
||||||
<div class="row m-t--10">
|
<div class="row m-t--10">
|
||||||
<div class="col-lg-5 col-md-5 col-sm-5 div_order_margin">
|
<div class="col-lg-5 col-md-5 col-sm-5 div_order_margin">
|
||||||
<ul class="nav nav-tabs tab-col-teal <%= @shop.shop_code ? @shop.shop_code : '' %>" role="tablist">
|
<ul class="nav nav-tabs tab-col-teal <%= @shop.shop_code ? @shop.shop_code : '' %>" role="tablist">
|
||||||
|
|||||||
Reference in New Issue
Block a user