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

@@ -30,6 +30,11 @@ function member_card(cardNo) {
success: function(data) { success: function(data) {
if (data[0].customer_id == false) { if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error"); swal("Alert!", data[0].message, "error");
if ($("#order-items-table tr").length > 1){
$("#create_pay_order").prop("disabled", false);
$("#create_order").prop("disabled", false);
}
$("#oqs_loading_wrapper").hide();
}else{ }else{
g_customer_id = data[0].customer_id; g_customer_id = data[0].customer_id;
g_customer_name = data[0].name; g_customer_name = data[0].name;
@@ -115,22 +120,6 @@ function update_sale(membership_id, customer_id, customer_name, sale_id) {
if(customer_name != ""){ if(customer_name != ""){
customer = '(' + customer_name + ')'; customer = '(' + customer_name + ')';
} }
swal({
title: "Confirmation !",
text: 'Are you sure to assign this customer' + customer + '!',
showCancelButton: true,
confirmButtonColor: "green",
confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger customer_assign_cancel',
closeOnConfirm: true,
}, function (inputValue) {
if (inputValue===false) {
if ($("#order-items-table tr").length > 1){
$("#create_pay_order").prop("disabled", false);
$("#create_order").prop("disabled", false);
}
} else {
$("#oqs_loading_wrapper").show(); $("#oqs_loading_wrapper").show();
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -150,5 +139,3 @@ function update_sale(membership_id, customer_id, customer_name, sale_id) {
} }
}); });
} }
});
}

View File

@@ -187,7 +187,7 @@ class Foodcourt::CustomersController < BaseFoodcourtController
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" ) sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
end end
@out = membership_data @out = membership_data
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]}) render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"], :balance => membership_data["balance"]})
end end
end end
end end

View File

@@ -375,6 +375,12 @@ class Customer < ApplicationRecord
rescue SocketError rescue SocketError
response = {"status" => false, "message" => "No internet connection "} response = {"status" => false, "message" => "No internet connection "}
end end
case response.code
when 404
response = {"status" => false, "message" => "Not Found "}
when 500...600
response = {"status" => false, "message" => response.message}
end
Rails.logger.debug "--------Search Paypar Account No response -------" Rails.logger.debug "--------Search Paypar Account No response -------"
Rails.logger.debug response.to_json Rails.logger.debug response.to_json
return response return response

View File

@@ -738,6 +738,7 @@ $(document).ready(function(){
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
if (data.status == true) { if (data.status == true) {
var customer_card_balance= data.balance;
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); // $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
@@ -788,6 +789,7 @@ $(document).ready(function(){
allowOutsideClick: false allowOutsideClick: false
}, },
function (isConfirm) { function (isConfirm) {
$("#loading_wrapper").show();
$('.confirm').attr("disabled","disabled"); $('.confirm').attr("disabled","disabled");
window.location.href = "<%= foodcourt_food_court_path %>"; window.location.href = "<%= foodcourt_food_court_path %>";
}); });
@@ -800,9 +802,10 @@ $(document).ready(function(){
customer_display_view(null,"reload"); customer_display_view(null,"reload");
} }
} else { } else {
var insufficient_message = result.message + '<br> Card balance : ' + customer_card_balance
swal({ swal({
title: 'Oops', title: 'Oops',
text: result.message, text: insufficient_message,
type: 'warning', type: 'warning',
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
@@ -827,6 +830,7 @@ $(document).ready(function(){
}, function () { }, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
}); });
$("#loading_wrapper").hide();
} }
} }
}); });
@@ -842,6 +846,7 @@ $(document).ready(function(){
}, function () { }, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
}); });
$("#loading_wrapper").hide();
} }
} }
@@ -939,17 +944,8 @@ $(document).ready(function(){
if(customer_name != ""){ if(customer_name != ""){
customer = '(' + customer_name + ')'; customer = '(' + customer_name + ')';
} }
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(); $("#loading_wrapper").show();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" , url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
@@ -968,7 +964,6 @@ $(document).ready(function(){
} }
} }
}); });
});
} }
$("#sxModal .btn_cancel").on('click',function(){ $("#sxModal .btn_cancel").on('click',function(){