payment method changed in report

This commit is contained in:
yarzar_code
2020-07-09 14:46:18 +06:30
parent 8f5ea9417d
commit 3d2d18a330
26 changed files with 1836 additions and 1976 deletions

View File

@@ -43,61 +43,66 @@ _VOUCHER_ = "/   VOUCHER";
_SURVEY_ = "/   SURVEY"; _SURVEY_ = "/   SURVEY";
/* Constant Varaibles */ /* Constant Varaibles */
$(document).on('turbolinks:load', function() { $(document).on("turbolinks:load", function () {
$("#customer_image_path").fileinput({ $("#customer_image_path").fileinput({
previewFileType: "image", previewFileType: "image",
allowedFileExtensions: ["jpg", "gif", "png"], allowedFileExtensions: ["jpg", "gif", "png"],
browseClass: "btn btn-success", browseClass: "btn btn-success",
browseLabel: "Pick Image", browseLabel: "Pick Image",
browseIcon: "<i class=\"fa fa-image\"></i> ", browseIcon: '<i class="fa fa-image"></i> ',
removeClass: "btn btn-danger", removeClass: "btn btn-danger",
removeLabel: "Delete", removeLabel: "Delete",
removeIcon: "<i class=\"fa fa-trash\"></i> ", removeIcon: '<i class="fa fa-trash"></i> ',
showUpload: false, showUpload: false,
// uploadClass: "btn btn-info", // uploadClass: "btn btn-info",
// uploadLabel: "Upload", // uploadLabel: "Upload",
// uploadIcon: "<i class=\"fa fa-upload\"></i> ", // uploadIcon: "<i class=\"fa fa-upload\"></i> ",
previewTemplates: { previewTemplates: {
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' + image:
'<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' + ' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
'</div>\n', "</div>\n",
} },
}); });
$('.datetimepicker').bootstrapMaterialDatePicker({ $(".datetimepicker").bootstrapMaterialDatePicker({
format: 'DD-MM-YYYY - HH:mm', format: "DD-MM-YYYY - HH:mm",
clearButton: true,
weekStart: 1
});
$('.datepicker').bootstrapMaterialDatePicker({
format: 'DD-MM-YYYY',
clearButton: true, clearButton: true,
weekStart: 1, weekStart: 1,
time: false
}); });
$('.timepicker').bootstrapMaterialDatePicker({ $(".datepicker").bootstrapMaterialDatePicker({
format: 'HH:mm', format: "DD-MM-YYYY",
clearButton: true, clearButton: true,
date: false weekStart: 1,
time: false,
});
$(".timepicker").bootstrapMaterialDatePicker({
format: "HH:mm",
clearButton: true,
date: false,
}); });
// For selected order return // For selected order return
var order_status = ""; var order_status = "";
order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); order_status = $(".selected-item")
.children()
.find(".orders-order-status")
.text()
.substr(0, 6)
.trim();
// Enable/Disable Button // Enable/Disable Button
//control_button(order_status); //control_button(order_status);
$(".orders").on('click', function(){ $(".orders").on("click", function () {
$("#order-sub-total").text(''); $("#order-sub-total").text("");
// $("#order-food").text(''); // $("#order-food").text('');
// $("#order-beverage").text(''); // $("#order-beverage").text('');
$("#order-discount").text(''); $("#order-discount").text("");
$("#order-Tax").text(''); $("#order-Tax").text("");
$("#order-grand-total").text(''); $("#order-grand-total").text("");
var zone_name = $(this).find(".orders-table").text(); var zone_name = $(this).find(".orders-table").text();
var receipt_no = $(this).find(".orders-receipt-no").text(); var receipt_no = $(this).find(".orders-receipt-no").text();
@@ -127,7 +132,7 @@ $(document).on('turbolinks:load', function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/origami/" + unique_id, url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id }, data: { booking_id: unique_id },
success: function (result) { success: function (result) {
for (i = 0; i < result.length; i++) { for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]); var data = JSON.stringify(result[i]);
@@ -139,21 +144,40 @@ $(document).on('turbolinks:load', function() {
cashier = result[i].cashier_name; cashier = result[i].cashier_name;
if (result[i].receipt_date != null) { if (result[i].receipt_date != null) {
receipt_date = new Date(result[i].receipt_date); receipt_date = new Date(result[i].receipt_date);
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() show_date =
receipt_date.getDate() +
"-" +
receipt_date.getMonth() +
"-" +
receipt_date.getFullYear() +
" " +
receipt_date.getHours() +
":" +
receipt_date.getMinutes();
} }
//Receipt Charges //Receipt Charges
sub_total += parseFloat(parse_data.price); sub_total += parseFloat(parse_data.price);
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount; discount_amount =
parse_data.discount_amount == null
? "0.0"
: parse_data.discount_amount;
tax_amount = parse_data.tax_amount; tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount; grand_total_amount = parse_data.grand_total_amount;
// Ordered Items // Ordered Items
var order_items_rows = "<tr>" + var order_items_rows =
"<td class='item-name'>" + parse_data.item_name + "</td>" + "<tr>" +
"<td class='item-attr'>" + parse_data.qty + "</td>" + "<td class='item-name'>" +
"<td class='item-attr'>" + parse_data.price + "</td>" + parse_data.item_name +
"</td>" +
"<td class='item-attr'>" +
parse_data.qty +
"</td>" +
"<td class='item-attr'>" +
parse_data.price +
"</td>" +
"</tr>"; "</tr>";
$("#order-items-table").children("tbody").append(order_items_rows); $("#order-items-table").children("tbody").append(order_items_rows);
@@ -171,54 +195,53 @@ $(document).on('turbolinks:load', function() {
$("#order-discount").text(discount_amount); $("#order-discount").text(discount_amount);
$("#order-Tax").text(tax_amount); $("#order-Tax").text(tax_amount);
$("#order-grand-total").text(grand_total_amount); $("#order-grand-total").text(grand_total_amount);
} },
}); });
// End AJAX Call // End AJAX Call
$('.orders').removeClass('selected-item'); $(".orders").removeClass("selected-item");
$(this).addClass('selected-item'); $(this).addClass("selected-item");
}); });
// Payment for Bill // Payment for Bill
$('#pay-bill').click(function() { $("#pay-bill").click(function () {
var sale_id = $(".selected-item").find(".orders-id").text().substr(0, 16); var sale_id = $(".selected-item").find(".orders-id").text().substr(0, 16);
if (sale_id != "") { if (sale_id != "") {
window.location.href = '/origami/sale/'+ sale_id + "/payment" window.location.href = "/origami/sale/" + sale_id + "/payment";
} } else {
else {
alert("Please select an order!"); alert("Please select an order!");
} }
return false; return false;
}); });
$(document).on('click', '.access_modal', function(event){ $(document).on("click", ".access_modal", function (event) {
type = $(this).data("type"); type = $(this).data("type");
$(".ok").attr("data-action", type); $(".ok").attr("data-action", type);
$('#AccessCodeModal').modal('show'); $("#AccessCodeModal").modal("show");
}); });
$(document).on('click', '.access_number', function(event){ $(document).on("click", ".access_number", function (event) {
if (event.handled !== true) { if (event.handled !== true) {
var original_value = $('#access_code').val(); var original_value = $("#access_code").val();
var input_type = $(this).attr("data-type"); var input_type = $(this).attr("data-type");
switch (input_type) { switch (input_type) {
case 'num': case "num":
var input_value = $(this).attr("data-value"); var input_value = $(this).attr("data-value");
if (original_value) { if (original_value) {
$('#access_code').val(original_value + input_value); $("#access_code").val(original_value + input_value);
} else { } else {
$('#access_code').val(original_value + input_value); $("#access_code").val(original_value + input_value);
} }
break; break;
case 'ok': case "ok":
var type = $(this).attr("data-action"); var type = $(this).attr("data-action");
code = $('#access_code').val(); code = $("#access_code").val();
check_emp_access_code(code,type) check_emp_access_code(code, type);
break; break;
case 'clr': case "clr":
$('#access_code').val(""); $("#access_code").val("");
break; break;
} }
event.handled = true; event.handled = true;
@@ -230,7 +253,7 @@ $(document).on('turbolinks:load', function() {
$(document).on("click", ".credit_detail", function () { $(document).on("click", ".credit_detail", function () {
var sale_id = $(this).attr("data-id"); var sale_id = $(this).attr("data-id");
var cashier_type = $(this).attr("data-type"); var cashier_type = $(this).attr("data-type");
if(cashier_type=='cashier'){ if (cashier_type == "cashier") {
window.location.href = "/origami/cashier/credit_sales/" + sale_id; window.location.href = "/origami/cashier/credit_sales/" + sale_id;
} else { } else {
window.location.href = "/origami/quick_service/credit_sales/" + sale_id; window.location.href = "/origami/quick_service/credit_sales/" + sale_id;
@@ -243,16 +266,20 @@ function checkReceiptNoInFirstBillData(receipt_no,payment) {
// localStorage.removeItem('receipt_lists'); // localStorage.removeItem('receipt_lists');
var status = false; var status = false;
var json_data = []; var json_data = [];
if((receipt_no!=undefined) && (receipt_no!="")){ if (receipt_no != undefined && receipt_no != "") {
if (localStorage.hasOwnProperty("receipt_lists") === true) { if (localStorage.hasOwnProperty("receipt_lists") === true) {
var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
if (payment) { if (payment) {
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); json_data = arr_data.filter(function (e) {
return e.receipt_no == receipt_no;
});
} else { } else {
json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); json_data = arr_data.filter(function (e) {
return e.receipt_no !== receipt_no;
});
} }
if((arr_data.length) > (json_data.length)){ if (arr_data.length > json_data.length) {
status = true; status = true;
} }
} }
@@ -274,15 +301,22 @@ function createReceiptNoInFirstBillData(receipt_no,payment) {
var json_data = []; var json_data = [];
if (localStorage.hasOwnProperty("receipt_lists") === true) { if (localStorage.hasOwnProperty("receipt_lists") === true) {
arr_data = JSON.parse(localStorage.getItem("receipt_lists")); arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); json_data = arr_data.filter(function (e) {
return e.receipt_no == receipt_no;
});
if (payment) { if (payment) {
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); jdata = arr_data.filter(function (e) {
jdata.push({'receipt_no':receipt_no,'payment':payment}); return e.receipt_no !== receipt_no;
});
jdata.push({ receipt_no: receipt_no, payment: payment });
localStorage.setItem("receipt_lists", JSON.stringify(jdata)); localStorage.setItem("receipt_lists", JSON.stringify(jdata));
} }
} }
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){ if (
arr_data.push({'receipt_no':receipt_no,'payment':payment}); (arr_data.length == 0 && json_data.length == 0) ||
(arr_data.length > 0 && json_data.length == 0)
) {
arr_data.push({ receipt_no: receipt_no, payment: payment });
localStorage.setItem("receipt_lists", JSON.stringify(arr_data)); localStorage.setItem("receipt_lists", JSON.stringify(arr_data));
} }
} }
@@ -290,7 +324,9 @@ function createReceiptNoInFirstBillData(receipt_no,payment) {
function deleteReceiptNoInFirstBillData(receipt_no) { function deleteReceiptNoInFirstBillData(receipt_no) {
if (localStorage.hasOwnProperty("receipt_lists") === true) { if (localStorage.hasOwnProperty("receipt_lists") === true) {
var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); var json_data = arr_data.filter(function (e) {
return e.receipt_no !== receipt_no;
});
localStorage.setItem("receipt_lists", JSON.stringify(json_data)); localStorage.setItem("receipt_lists", JSON.stringify(json_data));
} }
} }
@@ -299,40 +335,83 @@ function deleteReceiptNoInFirstBillData(receipt_no) {
//start CB ECR integration //start CB ECR integration
//set CB com port data //set CB com port data
function setCommPorts(comPortLists) { function setCommPorts(comPortLists) {
var sale_id = $('#sale_id').val(); var sale_id = $("#sale_id").val();
$('#com_port_name').html(""); $("#com_port_name").html("");
var jsonPortLists = $.parseJSON(comPortLists); var jsonPortLists = $.parseJSON(comPortLists);
// alert(jsonPortLists); // alert(jsonPortLists);
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){ if (
jsonPortLists != undefined &&
jsonPortLists != "" &&
jsonPortLists.length > 0
) {
$.each(jsonPortLists, function (key, value) { $.each(jsonPortLists, function (key, value) {
$('#com_port_name').append("<option value='"+value+"'>"+value+"</option>"); $("#com_port_name").append(
"<option value='" + value + "'>" + value + "</option>"
);
}); });
} } else {
else{ swal(
swal({ {
title: 'Oops', title: "Oops",
text: 'Payment device has been disconnected! Please plug it in.', text: "Payment device has been disconnected! Please plug it in.",
type: 'error', type: "error",
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false,
}, function () { },
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment"; function () {
}); window.location.href =
"/origami/sale/" +
sale_id +
"/" +
cashier_type +
"/payment/others_payment";
}
);
} }
} }
/** pay with CB bank **/ /** pay with CB bank **/
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) { function pay_withBank(
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
cashier_type
) {
$("#loading_wrapper").show(); $("#loading_wrapper").show();
var com_port = $("#com_port_name").val(); var com_port = $("#com_port_name").val();
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type); reqCardSaleTrans(
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
);
} }
//add req data to card_sale_trans table //add req data to card_sale_trans table
function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) { function reqCardSaleTrans(
var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port}; cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
) {
var jobj = {
cmd_type: cmd_type,
payment_type: "CARD",
amt: bnk_bill_amount,
sale_id: sale_id,
inv_no: receipt_no,
com_port: com_port,
};
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/origami/bank_integration/sale_trans", url: "/origami/bank_integration/sale_trans",
@@ -341,28 +420,56 @@ function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, rece
success: function (data) { success: function (data) {
if (data.status == "success") { if (data.status == "success") {
card_sale_trans_id = data.card_sale_trans_id; card_sale_trans_id = data.card_sale_trans_id;
resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type); resCardSaleTrans(
} card_sale_trans_id,
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
);
} }
},
}); });
} }
//add res data to card_sale_trans table //add res data to card_sale_trans table
function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) { function resCardSaleTrans(
card_sale_trans_id,
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
) {
var resMsg = ""; var resMsg = "";
var card_payment_type = ""; var card_payment_type = "";
if ($("#loading_wrapper").is(":visible")) { if ($("#loading_wrapper").is(":visible")) {
if(payment_type=="mpu" || payment_type=="visa" || payment_type=="master" || payment_type=="jcb" || payment_type=="unionpay"){ if (
payment_type == "mpu" ||
payment_type == "visa" ||
payment_type == "master" ||
payment_type == "jcb" ||
payment_type == "unionpay"
) {
card_payment_type = "CARD"; card_payment_type = "CARD";
} } else if (payment_type == "alipay") {
else if(payment_type == "alipay"){
card_payment_type = "EWALLET"; card_payment_type = "EWALLET";
} }
bnk_bill_amount = parseFloat(bnk_bill_amount); bnk_bill_amount = parseFloat(bnk_bill_amount);
resMsg = code2lab.reqBankPayment(cmd_type,card_payment_type,bnk_bill_amount,receipt_no,com_port); resMsg = code2lab.reqBankPayment(
cmd_type,
card_payment_type,
bnk_bill_amount,
receipt_no,
com_port
);
} }
if (resMsg.includes("STATUS")) { if (resMsg.includes("STATUS")) {
@@ -371,13 +478,27 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/origami/bank_integration/sale_trans", url: "/origami/bank_integration/sale_trans",
data: {type:"response", card_sale_trans_id: card_sale_trans_id, data: jobj}, data: {
type: "response",
card_sale_trans_id: card_sale_trans_id,
data: jobj,
},
dataType: "json", dataType: "json",
success: function (data) { success: function (data) {
if (data.status == "success") { if (data.status == "success") {
resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type); resCBPay(
} resMsg,
card_sale_trans_id,
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
);
} }
},
}); });
} else { } else {
if (payment_type != "master") { if (payment_type != "master") {
@@ -387,51 +508,87 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo
} }
$("#loading_wrapper").hide(); $("#loading_wrapper").hide();
swal({ swal(
title: 'Oops', {
title: "Oops",
text: resMsg.toString(), text: resMsg.toString(),
type: 'error', type: "error",
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false,
}, function () { },
function () {
var url_param = "payment"; var url_param = "payment";
if (location.pathname.includes("credit_payment")) { if (location.pathname.includes("credit_payment")) {
url_param = "credit_payment"; url_param = "credit_payment";
} }
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type; window.location.href =
}); "/origami/sale/" +
sale_id +
"/" +
cashier_type +
"/" +
url_param +
"/others_payment/" +
payment_type;
}
);
} }
} }
function resCBPay(
function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) { resMsg,
card_sale_trans_id,
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
) {
$("#loading_wrapper").hide(); $("#loading_wrapper").hide();
var jobj = $.parseJSON(resMsg); var jobj = $.parseJSON(resMsg);
$("#reference_no").val(jobj.REFNUM); $("#reference_no").val(jobj.REFNUM);
if (jobj.STATUS == "Approved") { if (jobj.STATUS == "Approved") {
$.ajax({type: "POST", $.ajax({
type: "POST",
url: "/origami/payment/" + payment_type, url: "/origami/payment/" + payment_type,
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM, data:
"amount=" +
bnk_bill_amount +
"&sale_id=" +
sale_id +
"&ref_no=" +
jobj.REFNUM,
success: function (result) { success: function (result) {
if (result) { if (result) {
swal({ swal(
{
title: "Information!", title: "Information!",
text: "Payment Successfully", text: "Payment Successfully",
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false,
}, function () { },
function () {
var url_param = "payment"; var url_param = "payment";
if (location.pathname.includes("credit_payment")) { if (location.pathname.includes("credit_payment")) {
url_param = "credit_payment"; url_param = "credit_payment";
} }
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/"+url_param; window.location.href =
}); "/origami/sale/" +
sale_id +
"/" +
cashier_type +
"/" +
url_param;
} }
);
} }
},
}); });
} else { } else {
if (payment_type != "master") { if (payment_type != "master") {
@@ -439,21 +596,32 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
} else { } else {
payment_type = "Master"; payment_type = "Master";
} }
swal({ swal(
title: 'Oops', {
text: "Transaction is " + (jobj.STATUS).toLowerCase(), title: "Oops",
type: 'error', text: "Transaction is " + jobj.STATUS.toLowerCase(),
type: "error",
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false,
}, function () { },
function () {
var url_param = "payment"; var url_param = "payment";
if (location.pathname.includes("credit_payment")) { if (location.pathname.includes("credit_payment")) {
url_param = "credit_payment"; url_param = "credit_payment";
} }
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type; window.location.href =
}); "/origami/sale/" +
sale_id +
"/" +
cashier_type +
"/" +
url_param +
"/others_payment/" +
payment_type;
}
);
} }
} }
//end CB ECR integration //end CB ECR integration
@@ -489,17 +657,17 @@ function createAccessCode(code) {
function getAllMenu() { function getAllMenu() {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: '/origami/get_all_menu', url: "/origami/get_all_menu",
data: {}, data: {},
success: function (result) { success: function (result) {
console.log(result) console.log(result);
localStorage.setItem("menus", JSON.stringify(result)); localStorage.setItem("menus", JSON.stringify(result));
var menu = localStorage.getItem("menus"); var menu = localStorage.getItem("menus");
if (menu != null) { if (menu != null) {
$("#loading_wrapper").hide(); $("#loading_wrapper").hide();
} }
} },
}); });
} }
@@ -510,9 +678,16 @@ if (!String.prototype.formatUnicorn) {
if (!arguments.length) { if (!arguments.length) {
return e; return e;
} }
var t=typeof arguments[0],n="string"==t||"number"==t?Array.prototype.slice.call(arguments):arguments[0]; var t = typeof arguments[0],
n =
"string" == t || "number" == t
? Array.prototype.slice.call(arguments)
: arguments[0];
for (var i in n) { for (var i in n) {
e=e.replace(new RegExp("\\{"+i+"\\}","gi"),n[i]==null?'':n[i]); e = e.replace(
new RegExp("\\{" + i + "\\}", "gi"),
n[i] == null ? "" : n[i]
);
} }
return e; return e;
}; };
@@ -523,9 +698,13 @@ if (!String.prototype.formatUnicorn) {
function timeFormat(date) { function timeFormat(date) {
var isPM = date.getHours() >= 12; var isPM = date.getHours() >= 12;
var isMidday = date.getHours() == 12; var isMidday = date.getHours() == 12;
var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0), var time =
(date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') + [
(isPM ? ' PM' : ' AM'); (date.getHours() > 10 ? date.getHours() : "0" + date.getHours()) -
(isPM && !isMidday ? 12 : 0),
(date.getMinutes() > 10 ? date.getMinutes() : "0" + date.getMinutes()) ||
"00",
].join(":") + (isPM ? " PM" : " AM");
return time; return time;
} }
@@ -535,10 +714,10 @@ function getCreditData(cashier_type){
var receipt_no = ""; var receipt_no = "";
var customer_id = ""; var customer_id = "";
if((filter!=undefined) && (filter!=null) && (filter!="")){ if (filter != undefined && filter != null && filter != "") {
receipt_no = filter; receipt_no = filter;
} }
if((customer!=undefined) && (customer!=null) && (customer!="")){ if (customer != undefined && customer != null && customer != "") {
customer_id = customer; customer_id = customer;
} }
getCreditSales(receipt_no, customer_id, cashier_type); getCreditSales(receipt_no, customer_id, cashier_type);
@@ -550,16 +729,16 @@ function getCreditSales(filter, customer, cashier_type){
var html_credit_items = $("#html_credit_items").html(); var html_credit_items = $("#html_credit_items").html();
var receipt_no = ""; var receipt_no = "";
var customer_id = ""; var customer_id = "";
if((filter!=undefined) && (filter!=null) && (filter!="")){ if (filter != undefined && filter != null && filter != "") {
receipt_no = filter; receipt_no = filter;
} }
if((customer!=undefined) && (customer!=null) && (customer!="")){ if (customer != undefined && customer != null && customer != "") {
customer_id = customer; customer_id = customer;
} }
$.ajax({ $.ajax({
type: "POST", type: "POST",
data: { receipt_no: receipt_no, customer_id: customer_id }, data: { receipt_no: receipt_no, customer_id: customer_id },
dataType: 'json', dataType: "json",
url: "/origami/" + cashier_type + "/credit_sales", url: "/origami/" + cashier_type + "/credit_sales",
success: function (data) { success: function (data) {
// console.log(data); // console.log(data);
@@ -570,23 +749,34 @@ function getCreditSales(filter, customer, cashier_type){
$(".credit_items").show(); $(".credit_items").show();
for (var i = 0; i < credit_sales.length; i++) { for (var i = 0; i < credit_sales.length; i++) {
var sale_date = new Date(credit_sales[i].sale_date); var sale_date = new Date(credit_sales[i].sale_date);
var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? (sale_date.getMonth()+1) : '0' + (sale_date.getMonth()+1)) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate()); var receipt_date =
$('.tbd_credit_lists').append(html_credit_items.formatUnicorn({ sale_date.getFullYear() +
'key':i, "-" +
'sale_id':credit_sales[i].sale_id, (sale_date.getMonth() > 10
'receipt_date':receipt_date +" "+timeFormat(sale_date), ? sale_date.getMonth() + 1
'receipt_no':credit_sales[i].receipt_no, : "0" + (sale_date.getMonth() + 1)) +
'cashier_name':credit_sales[i].cashier_name, "-" +
'customer_name':credit_sales[i].customer_name, (sale_date.getDate() > 10
'credit_amount':credit_sales[i].payment_amount, ? sale_date.getDate()
'cashier_type':cashier_type : "0" + sale_date.getDate());
})); $(".tbd_credit_lists").append(
html_credit_items.formatUnicorn({
key: i,
sale_id: credit_sales[i].sale_id,
receipt_date: receipt_date + " " + timeFormat(sale_date),
receipt_no: credit_sales[i].receipt_no,
cashier_name: credit_sales[i].cashier_name,
customer_name: credit_sales[i].customer_name,
credit_amount: credit_sales[i].payment_amount,
cashier_type: cashier_type,
})
);
} }
} }
} else { } else {
$(".tbd_credit_lists").html(data.message); $(".tbd_credit_lists").html(data.message);
} }
} },
}); });
} }
//End of credit sales function //End of credit sales function

