access code in foodcourt payment(void,waste&spoile,edit,change tax)

This commit is contained in:
Myat Zin Wai Maw
2020-02-05 12:09:04 +06:30
parent 978e7b7e07
commit 0582587f75
3 changed files with 78 additions and 24 deletions

View File

@@ -1,25 +1,14 @@
class Foodcourt::PaymalController < BaseFoodcourtController class Foodcourt::PaymalController < BaseFoodcourtController
def create def create
cash = params[:payment_amount] cash = params[:payment_amount]
sale_id = params[:sale_id] sale_id = params[:sale_id]
transaction_ref = params[:transaction_ref] transaction_ref = params[:transaction_ref]
account_no = params[:account_no] account_no = params[:account_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment
# if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
# rounding_adj = new_total-saleObj.grand_total
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
# end
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new sale_payment = SalePayment.new
status, @sale,@membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no) status, @sale,@membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no)
if status == true && @membership_data["status"] == true if status == true && @membership_data["status"] == true
@out = true, "Success!" @out = true, "Success!"
else else

View File

@@ -119,7 +119,11 @@
No Tax No Tax
<% end %></strong><br> <% end %></strong><br>
<%if @sale_payment.nil? && @changable_tax %> <%if @sale_payment.nil? && @changable_tax %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button> <% if current_login_employee.role == "cashier" %>
<a class="btn btn-link waves-effect bg-info access_modal" data-toggle="modal" data-type="change_tax"> Change Tax</a>
<% else %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
<% end %> <% end %>
</td> </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> <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>
@@ -397,17 +401,30 @@
Refresh Refresh
</button> </button>
<% if @sale_payment.nil? %> <% if @sale_payment.nil? %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button> <% if current_login_employee.role == "cashier" %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
<% else %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<%end %>
<% if @other_payment <= 0 %> <% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %> <%if @sale_data.total_discount == 0 %>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button> <% if current_login_employee.role == "cashier" %>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button> <a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
<% else %>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% if @sale_payment.nil? %> <% if @sale_payment.nil? %>
<hr> <hr>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button> <% if current_login_employee.role == "cashier" %>
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="edit">Edit</a>
<% else %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button> <button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button> <button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<%end %> <%end %>
@@ -1326,7 +1343,7 @@ $(document).ready(function(){
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
if ($("#sxModal").attr("data-for") == 'member') { if ($("#sxModal").attr("data-for") == 'member') {
@@ -1424,6 +1441,52 @@ $(document).ready(function(){
var sale_id = $("#sale_id").text() || 0; var sale_id = $("#sale_id").text() || 0;
update_sale("", customer_id, customer_name, sale_id); update_sale("", customer_id, customer_name, sale_id);
}); });
$(document).on('click', '.access_modal', function(event){
type = $(this).data("type");
$(".ok").attr("data-action",type)
$('#AccessCodeModal').modal('show');
});
function check_emp_access_code(access_code,type) {
var url = "/foodcourt/check_emp_access_code/" + access_code ;
$.ajax({
type: 'POST',
url: url,
data: {},
success: function (result) {
// console.log(result)
if (result.status == true) {
createAccessCode(code);
if (type == "edit") {
var dining_id = $('#dining').text();
var sale_id = $('#sale_id').text();
window.location.href = "/foodcourt/table/sale/" + sale_id + "/"+cashier_type+"/edit";
}else if(type == "void"){
$('#AccessCodeModal').modal('hide');
$('#voidModal').modal('show');
// overall_void();
}else if(type == "waste") {
// $('#AccessCodeModal').modal('hide');
// $('#focModal').modal('show');
waste_and_spoilage("waste")
}else if(type == "spoile") {
// $('#AccessCodeModal').modal('hide');
// $('#voidModal').modal('show');
waste_and_spoilage("spoile")
}else if(type == "foc"){
$('#AccessCodeModal').modal('hide');
$('#focModal').modal('show');
// overall_foc();
}else if(type == "change_tax"){
$('#AccessCodeModal').modal('hide');
$('#change_taxModal').modal('show');
}
}else{
swal("Oops",result.message,"warning");
}
}
});
}
$('#foc').on('click', function () { $('#foc').on('click', function () {
var access_code = localStorage.getItem("access_code"); var access_code = localStorage.getItem("access_code");
var remark = $("#foc_remark").val(); var remark = $("#foc_remark").val();
@@ -1553,6 +1616,7 @@ $(document).ready(function(){
closeOnConfirm: false closeOnConfirm: false
}, function (isConfirm) { }, function (isConfirm) {
if (isConfirm) { if (isConfirm) {
$('.confirm').prop("disabled",true);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/foodcourt/payment/"+cashier_type+"/change_tax", url: "/foodcourt/payment/"+cashier_type+"/change_tax",

View File

@@ -1253,6 +1253,7 @@ $(document).ready(function(){
title: "Payment Successful!", title: "Payment Successful!",
text: text, text: text,
html: true, html: true,
type: 'success',
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false