update unsuccessfully rebate and alert

This commit is contained in:
Aung Myo
2017-07-05 14:42:40 +06:30
parent 6ee4d19e99
commit 7cee40746d
3 changed files with 54 additions and 27 deletions

View File

@@ -205,5 +205,6 @@ tr.discount-item-row:hover {
/* Jquery Confirm */
.jconfirm-box-container{
margin-left:-40px !important
margin-left:-40px !important;
margin-top:-40px !important;
}

View File

@@ -41,11 +41,7 @@ class Origami::PaymentsController < BaseOrigamiController
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
# rounding_adj = saleObj.grand_total - new_total
# saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
rebate_amount = nil
unique_code = "ReceiptBillPdf"
@@ -65,7 +61,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
end
end

View File

@@ -341,28 +341,58 @@ $( document ).ready(function() {
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
localStorage.removeItem("cash");
if($('#balance').text() < 0){
alert("Changed amount " + $('#balance').text() * (-1) )
}else{
$('#pay').text("Pay")
alert("Thank you")
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}else{
var msg = '';
}
if($('#balance').text() < 0){
$.confirm({
title: 'Hi!',
content: 'Changed amount ' + $('#balance').text() * (-1) + '\n\n' + msg,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}else{
$('#pay').text("Pay")
$.confirm({
title: 'Hi!',
content: 'Thank you !'+'\n\n'+msg,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}
}
window.location.href = '/origami';
}
});
}
});
}
});
$('#void').on('click',function () {