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,7 +443,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/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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
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)
|
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
|
||||||
|
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)
|
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
|
||||||
|
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)
|
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
|
||||||
|
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)
|
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]
|
||||||
|
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
|
@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,12 +98,14 @@ 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 !path.include? ("credit_payment")
|
||||||
if shop_detail.is_rounding_adj
|
if shop_detail.is_rounding_adj
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
b = saleObj.grand_total / 25 # Division
|
b = saleObj.grand_total / 25 # Division
|
||||||
@@ -115,11 +117,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
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
|
||||||
end
|
end
|
||||||
|
end
|
||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
|
if path.include? ("credit_payment")
|
||||||
|
sale_payment.process_payment(saleObj, current_user.name, cash, "cash", nil, true)
|
||||||
|
else
|
||||||
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
||||||
|
end
|
||||||
|
|
||||||
|
if !path.include? ("credit_payment")
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
@@ -217,16 +225,15 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#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
|
||||||
|
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)
|
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
|
||||||
|
# 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)
|
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}"
|
||||||
|
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)
|
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
|
||||||
|
if !payment_for
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
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
|
||||||
|
update_shift_for_credit_payment
|
||||||
|
else
|
||||||
sale_update_payment_status(self.received_amount,status)
|
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
|
||||||
|
if !payment_for
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
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!
|
||||||
|
if payment_for
|
||||||
|
update_shift_for_credit_payment
|
||||||
|
else
|
||||||
sale_update_payment_status(self.received_amount)
|
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>
|
||||||
|
|||||||
@@ -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 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>
|
||||||
@@ -143,7 +143,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";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
@@ -218,8 +222,14 @@
|
|||||||
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{
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_master_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_master_path %>";
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_master_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){
|
||||||
@@ -231,7 +241,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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,5 +258,14 @@
|
|||||||
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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
<%if @sale_payment.nil? %>
|
||||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
<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 %>
|
||||||
|
<% if @sale_payment.nil? %>
|
||||||
<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-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="waste"> Waste</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>
|
<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 %>
|
||||||
|
<% if @sale_payment.nil? %>
|
||||||
<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 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="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="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>
|
<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>
|
||||||
@@ -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,7 +840,9 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#loading_wrapper" ).hide();
|
$("#loading_wrapper" ).hide();
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
payment_success_alert();
|
||||||
|
}else{
|
||||||
//PDF lightbox data
|
//PDF lightbox data
|
||||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
||||||
$("#sale_receipt_no").val(result.receipt_no);
|
$("#sale_receipt_no").val(result.receipt_no);
|
||||||
@@ -843,6 +866,7 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
print_receipt();
|
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,6 +1134,13 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
customer_display_view(null,"reload");
|
customer_display_view(null,"reload");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
payment_success_alert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function payment_success_alert(){
|
||||||
var title = "Payment Successful!";
|
var title = "Payment Successful!";
|
||||||
if($('#balance').text() < 0){
|
if($('#balance').text() < 0){
|
||||||
var text = 'Changed amount ' + $('#balance').text() * (-1);
|
var text = 'Changed amount ' + $('#balance').text() * (-1);
|
||||||
@@ -1134,9 +1165,6 @@ var pdf_view = '<%=@pdf_view%>';
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$(".btn_pdf_close").on('click',function(){
|
$(".btn_pdf_close").on('click',function(){
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -146,12 +146,16 @@
|
|||||||
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();
|
||||||
@@ -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();
|
||||||
@@ -195,6 +199,7 @@
|
|||||||
return false;
|
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();
|
||||||
@@ -223,8 +228,14 @@
|
|||||||
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no, cashier_type);
|
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no, cashier_type);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
if(location.pathname.includes("credit_payment")){
|
||||||
|
var url = "<%= origami_credit_payment_unionpay_path %>";
|
||||||
|
}else{
|
||||||
|
var url = "<%= origami_payment_unionpay_path %>";
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_unionpay_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 +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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,5 +264,14 @@
|
|||||||
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>
|
||||||
|
|||||||
@@ -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