Merge branch 'bank_integration' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2018-01-10 18:16:41 +06:30
37 changed files with 807 additions and 92 deletions

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -17,6 +20,16 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -106,11 +119,28 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
}
});
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'JCB is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
});
// number key pad
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
@@ -160,6 +190,7 @@ $(document).on('click', '.cashier_number', function(event){
$('#jcb_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -176,24 +207,7 @@ $('#jcb_pay').on('click',function(){
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
},function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no);
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -17,6 +20,16 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -106,10 +119,27 @@
</div>
<script>
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
}
}
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'MASTER is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
@@ -157,6 +187,7 @@
$('#master_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -173,24 +204,7 @@
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
},function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
pay_withBank("SALE", "master", amount, sale_id, receipt_no);
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -18,6 +21,16 @@
<div class="card" style="margin-top:10px;padding:20px;">
<div class="card-block">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -109,11 +122,30 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
}
});
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'MPU is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
@@ -157,9 +189,11 @@
return false;
}
});
$('#mpu_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -176,25 +210,8 @@
// });
// }
//end member discount
//Mpu Payment
$.ajax({type: "POST",
url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
@@ -203,5 +220,5 @@
}
}
})
</script>
</script>

View File

@@ -370,7 +370,7 @@
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(amt);
$('#cash').text(parseFloat(amt).toFixed(2));
update_balance();
break;
}

View File

@@ -1,4 +1,8 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class='row clearfix'>
<div class='col-md-10'>
<h1><%= t :close_cashier %></h1>
@@ -27,6 +31,27 @@
<div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
<button type="button" class="btn bg-blue btn-block green" id='close_cashier'> <%= t("views.btn.close_cashier") %> </button>
<button type="button" class="btn bg-blue btn-block green" id="card_settlement"> <%= t("views.btn.card_settle") %> </button>
</div>
</div>
<div class="modal fade" id="cardSettleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="cardSettleModal">Select Device: </h4>
</div>
<div class="modal-body">
<select class="form-control show-tick sel_com_port" id="sel_com_port" >
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect" id="card_settle">OK</button>
</div>
</div>
</div>
</div>
</div>
@@ -42,8 +67,175 @@
window.location.href = '/';
}
});
})
});
$('#back').on('click',function(){
window.location.href = '/origami';
})
});
/** start CB Card Settle process **/
$("#card_settlement").on('click', function(){
if(typeof code2lab != 'undefined'){
$('#cardSettleModal').modal({ keyboard: false, backdrop: false });
code2lab.getCommPorts();
}else{
swal({
title: 'Oops',
text: 'Settlement can not print out in browser!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/close';
});
}
});
//CB Bank payment settlement ECR integration
function setCommPorts(comPortLists) {
// alert(comPortLists);
$('#sel_com_port').html("");
var jsonPortLists = $.parseJSON(comPortLists);
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
$.each(jsonPortLists,function(key,value){
$('#sel_com_port').append("<option value='"+value+"'>"+value+"</option>");
});
}
else{
swal({
title: 'Oops',
text: 'Payment can not pay in browser!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/close';
});
}
}
$("#card_settle").on('click', function () {
$("#loading_wrapper").show();
$('#cardSettleModal').modal('hide');
reqCBBankMPUSettlement();
});
//add req data to card_settle_trans table
function reqCardSettleTrans(cmd_type,payment_type,com_port) {
var jobj = {"cmd_type" : cmd_type, "payment_type" : payment_type};
$.ajax({
type: "POST",
url: "/origami/bank_integration/settle_trans",
data: {type:"request", data: jobj},
dataType: "json",
success: function(data) {
if (data.status == "success"){
resCardSettleTrans(data.card_settle_trans_id,cmd_type,payment_type,com_port);
}
}
});
}
//add res data to card_settle_trans table
function resCardSettleTrans(card_settle_trans_id,cmd_type,payment_type,com_port) {
var resMsg = "";
if($("#loading_wrapper").is(':visible')){
resMsg = code2lab.reqBankPayment(cmd_type, payment_type, 1, "", com_port);
}
if(resMsg.includes("STATUS")){
var jobj = $.parseJSON(resMsg);
$.ajax({
type: "POST",
url: "/origami/bank_integration/settle_trans",
data: {type:"response", card_settle_trans_id: card_settle_trans_id, data: jobj},
dataType: "json",
success: function(data) {
if(data.status == "success"){
if(payment_type == "MPU"){
reqCBBankVMJSettlement();
}
else if(payment_type == "VMJ"){
reqCBBankJCBSettlement();
}
else if(payment_type == "JCB"){
reqCBBankCUPSettlement();
}
else if(payment_type == "CUP"){
$("#loading_wrapper").hide();
// reqCBBankAlipaySettlement();
}
// else if(payment_type == "Alipay"){
// reqCBBankIPPSettlement();
// $('#loading').hide();
// }
}
}
});
}
else{
$("#loading_wrapper").hide();
swal ( "Oops" , resMsg.toString() , "error" );
}
}
//settle for MPU / MPU-UPI
function reqCBBankMPUSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "MPU";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for VMJ (VISA, MASTER)
function reqCBBankVMJSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "VMJ"; //VISA,Master and JCB
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for JCB
function reqCBBankJCBSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "JCB";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for International Union Pay (CUP)
function reqCBBankCUPSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "CUP";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for Alipay
function reqCBBankAlipaySettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "Alipay";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for insert/direct swipe (now does not using this state - future one)
function reqCBBankIPPSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "IPP";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
/** end CB Card Settle process **/
</script>

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -17,6 +20,16 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -106,10 +119,28 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_visa %>") - parseFloat(localStorage.getItem("cash")));
}
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'VISA is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
@@ -157,6 +188,7 @@
$('#visa_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
console.log(amount);
console.log($("#validamount").attr("value"));
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
@@ -175,24 +207,7 @@
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_visa_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
pay_withBank("SALE", "visa", amount, sale_id, receipt_no);
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );