fixes
- no tax after edit, discount, other charges - redirect after discount, edit and other changes
This commit is contained in:
@@ -18,7 +18,7 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
|||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
@trans_flag = true
|
@trans_flag = true
|
||||||
|
|
||||||
@cashier_type = params[:cashier_type] || session[:cashier_type] || "food_court_qr"
|
@cashier_type = params[:cashier_type] || session[:cashier_type] || "food_court"
|
||||||
Rails.logger.info "Precreate action called with params: #{@cashier_type}"
|
Rails.logger.info "Precreate action called with params: #{@cashier_type}"
|
||||||
|
|
||||||
# if params[:type] == "transaction"
|
# if params[:type] == "transaction"
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% sub_total = 0 %>
|
<% sub_total = 0 %>
|
||||||
<% @sale_data.sale_items.includes(:discount_item).each do |sale_item| %>
|
<% @sale_data.sale_items.includes(:discount_item).each do |sale_item| %>
|
||||||
<% sub_total += sale_item.qty * sale_item.unit_price %>
|
<% sub_total += sale_item.status == "Discount"? sale_item.price : sale_item.qty * sale_item.unit_price %>
|
||||||
<% if sale_item.price > 0 && sale_item.status.blank? %>
|
<% if sale_item.price > 0 && sale_item.status.blank? %>
|
||||||
<tr class="item-row item" id="<%= sale_item.sale_item_id %>"
|
<tr class="item-row item" id="<%= sale_item.sale_item_id %>"
|
||||||
data-account-type="<%=sale_item.account_id%>"
|
data-account-type="<%=sale_item.account_id%>"
|
||||||
@@ -271,6 +271,8 @@
|
|||||||
var precision = <%= precision %>;
|
var precision = <%= precision %>;
|
||||||
var originalAmount = totalAmount;
|
var originalAmount = totalAmount;
|
||||||
var originalDiscount = totalDiscount;
|
var originalDiscount = totalDiscount;
|
||||||
|
var queryParams = new URLSearchParams(window.location.search)
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
setHeaderBreadCrumb(_DISCOUNTS_);
|
setHeaderBreadCrumb(_DISCOUNTS_);
|
||||||
/* check webview loaded*/
|
/* check webview loaded*/
|
||||||
@@ -281,17 +283,10 @@
|
|||||||
var id = $("#table_id").text();
|
var id = $("#table_id").text();
|
||||||
var type = $("#table_type").text();
|
var type = $("#table_type").text();
|
||||||
var sale_id = $('#sale-id').text();
|
var sale_id = $('#sale-id').text();
|
||||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
|
} else if(cashier_type == "food_court") {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
} else if (cashier_type == 'food_court_qr') {
|
|
||||||
window.location.href = '/foodcourt/'+sale_id+'/qrpay/precreate';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if (type=="Table") {
|
|
||||||
window.location.href = '/foodcourt/table/'+id
|
|
||||||
}else{
|
|
||||||
window.location.href = '/foodcourt/room/'+id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -488,12 +483,7 @@
|
|||||||
var sub_total = totalAmount;
|
var sub_total = totalAmount;
|
||||||
var ajax_url = "/foodcourt/" + sale_id + "/discount";
|
var ajax_url = "/foodcourt/" + sale_id + "/discount";
|
||||||
|
|
||||||
if (cashier_type == "food_court_qr") {
|
var params = { 'cashier_type' : cashier_type, 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
||||||
var c_type = "food_court";
|
|
||||||
var params = { 'cashier_type' : c_type, 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
|
||||||
}else{
|
|
||||||
var params = { 'cashier_type' : cashier_type, 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -505,18 +495,11 @@
|
|||||||
title: "Information!",
|
title: "Information!",
|
||||||
text: result.status,
|
text: result.status,
|
||||||
}, function () {
|
}, function () {
|
||||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
}else if(cashier_type == "food_court_qr") {
|
|
||||||
window.location.href = '/foodcourt/'+sale_id+'/qrpay/precreate';
|
|
||||||
}
|
}
|
||||||
else{
|
else if(cashier_type == "food_court") {
|
||||||
if(result.table_type == "Table"){
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
window.location.href = "/foodcourt/table/" + result.table_id
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window.location.href = "/foodcourt/room/" + result.table_id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -554,15 +537,11 @@
|
|||||||
text: result.status,
|
text: result.status,
|
||||||
type: "success",
|
type: "success",
|
||||||
}, function () {
|
}, function () {
|
||||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
|
}
|
||||||
|
else if(cashier_type == "food_court") {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
}else{
|
|
||||||
if(result.table_type == "Table"){
|
|
||||||
window.location.href = "/foodcourt/table/" + result.table_id
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window.location.href = "/foodcourt/room/" + result.table_id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -581,15 +560,11 @@
|
|||||||
text: result.status,
|
text: result.status,
|
||||||
type: "success",
|
type: "success",
|
||||||
}, function () {
|
}, function () {
|
||||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
|
}
|
||||||
|
else if(cashier_type == "food_court") {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
}else{
|
|
||||||
if(result.table_type == "Table"){
|
|
||||||
window.location.href = "/foodcourt/table/" + result.table_id
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window.location.href = "/foodcourt/room/" + result.table_id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<% sub_total = 0 %>
|
<% sub_total = 0 %>
|
||||||
<% @sale_data.sale_items.each do |sale_item| %>
|
<% @sale_data.sale_items.each do |sale_item| %>
|
||||||
<%
|
<%
|
||||||
sub_total += sale_item.qty*sale_item.unit_price
|
sub_total += sale_item.status == "Discount" ? sale_item.price : sale_item.qty*sale_item.unit_price
|
||||||
unless sale_item.price == 0
|
unless sale_item.price == 0
|
||||||
%>
|
%>
|
||||||
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
||||||
@@ -200,7 +200,7 @@
|
|||||||
<%if !@table.nil?%>
|
<%if !@table.nil?%>
|
||||||
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'" id="back"><i class="material-icons">reply</i> Back</button>
|
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'" id="back"><i class="material-icons">reply</i> Back</button>
|
||||||
<%else%>
|
<%else%>
|
||||||
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'" id="back"><i class="material-icons">reply</i> Back</button>
|
<button type="button" class="btn btn-block btn-default waves-effect" id="back"><i class="material-icons">reply</i> Back</button>
|
||||||
<%end%>
|
<%end%>
|
||||||
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
|
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
|
||||||
<hr>
|
<hr>
|
||||||
@@ -210,6 +210,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var queryParams = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
function otherCharges(val){
|
function otherCharges(val){
|
||||||
var aa = parseInt(val);
|
var aa = parseInt(val);
|
||||||
@@ -273,6 +274,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#back').on('click', function() {
|
||||||
|
window.location.href = '/foodcourt/<%= @sale_data.sale_id %>/qrpay/precreate';
|
||||||
|
});
|
||||||
|
|
||||||
// Remove selected discount items
|
// Remove selected discount items
|
||||||
$("#remove-item").on('click', function(e){
|
$("#remove-item").on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -336,19 +341,11 @@
|
|||||||
text: "Success",
|
text: "Success",
|
||||||
type:"success"
|
type:"success"
|
||||||
}, function () {
|
}, function () {
|
||||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
} else if (cashier_type == "food_court_qr") {
|
} else if(cashier_type == "food_court") {
|
||||||
window.location.href = '/foodcourt/'+sale_id+'/qrpay/precreate';
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
if(result.table_type == "Table"){
|
|
||||||
window.location.href = "/foodcourt/table/" + result.table_id
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window.location.href = "/foodcourt/room/" + result.table_id
|
|
||||||
}
|
|
||||||
}s
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ $(document).ready(function(){
|
|||||||
var sale_id = $('#save_order_id').attr('data-order');
|
var sale_id = $('#save_order_id').attr('data-order');
|
||||||
}
|
}
|
||||||
if (sale_id != "") {
|
if (sale_id != "") {
|
||||||
window.location.href = '/foodcourt/' + sale_id +"/"+cashier_type+ '/other_charges'
|
window.location.href = '/foodcourt/' + sale_id +"/"+cashier_type+ '/other_charges?payment_type=qr'
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
swal ( "Oops" , "Please select an table!" , "warning" );
|
swal ( "Oops" , "Please select an table!" , "warning" );
|
||||||
@@ -575,7 +575,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sale_id != "") {
|
if (sale_id != "") {
|
||||||
window.location.href = '/foodcourt/' + sale_id + "/"+cashier_type+'/discount'
|
window.location.href = '/foodcourt/' + sale_id + "/"+cashier_type+'/discount?payment_type=qr'
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
swal ( "Oops" , "Please select an table!" , "warning" );
|
swal ( "Oops" , "Please select an table!" , "warning" );
|
||||||
@@ -591,9 +591,9 @@ $(document).ready(function(){
|
|||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
if ($(this).attr('active')=== "true") {
|
if ($(this).attr('active')=== "true") {
|
||||||
if (dining_id) {
|
if (dining_id) {
|
||||||
window.location.href = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type+"/edit";
|
window.location.href = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type+"/edit?payment_type=qr";
|
||||||
}else{
|
}else{
|
||||||
window.location.href = "/foodcourt/table/sale/" + sale_id + "/"+cashier_type+"/edit";
|
window.location.href = "/foodcourt/table/sale/" + sale_id + "/"+cashier_type+"/edit?payment_type=qr";
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
@@ -1010,7 +1010,7 @@ $(document).ready(function(){
|
|||||||
if (type == "edit") {
|
if (type == "edit") {
|
||||||
var dining_id = $('#dining').text();
|
var dining_id = $('#dining').text();
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
window.location.href = "/foodcourt/table/sale/" + sale_id + "/"+cashier_type+"/edit";
|
window.location.href = "/foodcourt/table/sale/" + sale_id + "/"+cashier_type+"/edit?payment_type=qr";
|
||||||
}else if(type == "void"){
|
}else if(type == "void"){
|
||||||
$('#AccessCodeModal').modal('hide');
|
$('#AccessCodeModal').modal('hide');
|
||||||
$('#voidModal').modal('show');
|
$('#voidModal').modal('show');
|
||||||
|
|||||||
@@ -237,6 +237,8 @@
|
|||||||
<script>
|
<script>
|
||||||
var cashier_type = "<%= @cashier_type %>";
|
var cashier_type = "<%= @cashier_type %>";
|
||||||
var access_code = localStorage.getItem("access_code");
|
var access_code = localStorage.getItem("access_code");
|
||||||
|
var queryParams = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
// Bill Request
|
// Bill Request
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
@@ -370,15 +372,12 @@ var access_code = localStorage.getItem("access_code");
|
|||||||
$('#back').on('click', function () {
|
$('#back').on('click', function () {
|
||||||
var table_id = '<%= @table_id %>'
|
var table_id = '<%= @table_id %>'
|
||||||
var sale_id = "<%= @saleobj.sale_id %>"
|
var sale_id = "<%= @saleobj.sale_id %>"
|
||||||
if (cashier_type=="quick_service" || cashier_type == "food_court") {
|
|
||||||
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
|
} else if(cashier_type == "food_court") {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
}
|
}
|
||||||
else if(cashier_type=="food_court_qr"){
|
|
||||||
window.location.href = '/foodcourt/'+sale_id+'/'+ 'qrpay' +'/precreate';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
window.location.href = '/foodcourt/table/' + table_id;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#cancel_all_void').on('click', function () {
|
$('#cancel_all_void').on('click', function () {
|
||||||
@@ -403,16 +402,11 @@ var access_code = localStorage.getItem("access_code");
|
|||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'sale_id=' + sale_id+'&type='+cashier_type,
|
data: 'sale_id=' + sale_id+'&type='+cashier_type,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
if (cashier_type=="food_court" && queryParams.get('payment_type') == 'qr') {
|
||||||
|
window.location.href = '/foodcourt/'+sale_id+'/'+'qrpay/precreate';
|
||||||
|
} else if(cashier_type == "food_court") {
|
||||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||||
}
|
}
|
||||||
else if(cashier_type=="food_court_qr"){
|
|
||||||
window.location.href = '/foodcourt/'+sale_id+'/'+ 'qrpay' +'/precreate';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
window.location.href = '/foodcourt/table/' + table_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user