change tax profile overide

This commit is contained in:
phyusin
2018-05-25 13:26:55 +06:30
parent 36fe726fbe
commit 49453a22c0
7 changed files with 199 additions and 136 deletions

View File

@@ -1,4 +1,4 @@
`<div class="container-fluid">
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
@@ -99,52 +99,21 @@
<tr>
<td class="charges-name">
<strong>
Tax
<!-- (<% @i = 0
@account_arr.each do |ct| %>
<%=ct%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>) -->
<div class="row m-l-15">
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
<div class="form-check">
<input type="radio" class="form-check-input" id="tax_type_0" name="tax_type" checked="checked">
<label class="form-check-label" for="tax_type_0">
Service Charges + Commercial Tax
</label>
</div>
</div>
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
<div class="form-check">
<input type="radio" class="form-check-input" id="tax_type_1" name="tax_type">
<label class="form-check-label" for="tax_type_1">Service Charges</label>
</div>
</div>
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
<div class="form-check">
<input type="radio" class="form-check-input" id="tax_type_2" name="tax_type">
<label class="form-check-label" for="tax_type_2">
Commercial Tax
</label>
</div>
</div>
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
<div class="form-check">
<input type="radio" class="form-check-input" id="tax_type_3" name="tax_type">
<label class="form-check-label" for="tax_type_3">
No Tax
</label>
</div>
</div>
</div>
</strong>
<% if !@account_arr.empty? %>
Tax
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.tax_name%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
</td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
@@ -574,6 +543,61 @@
</div>
</div>
<!-- change tax modal -->
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="change_taxModalLabel">TAX</h1>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">&times;</button>
</div>
<div class="modal-body">
<% if !@tax_arr.empty? %>
<% if @tax_arr.count > 1 %>
<div class="row text-center">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="all">
<% @i = 0
@tax_arr.each do |tax| %>
<%= tax %>
<% if @tax_arr.count != @i+1%>
+ <% @i =+1 %><br>
<%end%>
<% end %>
</button>
</div>
<% @tax_arr.each_with_index do |tax, tax_index| %>
<% if (tax_index+1)%2 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>">
<%= tax %>
</button>
</div>
<% end %>
<% else %>
<div class="row clearfix"></div>
<div class="row text-center">
<% @tax_arr.each do |tax| %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>"><%= tax %></button>
</div>
<% end %>
<% end %>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="no_tax">No Tax</button>
</div>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content">
<h3>Card Tap</h3>
@@ -719,6 +743,8 @@ var customer_name = "<%= @customer.name %>";
var credit = $('#credit').text();
var card = $('#card').text();
var tax_type = $("input:radio[name=tax_type]:checked").val();
if (credit <= 0) {
calculate_member_discount(sale_id);
}
@@ -727,7 +753,7 @@ var customer_name = "<%= @customer.name %>";
$('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
@@ -1384,4 +1410,41 @@ var customer_name = "<%= @customer.name %>";
}
});
}
/* Start function for tax changable */
$(".change_tax").on("click",function(){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
});
$("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);
swal({
title: "Alert",
text: "Are you sure want to change tax?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, change it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
success:function(data){
if(data.status){
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment';
}
}
});
}else{
swal.close();
}
});
});
/* End function for tax changable */
</script>