show card balance when insufficient error occurred

This commit is contained in:
yarzar_code
2020-08-13 14:09:05 +06:30
parent 975d0f3ecd
commit e19bff005e
4 changed files with 50 additions and 62 deletions

View File

@@ -738,6 +738,7 @@ $(document).ready(function(){
dataType: "json",
success: function(data) {
if (data.status == true) {
var customer_card_balance= data.balance;
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
@@ -788,6 +789,7 @@ $(document).ready(function(){
allowOutsideClick: false
},
function (isConfirm) {
$("#loading_wrapper").show();
$('.confirm').attr("disabled","disabled");
window.location.href = "<%= foodcourt_food_court_path %>";
});
@@ -800,9 +802,10 @@ $(document).ready(function(){
customer_display_view(null,"reload");
}
} else {
var insufficient_message = result.message + '<br> Card balance : ' + customer_card_balance
swal({
title: 'Oops',
text: result.message,
text: insufficient_message,
type: 'warning',
html: true,
closeOnConfirm: false,
@@ -827,6 +830,7 @@ $(document).ready(function(){
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
$("#loading_wrapper").hide();
}
}
});
@@ -842,6 +846,7 @@ $(document).ready(function(){
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
$("#loading_wrapper").hide();
}
}
@@ -939,35 +944,25 @@ $(document).ready(function(){
if(customer_name != ""){
customer = '(' + customer_name + ')';
}
$("#loading_wrapper").show();
swal({
title: "Confirmation !",
text: 'Are you sure to assign this customer' + customer + '!',
showCancelButton: true,
confirmButtonColor: "green",
confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger',
closeOnConfirm: true,
}, function () {
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
//change customer detail
$("#customer_name").html(customer_name);
$("#membership_id").html(membership_id);
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
swal("Alert!", "Record not found!", "error");
location.reload();
}
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
//change customer detail
$("#customer_name").html(customer_name);
$("#membership_id").html(membership_id);
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
swal("Alert!", "Record not found!", "error");
location.reload();
}
});
}
});
}