update payment and memberdiscoun

This commit is contained in:
Aung Myo
2017-12-22 17:51:02 +06:30
parent 9094d46209
commit 5bd1daa152
4 changed files with 114 additions and 69 deletions

View File

@@ -290,6 +290,21 @@
<script>
$(document).ready(function(){
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if(payment_type=="Cash"){
$("#card_payment").hide();
$("#credit_payment").hide();
}else if(payment_type=="Credit"){
$("#card_payment").hide();
}
/* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
$("#back").on('click', function() {
@@ -380,74 +395,88 @@
});
$('#pay').click(function() {
// $('#pay').text("Processing, Please wait!")
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops" , "Insufficient Amount!" , "error" );
$( "#loading_wrapper").hide();
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Opps","Please Pay with MPU Payment","warning")
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Redeem Payment","warning")
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Visa Payment","warning")
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with jcb Payment","warning")
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Master Payment","warning")
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// if (item_row.length < 1) {
calculate_member_discount(sale_id);
// }
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops" , "Insufficient Amount!" , "error" );
$( "#loading_wrapper").hide();
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$( "#loading_wrapper" ).hide();
if($('#balance').text() < 0){
swal({
title: "Information!",
text: 'Changed amount ' + $('#balance').text() * (-1),
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
// if (item_row.length < 1) {
calculate_member_discount(sale_id);
// }
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$( "#loading_wrapper" ).hide();
if($('#balance').text() < 0){
swal({
title: "Information!",
text: 'Changed amount ' + $('#balance').text() * (-1),
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami';
});
}else{
$('#pay').text("Pay");
swal({
title: "Information!",
text: 'Thank You !',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami';
});
}else{
$('#pay').text("Pay");
swal({
title: "Information!",
text: 'Thank You !',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami';
});
}
}
}
});
});
}
}
});
});
$('#void').on('click',function () {
if ($(this).attr('active') === "true") {