add junctionpay(vaap)
This commit is contained in:
@@ -36,8 +36,20 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
end
|
||||
|
||||
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]
|
||||
|
||||
# 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))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
@@ -51,7 +63,7 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
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
|
||||
|
||||
|
||||
@@ -334,8 +334,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "junctionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ class SalePayment < ApplicationRecord
|
||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
self.payment_reference = remark
|
||||
amount_due = invoice.grand_total
|
||||
|
||||
#get all payment for this invoices
|
||||
@@ -305,7 +306,7 @@ class SalePayment < ApplicationRecord
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
self.payment_method = "JunctionPay"
|
||||
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.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
|
||||
@@ -202,32 +202,48 @@ $('#junction_pay').on('click',function(){
|
||||
//end member discount
|
||||
$("#loading_wrapper").show();
|
||||
var com_port = '/dev/' + $("#com_port_name").val();
|
||||
var is_rebate=false;
|
||||
//alert(cashier_id + amount + com_port);
|
||||
code2lab.reqJunctionPay(true, cashier_id, parseFloat(amount), receipt_no, com_port);
|
||||
|
||||
resJunctionPayUpdate(function(totalBillAmount , finalBillAmt,giftCardAmount,voucherAmount,voucherNumber,receiptNumber){
|
||||
code2lab.reqJunctionPay(true, cashier_id, parseFloat(amount), receipt_no, com_port);
|
||||
resJunctionPayUpdate = function(totalBillAmount , finalBillAmt,giftCardAmount, voucherAmount,voucherNumber,receiptNumber){
|
||||
$("#loading_wrapper").hide();
|
||||
$.ajax({type: "POST",
|
||||
url: "/origami/payment/junctionpay",
|
||||
data: "amount="+ totalBillAmount + "&sale_id="+ sale_id,
|
||||
success:function(result){
|
||||
if(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Payment Successfully",
|
||||
html: true,
|
||||
|
||||
var voucher_no = voucherNumber;
|
||||
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){
|
||||
if(result){
|
||||
var desc = 'Payment Successfully';
|
||||
// is_rebate get from resJunctionPay and if member
|
||||
if(is_rebate){ desc = desc + ". And You get Rebate!"}
|
||||
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: desc,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// resJunctionPay(function(memberno,transactionNo,finalBillingAmt){
|
||||
resJunctionPay = function(memberno,transactionNo,finalBillingAmt){
|
||||
if(memberno != ''){ is_rebate = true; }
|
||||
};
|
||||
|
||||
|
||||
// $("#loading_wrapper").hide();
|
||||
// $.ajax({type: "POST",
|
||||
// url: "/origami/payment/"+payment_type,
|
||||
@@ -249,11 +265,36 @@ $('#junction_pay').on('click',function(){
|
||||
// });
|
||||
// });
|
||||
|
||||
resError(function(message){
|
||||
$("#loading_wrapper").hide();
|
||||
swal ( "Oops" , message , "error" );
|
||||
});
|
||||
// var resError = function(message){
|
||||
// console.log(message);
|
||||
// $("#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>
|
||||
|
||||
@@ -510,7 +510,7 @@ var customer_name = "<%= @customer.name %>";
|
||||
$("#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();
|
||||
} else{
|
||||
$("#card_payment").hide();
|
||||
@@ -852,7 +852,7 @@ var customer_name = "<%= @customer.name %>";
|
||||
var master1 = $('#mastercount').text();
|
||||
var unionpay1 = $('#unionpaycount').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 amt = 0;
|
||||
<% if precision.to_i > 0 %>;
|
||||
@@ -882,7 +882,7 @@ var customer_name = "<%= @customer.name %>";
|
||||
var unionpay = $('#unionpaycount').text();
|
||||
var junctionpay = $('#junctionpaycount').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);
|
||||
<% if precision.to_i > 0 %>
|
||||
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
|
||||
|
||||
Reference in New Issue
Block a user