credit payment for quick service
This commit is contained in:
@@ -229,7 +229,12 @@ $(document).on('turbolinks:load', function() {
|
||||
|
||||
$(document).on("click", ".credit_detail",function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = "/origami/cashier/credit_sales/"+sale_id;
|
||||
var cashier_type = $(this).attr("data-type");
|
||||
if(cashier_type=='cashier'){
|
||||
window.location.href = "/origami/cashier/credit_sales/"+sale_id;
|
||||
}else{
|
||||
window.location.href = "/origami/quick_service/credit_sales/"+sale_id;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -523,7 +528,7 @@ function timeFormat(date){
|
||||
return time;
|
||||
}
|
||||
|
||||
function getCreditData(){
|
||||
function getCreditData(cashier_type){
|
||||
var filter = $("#filter").val();
|
||||
var customer = $("#sel_customer").val();
|
||||
|
||||
@@ -535,11 +540,11 @@ function getCreditData(){
|
||||
if((customer!=undefined) && (customer!=null) && (customer!="")){
|
||||
customer_id = customer;
|
||||
}
|
||||
getCreditSales(receipt_no, customer_id);
|
||||
getCreditSales(receipt_no, customer_id, cashier_type);
|
||||
}
|
||||
|
||||
function getCreditSales(filter, customer){
|
||||
$(".credit_items").hide();
|
||||
function getCreditSales(filter, customer, cashier_type){
|
||||
// $(".credit_items").hide();
|
||||
$(".tbd_credit_lists").empty();
|
||||
var html_credit_items = $("#html_credit_items").html();
|
||||
var receipt_no = "";
|
||||
@@ -554,7 +559,7 @@ function getCreditSales(filter, customer){
|
||||
type: "POST",
|
||||
data: {receipt_no: receipt_no, customer_id: customer_id},
|
||||
dataType: 'json',
|
||||
url: "/origami/cashier/credit_sales",
|
||||
url: "/origami/"+cashier_type+"/credit_sales",
|
||||
success: function(data){
|
||||
// console.log(data);
|
||||
if(data.status){
|
||||
@@ -572,7 +577,8 @@ function getCreditSales(filter, customer){
|
||||
'receipt_no':credit_sales[i].receipt_no,
|
||||
'cashier_name':credit_sales[i].cashier_name,
|
||||
'customer_name':credit_sales[i].customer_name,
|
||||
'credit_amount':credit_sales[i].payment_amount
|
||||
'credit_amount':credit_sales[i].payment_amount,
|
||||
'cashier_type':cashier_type
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Origami::CreditSalesController < BaseOrigamiController
|
||||
def show
|
||||
@cashier_type = params[:type]
|
||||
@cashier_type = 'cashier'
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
|
||||
@@ -6,7 +6,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@webview = check_mobile
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@@ -20,7 +20,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
|
||||
|
||||
@@ -235,8 +235,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
||||
.where("sale_id = ? and payment_method=?", sale_id, "creditnote")
|
||||
@sale_payment = SalePayment.get_credit_total_left(sale_id)
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@@ -371,11 +370,11 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
|
||||
else
|
||||
@sale_payment_data = @sale_data.sale_payments
|
||||
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash = spay.payment_amount
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += spay.payment_amount
|
||||
|
||||
@@ -4,12 +4,14 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
# @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@sale = Sale.pending_sale
|
||||
@order = Sale.pending_order
|
||||
@completed = Sale.completed_sale
|
||||
@completed = Sale.completed_sale("quick_service")
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
end
|
||||
def show
|
||||
@sales = Sale.pending_sale
|
||||
@orders = Sale.pending_order
|
||||
@completed = Sale.completed_sale
|
||||
@completed = Sale.completed_sale("quick_service")
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@id = params[:sale_id]
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@@ -32,7 +34,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
puts @status
|
||||
# puts @status
|
||||
if @bookings.dining_facility_id.to_i > 0
|
||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
@@ -40,13 +42,14 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
end
|
||||
|
||||
def completed_sale
|
||||
@sales = Sale.pending_sale
|
||||
@orders = Sale.pending_order
|
||||
@completed = Sale.completed_sale
|
||||
@completed = Sale.completed_sale("quick_service")
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@id = params[:sale_id]
|
||||
|
||||
@sale = Sale.find(@id)
|
||||
@@ -71,4 +74,37 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
render "origami/cash_outs/new"
|
||||
end
|
||||
|
||||
def credit_sale
|
||||
@sales = Sale.pending_sale
|
||||
@orders = Sale.pending_order
|
||||
@completed = Sale.completed_sale("quick_service")
|
||||
@id = params[:sale_id]
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
|
||||
@sale = Sale.find_by_sale_id(params[:sale_id])
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@bookings = Booking.find(@booking)
|
||||
@status = "sale"
|
||||
|
||||
if @bookings.dining_facility_id.to_i > 0
|
||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
|
||||
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
||||
.where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote")
|
||||
|
||||
@sale_taxes = []
|
||||
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@sale_taxes.push(sale_tax)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
def index
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@webview = false
|
||||
@@ -19,7 +19,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
|
||||
@@ -7,7 +7,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
|
||||
@@ -2552,11 +2552,11 @@ end
|
||||
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","quick_service")
|
||||
.group("bookings.booking_id")
|
||||
end
|
||||
def self.completed_sale
|
||||
def self.completed_sale(type)
|
||||
query = Sale.all
|
||||
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
|
||||
.joins("join orders as orders on orders.order_id = sale_orders.order_id")
|
||||
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service")
|
||||
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' AND orders.source =? ","#{type}")
|
||||
query = query.where("DATE_FORMAT(sales.created_at,'%Y-%m-%d') = ? ",DateTime.now.strftime('%Y-%m-%d'))
|
||||
.group("sales.sale_id")
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class SalePayment < ApplicationRecord
|
||||
#get all payment for this invoices
|
||||
if payment_for
|
||||
invoice_sale_payments = SalePayment.get_sale_payment_for_credit(invoice)
|
||||
amount_due = get_credit_total_left[0] ? get_credit_total_left[0].payment_amount.to_f : 0
|
||||
amount_due = SalePayment.get_credit_total_left(self.sale_id)[0] ? SalePayment.get_credit_total_left(self.sale_id)[0].payment_amount.to_f : 0
|
||||
else
|
||||
invoice_sale_payments = invoice.sale_payments
|
||||
amount_due = invoice.grand_total
|
||||
@@ -314,7 +314,7 @@ class SalePayment < ApplicationRecord
|
||||
if !payment_for
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
else
|
||||
credit_sale_payment = get_credit_total_left[0] ? get_credit_total_left[0].payment_amount.to_f : 0 ###need to calculate creditnote total in here
|
||||
credit_sale_payment = SalePayment.get_credit_total_left(self.sale_id)[0] ? SalePayment.get_credit_total_left(self.sale_id)[0].payment_amount.to_f : 0 ###need to calculate creditnote total in here
|
||||
self.outstanding_amount = credit_sale_payment - self.received_amount.to_f
|
||||
end
|
||||
self.payment_status = "paid"
|
||||
@@ -370,7 +370,7 @@ class SalePayment < ApplicationRecord
|
||||
if !payment_for
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
else
|
||||
credit_payment = get_credit_total_left ###need to calculate creditnote total in here
|
||||
credit_payment = SalePayment.get_credit_total_left(self.sale_id) ###need to calculate creditnote total in here
|
||||
self.outstanding_amount = credit_payment[0].payment_amount.to_f - self.received_amount.to_f
|
||||
end
|
||||
self.payment_status = "paid"
|
||||
@@ -860,18 +860,20 @@ class SalePayment < ApplicationRecord
|
||||
s.cashier_name as cashier_name, c.name as customer_name")
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.joins("INNER JOIN customers c ON c.customer_id = s.customer_id")
|
||||
.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' #{receipt_no} #{customer}")
|
||||
.joins("INNER JOIN sale_orders so ON so.sale_id = s.sale_id")
|
||||
.joins("INNER JOIN orders o ON o.order_id = so.order_id")
|
||||
.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' and o.source='#{params[:type]}' #{receipt_no} #{customer}")
|
||||
.group("s.receipt_no")
|
||||
.order("s.receipt_date ASC, s.receipt_no ASC")
|
||||
return query
|
||||
end
|
||||
|
||||
def get_credit_total_left
|
||||
def self.get_credit_total_left(sale_id)
|
||||
query = SalePayment.select("(SUM(sale_payments.payment_amount) -
|
||||
(CASE WHEN SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id
|
||||
THEN SUM(sale_payments.payment_amount) ELSE 0 END)) as payment_amount")
|
||||
.joins(" LEFT JOIN sale_audits sa on SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id")
|
||||
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{self.sale_id}'")
|
||||
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{sale_id}'")
|
||||
.group("sale_payments.sale_id")
|
||||
return query
|
||||
end
|
||||
@@ -880,9 +882,8 @@ class SalePayment < ApplicationRecord
|
||||
query = sale_data.sale_payments
|
||||
.joins(" JOIN sale_audits sa on SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id")
|
||||
.where("sa.action='SALEPAYMENT' AND sa.remark IS NOT NULL
|
||||
AND sale_payments.payment_method!='cash'
|
||||
AND DATE_FORMAT(sale_payments.created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(sale_payments.created_at,'%Y-%m-%d') = '#{Date.today.prev_day}'
|
||||
")
|
||||
") #AND sale_payments.payment_method!='cash'
|
||||
.group("sale_payments.sale_payment_id")
|
||||
return query
|
||||
end
|
||||
@@ -899,6 +900,25 @@ class SalePayment < ApplicationRecord
|
||||
return query
|
||||
end
|
||||
|
||||
def self.get_sale_payments(sale_data)
|
||||
query = sale_data.sale_payments
|
||||
.where("CASE WHEN ((SELECT SUM(payment_amount)
|
||||
FROM sale_payments where payment_method='creditnote'
|
||||
and sale_id='#{sale_data.sale_id}') -
|
||||
(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}')
|
||||
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")
|
||||
.group("sale_payments.sale_payment_id")
|
||||
return query
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||
|
||||
@@ -371,7 +371,21 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
stroke_horizontal_rule
|
||||
# move_down 10
|
||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method").where('sale_id = ?', sale_data.sale_id).group("payment_method")
|
||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||
.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
||||
FROM sale_payments where payment_method='creditnote'
|
||||
and sale_id='#{sale_data.sale_id}') -
|
||||
(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}')
|
||||
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"
|
||||
@@ -573,7 +587,19 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
|
||||
def sign(sale_data)
|
||||
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
|
||||
SalePayment.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
||||
FROM sale_payments where payment_method='creditnote'
|
||||
and sale_id='#{sale_data.sale_id}') -
|
||||
(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}')
|
||||
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
|
||||
|
||||
@@ -369,7 +369,22 @@ class ReceiptBillPdf < Prawn::Document
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
stroke_horizontal_rule
|
||||
#move_down line_move
|
||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method").where('sale_id = ?', sale_data.sale_id).group("payment_method")
|
||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||
.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
||||
FROM sale_payments where payment_method='creditnote'
|
||||
and sale_id='#{sale_data.sale_id}') -
|
||||
(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}')
|
||||
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"
|
||||
@@ -573,7 +588,19 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
def sign(sale_data)
|
||||
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
|
||||
SalePayment.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
||||
FROM sale_payments where payment_method='creditnote'
|
||||
and sale_id='#{sale_data.sale_id}') -
|
||||
(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}')
|
||||
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
|
||||
|
||||
@@ -163,10 +163,10 @@
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData();" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData('cashier');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData();">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');">
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
@@ -288,10 +288,12 @@
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= @sale.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
<%if !@sale_payment.nil? %>
|
||||
<tr class="bg-red">
|
||||
<td class="charges-name"><strong>Credit Amount:</strong></td>
|
||||
<td class="item-attr"><strong id="credit_amount"><%= @sale_payment[0].payment_amount rescue 0%></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr class="rebate_amount"></tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -302,14 +304,16 @@
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn bg-default btn-block waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<% if current_user.role != "waiter" %>
|
||||
<button type="button" class="btn bg-blue btn-block waves-effect" id='pay'>Pay</button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
@@ -326,7 +330,7 @@
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
|
||||
getCreditSales(); //credit sales script data binding
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
|
||||
@@ -139,10 +139,10 @@
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData();" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData('cashier');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData();">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');">
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
@@ -192,7 +192,7 @@
|
||||
<!-- Column One -->
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
@@ -214,7 +214,7 @@
|
||||
getAllMenu();
|
||||
}
|
||||
|
||||
getCreditSales(); //credit sales script data binding
|
||||
getCreditSales("","","cashier"); //credit sales script data binding
|
||||
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
|
||||
@@ -174,10 +174,10 @@
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData();">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData('cashier');">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData();" >
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');" >
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
@@ -736,7 +736,7 @@
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
@@ -753,7 +753,7 @@
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
getCreditSales(); //credit sales script data binding
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
/* start check first bill or not*/
|
||||
var receipt_no = "";
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
|
||||
@@ -143,10 +143,10 @@
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData();">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData('cashier');">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData();" >
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');" >
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
@@ -270,7 +270,7 @@
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
@@ -285,7 +285,7 @@
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
getCreditSales(); //credit sales script data binding
|
||||
getCreditSales("","","cashier"); //credit sales script data binding
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/table/' + dining_id;
|
||||
|
||||
@@ -190,11 +190,7 @@
|
||||
<div class="row payment cash-color p-l-5 p-r-5">
|
||||
<div class="col-md-8">Cash</div>
|
||||
<div class="col-md-4" id="cash" >
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
|
||||
<% else %>
|
||||
<%= number_with_precision(0, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @sale_payment.nil? %>
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " data-toggle="tab" href="#pending_order" role="tab">Pending</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item credit_items">
|
||||
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credits %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="custom-slimscroll">
|
||||
<div class="tab-content m-t-15">
|
||||
@@ -43,6 +47,40 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credit Sale Panel -->
|
||||
<div class="tab-pane dining" id="credits" role="tabpanel">
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData('quick_service');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('quick_service');">
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix m-t-20 m-l-10">
|
||||
<table class="table table-responsive tbl_credit_lists">
|
||||
<thead>
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Credit Sale Panel -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -251,9 +289,24 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
<td>{customer_name}</td>
|
||||
<td>{credit_amount}</td>
|
||||
</tr>
|
||||
</script>
|
||||
<!-- script data for credit lists -->
|
||||
|
||||
<script>
|
||||
var cashier_type = "quick_service";
|
||||
$(document).ready(function(){
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/pending_order/' + sale_id;
|
||||
|
||||
274
app/views/origami/pending_order/credit_sale.html.erb
Normal file
274
app/views/origami/pending_order/credit_sale.html.erb
Normal file
@@ -0,0 +1,274 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<ul class="nav nav-tabs tab-col-teal" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#completed" role="tab"><%= t :competed %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " data-toggle="tab" href="#pending_order" role="tab">Pending</a>
|
||||
</li>
|
||||
<li class="nav-item credit_items active">
|
||||
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credits %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="custom-slimscroll">
|
||||
<div class="tab-content m-t-15">
|
||||
<div class="tab-pane" id="completed" role="tabpanel">
|
||||
<div class="card-columns">
|
||||
<% @completed.each do |sale| %>
|
||||
<div class="card completed bg-red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane " id="pending_order" role="tabpanel">
|
||||
<div class="card-columns">
|
||||
<% @sales.each do |sale| %>
|
||||
<div class="card sales bg-red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;">Billed</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% @orders.each do |order| %>
|
||||
<div class="card sales blue text-white" data-id = "<%= order.booking_id %>">
|
||||
<div class="card-block">
|
||||
<%= order.booking_id %><span style="font-size:12px;float:right;line-height:inherit;">new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credit Sale Panel -->
|
||||
<div class="tab-pane dining active" id="credits" role="tabpanel">
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData('quick_service');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('quick_service');">
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix m-t-20 m-l-10">
|
||||
<table class="table table-responsive tbl_credit_lists">
|
||||
<thead>
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Credit Sale Panel -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">INVOICE DETAILS </strong>| Table <%= @dining.name rescue "" %></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title row p-l-5 p-r-5">
|
||||
|
||||
<% if @status == 'sale' %>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Receipt No: <span id="receipt_no">
|
||||
<%= @sale.receipt_no rescue '' %></span>
|
||||
</div>
|
||||
<% else%>
|
||||
<input type="hidden" id="save_order_id" value="<%=@bookings.booking_orders[0].order_id%>">
|
||||
<div class="col-lg-8 col-md-8 col-sm-8">
|
||||
Order No: <span id="receipt_no">
|
||||
<%= @bookings.booking_orders[0].order_id rescue '' %></span>
|
||||
</div>
|
||||
<% end%>
|
||||
|
||||
|
||||
<% if @status == 'sale' %>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> </span>
|
||||
</div>
|
||||
<% else%>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 text-right">
|
||||
Date: <span id="receipt_date"><%= @order.created_at.strftime("%I:%M %p") rescue '-'%> </span>
|
||||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="card-title row customer_detail p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<% if @status == 'sale' %>
|
||||
Customer : <%= @sale.customer.name rescue "-" %>
|
||||
<% else%>
|
||||
Customer : <%= @order.customer.name rescue "-" %>
|
||||
<% end%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="160">
|
||||
<div class="card-text" style="">
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @status == 'sale' %>
|
||||
<% sub_total = 0
|
||||
@sale.sale_items.each do |sale_item|
|
||||
sub_total = sub_total + sale_item.price %>
|
||||
<input type="hidden" id="sale_id" value="<%= @sale.sale_id %>">
|
||||
<tr>
|
||||
<td class='item-name'><%= sale_item.product_name %></td>
|
||||
<td class='item-attr'><%= sale_item.qty %></td>
|
||||
<td class='item-attr'><%= sale_item.price %></td>
|
||||
</tr>
|
||||
<% end%>
|
||||
<% else%>
|
||||
<% sub_total = 0
|
||||
total = 0
|
||||
@order_items.each do |order_item|
|
||||
total = order_item.qty * order_item.price
|
||||
sub_total = sub_total + total %>
|
||||
<input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>">
|
||||
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
|
||||
<td class='item-name'><%= order_item.item_name %></td>
|
||||
<td class='item-attr'><%= order_item.qty %></td>
|
||||
<td class='item-attr'><%= total %></td>
|
||||
</tr>
|
||||
<% end%>
|
||||
<% end%>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<% if @status == 'sale' %>
|
||||
<tr>
|
||||
<%if @sale.discount_type == 'member_discount'%>
|
||||
<td class="charges-name"><strong>Member Discount:</strong></td>
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= @sale.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
<%if !@sale_payment.nil? %>
|
||||
<tr class="bg-red">
|
||||
<td class="charges-name"><strong>Credit Amount:</strong></td>
|
||||
<td class="item-attr"><strong id="credit_amount"><%= @sale_payment[0].payment_amount rescue 0%></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr class="rebate_amount"></tr>
|
||||
<% else%>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<% end%>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<% if current_user.role != "waiter" %>
|
||||
<button type="button" class="btn bg-blue btn-block waves-effect" id='pay'>Pay</button>
|
||||
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
|
||||
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
||||
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
<td>{customer_name}</td>
|
||||
<td>{credit_amount}</td>
|
||||
</tr>
|
||||
</script>
|
||||
<!-- script data for credit lists -->
|
||||
|
||||
<script>
|
||||
var cashier_type = "quick_service";
|
||||
$(document).ready(function(){
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/pending_order/' + sale_id;
|
||||
})
|
||||
$(".completed").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/completed_sale/' + sale_id;
|
||||
})
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/origami/quick_service/pending_order';
|
||||
});
|
||||
|
||||
$('#close_cashier').on('click',function(e){
|
||||
e.preventDefault(); // Prevent the href from redirecting directly
|
||||
var linkURL = '/origami/shift/quick_service/close';
|
||||
warnBeforeRedirect(linkURL);
|
||||
});
|
||||
|
||||
$('#cash_in').on('click',function(){
|
||||
window.location.href = '/origami/quick_service/cash_ins';
|
||||
});
|
||||
|
||||
$('#cash_out').on('click',function(){
|
||||
window.location.href = '/origami/quick_service/cash_outs';
|
||||
});
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = '<%= @sale.sale_id %>';
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/credit_payment";
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -10,6 +10,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#pending_order" role="tab">Pending</a>
|
||||
</li>
|
||||
<li class="nav-item credit_items">
|
||||
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credits %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
<div id="custom-slimscroll">
|
||||
@@ -44,6 +47,40 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credit Sales Panel -->
|
||||
<div class="tab-pane dining" id="credits" role="tabpanel">
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData('quick_service');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('quick_service');">
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix m-t-20 m-l-10">
|
||||
<table class="table table-responsive tbl_credit_lists">
|
||||
<thead>
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Credit Sales Panel -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,47 +98,64 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
cashier_type = "quick_service"
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/pending_order/' + sale_id;
|
||||
})
|
||||
$(".completed").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/completed_sale/' + sale_id;
|
||||
})
|
||||
$('#pay').on('click', function () {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/origami/sale/' + sale_id + "/quick_service/payment";
|
||||
});
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/origami/quick_service';
|
||||
})
|
||||
|
||||
$('#close_cashier').on('click',function(e){
|
||||
e.preventDefault(); // Prevent the href from redirecting directly
|
||||
var linkURL = '/origami/shift/quick_service/close';
|
||||
warnBeforeRedirect(linkURL);
|
||||
});
|
||||
|
||||
$('#cash_in').on('click',function(){
|
||||
window.location.href = '/origami/quick_service/cash_ins';
|
||||
})
|
||||
|
||||
$('#cash_out').on('click',function(){
|
||||
window.location.href = '/origami/quick_service/cash_outs';
|
||||
})
|
||||
|
||||
function warnBeforeRedirect(linkURL) {
|
||||
swal({
|
||||
title: "Alert!",
|
||||
text: "Are you sure you want to close cashier?",
|
||||
type: "warning",
|
||||
showCancelButton: true
|
||||
}, function() {
|
||||
// Redirect the user
|
||||
window.location.href = linkURL;
|
||||
});
|
||||
}
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
<td>{customer_name}</td>
|
||||
<td>{credit_amount}</td>
|
||||
</tr>
|
||||
</script>
|
||||
<!-- script data for credit lists -->
|
||||
|
||||
<script>
|
||||
var cashier_type = "quick_service";
|
||||
$(document).ready(function(){
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/pending_order/' + sale_id;
|
||||
});
|
||||
$(".completed").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/completed_sale/' + sale_id;
|
||||
});
|
||||
$('#pay').on('click', function () {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/origami/sale/' + sale_id + "/quick_service/payment";
|
||||
});
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/origami/quick_service';
|
||||
});
|
||||
|
||||
$('#close_cashier').on('click',function(e){
|
||||
e.preventDefault(); // Prevent the href from redirecting directly
|
||||
var linkURL = '/origami/shift/quick_service/close';
|
||||
warnBeforeRedirect(linkURL);
|
||||
});
|
||||
|
||||
$('#cash_in').on('click',function(){
|
||||
window.location.href = '/origami/quick_service/cash_ins';
|
||||
});
|
||||
|
||||
$('#cash_out').on('click',function(){
|
||||
window.location.href = '/origami/quick_service/cash_outs';
|
||||
});
|
||||
});
|
||||
|
||||
function warnBeforeRedirect(linkURL) {
|
||||
swal({
|
||||
title: "Alert!",
|
||||
text: "Are you sure you want to close cashier?",
|
||||
type: "warning",
|
||||
showCancelButton: true
|
||||
}, function() {
|
||||
// Redirect the user
|
||||
window.location.href = linkURL;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#pending_order" role="tab">Pending</a>
|
||||
</li>
|
||||
<li class="nav-item credit_items">
|
||||
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credits %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="custom-slimscroll">
|
||||
<div class="tab-content m-t-15">
|
||||
@@ -42,6 +45,40 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credit Sale Panel -->
|
||||
<div class="tab-pane dining" id="credits" role="tabpanel">
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" onchange="getCreditData('quick_service');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('quick_service');">
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix m-t-20 m-l-10">
|
||||
<table class="table table-responsive tbl_credit_lists">
|
||||
<thead>
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Credit Sale Panel -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -194,9 +231,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
<td>{customer_name}</td>
|
||||
<td>{credit_amount}</td>
|
||||
</tr>
|
||||
</script>
|
||||
<!-- script data for credit lists -->
|
||||
|
||||
<script>
|
||||
var cashier_type = "quick_service";
|
||||
$(document).ready(function(){
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/quick_service/pending_order/' + sale_id;
|
||||
|
||||
@@ -175,10 +175,10 @@
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData();">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData('cashier');">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData();" >
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');" >
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
@@ -729,7 +729,7 @@
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
@@ -747,7 +747,7 @@ $(document).ready(function(){
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
|
||||
getCreditSales(); //credit sales script data binding
|
||||
getCreditSales("","",cashier_type); //credit sales script data binding
|
||||
// $(".tables").on('click', function(){
|
||||
// var customer_id=$(".customer-id").text();
|
||||
// show_customer_details(customer_id);
|
||||
|
||||
@@ -164,10 +164,10 @@
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData();">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData('cashier');">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData();" >
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');" >
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
@@ -392,7 +392,7 @@
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
@@ -406,7 +406,7 @@ $(document).ready(function(){
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
getCreditSales(); //credit sales script data binding
|
||||
getCreditSales("","","cashier"); //credit sales script data binding
|
||||
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
|
||||
@@ -289,7 +289,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
|
||||
#credit payment routes
|
||||
post '/:type/credit_sales' => "dashboard#get_credit_sales", :as => "get_credit_sales", :defaults => { :format => 'json' }
|
||||
get '/:type/credit_sales/:sale_id' => "credit_sales#show"
|
||||
get '/cashier/credit_sales/:sale_id' => "credit_sales#show"
|
||||
get '/quick_service/credit_sales/:sale_id' => "pending_order#credit_sale"
|
||||
get 'sale/:sale_id/:type/credit_payment' => "payments#show"
|
||||
|
||||
post 'credit_payment/cash' => 'payments#create'
|
||||
@@ -298,27 +299,27 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'credit_payment/master' => "master#create"
|
||||
post 'credit_payment/visa' => "visa#create"
|
||||
post 'credit_payment/unionpay' => "unionpay#create"
|
||||
post 'credit_payment/paypar' => 'paypar_payments#create'
|
||||
post 'credit_payment/voucher' => 'voucher_payments#create'
|
||||
post 'credit_payment/paymal' => 'paymal#create'
|
||||
# post 'credit_payment/paypar' => 'paypar_payments#create'
|
||||
# post 'credit_payment/voucher' => 'voucher_payments#create'
|
||||
# post 'credit_payment/paymal' => 'paymal#create'
|
||||
post 'credit_payment/alipay' => 'alipay#create'
|
||||
post 'credit_payment/junctionpay' => 'junction_pay#create'
|
||||
post 'credit_payment/dinga' => 'dinga#create'
|
||||
post 'credit_payment/gift_voucher' => 'gift_voucher#create'
|
||||
# post 'credit_payment/junctionpay' => 'junction_pay#create'
|
||||
# post 'credit_payment/dinga' => 'dinga#create'
|
||||
# post 'credit_payment/gift_voucher' => 'gift_voucher#create'
|
||||
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/MPU' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/VISA' => "visa#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/JCB' => "jcb#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/PAYMAL' => "paymal#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/PAYMAL' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/UNIONPAY' => "unionpay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Voucher' => "voucher#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/JunctionPay' => "junction_pay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/Voucher' => "voucher#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/JunctionPay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Alipay' => "alipay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
end
|
||||
|
||||
#--------- Waiter/Ordering Station ------------#
|
||||
|
||||
Reference in New Issue
Block a user