req bill bugs fixing
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -13,7 +13,7 @@ gem 'rails', '~> 5.1.0'
|
||||
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
||||
|
||||
#Use PosgreSQL
|
||||
# gem 'pg'
|
||||
#gem 'pg'
|
||||
|
||||
# redis server for cable
|
||||
# gem 'redis', '~> 3.0'
|
||||
|
||||
@@ -122,6 +122,7 @@ GEM
|
||||
nokogiri (1.7.2)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
pdf-core (0.7.0)
|
||||
pg (0.20.0)
|
||||
prawn (2.2.2)
|
||||
pdf-core (~> 0.7.0)
|
||||
ttfunk (~> 1.5)
|
||||
@@ -256,6 +257,7 @@ DEPENDENCIES
|
||||
kaminari!
|
||||
listen (~> 3.0.5)
|
||||
mysql2 (>= 0.3.18, < 0.5)
|
||||
pg
|
||||
prawn
|
||||
prawn-table
|
||||
puma (~> 3.0)
|
||||
|
||||
@@ -3,27 +3,25 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
def show
|
||||
@sale = Sale.new
|
||||
|
||||
|
||||
booking_id = params[:id]
|
||||
check_booking = Booking.find_by_booking_id(booking_id)
|
||||
if check_booking.sale_id.nil?
|
||||
#check if it doesn't exist
|
||||
@status = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name)
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",check_booking.sale_id)
|
||||
# Create Sale if it doesn't exist
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",check_booking.sale_id)
|
||||
end
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
end
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer_name = Customer.select("name").where('customer_id=' + @sale_data.customer_id)
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer_name)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -230,7 +230,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
|
||||
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
|
||||
.group("bookings.booking_id")
|
||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
|
||||
|
||||
end
|
||||
|
||||
@@ -243,7 +243,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
|
||||
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
|
||||
.group("bookings.booking_id")
|
||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name")
|
||||
end
|
||||
|
||||
#Origami: Cashier : to view order type Room
|
||||
@@ -255,7 +255,7 @@ class Order < ApplicationRecord
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.order_id")
|
||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
|
||||
.group("orders.order_id,order_items.order_items_id,dining_facilities.name")
|
||||
.group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no")
|
||||
|
||||
end
|
||||
|
||||
@@ -271,7 +271,7 @@ class Order < ApplicationRecord
|
||||
left join sale_orders on sale_orders.order_id = orders.order_id
|
||||
left join sales on sales.sale_id = sale_orders.sale_id")
|
||||
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
.group("orders.order_id,order_items.order_items_id,dining_facilities.name")
|
||||
.group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -64,11 +64,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
self.print(filename)
|
||||
end
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,sale_items,sale,sale_data)
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale,sale_data)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name)
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
order = booking.booking_orders.take.order
|
||||
link_order_sale(order.id)
|
||||
return status
|
||||
return status, sale_id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ReceiptBillPdf < Prawn::Document
|
||||
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
|
||||
def initialize(printer_settings, sale_items,sale, sale_data)
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name)
|
||||
self.p_width = 200
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
@@ -23,7 +23,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
header( printer_settings.printer_name, printer_settings.name)
|
||||
stroke_horizontal_rule
|
||||
cashier_info(sale.receipt_no,sale.customer, sale.receipt_date)
|
||||
cashier_info(sale_data, customer_name)
|
||||
line_items(sale_items)
|
||||
all_total(sale_data)
|
||||
|
||||
@@ -41,7 +41,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
end
|
||||
|
||||
def cashier_info(receipt_no, customer, receipt_date)
|
||||
def cashier_info(sale_data, customer_name)
|
||||
move_down 5
|
||||
move_down 2
|
||||
y_position = cursor
|
||||
@@ -50,7 +50,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.price_width, y_position], :width =>self.receipt_width) do
|
||||
text "#{receipt_no}" , :size => self.item_font_size, :align => :left
|
||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
move_down 5
|
||||
|
||||
@@ -59,7 +59,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Customer:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
text "#{customer}" , :size => self.item_font_size,:align => :left
|
||||
text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
move_down 5
|
||||
|
||||
@@ -68,7 +68,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Date:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
text "#{receipt_date}" , :size => self.item_font_size,:align => :left
|
||||
text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# stroke_horizontal_rule
|
||||
move_down 5
|
||||
@@ -139,7 +139,6 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
def all_total(sale_data)
|
||||
|
||||
move_down 5
|
||||
y_position =cursor
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<% if @booking_orders %>
|
||||
<% @booking_orders.each do |booking_order| %>
|
||||
<% if !booking_order.order_status = 'new'%>
|
||||
<% if booking_order.order_status != "new" %>
|
||||
<div style="background-color: red;color: white;" class="card" id="table-order-<%=booking_order.sale_id%>" onclick="callOrderDetails('sale_<%=booking_order.sale_id%>')">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">
|
||||
@@ -204,14 +204,17 @@
|
||||
var old_order_id = 0
|
||||
var old_table_name = ""
|
||||
var table_or_order_id = 0
|
||||
|
||||
var pay_sale_id = 0
|
||||
|
||||
function callOrderDetails(sale_order_id){
|
||||
|
||||
var order_id = 0
|
||||
var sale_id = 0
|
||||
var data_val = ""
|
||||
sale_order = sale_order_id.split("_")[0]
|
||||
|
||||
if (sale_order == 'sale') {
|
||||
order_id = sale_order_id.split("_")[1]
|
||||
sale_id = sale_order_id.split("_")[1]
|
||||
url = "origami/"+sale_order_id.split("_")[1]
|
||||
data_val = { sale_id: sale_order_id.split("_")[1]}
|
||||
|
||||
@@ -221,7 +224,9 @@ function callOrderDetails(sale_order_id){
|
||||
data_val = { order_id: sale_order_id.split("_")[1]}
|
||||
|
||||
}
|
||||
|
||||
table_or_order_id = order_id
|
||||
pay_sale_id = sale_id
|
||||
var tbody = ""
|
||||
$("#append-table").html("")
|
||||
if (old_order_id != order_id){
|
||||
@@ -305,6 +310,7 @@ function callOrderDetails(sale_order_id){
|
||||
|
||||
$( document ).ready(function() {
|
||||
$('#request_bills').click(function() {
|
||||
console.log(table_or_order_id);
|
||||
window.location.href = '/origami/request_bills/'+ table_or_order_id
|
||||
return false;
|
||||
});
|
||||
@@ -312,7 +318,7 @@ $( document ).ready(function() {
|
||||
|
||||
$( document ).ready(function() {
|
||||
$('#pay').click(function() {
|
||||
window.location.href = '/origami/sale/'+ 10 + "/payment"
|
||||
window.location.href = '/origami/sale/'+ pay_sale_id + "/payment"
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user