View File

@@ -1,7 +1,7 @@
class Foodcourt::VoidController < BaseFoodcourtController class Foodcourt::VoidController < BaseFoodcourtController
authorize_resource :class => false authorize_resource :class => false
def overall_void
def overall_void
sale_id = params[:sale_id] sale_id = params[:sale_id]
remark = params[:remark] remark = params[:remark]
order_source = params[:type] #tax profile source order_source = params[:type] #tax profile source
@@ -33,32 +33,10 @@ class Foodcourt::VoidController < BaseFoodcourtController
sale.sale_status = 'void' sale.sale_status = 'void'
sale.save sale.save
if sale.bookings[0].dining_facility_id.to_i > 0 if table = sale.booking.dining_facility
table_avaliable = true unless table.current_bookings.exists?
table_count = 0 table.update_attributes(status: 'available')
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end end
else
table_avaliable = false
table_count += 1
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end end
# FOr Sale Audit # FOr Sale Audit
@@ -102,6 +80,8 @@ class Foodcourt::VoidController < BaseFoodcourtController
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.current_shop
# get member information # get member information
rebate = MembershipSetting.find_by_rebate(1) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
@@ -132,7 +112,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -96,22 +96,25 @@ class HomeController < ApplicationController
def dashboard def dashboard
@from, @to = get_date_range_from_params @from, @to = get_date_range_from_params
@shop = Shop.current_shop
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'") @orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
@sales = Sale.receipt_date_between(@from, @to).completed @sales = Sale.receipt_date_between(@from, @to).completed
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user) if shift = ShiftSale.current_open_shift(current_user.id)
@orders = @orders.where(shift_sale_id: shift.id) @orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id) @sales = @sales.where(shift_sale_id: shift.id)
end end
end end
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top")
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top",current_shop) @bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom")
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom",current_shop) @hourly_sales = Sale.hourly_sales(current_user,@from,@to)
@hourly_sales = Sale.hourly_sales(current_user,@from,@to,current_shop) # .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
employee_sales = Sale.employee_sales(current_user,@from,@to,current_shop) # .sum(:grand_total)
employee_sales = Sale.employee_sales(current_user,@from,@to)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
@employee_sales = [] @employee_sales = []
if !employee_sales.nil? if !employee_sales.nil?
employee_sales.each do |emp| employee_sales.each do |emp|
@@ -123,12 +126,11 @@ class HomeController < ApplicationController
end end
end end
end end
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance) @inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
@total_trans = Sale.total_trans(current_user,@from,@to) @total_trans = Sale.total_trans(current_user,@from,@to)
@total_card = Sale.total_card_sale(current_user,@from,@to) @total_card = Sale.total_card_sale(current_user,@from,@to)
@total_credit = Sale.credit_payment(current_user,@from,@to, current_shop) @total_credit = Sale.credit_payment(current_user,@from,@to)
@sale_data = Array.new @sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to) @total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
@@ -144,12 +146,11 @@ class HomeController < ApplicationController
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to) @total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
# @total_other_customer = Sale.total_other_customer(today,current_user) # @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(current_user,@from,@to, current_shop) @total_order = Sale.total_order(current_user,@from,@to)
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title") @total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new @account_data = Array.new
if !@total_accounts.nil? if !@total_accounts.nil?
@total_accounts.each do |account| @total_accounts.each do |account|
acc = Sale.account_data(account.account_id,current_user,@from,@to) acc = Sale.account_data(account.account_id,current_user,@from,@to)
if !acc.nil? && acc.cnt_acc > 0 if !acc.nil? && acc.cnt_acc > 0
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
@@ -162,7 +163,7 @@ class HomeController < ApplicationController
@total_foc_items = Sale.total_foc_items(current_user,@from,@to) @total_foc_items = Sale.total_foc_items(current_user,@from,@to)
# get printer info # get printer info
# @print_settings = get_precision_delimiter @print_settings = PrintSetting.get_precision_delimiter()
end end
def destroy def destroy

