change tax func:

This commit is contained in:
EikhantMon
2018-07-06 18:24:03 +06:30
parent 08ae578e39
commit 26412da8ad
2 changed files with 22 additions and 20 deletions

View File

@@ -699,7 +699,7 @@
<script>
var cashier_type = "cashier";
$(document).ready(function () {
localStorage.removeItem("tax_type");
// localStorage.removeItem("tax_type");
/* check webview loaded*/
var webview = <%= @webview %>;
showHideNavbar(webview);
@@ -894,12 +894,14 @@
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
calculate_member_discount(sale_id,"Card");
calculate_member_discount(sale_id,"Card",tax_type);
}else{
calculate_member_discount(sale_id,"Cash");
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
@@ -920,7 +922,7 @@
});
});
function calculate_member_discount(sale_id,type) {
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
@@ -930,7 +932,7 @@
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier' },
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){
}
@@ -1251,7 +1253,7 @@
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var tax_type = $(this).attr("data-value");
var cashier_type = 'cashier';
var sale_id = $('#sale_id').text();
var dining_id = "<%= @dining.id rescue "" %> ";
@@ -1270,11 +1272,12 @@
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: tax_type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
alert(tax_type);
localStorage.setItem("tax_type", tax_type);
alert(localStorage.getItem("tax_type"));
window.location.href = '/origami/table/'+dining_id;
}
}

View File

@@ -694,7 +694,7 @@
<script>
var cashier_type = "cashier";
$(document).ready(function(){
localStorage.removeItem("tax_type");
// localStorage.removeItem("tax_type");
/* check webview loaded*/
var webview = <%= @webview %>;
showHideNavbar(webview);
@@ -913,14 +913,14 @@ $(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
// type = $('.payment_method').val();
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL", type)) != -1) {
calculate_member_discount(sale_id,"Card");
calculate_member_discount(sale_id,"Card",tax_type);
}else{
calculate_member_discount(sale_id,"Cash");
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
@@ -942,7 +942,7 @@ $(".choose_payment").on('click', function () {
}
});
});
function calculate_member_discount(sale_id,type) {
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
@@ -952,12 +952,11 @@ function calculate_member_discount(sale_id,type) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){
}
});
}
$('#pay').on('click',function() {
@@ -1319,7 +1318,7 @@ $('#add_invoice').on('click',function(){
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var tax_type = $(this).attr("data-value");
var cashier_type = 'cashier';
var sale_id = $('#sale_id').text();
var dining_id = "<%= @room.id rescue "" %> ";
@@ -1338,11 +1337,11 @@ $('#add_invoice').on('click',function(){
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: tax_type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
// console.log(tax_type);
localStorage.setItem("tax_type", tax_type);
window.location.href = '/origami/room/'+dining_id;
}
}