credit payment function
This commit is contained in:
@@ -228,8 +228,8 @@ $(document).on('turbolinks:load', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".credit_detail",function(){
|
$(document).on("click", ".credit_detail",function(){
|
||||||
var sale_payment_id = $(this).attr("data-id");
|
var sale_id = $(this).attr("data-id");
|
||||||
window.location.href = "/origami/cashier/credit_sales/"+sale_payment_id;
|
window.location.href = "/origami/cashier/credit_sales/"+sale_id;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -391,7 +391,11 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/"+payment_type;
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,7 +419,11 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/"+url_param;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,8 +443,12 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/"+payment_type;
|
var url_param = "payment";
|
||||||
});
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//end CB ECR integration
|
//end CB ECR integration
|
||||||
@@ -555,7 +567,7 @@ function getCreditSales(filter, customer){
|
|||||||
var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? sale_date.getMonth() : '0' + sale_date.getMonth()) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate());
|
var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? sale_date.getMonth() : '0' + sale_date.getMonth()) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate());
|
||||||
$('.tbd_credit_lists').append(html_credit_items.formatUnicorn({
|
$('.tbd_credit_lists').append(html_credit_items.formatUnicorn({
|
||||||
'key':i,
|
'key':i,
|
||||||
'sale_payment_id':credit_sales[i].sale_payment_id,
|
'sale_id':credit_sales[i].sale_id,
|
||||||
'receipt_date':receipt_date +" "+timeFormat(sale_date),
|
'receipt_date':receipt_date +" "+timeFormat(sale_date),
|
||||||
'receipt_no':credit_sales[i].receipt_no,
|
'receipt_no':credit_sales[i].receipt_no,
|
||||||
'cashier_name':credit_sales[i].cashier_name,
|
'cashier_name':credit_sales[i].cashier_name,
|
||||||
|
|||||||
@@ -2,8 +2,13 @@ class Origami::AlipayController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
|
path = request.fullpath
|
||||||
# limit alipay_amount
|
# limit alipay_amount
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
if path.include? ("credit_payment")
|
||||||
|
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||||
|
else
|
||||||
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
end
|
||||||
total = 0
|
total = 0
|
||||||
@alipaycount = 0
|
@alipaycount = 0
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
@@ -24,8 +29,13 @@ class Origami::AlipayController < BaseOrigamiController
|
|||||||
new_total = sale_data.grand_total
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
@rounding_adj = new_total-sale_data.grand_total
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||||
|
else
|
||||||
|
sale_payment_data = sale_data.sale_payments
|
||||||
|
end
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_payment_data.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "alipay"
|
if sale_payment.payment_method == "alipay"
|
||||||
@alipaycount = @alipaycount + sale_payment.payment_amount
|
@alipaycount = @alipaycount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
@@ -64,8 +74,14 @@ class Origami::AlipayController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
|
path = request.fullpath
|
||||||
|
payment_for = false
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
payment_for = true
|
||||||
|
end
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no,payment_for)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
|||||||
shop_details = Shop.first
|
shop_details = Shop.first
|
||||||
|
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if shop_details.is_rounding_adj
|
# if shop_details.is_rounding_adj
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||||
rounding_adj = new_total-saleObj.grand_total
|
# rounding_adj = new_total-saleObj.grand_total
|
||||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||||
end
|
# end
|
||||||
|
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ class Origami::CreditSalesController < BaseOrigamiController
|
|||||||
@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')
|
@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")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
@sale_payment = SalePayment.find_by_sale_payment_id(params[:sale_payment_id])
|
@sale = Sale.find_by_sale_id(params[:sale_id])
|
||||||
@sale = Sale.find_by_sale_id(@sale_payment.sale_id)
|
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
||||||
|
.where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote")
|
||||||
|
|
||||||
@sale_taxes = []
|
@sale_taxes = []
|
||||||
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
|
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
|
||||||
if !sale_taxes.empty?
|
if !sale_taxes.empty?
|
||||||
|
|||||||
@@ -4,22 +4,6 @@ class Origami::DashboardController < BaseOrigamiController
|
|||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
|
|
||||||
today = DateTime.now.strftime('%Y-%m-%d')
|
today = DateTime.now.strftime('%Y-%m-%d')
|
||||||
# @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
|
||||||
# @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
|
||||||
|
|
||||||
# @top_products = Sale.top_products(today).sum('i.qty')
|
|
||||||
# @bottom_products = Sale.bottom_products(today).sum('i.qty')
|
|
||||||
# @hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
|
||||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
|
||||||
# .sum(:grand_total)
|
|
||||||
# @employee_sales = Sale.employee_sales(today)
|
|
||||||
# .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
|
||||||
# @inventories = StockJournal.inventory_balances(today).sum(:balance)
|
|
||||||
|
|
||||||
# @total_sale = Sale.total_sale(today,current_user)
|
|
||||||
# @total_count = Sale.total_count(today,current_user)
|
|
||||||
# @total_card = Sale.total_card_sale(today,current_user)
|
|
||||||
# @total_credit = Sale.credit_payment(today,current_user)
|
|
||||||
|
|
||||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||||
|
|
||||||
@@ -92,7 +76,7 @@ def get_all_menu
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_credit_sales
|
def get_credit_sales
|
||||||
credit_sales = Sale.get_credit_sales(params)
|
credit_sales = SalePayment.get_credit_sales(params)
|
||||||
if !credit_sales.nil?
|
if !credit_sales.nil?
|
||||||
result = {:status=> true, :data=> credit_sales }
|
result = {:status=> true, :data=> credit_sales }
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,8 +3,13 @@ class Origami::JcbController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
|
path = request.fullpath
|
||||||
# limit jcb_amount
|
# limit jcb_amount
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
if path.include? ("credit_payment")
|
||||||
|
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||||
|
else
|
||||||
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
end
|
||||||
total = 0
|
total = 0
|
||||||
@jcbcount = 0
|
@jcbcount = 0
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
@@ -25,8 +30,13 @@ class Origami::JcbController < BaseOrigamiController
|
|||||||
new_total = sale_data.grand_total
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
@rounding_adj = new_total-sale_data.grand_total
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||||
|
else
|
||||||
|
sale_payment_data = sale_data.sale_payments
|
||||||
|
end
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_payment_data.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "jcb"
|
if sale_payment.payment_method == "jcb"
|
||||||
@jcbcount = @jcbcount + sale_payment.payment_amount
|
@jcbcount = @jcbcount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
@@ -66,8 +76,13 @@ class Origami::JcbController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
|
path = request.fullpath
|
||||||
|
payment_for = false
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
payment_for = true
|
||||||
|
end
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no)
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no,payment_for)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,13 @@ class Origami::MasterController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
|
path = request.fullpath
|
||||||
# limit master_amount
|
# limit master_amount
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
if path.include? ("credit_payment")
|
||||||
|
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||||
|
else
|
||||||
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
end
|
||||||
total = 0
|
total = 0
|
||||||
@mastercount = 0
|
@mastercount = 0
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
@@ -25,8 +30,13 @@ class Origami::MasterController < BaseOrigamiController
|
|||||||
new_total = sale_data.grand_total
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
@rounding_adj = new_total-sale_data.grand_total
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||||
|
else
|
||||||
|
sale_payment_data = sale_data.sale_payments
|
||||||
|
end
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_payment_data.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "master"
|
if sale_payment.payment_method == "master"
|
||||||
@mastercount = @mastercount + sale_payment.payment_amount
|
@mastercount = @mastercount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
@@ -63,8 +73,13 @@ class Origami::MasterController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
|
path = request.fullpath
|
||||||
|
payment_for = false
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
payment_for = true
|
||||||
|
end
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no)
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no,payment_for)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,13 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
|
path = request.fullpath
|
||||||
# limit mpu_amount
|
# limit mpu_amount
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
if path.include? ("credit_payment")
|
||||||
|
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||||
|
else
|
||||||
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
end
|
||||||
total = 0
|
total = 0
|
||||||
@mpucount = 0
|
@mpucount = 0
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
@@ -18,14 +23,19 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
|
|
||||||
others = 0
|
others = 0
|
||||||
|
|
||||||
if @shop.is_rounding_adj
|
if @shop.is_rounding_adj && (!path.include? ("credit_payment"))
|
||||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||||
else
|
else
|
||||||
new_total = sale_data.grand_total
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
@rounding_adj = new_total-sale_data.grand_total
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||||
|
else
|
||||||
|
sale_payment_data = sale_data.sale_payments
|
||||||
|
end
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_payment_data.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "mpu"
|
if sale_payment.payment_method == "mpu"
|
||||||
@mpucount = @mpucount + sale_payment.payment_amount
|
@mpucount = @mpucount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
@@ -64,8 +74,13 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
|
path = request.fullpath
|
||||||
|
payment_for = false
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
payment_for = true
|
||||||
|
end
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu",ref_no)
|
@status, @sale = sale_payment.process_payment(saleObj, current_user.name, cash, "mpu",ref_no,payment_for)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
|||||||
@membership_rebate_balance = 0
|
@membership_rebate_balance = 0
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
@payment_method_setting = PaymentMethodSetting.all
|
path = request.fullpath
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
@payment_method_setting = PaymentMethodSetting.where("LOWER(payment_method) in ('mpu','visa','master','jcb','unionpay','alipay') and is_active='1'")
|
||||||
|
else
|
||||||
|
@payment_method_setting = PaymentMethodSetting.all
|
||||||
|
end
|
||||||
|
|
||||||
@rebate = MembershipSetting.find_by_rebate(1)
|
@rebate = MembershipSetting.find_by_rebate(1)
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
|||||||
@@ -98,135 +98,142 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
member_info = nil
|
member_info = nil
|
||||||
type = params[:type]
|
type = params[:type]
|
||||||
tax_type = params[:tax_type]
|
tax_type = params[:tax_type]
|
||||||
|
path = request.fullpath
|
||||||
|
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||||
#shop_detail = Shop.first
|
#shop_detail = Shop.first
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if shop_detail.is_rounding_adj
|
if !path.include? ("credit_payment")
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
if shop_detail.is_rounding_adj
|
||||||
b = saleObj.grand_total / 25 # Division
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
#not calculate rounding if modulus is 0 and division is even
|
b = saleObj.grand_total / 25 # Division
|
||||||
#calculate rounding if modulus is zero or not zero and division are not even
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
#calculate rounding if modulus is zero or not zero and division are not even
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||||
rounding_adj = new_total-saleObj.grand_total
|
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
rounding_adj = new_total-saleObj.grand_total
|
||||||
|
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment.process_payment(saleObj, current_user.name, cash, "cash", nil, true)
|
||||||
rebate_amount = nil
|
|
||||||
|
|
||||||
# For Cashier by Zone
|
|
||||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
|
||||||
bookings = Booking.find_by_sale_id(sale_id)
|
|
||||||
if bookings.dining_facility_id.to_i > 0
|
|
||||||
table = DiningFacility.find(bookings.dining_facility_id)
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
|
||||||
|
|
||||||
type = 'payment'
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
|
||||||
else
|
else
|
||||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# For Print
|
if !path.include? ("credit_payment")
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
rebate_amount = nil
|
||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
|
||||||
unique_code = "ReceiptBillPdf"
|
# For Cashier by Zone
|
||||||
if !receipt_bill_a5_pdf.empty?
|
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
bookings = Booking.find_by_sale_id(sale_id)
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
if bookings.dining_facility_id.to_i > 0
|
||||||
if receipt_bilA5[1] == '1'
|
table = DiningFacility.find(bookings.dining_facility_id)
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
else
|
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
|
type = 'payment'
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
|
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||||
|
else
|
||||||
|
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||||
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
# For Print
|
||||||
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
if !receipt_bill_a5_pdf.empty?
|
||||||
|
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||||
|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||||
|
if receipt_bilA5[1] == '1'
|
||||||
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
|
else
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
|
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate(1)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||||
|
|
||||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
|
|
||||||
if member_info["status"] == true
|
if member_info["status"] == true
|
||||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||||
current_balance = SaleAudit.paymal_search(sale_id)
|
current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
#orders print out
|
|
||||||
if params[:type] == "quick_service"
|
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
|
||||||
if booking.dining_facility_id.to_i>0
|
|
||||||
table_id = booking.dining_facility_id
|
|
||||||
else
|
|
||||||
table_id = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
booking.booking_orders.each do |order|
|
#orders print out
|
||||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
if params[:type] == "quick_service"
|
||||||
oqs = OrderQueueStation.new
|
booking = Booking.find_by_sale_id(sale_id)
|
||||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
if booking.dining_facility_id.to_i>0
|
||||||
|
table_id = booking.dining_facility_id
|
||||||
|
else
|
||||||
|
table_id = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
booking.booking_orders.each do |order|
|
||||||
|
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||||
|
oqs = OrderQueueStation.new
|
||||||
|
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||||
|
|
||||||
|
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
|
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||||
|
end
|
||||||
|
|
||||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
#for card sale data
|
||||||
|
card_data = Array.new
|
||||||
#for card sale data
|
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||||
card_data = Array.new
|
if !card_sale_trans_ref_no.nil?
|
||||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||||
if !card_sale_trans_ref_no.nil?
|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
card_no = cash_sale_trans.pan.last(4)
|
||||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
card_no = card_no.rjust(19,"**** **** **** ")
|
||||||
card_no = cash_sale_trans.pan.last(4)
|
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||||
card_no = card_no.rjust(19,"**** **** **** ")
|
end
|
||||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
# 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)
|
||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(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,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data)
|
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)
|
||||||
|
|
||||||
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})
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if params[:sale_id]
|
path = request.fullpath
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
end
|
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
if params[:sale_payment_id]
|
if path.include? ("credit_payment")
|
||||||
sale_payment_id = params[:sale_payment_id]
|
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
||||||
@sale_payment = SalePayment.find(params[:sale_payment_id])
|
.where("sale_id = ? and payment_method=?", sale_id, "creditnote")
|
||||||
sale_id = @sale_payment.sale_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@member_discount = MembershipSetting.find_by_discount(1)
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
@@ -358,7 +365,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_data.sale_payments.each do |spay|
|
if path.include? ("credit_payment")
|
||||||
|
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
|
||||||
|
else
|
||||||
|
@sale_payment_data = @sale_data.sale_payments
|
||||||
|
end
|
||||||
|
@sale_payment_data.each do |spay|
|
||||||
if spay.payment_method == "cash"
|
if spay.payment_method == "cash"
|
||||||
@cash = spay.payment_amount
|
@cash = spay.payment_amount
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,8 +2,13 @@ class Origami::UnionpayController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
|
path = request.fullpath
|
||||||
# limit unionpay_amount
|
# limit unionpay_amount
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
if path.include? ("credit_payment")
|
||||||
|
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||||
|
else
|
||||||
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
end
|
||||||
total = 0
|
total = 0
|
||||||
@unionpaycount = 0
|
@unionpaycount = 0
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
@@ -23,8 +28,13 @@ class Origami::UnionpayController < BaseOrigamiController
|
|||||||
new_total = sale_data.grand_total
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
@rounding_adj = new_total-sale_data.grand_total
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||||
|
else
|
||||||
|
sale_payment_data = sale_data.sale_payments
|
||||||
|
end
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_payment_data.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "unionpay"
|
if sale_payment.payment_method == "unionpay"
|
||||||
@unionpaycount = @unionpaycount + sale_payment.payment_amount
|
@unionpaycount = @unionpaycount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
@@ -62,8 +72,13 @@ class Origami::UnionpayController < BaseOrigamiController
|
|||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
path = request.fullpath
|
||||||
|
payment_for = false
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
payment_for = true
|
||||||
|
end
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no)
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no,payment_for)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,13 @@ class Origami::VisaController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
# limit visa_amount
|
path = request.fullpath
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
# limit mpu_amount
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||||
|
else
|
||||||
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
end
|
||||||
total = 0
|
total = 0
|
||||||
@visacount = 0
|
@visacount = 0
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
@@ -23,8 +28,13 @@ class Origami::VisaController < BaseOrigamiController
|
|||||||
new_total = sale_data.grand_total
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
@rounding_adj = new_total-sale_data.grand_total
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||||
|
else
|
||||||
|
sale_payment_data = sale_data.sale_payments
|
||||||
|
end
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_payment_data.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "visa"
|
if sale_payment.payment_method == "visa"
|
||||||
@visacount = @visacount + sale_payment.payment_amount
|
@visacount = @visacount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
@@ -62,8 +72,13 @@ class Origami::VisaController < BaseOrigamiController
|
|||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
path = request.fullpath
|
||||||
|
payment_for = false
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
payment_for = true
|
||||||
|
end
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no)
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no,payment_for)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1238,7 +1238,7 @@ end
|
|||||||
credit = 0.0
|
credit = 0.0
|
||||||
self.sale_payments.each do |pay|
|
self.sale_payments.each do |pay|
|
||||||
if pay.payment_method == 'creditnote'
|
if pay.payment_method == 'creditnote'
|
||||||
credit = pay.payment_amount
|
credit += pay.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return credit
|
return credit
|
||||||
@@ -2568,25 +2568,12 @@ def self.all_receipt_details
|
|||||||
return query
|
return query
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_credit_sales(params)
|
def self.get_sale_data_for_other_payment_credit(sale_id)
|
||||||
receipt_no = ""
|
query = Sale.select("sales.sale_id,sales.receipt_no,sales.customer_id,SUM(sp.payment_amount) as total_amount,SUM(sp.payment_amount) as grand_total")
|
||||||
customer = ""
|
.joins(" JOIN sale_payments sp on sp.sale_id=sales.sale_id")
|
||||||
if !params["receipt_no"].blank?
|
.where("sp.payment_method ='creditnote' and sales.sale_id='#{sale_id}'")
|
||||||
receipt_no = " and s.receipt_no LIKE '%#{params["receipt_no"]}%'"
|
.group("sales.sale_id")
|
||||||
end
|
.first
|
||||||
|
|
||||||
if !params["customer_id"].blank?
|
|
||||||
customer = " and s.customer_id = '#{params["customer_id"]}'"
|
|
||||||
end
|
|
||||||
|
|
||||||
query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount,s.receipt_date as sale_date,
|
|
||||||
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")
|
|
||||||
|
|
||||||
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' #{receipt_no} #{customer}")
|
|
||||||
.order("s.receipt_date ASC, s.receipt_no ASC")
|
|
||||||
|
|
||||||
return query
|
return query
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,21 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
||||||
|
|
||||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
|
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
|
||||||
self.sale = invoice
|
self.sale = invoice
|
||||||
self.received_amount = cash_amount
|
self.received_amount = cash_amount
|
||||||
self.payment_reference = remark
|
self.payment_reference = remark
|
||||||
amount_due = invoice.grand_total
|
|
||||||
|
|
||||||
#get all payment for this invoices
|
#get all payment for this invoices
|
||||||
invoice.sale_payments.each do |payment|
|
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
|
||||||
|
else
|
||||||
|
invoice_sale_payments = invoice.sale_payments
|
||||||
|
amount_due = invoice.grand_total
|
||||||
|
end
|
||||||
|
|
||||||
|
invoice_sale_payments.each do |payment|
|
||||||
if (payment.payment_status == "paid" )
|
if (payment.payment_status == "paid" )
|
||||||
amount_due = amount_due - payment.payment_amount
|
amount_due = amount_due - payment.payment_amount
|
||||||
end
|
end
|
||||||
@@ -27,23 +34,23 @@ class SalePayment < ApplicationRecord
|
|||||||
#route to payment type
|
#route to payment type
|
||||||
case payment_method
|
case payment_method
|
||||||
when "cash"
|
when "cash"
|
||||||
payment_status = cash_payment
|
payment_status = cash_payment(payment_for)
|
||||||
when "creditnote"
|
when "creditnote"
|
||||||
if !self.sale.customer_id.nil?
|
if !self.sale.customer_id.nil?
|
||||||
payment_status = creditnote_payment(self.customer_id)
|
payment_status = creditnote_payment(self.customer_id)
|
||||||
end
|
end
|
||||||
when "visa"
|
when "visa"
|
||||||
payment_status = external_terminal_card_payment(:visa)
|
payment_status = external_terminal_card_payment(:visa, payment_for)
|
||||||
when "master"
|
when "master"
|
||||||
payment_status = external_terminal_card_payment(:master)
|
payment_status = external_terminal_card_payment(:master, payment_for)
|
||||||
when "jcb"
|
when "jcb"
|
||||||
payment_status = external_terminal_card_payment(:jcb)
|
payment_status = external_terminal_card_payment(:jcb, payment_for)
|
||||||
when "mpu"
|
when "mpu"
|
||||||
payment_status = external_terminal_card_payment(:mpu)
|
payment_status = external_terminal_card_payment(:mpu, payment_for)
|
||||||
when "unionpay"
|
when "unionpay"
|
||||||
payment_status = external_terminal_card_payment(:unionpay)
|
payment_status = external_terminal_card_payment(:unionpay, payment_for)
|
||||||
when "alipay"
|
when "alipay"
|
||||||
payment_status = external_terminal_card_payment(:alipay)
|
payment_status = external_terminal_card_payment(:alipay, payment_for)
|
||||||
when "vochure"
|
when "vochure"
|
||||||
payment_status = vochure_payment
|
payment_status = vochure_payment
|
||||||
when "giftcard"
|
when "giftcard"
|
||||||
@@ -65,8 +72,22 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
# remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
|
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
if payment_for
|
||||||
|
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||||
|
if !shift.nil?
|
||||||
|
shift_sale_id = shift.id
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_shift
|
||||||
|
shift_sale_id = shift.id
|
||||||
|
end
|
||||||
|
|
||||||
|
remark = "#{self.sale_payment_id}||#{shift_sale_id} -> #{remark}"
|
||||||
|
|
||||||
|
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
||||||
|
else
|
||||||
|
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
||||||
|
end
|
||||||
|
|
||||||
# update complete order items in oqs
|
# update complete order items in oqs
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
booking = Booking.find_by_sale_id(sale_id)
|
||||||
@@ -82,7 +103,7 @@ class SalePayment < ApplicationRecord
|
|||||||
return true, self.save,membership_data
|
return true, self.save,membership_data
|
||||||
else
|
else
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
# remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
|
||||||
|
|
||||||
return false, "No outstanding Amount"
|
return false, "No outstanding Amount"
|
||||||
@@ -280,7 +301,7 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def cash_payment
|
def cash_payment(payment_for=false)
|
||||||
status = false
|
status = false
|
||||||
sale_payments_data = SalePayment.find_by_sale_id(self.sale_id)
|
sale_payments_data = SalePayment.find_by_sale_id(self.sale_id)
|
||||||
if sale_payments_data.nil?
|
if sale_payments_data.nil?
|
||||||
@@ -290,11 +311,19 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = false
|
payment_status = false
|
||||||
self.payment_method = "cash"
|
self.payment_method = "cash"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
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
|
||||||
|
self.outstanding_amount = credit_sale_payment - self.received_amount.to_f
|
||||||
|
end
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
|
if payment_for
|
||||||
sale_update_payment_status(self.received_amount,status)
|
update_shift_for_credit_payment
|
||||||
|
else
|
||||||
|
sale_update_payment_status(self.received_amount,status)
|
||||||
|
end
|
||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -333,15 +362,24 @@ class SalePayment < ApplicationRecord
|
|||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
def external_terminal_card_payment(method)
|
def external_terminal_card_payment(method, payment_for=false)
|
||||||
payment_status = false
|
payment_status = false
|
||||||
self.payment_method = method
|
self.payment_method = method
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
# self.payment_reference = self.card_payment_reference
|
# self.payment_reference = self.card_payment_reference
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
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
|
||||||
|
self.outstanding_amount = credit_payment[0].payment_amount.to_f - self.received_amount.to_f
|
||||||
|
end
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
sale_update_payment_status(self.received_amount)
|
if payment_for
|
||||||
|
update_shift_for_credit_payment
|
||||||
|
else
|
||||||
|
sale_update_payment_status(self.received_amount)
|
||||||
|
end
|
||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -594,6 +632,33 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# update for shift with credit payment
|
||||||
|
def update_shift_for_credit_payment
|
||||||
|
shift = ShiftSale.find_by_id(self.sale.shift_sale_id)
|
||||||
|
if !shift.nil?
|
||||||
|
credit_payment_left = get_credit_payment_left[0].payment_amount.to_f
|
||||||
|
if self.payment_method == "cash"
|
||||||
|
if credit_payment_left == 0 || credit_payment_left >= self.received_amount.to_f
|
||||||
|
shift.cash_sales = shift.cash_sales.to_f + self.received_amount.to_f
|
||||||
|
else
|
||||||
|
shift.cash_sales = shift.cash_sales.to_f + credit_payment_left
|
||||||
|
extra_changed_amount = self.received_amount.to_f - credit_payment_left
|
||||||
|
self.sale.amount_received = self.sale.amount_received.to_f + extra_changed_amount.to_f
|
||||||
|
self.sale.amount_changed = self.sale.amount_changed.to_f + extra_changed_amount.to_f
|
||||||
|
self.sale.save!
|
||||||
|
end
|
||||||
|
else
|
||||||
|
shift.other_sales = shift.other_sales.to_f + self.received_amount.to_f
|
||||||
|
end
|
||||||
|
if credit_payment_left == 0 || credit_payment_left >= self.received_amount.to_f
|
||||||
|
shift.credit_sales = shift.credit_sales.to_f - self.received_amount.to_f
|
||||||
|
else
|
||||||
|
shift.cash_sales = shift.credit_sales.to_f - credit_payment_left
|
||||||
|
end
|
||||||
|
shift.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def table_update_status(sale_obj)
|
def table_update_status(sale_obj)
|
||||||
status = true
|
status = true
|
||||||
sale_count = 0
|
sale_count = 0
|
||||||
@@ -775,6 +840,65 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#credit payment query
|
||||||
|
def self.get_credit_sales(params)
|
||||||
|
receipt_no = ""
|
||||||
|
customer = ""
|
||||||
|
if !params["receipt_no"].blank?
|
||||||
|
receipt_no = " and s.receipt_no LIKE '%#{params["receipt_no"]}%'"
|
||||||
|
end
|
||||||
|
|
||||||
|
if !params["customer_id"].blank?
|
||||||
|
customer = " and s.customer_id = '#{params["customer_id"]}'"
|
||||||
|
end
|
||||||
|
|
||||||
|
query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id,
|
||||||
|
sale_payments.payment_method,
|
||||||
|
SUM(sale_payments.payment_amount) as payment_amount,
|
||||||
|
s.receipt_date as sale_date,
|
||||||
|
s.sale_id,
|
||||||
|
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}")
|
||||||
|
.group("s.receipt_no")
|
||||||
|
.order("s.receipt_date ASC, s.receipt_no ASC")
|
||||||
|
return query
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_credit_total_left
|
||||||
|
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}'")
|
||||||
|
.group("sale_payments.sale_id")
|
||||||
|
return query
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_sale_payment_for_credit(sale_data)
|
||||||
|
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}'
|
||||||
|
")
|
||||||
|
.group("sale_payments.sale_payment_id")
|
||||||
|
return query
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_credit_payment_left
|
||||||
|
query = SalePayment.select("(CASE WHEN (SUM(payment_amount) - (SELECT SUM(payment_amount)
|
||||||
|
from sale_payments
|
||||||
|
join sale_audits on SUBSTRING_INDEX(remark,'||',1)=sale_payment_id
|
||||||
|
where sale_payments.sale_id = '#{self.sale_id}')) > 0 THEN (SUM(payment_amount) - (SELECT SUM(payment_amount)
|
||||||
|
from sale_payments
|
||||||
|
join sale_audits on SUBSTRING_INDEX(remark,'||',1)=sale_payment_id
|
||||||
|
where sale_payments.sale_id = '#{self.sale_id}')) ELSE 0 END) as payment_amount")
|
||||||
|
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{self.sale_id}'")
|
||||||
|
return query
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
||||||
<div class="col-md-1 col-lg-1 col-sm-1">
|
<div class="col-md-1 col-lg-1 col-sm-1">
|
||||||
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
|
<button type="button" class="btn bg-default btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -146,7 +146,11 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment/others_payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param+"/others_payment";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,8 +185,8 @@
|
|||||||
$('#amount').html("0.0");
|
$('#amount').html("0.0");
|
||||||
break;
|
break;
|
||||||
case 'del' :
|
case 'del' :
|
||||||
var cash=$('#amount').text();
|
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#validamount').val();
|
var remain_amount = $('#validamount').val();
|
||||||
@@ -223,8 +227,14 @@
|
|||||||
if(bank_integration == '1'){
|
if(bank_integration == '1'){
|
||||||
pay_withBank("SALE", "alipay", amount, sale_id, receipt_no,cashier_type);
|
pay_withBank("SALE", "alipay", amount, sale_id, receipt_no,cashier_type);
|
||||||
}else{
|
}else{
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_alipay_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_alipay_path %>";
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_alipay_path %>",
|
url: url,
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
@@ -236,7 +246,11 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,6 +264,15 @@
|
|||||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
$('#back').on('click',function(){
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="bg-red">
|
<tr class="bg-red">
|
||||||
<td class="charges-name"><strong>Credit Amount:</strong></td>
|
<td class="charges-name"><strong>Credit Amount:</strong></td>
|
||||||
<td class="item-attr"><strong id="credit_amount"><%= @sale_payment.payment_amount rescue 0%></strong></td>
|
<td class="item-attr"><strong id="credit_amount"><%= @sale_payment[0].payment_amount rescue 0%></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="rebate_amount"></tr>
|
<tr class="rebate_amount"></tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -309,7 +309,7 @@
|
|||||||
|
|
||||||
<!-- script data for credit lists -->
|
<!-- script data for credit lists -->
|
||||||
<script type="text/html" id="html_credit_items">
|
<script type="text/html" id="html_credit_items">
|
||||||
<tr class="row_{key} credit_detail" data-id="{sale_payment_id}">
|
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||||
<td>{receipt_date}</td>
|
<td>{receipt_date}</td>
|
||||||
<td>{receipt_no}</td>
|
<td>{receipt_no}</td>
|
||||||
<td>{cashier_name}</td>
|
<td>{cashier_name}</td>
|
||||||
@@ -348,8 +348,7 @@
|
|||||||
|
|
||||||
$('#pay').on('click',function() {
|
$('#pay').on('click',function() {
|
||||||
var sale_id = '<%= @sale.sale_id %>';
|
var sale_id = '<%= @sale.sale_id %>';
|
||||||
var sale_payment_id = '<%= @sale_payment.sale_payment_id %>';
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/credit_payment";
|
||||||
window.location.href = '/origami/sale/'+ sale_payment_id + "/"+cashier_type+"/credit_sales";
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#back').on('click',function(){
|
$('#back').on('click',function(){
|
||||||
|
|||||||
@@ -192,7 +192,7 @@
|
|||||||
<!-- Column One -->
|
<!-- Column One -->
|
||||||
<!-- script data for credit lists -->
|
<!-- script data for credit lists -->
|
||||||
<script type="text/html" id="html_credit_items">
|
<script type="text/html" id="html_credit_items">
|
||||||
<tr class="row_{key} credit_detail" data-id="{sale_payment_id}">
|
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||||
<td>{receipt_date}</td>
|
<td>{receipt_date}</td>
|
||||||
<td>{receipt_no}</td>
|
<td>{receipt_no}</td>
|
||||||
<td>{cashier_name}</td>
|
<td>{cashier_name}</td>
|
||||||
|
|||||||
@@ -736,7 +736,7 @@
|
|||||||
|
|
||||||
<!-- script data for credit lists -->
|
<!-- script data for credit lists -->
|
||||||
<script type="text/html" id="html_credit_items">
|
<script type="text/html" id="html_credit_items">
|
||||||
<tr class="row_{key} credit_detail" data-id="{sale_payment_id}">
|
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||||
<td>{receipt_date}</td>
|
<td>{receipt_date}</td>
|
||||||
<td>{receipt_no}</td>
|
<td>{receipt_no}</td>
|
||||||
<td>{cashier_name}</td>
|
<td>{cashier_name}</td>
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn btn-default btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
|
<button type="button" class="btn btn-default btn-block" id="back"> <i class="material-icons m-t--5">reply</i>Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -142,7 +142,11 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,8 +181,8 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
$('#amount').html("0.0");
|
$('#amount').html("0.0");
|
||||||
break;
|
break;
|
||||||
case 'del' :
|
case 'del' :
|
||||||
var cash=$('#amount').text();
|
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#validamount').val();
|
var remain_amount = $('#validamount').val();
|
||||||
@@ -220,8 +224,14 @@ $('#jcb_pay').on('click',function(){
|
|||||||
$("#reference_no").val("");
|
$("#reference_no").val("");
|
||||||
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no,cashier_type);
|
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no,cashier_type);
|
||||||
}else{
|
}else{
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_jcb_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_jcb_path %>";
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_jcb_path %>",
|
url: url,
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
@@ -233,7 +243,11 @@ $('#jcb_pay').on('click',function(){
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,5 +260,14 @@ $('#jcb_pay').on('click',function(){
|
|||||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
$('#back').on('click',function(){
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -31,41 +31,41 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label>You can pay up to </label>
|
<label>You can pay up to </label>
|
||||||
<%@can_master = @can_master +@rounding_adj%>
|
<%@can_master = @can_master +@rounding_adj%>
|
||||||
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_master %>" data-member-value="">
|
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_master %>" data-member-value="">
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<% if @mastercount != 0 %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<label>Recent Master paid amount </label>
|
||||||
|
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@mastercount %>" data-member-value="">
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<label>Reference Number</label>
|
||||||
|
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
||||||
|
<br><span id="reference_no_Err" style="color:red;"></span>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% if @mastercount != 0 %>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<label>Recent Master paid amount </label>
|
|
||||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@mastercount %>" data-member-value="">
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label>Reference Number</label>
|
<label>Amount</label>
|
||||||
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||||
<br><span id="reference_no_Err" style="color:red;"></span>
|
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<label>Amount</label>
|
|
||||||
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:;">
|
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:;">
|
||||||
<div class="m-t-10 p-l-20">
|
<div class="m-t-10 p-l-20">
|
||||||
@@ -115,23 +115,23 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn btn-default m-t-10 btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
|
<button type="button" class="btn btn-default m-t-10 btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var cashier_type = "<%= @cashier_type %>";
|
var cashier_type = "<%= @cashier_type %>";
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
setHeaderBreadCrumb(_MASTER_);
|
setHeaderBreadCrumb(_MASTER_);
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
var bank_integration = "<%= @bank_integration %>";
|
var bank_integration = "<%= @bank_integration %>";
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
|
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bank_integration == '1'){
|
if(bank_integration == '1'){
|
||||||
if(typeof code2lab != 'undefined'){
|
if(typeof code2lab != 'undefined'){
|
||||||
code2lab.getCommPorts(); //get comportlists from jade
|
code2lab.getCommPorts(); //get comportlists from jade
|
||||||
}else{
|
}else{
|
||||||
swal({
|
swal({
|
||||||
@@ -143,11 +143,15 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -177,8 +181,8 @@
|
|||||||
$('#amount').html("0.0");
|
$('#amount').html("0.0");
|
||||||
break;
|
break;
|
||||||
case 'del' :
|
case 'del' :
|
||||||
var cash=$('#amount').text();
|
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#validamount').val();
|
var remain_amount = $('#validamount').val();
|
||||||
@@ -198,7 +202,7 @@
|
|||||||
var receipt_no = "<%= @receipt_no %>";
|
var receipt_no = "<%= @receipt_no %>";
|
||||||
var bank_integration = "<%= @bank_integration %>";
|
var bank_integration = "<%= @bank_integration %>";
|
||||||
$("#reference_no_Err").html("");
|
$("#reference_no_Err").html("");
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
||||||
|
|
||||||
$(this).off("click");
|
$(this).off("click");
|
||||||
//start member discount 5% by pay card
|
//start member discount 5% by pay card
|
||||||
@@ -218,31 +222,50 @@
|
|||||||
if(bank_integration == '1'){
|
if(bank_integration == '1'){
|
||||||
pay_withBank("SALE", "master", amount, sale_id, receipt_no,cashier_type);
|
pay_withBank("SALE", "master", amount, sale_id, receipt_no,cashier_type);
|
||||||
}else{
|
}else{
|
||||||
$.ajax({type: "POST",
|
if(location.pathname.includes("credit_payment")){
|
||||||
url: "<%= origami_payment_master_path %>",
|
var url = "<%= origami_credit_payment_master_path %>";
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
|
||||||
success:function(result){
|
|
||||||
if(result){
|
|
||||||
swal({
|
|
||||||
title: "Information!",
|
|
||||||
text: "Payment Successfully",
|
|
||||||
html: true,
|
|
||||||
closeOnConfirm: false,
|
|
||||||
closeOnCancel: false,
|
|
||||||
allowOutsideClick: false
|
|
||||||
}, function () {
|
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (amount>0) {
|
|
||||||
swal ( "Oops" , "Paid Amount is over!" , "error" );
|
|
||||||
}else{
|
}else{
|
||||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
var url = "<%= origami_payment_master_path %>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.ajax({type: "POST",
|
||||||
|
url: url,
|
||||||
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
success:function(result){
|
||||||
|
if(result){
|
||||||
|
swal({
|
||||||
|
title: "Information!",
|
||||||
|
text: "Payment Successfully",
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
}else{
|
||||||
|
if (amount>0) {
|
||||||
|
swal ( "Oops" , "Paid Amount is over!" , "error" );
|
||||||
|
}else{
|
||||||
|
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#back').on('click',function(){
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-1 col-lg-1 col-sm-1">
|
<div class="col-md-1 col-lg-1 col-sm-1">
|
||||||
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
|
<button type="button" class="btn bg-default btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -148,7 +148,11 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment/others_payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param+"/others_payment";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,8 +187,8 @@
|
|||||||
$('#amount').html("0.0");
|
$('#amount').html("0.0");
|
||||||
break;
|
break;
|
||||||
case 'del' :
|
case 'del' :
|
||||||
var cash=$('#amount').text();
|
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#validamount').val();
|
var remain_amount = $('#validamount').val();
|
||||||
@@ -225,8 +229,13 @@
|
|||||||
if(bank_integration == '1'){
|
if(bank_integration == '1'){
|
||||||
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no,cashier_type);
|
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no,cashier_type);
|
||||||
}else{
|
}else{
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_mpu_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_mpu_path %>";
|
||||||
|
}
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_mpu_path %>",
|
url: url,
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
@@ -238,7 +247,11 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,6 +265,15 @@
|
|||||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
$('#back').on('click',function(){
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@
|
|||||||
|
|
||||||
<!-- script data for credit lists -->
|
<!-- script data for credit lists -->
|
||||||
<script type="text/html" id="html_credit_items">
|
<script type="text/html" id="html_credit_items">
|
||||||
<tr class="row_{key} credit_detail" data-id="{sale_payment_id}">
|
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||||
<td>{receipt_date}</td>
|
<td>{receipt_date}</td>
|
||||||
<td>{receipt_no}</td>
|
<td>{receipt_no}</td>
|
||||||
<td>{cashier_name}</td>
|
<td>{cashier_name}</td>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1 m-t-10">
|
<div class="col-lg-1 col-md-1 col-sm-1 m-t-10">
|
||||||
<button type="button" class="btn bg-default m- btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
|
<button type="button" class="btn bg-default m- btn-block" id="back"> <i class="material-icons m-t--5">reply</i>Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -55,11 +55,19 @@
|
|||||||
$('.others-payment').on('click',function(){
|
$('.others-payment').on('click',function(){
|
||||||
var input_type = $(this).attr("data-type");
|
var input_type = $(this).attr("data-type");
|
||||||
var sale_id = $(this).attr("data-sale-id");
|
var sale_id = $(this).attr("data-sale-id");
|
||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+ cashier_type + "/payment/others_payment/" + input_type;
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+ cashier_type + "/"+url_param+"/others_payment/" + input_type;
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#back').on('click',function(){
|
$('#back').on('click',function(){
|
||||||
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/payment';
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -118,7 +118,9 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
No Tax
|
No Tax
|
||||||
<% end %></strong><br>
|
<% end %></strong><br>
|
||||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
<%if @sale_payment.nil? %>
|
||||||
|
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -164,21 +166,21 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div class="row m-l-5 m-r-5">
|
<div class="row m-l-5 m-r-5">
|
||||||
<div class="col-md-8"><strong>Amount Due</strong></div>
|
<div class="col-md-8"><strong>Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %></strong></div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<strong>
|
<strong>
|
||||||
<span id="grand_total" class="hidden">
|
<span id="grand_total" class="hidden">
|
||||||
<% if @sale_payment.nil? %>
|
<% if @sale_payment.nil? %>
|
||||||
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= number_with_precision(@sale_payment.payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
<%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
<span id="amount_due">
|
<span id="amount_due">
|
||||||
<% if @sale_payment.nil? %>
|
<% if @sale_payment.nil? %>
|
||||||
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
|
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= number_with_precision(@sale_payment.payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
<%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</strong>
|
</strong>
|
||||||
@@ -206,12 +208,16 @@
|
|||||||
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
|
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
|
||||||
<div class="row payment other-payment-color" id="card_payment" >
|
<div class="row payment other-payment-color" id="card_payment" >
|
||||||
<div class="col-md-8">Other Payments</div>
|
<div class="col-md-8">Other Payments</div>
|
||||||
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
<div class="col-md-4" id="others">
|
||||||
|
<%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row payment other-payment-color" id="card_payment" >
|
<div class="row payment other-payment-color" id="card_payment" >
|
||||||
<div class="col-md-8">Other Payments</div>
|
<div class="col-md-8">Other Payments</div>
|
||||||
<div class="col-md-4" id="other_payment_amount"><%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
<div class="col-md-4" id="other_payment_amount">
|
||||||
|
<%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -399,22 +405,26 @@
|
|||||||
</button>
|
</button>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<% if current_login_employee.role == "cashier" %>
|
<% if current_login_employee.role == "cashier" %>
|
||||||
<% if @other_payment <= 0%>
|
<% if @other_payment <= 0 && @sale_payment.nil? %>
|
||||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
|
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
|
||||||
<%end %>
|
<%end %>
|
||||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
<% if @sale_payment.nil? %>
|
||||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
|
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
|
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
|
||||||
|
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @other_payment <= 0%>
|
<% if @other_payment <= 0 && @sale_payment.nil?%>
|
||||||
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
|
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
|
||||||
<%end %>
|
<%end %>
|
||||||
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
<% if @sale_payment.nil? %>
|
||||||
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
|
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
||||||
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>
|
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
|
||||||
|
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @cashier_type=="quick_service" %>
|
<% if @cashier_type=="quick_service" && @sale_payment.nil? %>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
||||||
@@ -710,7 +720,7 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
customer_display_view(null,"reload");
|
customer_display_view(null,"reload");
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
if (cashier_type=="cashier") {
|
if (cashier_type=="cashier") {
|
||||||
window.location.href = '/origami/table/'+ dining_id;
|
window.location.href = '/origami/table/'+ dining_id;
|
||||||
}else{
|
}else{
|
||||||
window.location.href = '/origami/quick_service/pending_order/'+sale_id;
|
window.location.href = '/origami/quick_service/pending_order/'+sale_id;
|
||||||
}
|
}
|
||||||
@@ -738,7 +748,11 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
$('#card_payment').click(function() {
|
$('#card_payment').click(function() {
|
||||||
localStorage.setItem("cash",$('#cash').text() );
|
localStorage.setItem("cash",$('#cash').text() );
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment"
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -799,8 +813,15 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
|
|
||||||
// $("#pdfModal").on('shown.bs.modal', function () {
|
// $("#pdfModal").on('shown.bs.modal', function () {
|
||||||
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
||||||
|
/* check credit payment or not*/
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_cash_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_cash_path %>";
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_cash_path %>",
|
url: url,
|
||||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
|
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
/* start delete receipt no in first bill*/
|
/* start delete receipt no in first bill*/
|
||||||
@@ -819,28 +840,31 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#loading_wrapper" ).hide();
|
$("#loading_wrapper" ).hide();
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
//PDF lightbox data
|
payment_success_alert();
|
||||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
|
||||||
$("#sale_receipt_no").val(result.receipt_no);
|
|
||||||
$("#filename").val(result.filename);
|
|
||||||
$("#printer_name").val(result.printer_name);
|
|
||||||
$("#receipt_pdf").attr("src", pdfPath);
|
|
||||||
$("#changed_amount").text("");
|
|
||||||
if($('#balance').text() < 0){
|
|
||||||
<% if precision.to_i > 0 %>
|
|
||||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
|
|
||||||
<% else %>
|
|
||||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
|
|
||||||
<% end %>
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pdf_view == 1) {
|
|
||||||
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
|
|
||||||
$("#pdfModalLabel").text("Sale Completed");
|
|
||||||
}else{
|
}else{
|
||||||
//PDF lightbox data
|
//PDF lightbox data
|
||||||
print_receipt();
|
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
||||||
|
$("#sale_receipt_no").val(result.receipt_no);
|
||||||
|
$("#filename").val(result.filename);
|
||||||
|
$("#printer_name").val(result.printer_name);
|
||||||
|
$("#receipt_pdf").attr("src", pdfPath);
|
||||||
|
$("#changed_amount").text("");
|
||||||
|
if($('#balance').text() < 0){
|
||||||
|
<% if precision.to_i > 0 %>
|
||||||
|
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
|
||||||
|
<% else %>
|
||||||
|
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
|
||||||
|
<% end %>
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdf_view == 1) {
|
||||||
|
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
|
||||||
|
$("#pdfModalLabel").text("Sale Completed");
|
||||||
|
}else{
|
||||||
|
//PDF lightbox data
|
||||||
|
print_receipt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -948,7 +972,7 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
var original_value;
|
var original_value;
|
||||||
original_value = $('#cash').text();
|
original_value = parseFloat($('#cash').text());
|
||||||
|
|
||||||
var input_type = $(this).attr("data-type");
|
var input_type = $(this).attr("data-type");
|
||||||
|
|
||||||
@@ -1110,34 +1134,38 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
customer_display_view(null,"reload");
|
customer_display_view(null,"reload");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
var title = "Payment Successful!";
|
payment_success_alert();
|
||||||
if($('#balance').text() < 0){
|
|
||||||
var text = 'Changed amount ' + $('#balance').text() * (-1);
|
|
||||||
}else{
|
|
||||||
$('#pay').text("Pay");
|
|
||||||
var text = 'Thank You !';
|
|
||||||
}
|
|
||||||
|
|
||||||
swal({
|
|
||||||
title: "Payment Successful!",
|
|
||||||
text: text,
|
|
||||||
html: true,
|
|
||||||
closeOnConfirm: false,
|
|
||||||
closeOnCancel: false,
|
|
||||||
allowOutsideClick: false
|
|
||||||
}, function () {
|
|
||||||
if (cashier_type=="cashier") {
|
|
||||||
window.location.href = '/origami';
|
|
||||||
}else{
|
|
||||||
window.location.href = '/origami/quick_service';
|
|
||||||
customer_display_view(null,"reload");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function payment_success_alert(){
|
||||||
|
var title = "Payment Successful!";
|
||||||
|
if($('#balance').text() < 0){
|
||||||
|
var text = 'Changed amount ' + $('#balance').text() * (-1);
|
||||||
|
}else{
|
||||||
|
$('#pay').text("Pay");
|
||||||
|
var text = 'Thank You !';
|
||||||
|
}
|
||||||
|
|
||||||
|
swal({
|
||||||
|
title: "Payment Successful!",
|
||||||
|
text: text,
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
|
if (cashier_type=="cashier") {
|
||||||
|
window.location.href = '/origami';
|
||||||
|
}else{
|
||||||
|
window.location.href = '/origami/quick_service';
|
||||||
|
customer_display_view(null,"reload");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$(".btn_pdf_close").on('click',function(){
|
$(".btn_pdf_close").on('click',function(){
|
||||||
if (cashier_type=="cashier") {
|
if (cashier_type=="cashier") {
|
||||||
|
|||||||
@@ -729,7 +729,7 @@
|
|||||||
|
|
||||||
<!-- script data for credit lists -->
|
<!-- script data for credit lists -->
|
||||||
<script type="text/html" id="html_credit_items">
|
<script type="text/html" id="html_credit_items">
|
||||||
<tr class="row_{key} credit_detail" data-id="{sale_payment_id}">
|
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||||
<td>{receipt_date}</td>
|
<td>{receipt_date}</td>
|
||||||
<td>{receipt_no}</td>
|
<td>{receipt_no}</td>
|
||||||
<td>{cashier_name}</td>
|
<td>{cashier_name}</td>
|
||||||
|
|||||||
@@ -392,7 +392,7 @@
|
|||||||
|
|
||||||
<!-- script data for credit lists -->
|
<!-- script data for credit lists -->
|
||||||
<script type="text/html" id="html_credit_items">
|
<script type="text/html" id="html_credit_items">
|
||||||
<tr class="row_{key} credit_detail" data-id="{sale_payment_id}">
|
<tr class="row_{key} credit_detail" data-id="{sale_id}">
|
||||||
<td>{receipt_date}</td>
|
<td>{receipt_date}</td>
|
||||||
<td>{receipt_no}</td>
|
<td>{receipt_no}</td>
|
||||||
<td>{cashier_name}</td>
|
<td>{cashier_name}</td>
|
||||||
|
|||||||
@@ -31,41 +31,41 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label>You can pay up to </label>
|
<label>You can pay up to </label>
|
||||||
<%@can_unionpay = @can_unionpay +@rounding_adj%>
|
<%@can_unionpay = @can_unionpay +@rounding_adj%>
|
||||||
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_unionpay %>" data-member-value="">
|
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_unionpay %>" data-member-value="">
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<% if @unionpaycount != 0 %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<label>Recent Visa paid amount </label>
|
||||||
|
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@unionpaycount %>" data-member-value="">
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<label>Reference Number</label>
|
||||||
|
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
||||||
|
<br><span id="reference_no_Err" style="color:red;"></span>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% if @unionpaycount != 0 %>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<label>Recent Visa paid amount </label>
|
|
||||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@unionpaycount %>" data-member-value="">
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label>Reference Number</label>
|
<label>Amount</label>
|
||||||
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||||
<br><span id="reference_no_Err" style="color:red;"></span>
|
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<label>Amount</label>
|
|
||||||
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6" style="">
|
<div class="col-lg-6 col-md-6 col-sm-6" style="">
|
||||||
<div class=" m-t-10 p-l-20">
|
<div class=" m-t-10 p-l-20">
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn bg-default m-t-10 btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
|
<button type="button" class="btn bg-default m-t-10 btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
$('#validamount').attr("value",parseFloat("<%= @can_unionpay %>") - parseFloat(localStorage.getItem("cash")));
|
$('#validamount').attr("value",parseFloat("<%= @can_unionpay %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bank_integration == '1'){
|
if(bank_integration == '1'){
|
||||||
if(typeof code2lab != 'undefined'){
|
if(typeof code2lab != 'undefined'){
|
||||||
code2lab.getCommPorts(); //get comportlists from jade
|
code2lab.getCommPorts(); //get comportlists from jade
|
||||||
}
|
}
|
||||||
@@ -146,55 +146,60 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
var original_value;
|
var original_value;
|
||||||
original_value = $('#amount').text();
|
original_value = $('#amount').text();
|
||||||
|
|
||||||
var input_value = $(this).attr("data-value");
|
var input_value = $(this).attr("data-value");
|
||||||
|
|
||||||
|
var input_type = $(this).attr("data-type");
|
||||||
|
switch (input_type) {
|
||||||
|
case 'num':
|
||||||
|
if (original_value == "0.0"){
|
||||||
|
$('#amount').text(input_value);
|
||||||
|
}else{
|
||||||
|
$('#amount').append(input_value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'add':
|
||||||
|
var input_value = $(this).attr("data-value");
|
||||||
|
amount = parseInt(input_value) + parseInt(original_value);
|
||||||
|
$('#amount').html(amount);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'clr':
|
||||||
|
$('#amount').html("0.0");
|
||||||
|
break;
|
||||||
|
case 'del' :
|
||||||
|
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||||
|
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||||
|
break;
|
||||||
|
case 'nett':
|
||||||
|
var remain_amount = $('#validamount').val();
|
||||||
|
$('#amount').text(remain_amount);
|
||||||
|
break;
|
||||||
|
|
||||||
var input_type = $(this).attr("data-type");
|
|
||||||
switch (input_type) {
|
|
||||||
case 'num':
|
|
||||||
if (original_value == "0.0"){
|
|
||||||
$('#amount').text(input_value);
|
|
||||||
}else{
|
|
||||||
$('#amount').append(input_value);
|
|
||||||
}
|
}
|
||||||
break;
|
event.handled = true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
case 'add':
|
|
||||||
var input_value = $(this).attr("data-value");
|
|
||||||
amount = parseInt(input_value) + parseInt(original_value);
|
|
||||||
$('#amount').html(amount);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'clr':
|
|
||||||
$('#amount').html("0.0");
|
|
||||||
break;
|
|
||||||
case 'del' :
|
|
||||||
var cash=$('#amount').text();
|
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
|
||||||
break;
|
|
||||||
case 'nett':
|
|
||||||
var remain_amount = $('#validamount').val();
|
|
||||||
$('#amount').text(remain_amount);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
event.handled = true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('#unionpay_pay').on('click',function(){
|
$('#unionpay_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var reference_no = $('#reference_no').val();
|
var reference_no = $('#reference_no').val();
|
||||||
@@ -202,8 +207,8 @@
|
|||||||
var receipt_no = "<%= @receipt_no %>";
|
var receipt_no = "<%= @receipt_no %>";
|
||||||
|
|
||||||
$("#reference_no_Err").html("");
|
$("#reference_no_Err").html("");
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
||||||
$(this).off("click");
|
$(this).off("click");
|
||||||
//start member discount 5% by pay card
|
//start member discount 5% by pay card
|
||||||
// var sub_total = $('#sub-total').text();
|
// var sub_total = $('#sub-total').text();
|
||||||
// var member_id = $('#membership_id').text();
|
// var member_id = $('#membership_id').text();
|
||||||
@@ -223,31 +228,50 @@
|
|||||||
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no, cashier_type);
|
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no, cashier_type);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$.ajax({type: "POST",
|
if(location.pathname.includes("credit_payment")){
|
||||||
url: "<%= origami_payment_unionpay_path %>",
|
var url = "<%= origami_credit_payment_unionpay_path %>";
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
|
||||||
success:function(result){
|
|
||||||
if(result){
|
|
||||||
swal({
|
|
||||||
title: "Information!",
|
|
||||||
text: "Payment Successfully",
|
|
||||||
html: true,
|
|
||||||
closeOnConfirm: false,
|
|
||||||
closeOnCancel: false,
|
|
||||||
allowOutsideClick: false
|
|
||||||
}, function () {
|
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (amount>0) {
|
|
||||||
swal ( "Oops" , "Paid Amount is over!" , "error" );
|
|
||||||
}else{
|
}else{
|
||||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
var url = "<%= origami_payment_unionpay_path %>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.ajax({type: "POST",
|
||||||
|
url: url,
|
||||||
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
success:function(result){
|
||||||
|
if(result){
|
||||||
|
swal({
|
||||||
|
title: "Information!",
|
||||||
|
text: "Payment Successfully",
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
}else{
|
||||||
</script>
|
if (amount>0) {
|
||||||
|
swal ( "Oops" , "Paid Amount is over!" , "error" );
|
||||||
|
}else{
|
||||||
|
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#back').on('click',function(){
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -115,7 +115,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn bg-default m-t-10 btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
|
<button type="button" class="btn bg-default m-t-10 btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -146,7 +146,11 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment/others_payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,8 +185,8 @@
|
|||||||
$('#amount').html("0.0");
|
$('#amount').html("0.0");
|
||||||
break;
|
break;
|
||||||
case 'del' :
|
case 'del' :
|
||||||
var cash=$('#amount').text();
|
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#validamount').val();
|
var remain_amount = $('#validamount').val();
|
||||||
@@ -200,8 +204,8 @@
|
|||||||
var reference_no = $('#reference_no').val();
|
var reference_no = $('#reference_no').val();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
var receipt_no = "<%= @receipt_no %>";
|
var receipt_no = "<%= @receipt_no %>";
|
||||||
console.log(amount);
|
// console.log(amount);
|
||||||
console.log($("#validamount").attr("value"));
|
// console.log($("#validamount").attr("value"));
|
||||||
$("#reference_no_Err").html("");
|
$("#reference_no_Err").html("");
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
||||||
$(this).off("click");
|
$(this).off("click");
|
||||||
@@ -224,8 +228,13 @@
|
|||||||
pay_withBank("SALE", "visa", amount, sale_id, receipt_no,cashier_type);
|
pay_withBank("SALE", "visa", amount, sale_id, receipt_no,cashier_type);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_visa_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_visa_path %>";
|
||||||
|
}
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_visa_path %>",
|
url: url,
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
@@ -237,7 +246,11 @@
|
|||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
allowOutsideClick: false
|
allowOutsideClick: false
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,4 +264,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#back').on('click',function(){
|
||||||
|
var url_param = "payment";
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
url_param = "credit_payment";
|
||||||
|
}
|
||||||
|
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -289,8 +289,36 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
|
|
||||||
#credit payment routes
|
#credit payment routes
|
||||||
post '/:type/credit_sales' => "dashboard#get_credit_sales", :as => "get_credit_sales", :defaults => { :format => 'json' }
|
post '/:type/credit_sales' => "dashboard#get_credit_sales", :as => "get_credit_sales", :defaults => { :format => 'json' }
|
||||||
get '/:type/credit_sales/:sale_payment_id' => "credit_sales#show"
|
get '/:type/credit_sales/:sale_id' => "credit_sales#show"
|
||||||
get 'sale/:sale_payment_id/:type/credit_sales' => "payments#show"
|
get 'sale/:sale_id/:type/credit_payment' => "payments#show"
|
||||||
|
|
||||||
|
post 'credit_payment/cash' => 'payments#create'
|
||||||
|
post 'credit_payment/mpu' => "mpu#create"
|
||||||
|
post 'credit_payment/jcb' => "jcb#create"
|
||||||
|
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/alipay' => 'alipay#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/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/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"
|
||||||
end
|
end
|
||||||
|
|
||||||
#--------- Waiter/Ordering Station ------------#
|
#--------- Waiter/Ordering Station ------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user