View File

@@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
path = request.fullpath path = request.fullpath
if path.include? ("credit_payment") if path.include? ("credit_payment")
@payment_method_setting = PaymentMethodSetting.where("LOWER(payment_method) in ('mpu','visa','master','jcb','unionpay','alipay') and is_active='1'") @payment_method_setting = PaymentMethodSetting.where("is_active='1'")
else else
@payment_method_setting = PaymentMethodSetting.all @payment_method_setting = PaymentMethodSetting.all
end end
@@ -39,7 +39,92 @@ class Origami::OthersPaymentsController < BaseOrigamiController
# end # end
end end
def new
@sale_id = params[:sale_id]
@cashier_type = params[:type]
payment_methods = PaymentMethodSetting.pluck(:payment_method)
if @payment_method = payment_methods.find { |m| m.parameterize == params[:method] }
path = request.fullpath
# limit master_amount
if path.include? ("credit_payment")
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
else
sale_data = Sale.find_by_sale_id(@sale_id)
end
total = 0
@shop = Shop.current_shop
@paid_amount = 0
@can_paid = 0
@rounding_adj = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
if path.include? ("credit_payment")
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
else
sale_payment_data = sale_data.sale_payments
end
sale_payment_data.each do |sale_payment|
if sale_payment.payment_method == @payment_method.parameterize
@paid_amount = @paid_amount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_paid = total - @paid_amount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
else
if path.include? ("credit_payment")
redirect_to "sale/#{@sale_id}/#{@cashier_type}/payment/others_payment"
else
redirect_to "sale/#{@sale_id}/#{@cashier_type}/credit_payment/others_payment"
end
end
end
def create def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
payment_method = params[:method]
if PaymentMethodSetting.pluck(:payment_method).map(&:parameterize).include? payment_method
if saleObj = Sale.find(sale_id)
shop_details = Shop.current_shop
path = request.fullpath
payment_for = false
if path.include? ("credit_payment")
payment_for = true
end
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, payment_method, ref_no, payment_for)
end
end
end end
end end

View File

@@ -51,7 +51,8 @@ class Origami::PaymentsController < BaseOrigamiController
#TODO :: KBZPAY ( QR ) #TODO :: KBZPAY ( QR )
# On/Off setting ( show or not qr ) # On/Off setting ( show or not qr )
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD" # qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
.where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
status = false status = false
qr = nil qr = nil
@@ -193,7 +194,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
#card_balance amount for Paymal payment #card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info # get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
@@ -209,7 +210,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
#end #end
@@ -232,15 +233,29 @@ class Origami::PaymentsController < BaseOrigamiController
# end # end
def show def show
@sale = Sale.find(params[:sale_id])
@shop = Shop.current_shop
@customer = @sale.customer
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
@member_discount = MembershipSetting.find_by_discount(1)
if dining_facility = @sale.booking.dining_facility
@table_no = dining_facility.type + ' ' + dining_facility.name
@checkin_time = @sale.booking.checkin_at
@dining = dining_facility
end
display_type = Lookup.find_by_lookup_type("display_type") display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2 if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value @display_type = display_type.value
else else
@display_type = nil @display_type = nil
end end
path = request.fullpath path = request.fullpath
sale_id = params[:sale_id]
@trans_flag = true @trans_flag = true
if params[:type] == "transaction" if params[:type] == "transaction"
@trans_flag = false @trans_flag = false
@cashier_type = "cashier" @cashier_type = "cashier"
@@ -248,43 +263,29 @@ class Origami::PaymentsController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
end end
if path.include? ("credit_payment") if path.include? 'credit_payment'
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount") @sale_payment = false
@amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method == 'paypar' ? 'redeem' : method, payments.sum { |payment| payment.payment_amount }] }
else
@sale_payment = true
@amount_due = @sale.grand_total
payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method == 'paypar' ? 'redeem' : method, payments.sum { |payment| payment.payment_amount }] }
end end
@member_discount = MembershipSetting.find_by_discount(1) @payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
@membership_rebate_balance=0 @cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
@credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
@other_payments = payments.select { |payment| !['cash', 'creditnote', 'foc'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
@other_payment = @other_payments.sum { |payment| payment[1] }
if Sale.exists?(sale_id) #total customer with individual total amount
@cash = 0.0 @individual_total = Array.new
@kbz_pay_amount = 0.0 if !@sale.equal_persons.nil?
@other = 0.0 per_person_amount = @sale.grand_total / @sale.equal_persons.to_i
@ppamount = 0.0 @individual_total.push({'total_customer' => @sale.equal_persons.to_i, 'per_person_amount' => per_person_amount })
@visacount= 0.0
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@alipaycount = 0.0
@junctionpaycount = 0.0
@credit = 0.0
@paymalcount = 0.0
@dingacount = 0.0
@giftvouchercount = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0
@accountable_type = ''
@table_no = ''
@dining = ''
@other_payment = 0.0
@pdf_view = nil
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
end end
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
@kbz_pay_amount += amount.to_f
#for changable on/off #for changable on/off
@changable_tax = true @changable_tax = true
lookup_changable_tax = Lookup.collection_of('changable_tax') lookup_changable_tax = Lookup.collection_of('changable_tax')
@@ -298,19 +299,18 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
# @shop = shop_detail #show shop info # get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"]) @pdf_view = nil
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
saleObj = Sale.find(sale_id) if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
#total customer with individual total amount
@individual_total = Array.new
if !saleObj.equal_persons.nil?
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
end end
# amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
# @kbz_pay_amount += amount.to_f
# rounding adjustment # rounding adjustment
# if @shop.is_rounding_adj # if @shop.is_rounding_adj
# a = saleObj.grand_total % 25 # Modulus # a = saleObj.grand_total % 25 # Modulus
@@ -320,6 +320,10 @@ class Origami::PaymentsController < BaseOrigamiController
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) # if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
# @rounding_adj = new_total-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)
# @sale_data.grand_total = new_total
# @sale_data.old_grand_total = saleObj.grand_total
# @sale_data.rounding_adjustment = @rounding_adj
# else # else
# @rounding_adj = @sale_data.rounding_adjustment # @rounding_adj = @sale_data.rounding_adjustment
# end # end
@@ -328,49 +332,29 @@ class Origami::PaymentsController < BaseOrigamiController
# end # end
#end rounding adjustment #end rounding adjustment
# rounding adjustment
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
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)
@sale_data.grand_total = new_total
@sale_data.old_grand_total = saleObj.grand_total
@sale_data.rounding_adjustment = @rounding_adj
else
@rounding_adj = @sale_data.rounding_adjustment
end
else
@rounding_adj = @sale_data.rounding_adjustment
end
#end rounding adjustment
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# accounts = @customer.tax_profiles # accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC") accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[] @account_arr =[]
@tax_arr =[] @tax_arr =[]
accounts.each do |acc| accounts.each do |acc|
account = TaxProfile.find(acc.id) account = TaxProfile.find(acc.id)
# @account_arr.push(account) # @account_arr.push(account)
@tax_arr.push(account.name) @tax_arr.push(account.name)
end end
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
sale_taxes = @sale.sale_taxes
if !sale_taxes.empty? if !sale_taxes.empty?
sale_taxes.each do |sale_tax| sale_taxes.each do |sale_tax|
@account_arr.push(sale_tax) @account_arr.push(sale_tax)
end end
end end
rebate = MembershipSetting.find_by_rebate(1) rebate = MembershipSetting.find_by_rebate(1)
# get member information # get member information
@balance = 0
@accountable_type = ''
if @customer.membership_id != nil && rebate if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer) response = Customer.get_member_account(@customer)
if response["status"]==true if response["status"]==true
@@ -383,66 +367,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
end end
#end customer amount #end customer amount
#paymal payment
@sale_data.bookings.each do |sbk|
if sbk.dining_facility_id.to_i >0
df = DiningFacility.find(sbk.dining_facility_id)
@table_no = df.type + ' ' + df.name
@checkin_time = sbk.checkin_at
@dining = df
break
else
@table_no = nil
@checkin_time = nil
@dining = nil
end
end
if path.include? ("credit_payment")
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
else
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
end
@sale_payment_data.each do |spay|
if spay.payment_method == "cash"
@cash += spay.payment_amount
end
if spay.payment_method !="creditnote"
@other_payment += spay.payment_amount
end
if spay.payment_method == "mpu"
@other += spay.payment_amount
elsif spay.payment_method == "paypar"
@ppamount += spay.payment_amount
elsif spay.payment_method == "visa"
@visacount += spay.payment_amount
elsif spay.payment_method == "jcb"
@jcbcount += spay.payment_amount
elsif spay.payment_method == "master"
@mastercount += spay.payment_amount
elsif spay.payment_method == "unionpay"
@unionpaycount += spay.payment_amount
elsif spay.payment_method == "JunctionPay"
@junctionpaycount += spay.payment_amount
elsif spay.payment_method == "creditnote"
@credit += spay.payment_amount
elsif spay.payment_method == "paymal"
@paymalcount += spay.payment_amount
elsif spay.payment_method == "alipay"
@alipaycount += spay.payment_amount
elsif spay.payment_method == "dinga"
@dingacount += spay.payment_amount
elsif spay.payment_method == "giftvoucher"
@giftvouchercount += spay.payment_amount
end
end
end
end end
def reprint def reprint
@@ -465,7 +390,7 @@ class Origami::PaymentsController < BaseOrigamiController
# else # else
# table = DiningFacility.find(bookings[0].dining_facility_id) # table = DiningFacility.find(bookings[0].dining_facility_id)
# end # end
shift = ShiftSale.current_open_shift(current_user) shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil? if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else else
@@ -496,7 +421,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id) customer= Customer.find(saleObj.customer_id)
#shop detail #shop detail
#shop_detail = @shop #shop_detail = Shop.current_shop
# get member information # get member information
rebate = MembershipSetting.find_by_rebate(1) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
@@ -519,7 +444,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
#card_balance amount for Paymal payment #card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -531,7 +456,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
result = { result = {
:status => true, :status => true,
@@ -581,7 +506,7 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone # For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'") bookings = Booking.where("sale_id='#{sale_id}'")
shift = ShiftSale.current_open_shift(current_user) shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil? if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else else
@@ -603,8 +528,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id) customer= Customer.find(saleObj.customer_id)
#shop detail #shop detail
#shop_detail = Shop.current_shop
#shop_detail = @shop
printer = PrintSetting.all printer = PrintSetting.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
@@ -629,7 +553,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil)
result = { result = {
:status => true, :status => true,
:filepath => filename, :filepath => filename,
@@ -663,8 +587,9 @@ class Origami::PaymentsController < BaseOrigamiController
def rounding_adj def rounding_adj
saleObj = Sale.find(params[:sale_id]) saleObj = Sale.find(params[:sale_id])
@shop = current_shop
if current_shop.is_rounding_adj if @shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #not calculate rounding if modulus is 0 and division is even

View File

@@ -1,10 +1,12 @@
class Origami::VoidController < BaseOrigamiController class Origami::VoidController < BaseOrigamiController
authorize_resource :class => false authorize_resource :class => false
def overall_void def overall_void
sale_id = params[:sale_id] sale_id = params[:sale_id]
remark = params[:remark] remark = params[:remark]
order_source = params[:type] #tax profile source order_source = params[:type] #tax profile source
access_code = params[:access_code] access_code = params[:access_code]
if Sale.exists?(sale_id) if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id) sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount" if sale.discount_type == "member_discount"
@@ -41,32 +43,10 @@ class Origami::VoidController < BaseOrigamiController
# end # end
# end # end
if sale.bookings[0].dining_facility_id.to_i > 0 if table = sale.booking.dining_facility
table_avaliable = true unless table.current_bookings.exists?
table_count = 0 table.update_attributes(status: 'available')
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end end
else
table_avaliable = false
table_count += 1
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end end
# FOr Sale Audit # FOr Sale Audit
@@ -113,6 +93,9 @@ class Origami::VoidController < BaseOrigamiController
# end # end
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.current_shop
# get member information # get member information
rebate = MembershipSetting.find_by_rebate(1) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
@@ -143,7 +126,7 @@ class Origami::VoidController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -1,27 +1,30 @@
class Reports::PaymentMethodController < BaseReportController class Reports::PaymentMethodController < BaseReportController
# authorize_resource :class => false # authorize_resource :class => false
def index def index
@payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"],
["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"], @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
["Alipay Payment","alipay"],["Card Payment", "paymal"],["Dinga Payment","dinga"], @payments = [["All",''], ["Cash","cash"], ["Card", "card"], ["Credit","creditnote"],
["JunctionPay","junctionpay"],["Redeem Payment","paypar"],["Gift Voucher","giftvoucher"]] ["FOC","foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
# @payment_methods.each do |m|
# @payments.push(["#{m} Payment", m.parameterize])
# end
from, to = get_date_range_from_params from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = '' @shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
@payment_type = params[:payment_type] @payment_type = params[:payment_type]
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type) @sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift,from,to,@payment_type)
@from = from @from = from
@to = to @to = to
# get printer info # get printer info

