add junctionpay(vaap)
This commit is contained in:
@@ -36,8 +36,20 @@ class Origami::JunctionPayController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
cash = params[:amount]
|
gift_amount = params[:gift_amount]
|
||||||
|
voucher_amount = params[:voucher_amount]
|
||||||
|
voucher_no = params[:voucher_no]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
|
|
||||||
|
# Gift card or Voucher classified and add for payment_reference
|
||||||
|
remarks = ''
|
||||||
|
cash = (gift_amount.to_f + voucher_amount.to_f)
|
||||||
|
if gift_amount.to_f > 0
|
||||||
|
remarks = "Junciton Gift Card Payment. RefNo-" + voucher_no
|
||||||
|
else
|
||||||
|
remarks = "Junciton Voucher Payment. RefNo-" + voucher_no
|
||||||
|
end
|
||||||
|
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
shop_details = Shop::ShopDetail
|
shop_details = Shop::ShopDetail
|
||||||
@@ -51,7 +63,7 @@ class Origami::JunctionPayController < BaseOrigamiController
|
|||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
# saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "JunctionPay")
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "JunctionPay", remarks)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -334,8 +334,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@mastercount += spay.payment_amount
|
@mastercount += spay.payment_amount
|
||||||
elsif spay.payment_method == "unionpay"
|
elsif spay.payment_method == "unionpay"
|
||||||
@unionpaycount += spay.payment_amount
|
@unionpaycount += spay.payment_amount
|
||||||
elsif spay.payment_method == "junctionpay"
|
elsif spay.payment_method == "JunctionPay"
|
||||||
@unionpaycount += spay.payment_amount
|
@junctionpaycount += spay.payment_amount
|
||||||
elsif spay.payment_method == "creditnote"
|
elsif spay.payment_method == "creditnote"
|
||||||
@credit += spay.payment_amount
|
@credit += spay.payment_amount
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class SalePayment < ApplicationRecord
|
|||||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
|
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
|
||||||
self.sale = invoice
|
self.sale = invoice
|
||||||
self.received_amount = cash_amount
|
self.received_amount = cash_amount
|
||||||
|
self.payment_reference = remark
|
||||||
amount_due = invoice.grand_total
|
amount_due = invoice.grand_total
|
||||||
|
|
||||||
#get all payment for this invoices
|
#get all payment for this invoices
|
||||||
@@ -305,7 +306,7 @@ class SalePayment < ApplicationRecord
|
|||||||
#Next time - validate if the vochure number is valid - within
|
#Next time - validate if the vochure number is valid - within
|
||||||
self.payment_method = "JunctionPay"
|
self.payment_method = "JunctionPay"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
self.payment_reference = self.voucher_no
|
# self.payment_reference = self.payment_reference
|
||||||
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
|
|||||||
@@ -202,19 +202,31 @@ $('#junction_pay').on('click',function(){
|
|||||||
//end member discount
|
//end member discount
|
||||||
$("#loading_wrapper").show();
|
$("#loading_wrapper").show();
|
||||||
var com_port = '/dev/' + $("#com_port_name").val();
|
var com_port = '/dev/' + $("#com_port_name").val();
|
||||||
|
var is_rebate=false;
|
||||||
//alert(cashier_id + amount + com_port);
|
//alert(cashier_id + amount + com_port);
|
||||||
code2lab.reqJunctionPay(true, cashier_id, parseFloat(amount), receipt_no, com_port);
|
code2lab.reqJunctionPay(true, cashier_id, parseFloat(amount), receipt_no, com_port);
|
||||||
|
resJunctionPayUpdate = function(totalBillAmount , finalBillAmt,giftCardAmount, voucherAmount,voucherNumber,receiptNumber){
|
||||||
resJunctionPayUpdate(function(totalBillAmount , finalBillAmt,giftCardAmount,voucherAmount,voucherNumber,receiptNumber){
|
|
||||||
$("#loading_wrapper").hide();
|
$("#loading_wrapper").hide();
|
||||||
$.ajax({type: "POST",
|
|
||||||
url: "/origami/payment/junctionpay",
|
var voucher_no = voucherNumber;
|
||||||
data: "amount="+ totalBillAmount + "&sale_id="+ sale_id,
|
if (voucher_no == ''){
|
||||||
|
voucher_no = reference_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "<%= origami_payment_junctionpay_path %>",
|
||||||
|
data: "gift_amount="+ giftCardAmount + "&voucher_amount=" + voucherAmount +
|
||||||
|
"&voucher_no=" + voucher_no + "&sale_id="+ sale_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
|
var desc = 'Payment Successfully';
|
||||||
|
// is_rebate get from resJunctionPay and if member
|
||||||
|
if(is_rebate){ desc = desc + ". And You get Rebate!"}
|
||||||
|
|
||||||
swal({
|
swal({
|
||||||
title: "Information!",
|
title: "Information!",
|
||||||
text: "Payment Successfully",
|
text: desc,
|
||||||
html: true,
|
html: true,
|
||||||
closeOnConfirm: false,
|
closeOnConfirm: false,
|
||||||
closeOnCancel: false,
|
closeOnCancel: false,
|
||||||
@@ -225,9 +237,13 @@ $('#junction_pay').on('click',function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
};
|
||||||
|
|
||||||
|
resJunctionPay = function(memberno,transactionNo,finalBillingAmt){
|
||||||
|
if(memberno != ''){ is_rebate = true; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// resJunctionPay(function(memberno,transactionNo,finalBillingAmt){
|
|
||||||
// $("#loading_wrapper").hide();
|
// $("#loading_wrapper").hide();
|
||||||
// $.ajax({type: "POST",
|
// $.ajax({type: "POST",
|
||||||
// url: "/origami/payment/"+payment_type,
|
// url: "/origami/payment/"+payment_type,
|
||||||
@@ -249,11 +265,36 @@ $('#junction_pay').on('click',function(){
|
|||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
|
||||||
resError(function(message){
|
// var resError = function(message){
|
||||||
$("#loading_wrapper").hide();
|
// console.log(message);
|
||||||
swal ( "Oops" , message , "error" );
|
// $("#loading_wrapper").hide();
|
||||||
});
|
// swal ( "Oops" , message , "error" );
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// var resJunctionPayUpdate = function(totalBillAmount , finalBillAmt,giftCardAmount,voucherAmount, voucherNumber,receiptNumber){
|
||||||
|
// $("#loading_wrapper").hide();
|
||||||
|
// // alert(voucherNumber + ' ' + totalBillAmount + ' ' + receiptNumber + ' ' + giftCardAmount);
|
||||||
|
// $.ajax({
|
||||||
|
// type: "POST",
|
||||||
|
// url: "<%= origami_payment_junctionpay_path %>",
|
||||||
|
// data: "amount="+ totalBillAmount + "&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";
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// };
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -510,7 +510,7 @@ var customer_name = "<%= @customer.name %>";
|
|||||||
$("#credit_payment").show();
|
$("#credit_payment").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1){
|
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1 || parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) !=-1){
|
||||||
$("#card_payment").show();
|
$("#card_payment").show();
|
||||||
} else{
|
} else{
|
||||||
$("#card_payment").hide();
|
$("#card_payment").hide();
|
||||||
@@ -852,7 +852,7 @@ var customer_name = "<%= @customer.name %>";
|
|||||||
var master1 = $('#mastercount').text();
|
var master1 = $('#mastercount').text();
|
||||||
var unionpay1 = $('#unionpaycount').text();
|
var unionpay1 = $('#unionpaycount').text();
|
||||||
var junctionpay1 = $('#junctionpaycount').text();
|
var junctionpay1 = $('#junctionpaycount').text();
|
||||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(junctionpay1);
|
||||||
var total = $('#amount_due').text();
|
var total = $('#amount_due').text();
|
||||||
var amt = 0;
|
var amt = 0;
|
||||||
<% if precision.to_i > 0 %>;
|
<% if precision.to_i > 0 %>;
|
||||||
@@ -882,7 +882,7 @@ var customer_name = "<%= @customer.name %>";
|
|||||||
var unionpay = $('#unionpaycount').text();
|
var unionpay = $('#unionpaycount').text();
|
||||||
var junctionpay = $('#junctionpaycount').text();
|
var junctionpay = $('#junctionpaycount').text();
|
||||||
var amount_due = $('#amount_due').text();
|
var amount_due = $('#amount_due').text();
|
||||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
|
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(junctionpay)
|
||||||
var result = parseFloat(amount_due) - parseFloat(total);
|
var result = parseFloat(amount_due) - parseFloat(total);
|
||||||
<% if precision.to_i > 0 %>
|
<% if precision.to_i > 0 %>
|
||||||
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
|
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
|
||||||
|
|||||||
Reference in New Issue
Block a user