change tax override in payment page

This commit is contained in:
phyusin
2018-05-29 10:10:49 +06:30
parent bf9bb1c58a
commit 089630616d
4 changed files with 34 additions and 5 deletions

View File

@@ -139,6 +139,8 @@
<!-- Column One -->
<script>
$(document).ready(function(){
localStorage.removeItem("tax_type");
var webview = <%= @webview %>;
showHideNavbar(webview,"index");

View File

@@ -622,6 +622,7 @@
<script>
var cashier_type = "cashier";
$(document).ready(function () {
localStorage.removeItem("tax_type");
/* check webview loaded*/
var webview = <%= @webview %>;
showHideNavbar(webview);

View File

@@ -678,6 +678,8 @@ var customer_name = "<%= @customer.name %>";
$('#cash').text(localStorage.getItem("cash"));
}
update_balance();
//checkChangableTax
checkChangableTax();
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
@@ -743,7 +745,7 @@ var customer_name = "<%= @customer.name %>";
var credit = $('#credit').text();
var card = $('#card').text();
var tax_type = $("input:radio[name=tax_type]:checked").val();
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : '';
if (credit <= 0) {
calculate_member_discount(sale_id);
@@ -842,7 +844,7 @@ var customer_name = "<%= @customer.name %>";
// }
// })
// }else{
// swal("Opps","You are not authorized for void","warning")
// swal("Oops","You are not authorized for void","warning")
// }
// });
@@ -1018,6 +1020,7 @@ var customer_name = "<%= @customer.name %>";
$('#balance').text(parseFloat(result));
<% end %>
}
function customer_display_view(data,status) {
$.ajax({
type: "POST",
@@ -1288,7 +1291,7 @@ var customer_name = "<%= @customer.name %>";
// overall_foc();
}
}else{
swal("Opps",result.message,"warning")
swal("Oops",result.message,"warning");
}
}
});
@@ -1413,14 +1416,22 @@ var customer_name = "<%= @customer.name %>";
/* Start function for tax changable */
$(".change_tax").on("click",function(){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
var balance = parseFloat($("#balance").text());
var sub_total = parseFloat($("#sub-total").text());
var total_tax = parseFloat($("#total_tax").text());
if(balance > 0 && (balance >= total_tax)){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
}
else{
swal("Oops","You cann't change tax!","warning");
}
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var cashier_type = '<%= @cashier_type %>';
var sale_id = $('#sale_id').text();
console.log(type);
localStorage.removeItem("tax_type");
swal({
title: "Alert",
text: "Are you sure want to change tax?",
@@ -1437,6 +1448,8 @@ var customer_name = "<%= @customer.name %>";
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment';
}
}
@@ -1447,4 +1460,16 @@ var customer_name = "<%= @customer.name %>";
});
});
/* End function for tax changable */
/* check change tax is available or not*/
function checkChangableTax(){
var balance = parseFloat($("#balance").text());
var sub_total = parseFloat($("#sub-total").text());
var total_tax = parseFloat($("#total_tax").text());
if(balance > 0 && (balance >= total_tax)){
$(".change_tax").show();
}else{
$(".change_tax").hide();
}
}
</script>

View File

@@ -603,6 +603,7 @@
<script>
var cashier_type = "cashier";
$(document).ready(function(){
localStorage.removeItem("tax_type");
/* check webview loaded*/
var webview = <%= @webview %>;
showHideNavbar(webview);