View File

@@ -1,15 +1,14 @@
class Reports::ReceiptNoDetailController < BaseReportController class Reports::ReceiptNoDetailController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payment_methods = [["All", ''], ["Cash", "cash"], ["Card", "card"], ["Credit", "creditnote"], ["FOC", "foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
@payment_method = PaymentMethodSetting.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
@shift_sale_range = '' @shift_sale_range = ''
@shift = '' @shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift_sale = ShiftSale.find(params[:shift_name]) @shift_sale = ShiftSale.find(params[:shift_name])
@@ -17,18 +16,16 @@ authorize_resource :class => false
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else else
if @shift_sale.shift_closed_at.blank? if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end end
end end
end end
payment_type = params[:payment_type] payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type) @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
@from = from @from = from
@to = to @to = to
# get printer info # get printer info

View File

@@ -26,7 +26,6 @@ class Reports::ShiftsaleController < BaseReportController
end end
def show def show
from, to = get_date_range_from_params from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@@ -50,7 +49,6 @@ class Reports::ShiftsaleController < BaseReportController
end end
def print_close_receipt def print_close_receipt
shift_id = params[:id] shift_id = params[:id]
@shift = ShiftSale.find_by_id(shift_id) @shift = ShiftSale.find_by_id(shift_id)
shift_obj = ShiftSale.where('id =?',shift_id) shift_obj = ShiftSale.where('id =?',shift_id)
@@ -82,6 +80,7 @@ class Reports::ShiftsaleController < BaseReportController
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card #other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift) @other_payment = ShiftSale.get_by_shift_other_payment(@shift)
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# Calculate price_by_accounts # Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@@ -97,7 +96,7 @@ class Reports::ShiftsaleController < BaseReportController
printer = Printer::CashierStationPrinter.new(print_settings) printer = Printer::CashierStationPrinter.new(print_settings)
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) # printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, current_shops,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods)
respond_to do |format| respond_to do |format|
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'} format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}

View File

@@ -5,13 +5,12 @@ class Transactions::ShiftSalesController < ApplicationController
def index def index
filter = params[:filter] filter = params[:filter]
from = params[:from] from = params[:from]
to = params[:to] to = params[:to]
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
@shift_sales = ShiftSale.order("id desc") @shift_sales = ShiftSale.all.order("id desc")
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
else else
shift_sale = ShiftSale.search(filter,from,to) shift_sale = ShiftSale.search(filter,from,to)
@@ -40,15 +39,13 @@ class Transactions::ShiftSalesController < ApplicationController
shift_obj = ShiftSale.where('id =?',@shift.id) shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card #other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift) @other_payment = ShiftSale.get_by_shift_other_payment(@shift).first
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
# Calculate price_by_accounts # Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift) @total_member_discount = ShiftSale.get_total_member_discount(@shift)
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb
format.json { render json: @shift } format.json { render json: @shift }

View File

@@ -35,7 +35,10 @@ class Sale < ApplicationRecord
scope :completed, -> { where(sale_status: 'completed') } scope :completed, -> { where(sale_status: 'completed') }
scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) } scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) }
scope :along_with_sale_payments_except_void_between, -> (from, to) { joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to])) } scope :sale_payments_with_audit_except_void_between, -> (from, to) do
joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to]))
.joins("LEFT JOIN sale_audits ON sale_audits.sale_id = sale_payments.sale_id AND SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id")
end
def qty_of(item_instance_code) def qty_of(item_instance_code)
order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first
@@ -789,28 +792,15 @@ class Sale < ApplicationRecord
end end
def self.daily_sales_list(from,to) def self.daily_sales_list(from,to)
sales = select(" payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sales.*,
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount, sales = select(Sale.column_names)
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, .select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.push('').join(', ')}
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote') SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) -
then sale_payments.payment_amount else 0 end) < sales.grand_total SUM(case when (sale_payments.payment_method not in('creditnote') and sale_audits.sale_audit_id IS NOT NULL) then sale_payments.payment_amount else 0 end) as credit_amount,
THEN sales.grand_total - SUM(case when sale_payments.payment_method not in('creditnote')
then sale_payments.payment_amount else 0 end)
ELSE 0 END as credit_amount,
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
.along_with_sale_payments_except_void_between(from, to) .sale_payments_with_audit_except_void_between(from, to)
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to) .where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
.group("sale_id").to_sql .group("sale_id").to_sql
@@ -826,26 +816,14 @@ def self.daily_sales_list(from,to)
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) - (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale, (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) - (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale, (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
SUM(kbzpay_amount) as kbzpay_amount, #{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(#{pm}) as #{pm}"}.push('').join(', ')}
SUM(mpu_amount) as mpu_amount,
SUM(master_amount) as master_amount,
SUM(visa_amount) as visa_amount,
SUM(jcb_amount) as jcb_amount,
SUM(paypar_amount) as paypar_amount,
SUM(unionpay_amount) as unionpay_amount,
SUM(alipay_amount) as alipay_amount,
SUM(paymal_amount) as paymal_amount,
SUM(dinga_amount) as dinga_amount,
SUM(junctionpay_amount) as junctionpay_amount,
SUM(cash_amount) as cash_amount, SUM(cash_amount) as cash_amount,
SUM(credit_amount) as credit_amount, SUM(credit_amount) as credit_amount,
SUM(giftvoucher_amount) as giftvoucher_amount,
SUM(foc_amount) as foc_amount SUM(foc_amount) as foc_amount
FROM ( FROM (
#{sales} #{sales}
) as s ) as s
GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys) GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
return daily_total return daily_total
end end
@@ -1013,6 +991,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
other_charges = self.get_other_charges() other_charges = self.get_other_charges()
end end
product = self.get_product_sale() product = self.get_product_sale()
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
if shift.present? if shift.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
@@ -1022,7 +1001,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1045,7 +1024,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1069,7 +1048,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1100,6 +1079,8 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
customer_id = customer_id.to_s customer_id = customer_id.to_s
customer_id[0] = "" customer_id[0] = ""
customer_id = customer_id.chomp("]") customer_id = customer_id.chomp("]")
else
customer_id = "''"
end end
query = self.get_staff_meal_query() query = self.get_staff_meal_query()
@@ -1116,6 +1097,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
# other_charges = self.get_other_charges() # other_charges = self.get_other_charges()
# end # end
product = self.get_product_sale() product = self.get_product_sale()
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
if shift.present? if shift.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN (#{customer_id})",shift.to_a) query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN (#{customer_id})",shift.to_a)
@@ -1125,7 +1107,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1148,7 +1130,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1172,7 +1154,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1383,20 +1365,12 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
end end
end end
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type) def self.get_payment_method_by_shift(shift,from,to,payment_type)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
payments_total = SalePayment.select(" payments_total = SalePayment.select("
sales.receipt_date as sale_date, sales.receipt_date as sale_date,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, #{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.join(', ')},
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='cash') then SUM(case when (sale_payments.payment_method='cash') then
sales.amount_changed else 0 end) as total_change_amount, sales.amount_changed else 0 end) as total_change_amount,
@@ -1424,13 +1398,14 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
if shift.present? if shift.present?
payments_total = payments_total.where(sales: {shift_sale_id: shift.to_a}) payments_total = payments_total.where(sales: {shift_sale_id: shift.to_a})
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift.to_a})) sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift.to_a}))
elsif shift_sale_range.present?
payments_total = payments_total.where(sales: {shift_sale_id: shift_sale_range.to_a})
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift_sale_range.to_a}))
end end
if payment_type.present? if payment_type.present?
sale_payment = sale_payment.where(payment_method: payment_type) if payment_type == 'card'
sale_payment = sale_payment.where(sanitize_sql_array(["payment_method IN (?)", SalePayment::CARD]))
else
sale_payment = sale_payment.where("payment_method = (?)", payment_type)
end
end end
return payments_total, sale_payment return payments_total, sale_payment
@@ -1502,7 +1477,7 @@ end
end end
def self.top_bottom_products(current_user,from,to,type,current_shop) def self.top_bottom_products(current_user,from,to,type)
query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
.completed .completed
.where("qty > 0 AND price > 0") .where("qty > 0 AND price > 0")
@@ -1531,7 +1506,7 @@ end
end end
def self.hourly_sales(current_user,from,to, current_shop) def self.hourly_sales(current_user,from,to)
query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '#{Time.zone.formatted_offset}'), '%I %p')") query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '#{Time.zone.formatted_offset}'), '%I %p')")
.order('receipt_date').completed .order('receipt_date').completed
@@ -1551,19 +1526,18 @@ end
end end
def self.employee_sales(current_user,from,to, current_shop) def self.employee_sales(current_user,from,to)
shift = if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') shift = if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
ShiftSale.current_open_shift(current_user) ShiftSale.current_open_shift(current_user.id)
end end
payments_for_credits = SalePayment.joins(:sale_audit).to_sql payments_for_credits = SalePayment.joins(:sale_audit).to_sql
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
query = employee_sale(shift, from, to)
query = employee_sale(shift, from, to, current_shop)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id") .joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount, .select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount,
CASE WHEN sale_payments.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' CASE WHEN sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card'
ELSE sale_payments.payment_method END AS payment_method, employees.name AS e_name") ELSE sale_payments.payment_method END AS payment_method, employees.name AS e_name")
end end
@@ -1590,18 +1564,18 @@ end
def self.total_card_sale(current_user=nil,from=nil,to=nil) def self.total_card_sale(current_user=nil,from=nil,to=nil)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
query = Sale.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.where('sales.sale_status = "completed" and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")') .where("sales.sale_status = 'completed' and (sp.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }))")
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user) if shift = ShiftSale.current_open_shift(current_user.id)
query = query.where("sales.shift_sale_id = ?", shift.id) query = query.where("sales.shift_sale_id = ?", shift.id)
end end
end end
@@ -1610,7 +1584,7 @@ end
end end
def self.credit_payment(current_user=nil,from=nil,to=nil, current_shop) def self.credit_payment(current_user=nil,from=nil,to=nil)
payments_for_credits = SalePayment.joins(:sale_audit).to_sql payments_for_credits = SalePayment.joins(:sale_audit).to_sql
@@ -1831,7 +1805,7 @@ end
# end # end
def self.total_order(current_user=nil,from=nil,to=nil, current_shop) def self.total_order(current_user=nil,from=nil,to=nil)
query = Sale.select("count(distinct sale_orders.order_id) as total_order") query = Sale.select("count(distinct sale_orders.order_id) as total_order")
.joins(:sale_orders) .joins(:sale_orders)
@@ -2054,7 +2028,7 @@ def unique_tax_profiles(order_source, customer_id)
end end
def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, current_shop) def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
query = Sale.joins(:cashier) query = Sale.joins(:cashier)
.joins(:sale_payments) .joins(:sale_payments)
@@ -2114,6 +2088,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
other_charges = self.get_other_charges() other_charges = self.get_other_charges()
end end
product = self.get_product_sale() product = self.get_product_sale()
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
if shift.present? if shift.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
@@ -2123,7 +2098,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -2146,7 +2121,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -2170,7 +2145,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -2330,8 +2305,9 @@ def self.get_daily_sale_data(transaction_date)
end end
def self.get_check_sale_data(transaction_date) def self.get_check_sale_data(transaction_date)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sale_receivables_subquery = "SELECT sale_payments.sale_id, sale_receivables_subquery = "SELECT sale_payments.sale_id,
CASE WHEN sale_payments.payment_method = 'mpu' OR sale_payments.payment_method = 'visa' OR sale_payments.payment_method = 'master' OR sale_payments.payment_method = 'jcb' OR sale_payments.payment_method = 'paypar' OR sale_payments.payment_method = 'unionpay' OR sale_payments.payment_method = 'alipay' OR sale_payments.payment_method = 'paymal' OR sale_payments.payment_method = 'dinga' OR sale_payments.payment_method = 'JunctionPay' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as credit_card_sales, SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as credit_card_sales,
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
FROM sale_payments FROM sale_payments
GROUP BY sale_payments.sale_id, sale_payments.payment_method" GROUP BY sale_payments.sale_id, sale_payments.payment_method"

View File

@@ -132,13 +132,13 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_f - tax.to_f self.commercial_taxes = self.commercial_taxes.to_f - tax.to_f
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
self.total_void = self.total_void + saleobj.grand_total self.total_void = self.total_void + saleobj.grand_total
if saleobj.customer.customer_type == "Dinein" if saleobj.customer.customer_type == "Dinein"
self.dining_count = self.dining_count - 1 self.dining_count = self.dining_count - 1
else else
self.takeaway_count = self.takeaway_count - 1 self.takeaway_count = self.takeaway_count - 1
end end
self.save self.save
end end
end end

View File

@@ -82,7 +82,7 @@ class ReceiptBillPdf < Prawn::Document
end end
#end card sale trans data #end card sale trans data
#start card blanace amount #start card blanace amount
if !card_balance_amount.nil? && card_balance_amount >0 if !card_balance_amount.nil?
card_balance_data(card_balance_amount) card_balance_data(card_balance_amount)
card_transaction_ref(transaction_ref) card_transaction_ref(transaction_ref)
end end

View File

@@ -189,9 +189,8 @@
<td align="right"><%= @summ_sale.total_receipt %></td> <td align="right"><%= @summ_sale.total_receipt %></td>
</tr> </tr>
<tr> <tr>
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%> <% revenue = @summ_sale.grand_total - @summ_sale.total_discount - @summ_sale.total_tax %>
<td><%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : </td> <td><%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : </td>
<td align="right"><%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %></td> <td align="right"><%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr> </tr>
<tr> <tr>
@@ -210,8 +209,8 @@
<table class="table"> <table class="table">
<% if !(@total_payment_methods.nil?) %> <% if !(@total_payment_methods.nil?) %>
<% @total_payment_methods.each do |payment| %> <% @total_payment_methods.each do |payment| %>
<% if !@sale_data[0].empty? %>
<% if payment.payment_method != 'card' %> <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
<tr> <tr>
<% if payment.payment_method == 'paypar' %> <% if payment.payment_method == 'paypar' %>
<td>Redeem Sale : </td> <td>Redeem Sale : </td>
@@ -219,24 +218,27 @@
<td><%= payment.payment_method.to_s.capitalize %> Sale : </td> <td><%= payment.payment_method.to_s.capitalize %> Sale : </td>
<% end %> <% end %>
<td align="right"> <td align="right">
<%= number_format(@sale_data.find {|x| x.key?(payment.payment_method) }[payment.payment_method], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> <% @sale_data.each do |data| %>
<% pay_mth = payment.payment_method %>
<%= data[""+pay_mth+""] %>
<% end %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
<% end %> <% end %>
<% end %>
<% total_card = @sale_data.find {|x| x.key?("card") } %> <% total_card = @sale_data.select { |hash| hash["card"]!=nil } %>
<% if !total_card.nil? %> <% if !total_card.nil? %>
<tr> <tr>
<td><%= t("views.right_panel.detail.other_payment") %> : </td> <td><%= t("views.right_panel.detail.other_payment") %> : </td>
<td align="right"> <td align="right">
<% total_other_amt = 0 %>
<%= number_format(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> <% @sale_data.map { |k,v| k.map{|meth,amt| meth != 'cash' && meth != 'foc' && meth != 'creditnote' ? total_other_amt += amt : meth }} %>
<%= total_other_amt %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
<% end %> <% end %>
</table> </table>
</div> </div>
@@ -347,7 +349,8 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<% if isMobile.to_s.include? "Mobile" %> <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% if isMobile.include? "Mobile" %>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 "> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 ">
<div class="card"> <div class="card">
@@ -369,6 +372,7 @@
</div> </div>
</div> </div>
<% end %> <% end %>
<% end %>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

View File

@@ -19,7 +19,7 @@
<div class="row clearfix"></div> <div class="row clearfix"></div>
<% end %> <% end %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4"> <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div class="purple others-payment text-center m-l-10 m-b-10 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div> <div class="purple others-payment text-center m-l-10 m-b-10 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method.parameterize %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@@ -0,0 +1,279 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
<li class="breadcrumb-item active"><%= t("views.btn.mpu") %></li>
<span class="float-right">
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
</span>
</ol>
</div> -->
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-5">
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card" style="margin-top:10px;padding:20px;">
<div class="card-block">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_paid = @can_paid + @rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @can_paid %>" data-member-value="">
</div>
<hr>
</div>
<% if @paid_amount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label><%= "Recent #{@payment_method} paid amount" %></label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@paid_amount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label>
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:;">
<div class=" m-t-10 p-l-20">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left green" data-type="nett" >Nett</div>
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom m-l-5">
<div class="pay purple left" id="pay">Pay</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1 col-lg-1 col-sm-1">
<button type="button" class="btn bg-default btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
</div>
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function() {
setHeaderBreadCrumb('/&nbsp;&nbsp;&nbsp;<%= "#{@payment_method} PAYMENT" %>');
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_paid %>") - parseFloat(localStorage.getItem("cash")));
}
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: '<%= "#{@payment_method} is not available in here!" %>',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
var url_param = "payment";
if(location.pathname.includes("credit_payment")){
url_param = "credit_payment";
}
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param+"/others_payment";
});
}
}
});
$(document).on('click', '.cashier_number', function(event){
console.log("click");
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$('#pay').on('click',function(){
var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>";
var cashier_type = "<%= @cashier_type %>";
$("#reference_no_Err").html("");
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
if(bank_integration == '1'){
pay_withBank("SALE", "<%= @payment_method %>", amount, sale_id, receipt_no,cashier_type);
}else{
if(location.pathname.includes("credit_payment")){
var url = "<%= origami_credit_payment_path(method: @payment_method.parameterize) %>";
}else{
var url = "<%= origami_payment_path(method: @payment_method.parameterize) %>";
}
$.ajax({type: "POST",
url: url,
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
var url_param = "payment";
if(location.pathname.includes("credit_payment")){
url_param = "credit_payment";
}
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param;
});
}
}
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
}
});
$('#back').on('click',function(){
var url_param = "payment";
if(location.pathname.includes("credit_payment")){
url_param = "credit_payment";
}
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
});
</script>

View File

@@ -1,32 +1,32 @@
<div class="container-fluid" style= "overflow-y: hidden;"> <div class="container-fluid m-top-100">
<div id="loading_wrapper" style="display:none;"> <div id="loading_wrapper" style="display:none;">
<div id="loading"></div> <div id="loading"></div>
</div> </div>
<div class="row clearfix"> <div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="card" style="height: 100%"> <div class="card">
<div class="card-header m-l-5 m-r-5"> <div class="card-header m-l-5 m-r-5">
<div id="order-title"> <div id="order-title">
<div class="row p-l-5 p-r-5"> <div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></div> <div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale.receipt_no rescue ' '%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div> <div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div>
</div> </div>
<div class="row p-l-5 p-r-5"> <div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Table No :</strong> <%=@table_no%></div> <div class="col-lg-6 col-md-6 col-sm-6"><strong>Table No :</strong> <%=@table_no%></div>
<span class="hidden" id="dining"><%if !@dining.nil?%><%= @dining.id%><%end%></span> <span class="hidden" id="dining"><%if !@dining.nil?%><%= @dining.id%><%end%></span>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></span></div> <div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale %><%=@sale.sale_id %><% end %></span></div>
</div> </div>
<div class="row p-l-5 p-r-5"> <div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<strong>Customer :</strong> <strong>Customer :</strong>
<% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %> <% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %>
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale_data.customer.name%></button> <button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale.customer.name%></button>
<% else %> <% else %>
<span id="customer_name"><%= @sale_data.customer.name%></span> <span id="customer_name"><%= @sale.customer.name%></span>
<% end %> <% end %>
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span> <span class="hidden" id="membership_id"><%= @sale.customer.membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span></div> <span class="hidden" id="member_discount"><%= @member_discount%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %> <div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
<%end%></div> <%end%></div>
@@ -49,7 +49,7 @@
</table> </table>
</div> </div>
</div> </div>
<div id="order-detail-slimscroll" data-height="190"> <div id="order-detail-slimscroll" data-height="300">
<!-- <div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll"> --> <!-- <div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll"> -->
<div id="table-details" class="card-text m-t--10" > <div id="table-details" class="card-text m-t--10" >
<table class="table" id="append-table"> <table class="table" id="append-table">
@@ -57,7 +57,7 @@
<% sub_total = 0 <% sub_total = 0
count = 0 count = 0
%> %>
<% @sale_data.sale_items.each do |sale_item| <% @sale.sale_items.each do |sale_item|
count += 1 count += 1
%> %>
@@ -77,17 +77,17 @@
<div class="card-footer "> <div class="card-footer ">
<table class="table m-t--10 "> <table class="table m-t--10 ">
<tfooter> <tfooter>
<tr style="border-top-style: none!important"> <tr>
<td class="charges-name"><strong>Sub Total</strong></td> <td class="charges-name"><strong>Sub Total</strong></td>
<td class="item-attr"><strong><span id="sub-total"><%=number_format(sub_total, precision: precision.to_i)%></span></strong></td> <td class="item-attr"><strong><span id="sub-total"><%=number_format(sub_total, precision: precision.to_i)%></span></strong></td>
</tr> </tr>
<tr> <tr>
<%if @sale_data.discount_type == 'member_discount'%> <%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td> <td class="charges-name"><strong>Member Discount:</strong></td>
<%else%> <%else%>
<td class="charges-name"><strong>(Discount)</strong></td> <td class="charges-name"><strong>(Discount)</strong></td>
<%end%> <%end%>
<td class="item-attr"><strong><span>(<%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td> <td class="item-attr"><strong><span>(<%= number_format(@sale.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td>
</tr> </tr>
<tr> <tr>
<td class="charges-name"> <td class="charges-name">
@@ -104,23 +104,23 @@
<% else %> <% else %>
No Tax No Tax
<% end %></strong><br> <% end %></strong><br>
<%if @sale_payment.nil? && @changable_tax %> <%if @sale_payment && @changable_tax %>
<% if @current_user.role == 'cashier' %> <% if @current_user.role == 'cashier' %>
<button class="btn btn-link waves-effect bg-info access_modal" data-type="change_tax">Change Tax</button> <button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
<% else %> <% else %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button> <button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %> <% end %>
<% end %> <% end %>
</td> </td>
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td> <td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
</tr> </tr>
<tr> <tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td> <td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><%= number_format(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td> <td class="item-attr"><strong><%= number_format(@sale.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
</tr> </tr>
<tr> <tr>
<td class="charges-name"><strong>Grand Total</strong></td> <td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td> <td class="item-attr"><strong><span><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
</tr> </tr>
<%if @balance > 0%> <%if @balance > 0%>
<tr> <tr>
@@ -153,25 +153,17 @@
</div> </div>
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5"> <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
<div class="card" style="height: 100%"> <div class="card">
<div class="card-header"> <div class="card-header">
<div class="row m-l-5 m-r-5"> <div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %></strong></div> <div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment %>( Credit )<% end %></strong></div>
<div class="col-md-4"> <div class="col-md-4">
<strong> <strong>
<span id="grand_total" class="hidden"> <span id="grand_total" class="hidden">
<% if @sale_payment.nil? %> <%= number_format(@amount_due, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<% else %>
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<% end %>
</span> </span>
<span id="amount_due"> <span id="amount_due">
<% if @sale_payment.nil? %> <%= number_format(@amount_due, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<% end %>
</span> </span>
</strong> </strong>
</div> </div>
@@ -183,7 +175,7 @@
<%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %> <%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
</div> </div>
</div> </div>
<% if @sale_payment.nil? && @cashier_type != "food_court" %> <% if @sale_payment && @cashier_type != "food_court" %>
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" > <div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
<div class="col-md-8">Credit</div> <div class="col-md-8">Credit</div>
<div class="col-md-4" id="credit"><%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div> <div class="col-md-4" id="credit"><%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
@@ -191,155 +183,25 @@
<% else %> <% else %>
<div class="col-md-4 hidden" id="credit">0</div> <div class="col-md-4 hidden" id="credit">0</div>
<% end %> <% end %>
<% if @kbz_pay_amount > 0.0 %> <div class="row payment other-payment-color p-l-5 p-r-5" id="card_payment" >
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments (KBZ Pay)</div>
<div class="col-md-4" id="others">
<%= number_format(@kbz_pay_amount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
</div>
</div>
<% elsif @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others">
<%= number_format(@other, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
</div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div> <div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="other_payment_amount"> <div class="col-md-4" id="other_payment_amount">
<%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %> <%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
</div> </div>
</div> </div>
<% end %>
</div> </div>
<div class="card-block"> <div class="card-block">
<div class="card-title m-l-5 m-r-5"> <div class="card-title">
<!-- mpu --> <% @other_payments.each do |payment| %>
<div class="row <%= @other!=0.0 ? 'payment others-color' : 'hidden' %>"> <div class="row payment others-color p-l-5 p-r-5">
<div class="col-md-5"></div> <div class="col-md-8"><%= payment[0] %></div>
<div class="col-md-3">MPU</div> <div class="col-md-4 <%= payment[0].parameterize %> is_card"><%= number_format(payment[1], precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% if @other != 0.0 %>
<div class="col-md-4 mpu is_card" id="others"><%= number_format(@other, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="others"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div> </div>
<!-- paypar -->
<div class="row <%= @ppamount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<% if @ppamount != 0.0 %>
<div class="col-md-4" id="ppamount"><%= number_format(@ppamount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="ppamount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %> <% end %>
</div>
<!-- Visa -->
<div class="row <%= @visacount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<% if @visacount != 0.0 %>
<div class="col-md-4 visa is_card" id="visacount"><%= number_format(@visacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="visacount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- JCB -->
<div class="row <%= @jcbcount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<% if @jcbcount != 0.0 %>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_format(@jcbcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="jcbcount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Master -->
<div class="row <%= @mastercount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<% if @mastercount != 0.0 %>
<div class="col-md-4 master is_card" id="mastercount"><%= number_format(@mastercount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="mastercount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- <br> -->
<!-- UNIONPAY -->
<div class="row <%= @unionpaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<% if @unionpaycount != 0.0 %>
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_format(@unionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="unionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Alipay -->
<div class="row <%= @alipaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">Alipay</div>
<% if @alipaycount != 0.0 %>
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_format(@alipaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="alipaycount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- PAYMAL -->
<div class="row <%= @paymalcount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">PAYMAL</div>
<% if @paymalcount != 0.0 %>
<div class="col-md-4 master is_card" id="paymalcount"><%= number_format(@paymalcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="paymalcount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- DINGA -->
<div class="row <%= @dingacount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">DINGA</div>
<% if @dingacount != 0.0 %>
<div class="col-md-4 master is_card" id="dingacount"><%= number_format(@dingacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="dingacount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Junction Pay -->
<div class="row <%= @junctionpaycount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">JUNCTION PAY</div>
<% if @junctionpaycount != 0.0 %>
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_format(@junctionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="junctionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Gift Voucher -->
<div class="row <%= @giftvouchercount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">GIFT VOUCHER</div>
<% if @giftvouchercount != 0.0 %>
<div class="col-md-4 master is_card" id="giftvouchercount"><%= number_format(@giftvouchercount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="giftvouchercount"><%= number_format(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<div class="row m-l-5 m-r-5"> <div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong class='amount_balance'>Balance</strong></div> <div class="col-md-8"><strong class='amount_balance'>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div> <div class="col-md-4"><strong><span id='balance'><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div>
</div> </div>
<!-- <br> --> <!-- <br> -->
</div> </div>
@@ -404,30 +266,30 @@
</button> </button>
<!-- --> <!-- -->
<% if current_login_employee.role == "cashier" %> <% if current_login_employee.role == "cashier" %>
<% if @other_payment <= 0 && @sale_payment.nil? %> <% if @other_payment <= 0 && @sale_payment %>
<%if @sale_data.total_discount == 0 %> <%if @sale.total_discount == 0 %>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a> <a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
<% end %> <% end %>
<%end %> <%end %>
<% if @sale_payment.nil? %> <% if @sale_payment %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a> <a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
<% if @other_payment <= 0 %> <% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %> <%if @sale.total_discount == 0 %>
<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="waste"> Waste</a>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a> <a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% else %> <% else %>
<% if @other_payment <= 0 && @sale_payment.nil?%> <% if @other_payment <= 0 && @sale_payment%>
<%if @sale_data.total_discount == 0 %> <%if @sale.total_discount == 0 %>
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button> <button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
<%end %> <%end %>
<%end %> <%end %>
<% if @sale_payment.nil? %> <% if @sale_payment %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button> <button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<% if @other_payment <= 0 %> <% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %> <%if @sale.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> <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> <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 %>
@@ -435,7 +297,7 @@
<% end %> <% end %>
<% end %> <% end %>
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %> <% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment %>
<hr> <hr>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button> <button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
@@ -709,10 +571,14 @@ var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>"; var customer_name = "<%= @customer.name %>";
var pdf_view = '<%=@pdf_view%>'; var pdf_view = '<%=@pdf_view%>';
var trans_flag = <%= @trans_flag %>; var trans_flag = <%= @trans_flag %>;
var paymalcount = <%= @paymalcount %>; var other_payments = <%= raw @other_payments %>;
var payment_methods = <%= raw @payment_methods %>;
// console.log(pdf_view) // console.log(pdf_view)
$(document).ready(function(){ $(document).ready(function(){
$("#sxModal").hide(); $("#sxModal").hide();
var paymalcount = other_payments.some(x => x[0] == 'paymal') ? other_payments.find(x => x[0] == 'paymal')[1] : 0.0;
if(cashier_type == "food_court" && paymalcount == 0.0){ if(cashier_type == "food_court" && paymalcount == 0.0){
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false}); $("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
} }
@@ -733,11 +599,10 @@ $(document).ready(function(){
receipt_no = ($("#receipt_no").html()).trim(); receipt_no = ($("#receipt_no").html()).trim();
} }
payment_type = '';
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud // if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment"); payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
// console.log(payment_type)
console.log(payment_type)
// console.log(parseInt(jQuery.inArray("MPU", payment_type))) // console.log(parseInt(jQuery.inArray("MPU", payment_type)))
if (member_id && member_discount) { if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){ if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
@@ -745,17 +610,8 @@ $(document).ready(function(){
} else{ } else{
$("#credit_payment").show(); $("#credit_payment").show();
} }
if(parseInt(jQuery.inArray("MPU", payment_type)) != -1 ||
parseInt(jQuery.inArray("VISA", payment_type)) != -1 || if(payment_type && payment_methods.some(x => payment_type.indexOf(x) >= 0)){
parseInt(jQuery.inArray("JCB", payment_type)) != -1 ||
parseInt(jQuery.inArray("Master", payment_type)) != -1 ||
parseInt(jQuery.inArray("UNIONPAY", payment_type)) != -1 ||
parseInt(jQuery.inArray("Redeem", payment_type)) != -1 ||
parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 ||
parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 ||
parseInt(jQuery.inArray("Alipay", payment_type)) != -1 ||
parseInt(jQuery.inArray("DINGA", payment_type)) != -1 ||
parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1){
$("#card_payment").show(); $("#card_payment").show();
} else{ } else{
$("#card_payment").hide(); $("#card_payment").hide();
@@ -764,7 +620,7 @@ $(document).ready(function(){
// } // }
/* end check first bill or not*/ /* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>"; var dining_id = "<%= @sale.bookings[0].dining_facility_id %>";
$("#back").on('click', function() { $("#back").on('click', function() {
localStorage.removeItem('cash'); localStorage.removeItem('cash');
@@ -787,12 +643,10 @@ $(document).ready(function(){
window.location.reload(); window.location.reload();
}) })
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){ if (localStorage.getItem("cash") && localStorage.getItem("cash") != 'null') {
}
else {
$('#cash').text(localStorage.getItem("cash")); $('#cash').text(localStorage.getItem("cash"));
} }
update_balance(); update_balance();
//checkChangableTax //checkChangableTax
checkChangableTax(); checkChangableTax();
@@ -826,39 +680,9 @@ $(document).ready(function(){
$('#pay').click(function() { $('#pay').click(function() {
sub_total = $('#sub-total').text(); sub_total = $('#sub-total').text();
member = $('#membership_id').text(); member = $('#membership_id').text();
// console.log(member) if (payment_type && payment_type.length > 0 && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0) && sub_total != 0.0 && member) {
if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) { swal("Oops","Please Pay with " + payment_methods.find(x => payment_type.indexOf(x) >= 0) + " Payment","warning");
swal("Oops","Please Pay with MPU Payment","warning");
}else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(parseInt(jQuery.inArray("VISA", payment_type)) != -1 && $('#visacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Visa Payment","warning");
}else if(parseInt(jQuery.inArray("JCB", payment_type)) != -1 && $('#jcbcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(parseInt(jQuery.inArray("Master", payment_type)) != -1 && $('#mastercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Alipay Payment","warning");
}
else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Credit Payment","warning");
}else if(parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 && $('#paymalcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Paymal Payment","warning");
}else if(parseInt(jQuery.inArray("DINGA", payment_type)) != -1 && $('#dingacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Dinga Payment","warning");
}else if(parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1 && $('#giftvouchercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Gift Voucher","warning");
} else { } else {
$( "#loading_wrapper").show(); $( "#loading_wrapper").show();
if($('#balance').text() > 0){ if($('#balance').text() > 0){
swal ( "Oops", "Insufficient Amount!" , "error" ); swal ( "Oops", "Insufficient Amount!" , "error" );
@@ -1098,18 +922,8 @@ $(document).ready(function(){
break; break;
case 'nett': case 'nett':
var credit1 = $('#credit').text(); var credit1 = $('#credit').text();
var card1 = $('#others').text(); var others = other_payments.map(x => x[1]).reduce((acc, v) => acc + v, 0);
var paypar1 = $('#ppamount').text(); var othertotal = parseFloat(credit1) + parseFloat(others);
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var unionpay1 = $('#unionpaycount').text();
var paymal1 = $('#paymalcount').text();
var alipay1 = $('#alipaycount').text();
var junctionpay1 = $('#junctionpaycount').text();
var dingapay1 = $('#dingacount').text();
var giftvoucherpay1 = $('#giftvouchercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(alipay1) + parseFloat(junctionpay1) + parseFloat(paymal1) + parseFloat(dingapay1) + parseFloat(giftvoucherpay1);
var total = $('#amount_due').text(); var total = $('#amount_due').text();
var amt = 0; var amt = 0;
<% if precision.to_i > 0 %>; <% if precision.to_i > 0 %>;
@@ -1131,19 +945,10 @@ $(document).ready(function(){
function update_balance(){ function update_balance(){
var cash = $('#cash').text(); var cash = $('#cash').text();
var credit = $('#credit').text(); var credit = $('#credit').text();
var card = $('#others').text(); var others = other_payments.map(x => x[1]).reduce((acc, v) => acc + v, 0);
var paypar = $('#ppamount').text();
var visa = $('#visacount').text();
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var unionpay = $('#unionpaycount').text();
var paymal = $('#paymalcount').text();
var alipay = $('#alipaycount').text();
var junctionpay = $('#junctionpaycount').text();
var dinga = $('#dingacount').text();
var giftvoucher = $('#giftvouchercount').text();
var amount_due = $('#amount_due').text(); var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(alipay) + parseFloat(junctionpay) + parseFloat(paymal) + parseFloat(dinga) + parseFloat(giftvoucher); var total = parseFloat(cash) + parseFloat(credit) + parseFloat(others);
var result = parseFloat(amount_due) - parseFloat(total); var result = parseFloat(amount_due) - parseFloat(total);
@@ -1253,7 +1058,6 @@ $(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
@@ -1310,6 +1114,7 @@ $(document).ready(function(){
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){ if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -1346,7 +1151,6 @@ $(document).ready(function(){
function setCardNo(cardNo){ function setCardNo(cardNo){
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
} }
} }
@@ -1477,7 +1281,7 @@ $(document).ready(function(){
$('#AccessCodeModal').modal('hide'); $('#AccessCodeModal').modal('hide');
$('#focModal').modal('show'); $('#focModal').modal('show');
// overall_foc(); // overall_foc();
}else if(type == "change_tax"){ }else if(type == 'change_tax'){
$('#AccessCodeModal').modal('hide'); $('#AccessCodeModal').modal('hide');
$('#change_taxModal').modal('show'); $('#change_taxModal').modal('show');
} }
@@ -1715,6 +1519,7 @@ $(document).ready(function(){
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) { if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0; customer_mamber_card_no = $("#membership_id").text() || 0;

View File

@@ -1,5 +1,13 @@
<% breadcrumb_add t("views.right_panel.detail.daily_sale_report"), "", dashboard_path %>
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.daily_sale_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row"> <div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 "> <div class="col-md-12 col-lg-12 col-sm-12 ">
<%= render :partial=>'shift_sale_report_filter', <%= render :partial=>'shift_sale_report_filter',
@@ -19,99 +27,25 @@
<th colspan="<%= column_count = @payment_methods.length + 12 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th> <th colspan="<%= column_count = @payment_methods.length + 12 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr> </tr>
<% @count = 1 %> <% @count = 1 %>
<% @payment_methods.each_slice(10) do |slice| %>
<!-- <tr>
<th></th>
<th></th>
<% alph = "A" %>
<% slice.each do |payment_method| %>
<th style="text-align:center;">
<%= alph %>
</th>
<% alph = alph.ord.next.chr %>
<% @count += 1 %>
<% end %>
<th style="text-align:center;" ><%= alph %></th>
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
</tr> -->
<!-- <tr>
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<% slice.each do |payment_method| %>
<th style="text-align:center;">
<%= payment_method %>
</th>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
<% if @payment_methods.include? ("GiftVoucher") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
<% end %>
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
</tr> -->
<% end %>
<tr> <tr>
<th></th> <th></th>
<th></th> <th></th>
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th> <th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
<th colspan=4 style='text-align:center;'>Outgoing</th> <th colspan=4 style='text-align:center;'>Outgoing</th>
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Gross Sales = (Income+Discount) - (FOC+Void)"><i class="material-icons md-18">live_help</i></th> <th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Gross Sales = (Income+Discount) - Void"><i class="material-icons md-18">live_help</i></th>
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th> <th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th>
<% if @tax.blank? %> <% if @tax.blank? %>
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Tax = Total Sales / 21"><i class="material-icons md-18">live_help</i></th> <th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Tax = Total Sales / 21"><i class="material-icons md-18">live_help</i></th>
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Net Sales = Total Sales - Tax"><i class="material-icons md-18">live_help</i></th> <th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Net Sales = Total Sales - Tax"><i class="material-icons md-18">live_help</i></th>
<% end %> <% end %>
</tr> </tr>
<tr> <tr>
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th> <th style='text-align:center;'><%= t("views.righ_panel.detail.date") %></th>
<% @payment_methods.each do |method| %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
<% end %>
<% if @payment_methods.include? ("MPU") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.mpu_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Master") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.master_sales") %></th>
<% end %>
<% if @payment_methods.include? ("VISA") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.visa_sales") %></th>
<% end %>
<% if @payment_methods.include? ("JCB") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.jcb_sales") %></th>
<% end %>
<% if @payment_methods.include? ("UNIONPAY") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.unionpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("KBZPay") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.kbzpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.alipay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.paymal_sales") %></th>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.dinga_sales") %></th>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.redeem_sales") %></th>
<% end %>
<% if @payment_methods.include? ("GiftVoucher") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
@@ -132,22 +66,10 @@
<% unless @sale_data.blank? %> <% unless @sale_data.blank? %>
<tbody> <tbody>
<% void = 0 %> <% void = 0 %>
<% mpu = 0 %>
<% master = 0 %>
<% visa = 0 %>
<% jcb = 0 %>
<% unionpay = 0 %>
<% alipay = 0 %>
<% paymal = 0 %>
<% dinga = 0 %>
<% junctionpay = 0 %>
<% giftvoucher = 0 %>
<% paypar = 0 %>
<% cash = 0 %> <% cash = 0 %>
<% credit = 0 %> <% credit = 0 %>
<% foc = 0 %> <% foc = 0 %>
<% discount = 0 %> <% discount = 0 %>
<% kbzpay = 0 %>
<% total = 0 %> <% total = 0 %>
<% grand_total = 0 %> <% grand_total = 0 %>
<% old_grand_total = 0 %> <% old_grand_total = 0 %>
@@ -156,24 +78,13 @@
<% tax = 0 %> <% tax = 0 %>
<% net_sale = 0 %> <% net_sale = 0 %>
<% count = 1 %> <% rounding_adj = 0 %> <% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %> <% void += sale[:void_amount] %>
<% mpu += sale[:mpu_amount] %>
<% master += sale[:master_amount] %>
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% unionpay += sale[:unionpay_amount] %>
<% alipay += sale[:alipay_amount] %>
<% paymal += sale[:paymal_amount] %>
<% dinga += sale[:dinga_amount] %>
<% junctionpay += sale[:junctionpay_amount] %>
<% giftvoucher += sale[:giftvoucher_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %> <% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %> <% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %> <% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %> <% discount += sale[:total_discount] %>
<% kbzpay += sale[:kbzpay_amount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %> <% grand_total += sale[:grand_total].to_f %>
<% old_grand_total += sale[:old_grand_total].to_f %> <% old_grand_total += sale[:old_grand_total].to_f %>
@@ -185,41 +96,8 @@
<tr> <tr>
<td style='text-align:right;'><%= count %></td> <td style='text-align:right;'><%= count %></td>
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td> <td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
<% if @payment_methods.include? ("MPU") %> <% @payment_methods.each do |method| %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[method.parameterize.to_sym], precision:precision.to_i, delimiter: delimiter) rescue 0 %></td>
<% end %>
<% if @payment_methods.include? ("Master") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("VISA") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("JCB") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("UNIONPAY") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("KBZPay") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("GiftVoucher") %>
<td style='text-align:right;'><%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %> <% end %>
<td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
@@ -228,7 +106,7 @@
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td> <td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> --> <!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
<td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:rounding_adj], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax.blank? %> <% if @tax.blank? %>
@@ -242,75 +120,9 @@
<% colspan = 7 %> <% colspan = 7 %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="2" style='text-align:center;'>Total</td> <td colspan="2" style='text-align:center;'>Total</td>
<% if @payment_methods.include? ("MPU") %> <% @payment_methods.each do |method| %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %> <% colspan += 1 %>
<% end %> <td style='text-align:right;'><%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[method.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue 0 %></td>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("Master") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("VISA") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("JCB") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("UNIONPAY") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("KBZPay") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("GiftVoucher") %>
<% colspan += 1 %>
<td style='text-align:right;'><%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %> <% end %>
<td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>

View File

@@ -27,41 +27,8 @@
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<% if @payment_methods.include? ("MPU") %> <% @payment_methods.each do |method| %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.mpu_sales") %></th> <th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
<% end %>
<% if @payment_methods.include? ("Master") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.master_sales") %></th>
<% end %>
<% if @payment_methods.include? ("VISA") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.visa_sales") %></th>
<% end %>
<% if @payment_methods.include? ("JCB") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.jcb_sales") %></th>
<% end %>
<% if @payment_methods.include? ("UNIONPAY") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.unionpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("KBZPay") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.kbzpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.alipay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.paymal_sales") %></th>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.dinga_sales") %></th>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.redeem_sales") %></th>
<% end %>
<% if @payment_methods.include? ("GiftVoucher") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
<% end %> <% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
@@ -108,22 +75,10 @@
<% count = 1 %> <% rounding_adj = 0 %> <% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %> <% void += sale[:void_amount] %>
<% mpu += sale[:mpu_amount] %>
<% master += sale[:master_amount] %>
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% unionpay += sale[:unionpay_amount] %>
<% alipay += sale[:alipay_amount] %>
<% paymal += sale[:paymal_amount] %>
<% dinga += sale[:dinga_amount] %>
<% junctionpay += sale[:junctionpay_amount] %>
<% giftvoucher += sale[:giftvoucher_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %> <% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %> <% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %> <% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %> <% discount += sale[:total_discount] %>
<% kbzpay += sale[:kbzpay_amount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %> <% grand_total += sale[:grand_total].to_f %>
<% old_grand_total += sale[:old_grand_total].to_f %> <% old_grand_total += sale[:old_grand_total].to_f %>
@@ -135,41 +90,8 @@
<tr> <tr>
<td style='text-align:right;'><%= count %></td> <td style='text-align:right;'><%= count %></td>
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td> <td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
<% if @payment_methods.include? ("MPU") %> <% @payment_methods.each do |method| %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[method.parameterize.to_sym], precision:precision.to_i, delimiter: delimiter) rescue 0 %></td>
<% end %>
<% if @payment_methods.include? ("Master") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("VISA") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("JCB") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("UNIONPAY") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("KBZPay") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("GiftVoucher") %>
<td style='text-align:right;'><%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %> <% end %>
<td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
@@ -192,75 +114,9 @@
<% colspan = 7 %> <% colspan = 7 %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="2" style='text-align:center;'>Total</td> <td colspan="2" style='text-align:center;'>Total</td>
<% if @payment_methods.include? ("MPU") %> <% @payment_methods.each do |method| %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %> <% colspan += 1 %>
<% end %> <td style='text-align:right;'><%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[method.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue 0 %></td>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("Master") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("VISA") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("JCB") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end%>
<% if @payment_methods.include? ("UNIONPAY") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("KBZPay") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<% if !request.user_agent.include? "Mobile" %>
<% colspan += 1 %>
<% end %>
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% if @payment_methods.include? ("GiftVoucher") %>
<% colspan += 1 %>
<td style='text-align:right;'><%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %> <% end %>
<td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
@@ -293,12 +149,12 @@
<% net = net - total_tax %> <% net = net - total_tax %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td> <td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
<td colspan="5" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td colspan="2" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr> </tr>
<% else %> <% else %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td> <td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
<td colspan="5" style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td colspan="2" style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -1,5 +1,12 @@
<% breadcrumb_add 'Payment Method Report', "", dashboard_path %> <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active">Payment Method Report</li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@@ -33,42 +40,25 @@
</tr> </tr>
<% end %> <% end %>
<tr> <tr>
<th><%= t("views.right_panel.detail.mpu_sales") %></th> <% @payment_methods.each do |method| %>
<th><%= t("views.right_panel.detail.master_sales") %></th> <th><%= t("views.right_panel.detail.#{method} Sales") %></th>
<th><%= t("views.right_panel.detail.visa_sales") %></th> <% end %>
<th><%= t("views.right_panel.detail.jcb_sales") %></th>
<th><%= t("views.right_panel.detail.unionpay_sales") %></th>
<th><%= t("views.right_panel.detail.alipay_sales") %></th>
<th><%= t("views.right_panel.detail.kbzpay_sales") %></th>
<!-- <th><%= t("views.right_panel.detail.paymal_sales") %></th> -->
<th><%= t("views.right_panel.detail.dinga_sales") %></th>
<th><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<th><%= t("views.right_panel.detail.redeem_sales") %></th>
<th><%= t("views.right_panel.detail.cash_sales") %></th> <th><%= t("views.right_panel.detail.cash_sales") %></th>
<th><%= t("views.right_panel.detail.credit_sales") %></th> <th><%= t("views.right_panel.detail.credit_sales") %></th>
<th><%= t("views.right_panel.detail.foc_sales") %></th> <th><%= t("views.right_panel.detail.foc_sales") %></th>
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
</tr> </tr>
</thead> </thead>
<% unless @sale_data.empty? %> <% unless @sale_data.empty? %>
<tbody> <tbody>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<tr> <tr>
<td><%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <% @payment_methods.each do |method| %>
<td><%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[method.parameterize.to_sym] , precision: precision.to_i ,delimiter: delimiter) rescue 0 %></td>
<td><%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <% end %>
<td><%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<!-- <td><%= number_format(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
<td><%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <!-- <td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
</tr> </tr>
<% end %> <% end %>

View File

@@ -27,42 +27,24 @@
</tr> </tr>
<% end %> <% end %>
<tr> <tr>
<th><%= t("views.right_panel.detail.mpu_sales") %></th> <% @payment_methods.each do |method| %>
<th><%= t("views.right_panel.detail.master_sales") %></th> <th><%= t("views.right_panel.detail.#{method} Sales") %></th>
<th><%= t("views.right_panel.detail.visa_sales") %></th> <% end %>
<th><%= t("views.right_panel.detail.jcb_sales") %></th>
<th><%= t("views.right_panel.detail.unionpay_sales") %></th>
<th><%= t("views.right_panel.detail.alipay_sales") %></th>
<th><%= t("views.right_panel.detail.kbzpay_sales") %></th>
<!-- <th><%= t("views.right_panel.detail.paymal_sales") %></th> -->
<th><%= t("views.right_panel.detail.dinga_sales") %></th>
<th><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<th><%= t("views.right_panel.detail.redeem_sales") %></th>
<th><%= t("views.right_panel.detail.cash_sales") %></th> <th><%= t("views.right_panel.detail.cash_sales") %></th>
<th><%= t("views.right_panel.detail.credit_sales") %></th> <th><%= t("views.right_panel.detail.credit_sales") %></th>
<th><%= t("views.right_panel.detail.foc_sales") %></th> <th><%= t("views.right_panel.detail.foc_sales") %></th>
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
</tr> </tr>
</thead> </thead>
<% unless @sale_data.empty? %> <% unless @sale_data.empty? %>
<tbody> <tbody>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<tr> <tr>
<td><%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <% @payment_methods.each do |method| %>
<td><%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[method.parameterize.to_sym] , precision: precision.to_i ,delimiter: delimiter) rescue 0 %></td>
<td><%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <% end %>
<td><%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<!-- <td><%= number_format(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
<td><%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -18,17 +18,14 @@
<option value="9">Last year</option> <option value="9">Last year</option>
</select> </select>
</div> </div>
<% if defined? payments %> <% if defined? @payment_methods %>
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style"> <div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_payments") %></label> <label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_payments") %></label>
<select name="payment_type" id="payment_type" class="form-control"> <select name="payment_type" id="payment_type" class="form-control">
<% @payments.each do |pm| %> <% @payment_methods.each do |pm| %>
<option class="<%=pm[1].downcase%>" value="<%=pm[1].downcase%>"><%=pm[0]%></option> <option value="<%=pm[1].downcase%>"><%=pm[0]%></option>
<%end %>
<% @payment_method.each do |pm| %>
<option value="<%=pm.payment_method%>" class="<%=pm.payment_method%>" > <%=pm.payment_method%></option>
<%end %> <%end %>
</select> </select>
</div> </div>

View File

@@ -1,6 +1,13 @@
<div class="container-fluid"> <div class="container-fluid">
<% breadcrumb_add t("views.right_panel.detail.waste_spoilage_report"), "", dashboard_path %> <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.waste_spoilage_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter', <%= render :partial=>'shift_sale_report_filter',
@@ -48,7 +55,7 @@
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<% if !sale.item_instance_code.nil?%> <% if !sale.item_instance_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %> <% waste_and_spoil_item_count += sale.qty.to_i %>
<% grand_total += sale.grand_total.to_i %> <% grand_total += sale.price.to_i %>
<% end %> <% end %>
<tr> <tr>
<% if !menu_cat_arr.include?(sale.name) %> <% if !menu_cat_arr.include?(sale.name) %>

View File

@@ -1,4 +1,13 @@
<% breadcrumb_add t('shiftsale'), transactions_shift_sales_path, transactions_shift_sales_path, t('details') %> <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item"><a href="<%= transactions_shift_sales_path %>"><%= t :shiftsale %></a></li>
<li class="breadcrumb-item active"><%= t :details %></li>
<span class="float-right">
<%= link_to 'Back', transactions_shift_sales_path %>
</span>
</ol>
</div>
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="main-box-body clearfix p-l-5 p-r-5"> <div class="main-box-body clearfix p-l-5 p-r-5">
@@ -31,7 +40,7 @@
<th><%= @shift.total_receipt %></th> <th><%= @shift.total_receipt %></th>
<th><%= @shift.dining_count %></th> <th><%= @shift.dining_count %></th>
<th><%= @shift.takeaway_count %></th> <th><%= @shift.takeaway_count %></th>
<th>(<%= @shift.total_void.round(2) %>)</th> <th>(<%= @shift.total_void %>)</th>
</tr> </tr>
<tr> <tr>
@@ -41,7 +50,7 @@
<tr> <tr>
<th></th> <th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td> <td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
<td><%= amount.total_price.round(2) %></td> <td><%= amount.total_price %></td>
</tr> </tr>
<%end%> <%end%>
<tr> <tr>
@@ -54,7 +63,7 @@
<tr> <tr>
<th></th> <th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td> <td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
<td><%= amount.total_price.round(2) %></td> <td><%= amount.total_price %></td>
</tr> </tr>
<%end%> <%end%>
@@ -85,7 +94,7 @@
<tr> <tr>
<th></th> <th></th>
<td style="text-align: right;"> <%= tax.tax_name %> </td> <td style="text-align: right;"> <%= tax.tax_name %> </td>
<td><%= tax.st_amount.round(2) %></td> <td><%= tax.st_amount %></td>
</tr> </tr>
<%end%> <%end%>
<tr> <tr>
@@ -96,17 +105,18 @@
<tr> <tr>
<th></th> <th></th>
<th style="text-align: right;"> Rounding Adj </th> <th style="text-align: right;"> Rounding Adj </th>
<th><%= @shift.total_rounding.round(2) %></th> <th><%= @shift.total_rounding %></th>
</tr> </tr>
<tr> <tr>
<th></th> <th></th>
<th style="text-align: right;"> Grand Total </th> <th style="text-align: right;"> Grand Total </th>
<th><%= @shift.grand_total.round(2) %></th> <th><%= @shift.grand_total %></th>
</tr> </tr>
</table> </table>
</td> </td>
<td colspan="6"> <td colspan="6">
<table width="100%"> <table width="100%">
<% total_other_amount = 0 %>
<tr> <tr>
<th></th> <th></th>
<th style="text-align: right;">Cash Payment </th> <th style="text-align: right;">Cash Payment </th>
@@ -117,63 +127,35 @@
<th style="text-align: right;">Credit Payment </th> <th style="text-align: right;">Credit Payment </th>
<th><%= @shift.credit_sales %></th> <th><%= @shift.credit_sales %></th>
</tr> </tr>
<% @total_amount = 0
@other_payment.each do |other| %>
<tr> <tr>
<th></th> <th></th>
<th style="text-align: right;">Other Payment Detail </th> <th style="text-align: right;">Other Payment Detail </th>
<th></th> <th></th>
</tr> </tr>
<% @payment_methods.each do |method| %>
<tr> <tr>
<th></th> <th></th>
<td style="text-align: right;">MPU Payment </td> <td style="text-align: right;"><%= method %> Payment</td>
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td> <td><%= @other_payment[method.parameterize.to_sym] || 0.0 %></td>
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %> <% total_other_amount = total_other_amount + (@other_payment[method.parameterize.to_sym] || 0.0) %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">VISA Payment </td>
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Master Payment </td>
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">JCB Payment </td>
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Reedem Payment </td>
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
</tr> </tr>
<% end %>
<tr> <tr>
<th></th> <th></th>
<td style="text-align: right;"><strong>FOC </strong></td> <td style="text-align: right;"><strong>FOC </strong></td>
<td><%=other.foc_amount.round(2) rescue 0.0 %></td> <td><%= @other_payment.foc_amount rescue 0.0 %></td>
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
</tr> </tr>
<%end%>
<tr> <tr>
<th></th> <th></th>
<th style="text-align: right;">Total Other Payment </th> <th style="text-align: right;">Total Other Payment </th>
<th><%=@shift.other_sales %></th> <th><%= total_other_amount %></th>
</tr> </tr>
<tr> <tr>
<th></th> <th></th>
<th style="text-align: right;">Total Payment </th> <th style="text-align: right;">Total Payment </th>
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th> <th><%= total_other_amount + @other_payment.foc_amount + @shift.cash_sales + @shift.credit_sales %></th>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>

View File

@@ -260,23 +260,26 @@ scope "(:locale)", locale: /en|mm/ do
post 'payment/dinga' => 'dinga#create' post 'payment/dinga' => 'dinga#create'
post 'payment/gift_voucher' => 'gift_voucher#create' post 'payment/gift_voucher' => 'gift_voucher#create'
post 'payment/credit_payment' => 'credit_payments#create_credit_payment' post 'payment/credit_payment' => 'credit_payments#create_credit_payment'
post 'payment/:method' => 'others_payments#create', :as => 'payment'
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'} post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index" get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
get 'sale/:sale_id/:type/payment/others_payment/MPU' => "mpu#index" get 'sale/:sale_id/:type/payment/others_payment/mpu' => "mpu#index"
get 'sale/:sale_id/:type/payment/others_payment/VISA' => "visa#index" get 'sale/:sale_id/:type/payment/others_payment/visa' => "visa#index"
get 'sale/:sale_id/:type/payment/others_payment/Master' => "master#index" get 'sale/:sale_id/:type/payment/others_payment/master' => "master#index"
get 'sale/:sale_id/:type/payment/others_payment/JCB' => "jcb#index" get 'sale/:sale_id/:type/payment/others_payment/jcb' => "jcb#index"
get 'sale/:sale_id/:type/payment/others_payment/PAYMAL' => "paymal#index" get 'sale/:sale_id/:type/payment/others_payment/paymal' => "paymal#index"
get 'sale/:sale_id/:type/payment/others_payment/UNIONPAY' => "unionpay#index" get 'sale/:sale_id/:type/payment/others_payment/unionpay' => "unionpay#index"
get 'sale/:sale_id/:type/payment/others_payment/Redeem' => "redeem_payments#index" get 'sale/:sale_id/:type/payment/others_payment/redeem' => "redeem_payments#index"
get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index" get 'sale/:sale_id/:type/payment/others_payment/voucher' => "voucher#index"
get 'sale/:sale_id/:type/payment/others_payment/JunctionPay' => "junction_pay#index" get 'sale/:sale_id/:type/payment/others_payment/junctionpay' => "junction_pay#index"
get 'sale/:sale_id/:type/payment/others_payment/Alipay' => "alipay#index" get 'sale/:sale_id/:type/payment/others_payment/alipay' => "alipay#index"
get 'sale/:sale_id/:type/payment/others_payment/DINGA' => "dinga#index" get 'sale/:sale_id/:type/payment/others_payment/dinga' => "dinga#index"
get 'sale/:sale_id/:type/payment/others_payment/GiftVoucher' => "gift_voucher#index" get 'sale/:sale_id/:type/payment/others_payment/giftvoucher' => "gift_voucher#index"
get 'sale/:sale_id/:type/payment/others_payment/:method' => 'others_payments#new'
#---------Void --------------# #---------Void --------------#
post 'sale/:sale_id/:type/void' => 'void#overall_void' post 'sale/:sale_id/:type/void' => 'void#overall_void'
@@ -369,18 +372,20 @@ scope "(:locale)", locale: /en|mm/ do
# post 'credit_payment/gift_voucher' => 'gift_voucher#create' # post 'credit_payment/gift_voucher' => 'gift_voucher#create'
get 'sale/:sale_id/:type/credit_payment/others_payment' => "others_payments#index" get 'sale/:sale_id/:type/credit_payment/others_payment' => "others_payments#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/MPU' => "mpu#index" get 'sale/:sale_id/:type/credit_payment/others_payment/mpu' => "mpu#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/VISA' => "visa#index" get 'sale/:sale_id/:type/credit_payment/others_payment/visa' => "visa#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/Master' => "master#index" get 'sale/:sale_id/:type/credit_payment/others_payment/master' => "master#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/JCB' => "jcb#index" get 'sale/:sale_id/:type/credit_payment/others_payment/jcb' => "jcb#index"
# get 'sale/:sale_id/:type/credit_payment/others_payment/PAYMAL' => "paymal#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/paymal' => "paymal#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/UNIONPAY' => "unionpay#index" get 'sale/:sale_id/:type/credit_payment/others_payment/unionpay' => "unionpay#index"
# get 'sale/:sale_id/:type/credit_payment/others_payment/Redeem' => "redeem_payments#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/redeem' => "redeem_payments#index"
# get 'sale/:sale_id/:type/credit_payment/others_payment/Voucher' => "voucher#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/voucher' => "voucher#index"
# get 'sale/:sale_id/:type/credit_payment/others_payment/JunctionPay' => "junction_pay#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/junctionpay' => "junction_pay#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/Alipay' => "alipay#index" get 'sale/:sale_id/:type/credit_payment/others_payment/alipay' => "alipay#index"
# get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/dinga' => "dinga#index"
# get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/giftvoucher' => "gift_voucher#index"
get 'sale/:sale_id/:type/credit_payment/others_payment/:method' => 'others_payments#new'
#------------- Start Reservation -------------------# #------------- Start Reservation -------------------#
resources :reservation resources :reservation