separate foodcourt module

This commit is contained in:
Myat Zin Wai Maw
2019-12-02 16:10:51 +06:30
parent 09e7650452
commit cac6994ccb
113 changed files with 14365 additions and 193 deletions

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -0,0 +1 @@
<h1> Close Cashier </h1>

View File

@@ -0,0 +1,2 @@
<h1>Origami::Shifts#index</h1>
<p>Find me in app/views/origami/shifts/index.html.erb</p>

View File

@@ -0,0 +1,126 @@
<div class="container-fluid">
<h1>Open Cashier</h1>
<br>
<div class="row">
<div class="col-md-4">
<table class='table table-striped'>
<tr>
<th>Cashier Terminal</th>
<th>
<select class="form-control show-tick" id='cashier_terminal'>
<% @terminal.each do |ter| %>
<option value="<%= ter.id %>" ><%= ter.name %></option>
<% end %>
</select>
</th>
</tr>
<% @float.each do |float| %>
<tr>
<th><%= float.name %></th>
<th><input class='float-value form-control' type='text' data-value ="<%= float.value %>" value='0' id='<%= float.value %>'></input></th>
</tr>
<% end %>
<tr>
<th>Total</th>
<th><div id='total'></div></th>
</tr>
</table>
</div>
<div class='col-md-8'>
<div class="row p-l-30">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number orange " data-type="clr">Clr</div>
<div class=" cashier_number left" data-type='ent' >Calculate</div>
<div class=" cashier_number purple left" id="open_cashier">Open Cashier</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var float_value = ""
var total = 0
$(document).on('focusout', '.float-value', function(event){
float_value = $(this).attr("data-value");
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
var original = $('#'+float_value).val();
if (original == "0"){
$('#'+float_value).val(input_value);
}else{
$('#'+float_value).val(original + input_value);
}
break;
case 'clr':
$('#'+float_value).val("0");
break;
case 'ent':
var sum = 0
<%
sum = 0
@float.each do |float|
%>
var float = "<%= float.value %>"
console.log(float)
var cal = $('#'+ float).val() * float
sum += cal;
<%
end
%>
total = sum
$('#total').text(total)
break;
}
event.handled = true;
} else {
return false;
}
});
})
$('#open_cashier').on('click touchstart', function(event){
$(this).off("click touchstart touchend");
var cashier_terminal = $('#cashier_terminal').val();
var amount = $('#total').text()||0;
$.ajax({type: "POST",
url: "<%= foodcourt_shifts_path %>",
data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal,
success:function(result){
if(result){
window.location.href = "<%= foodcourt_food_court_path%>";
}
}
});
})
</script>

View File

@@ -0,0 +1,201 @@
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10">
<h3 style="text-align: center;">Sales Summary Quick View </h3>
<table class="table table-striped">
<tbody>
<tr>
<th>Cashier </th>
<th>Cashier Terminal </th>
<th>Opening Date </th>
<th>Opening float </th>
<th>Received Amount </th>
<th>Cast In </th>
<th>Cast Out </th>
<th>Total Receipt </th>
<th>Dining Count </th>
<th>Takeaway Count </th>
<th>Total Void</th>
</tr>
<tr style="border-bottom:2px solid #000">
<td><%= @shift.employee.name%></td>
<td><%=@shift.cashier_terminal.name%></td>
<td><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %>
</td>
<td><%=@shift.opening_balance %></td>
<td><%=@shift.closing_balance %></td>
<td><%=@shift.cash_in %></td>
<td><%=@shift.cash_out %></td>
<th><%= @shift.total_receipt %></th>
<th><%= @shift.dining_count %></th>
<th><%= @shift.takeaway_count %></th>
<th>(<%= @shift.total_void.round(2) %>)</th>
</tr>
<tr>
<td colspan="5">
<table width="100%">
<% @total_amount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Net Sales</th>
<th><%=@shift.nett_sales %></th>
</tr>
<% @total_discount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<% if !@total_member_discount[0].member_discount.nil?
@member_discount = @total_member_discount[0].member_discount rescue 0.0
@overall = @shift.total_discounts - @member_discount
%>
<tr>
<th></th>
<th style="text-align: right;"> Total Member Discount</th>
<th><%= @member_discount %></th>
</tr>
<%else @overall = @shift.total_discounts %>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Overall Discount</th>
<th><%= @overall %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Total Discount</th>
<th><%= @shift.total_discounts %></th>
</tr>
<% @sale_taxes.each do |tax| %>
<tr>
<th></th>
<td style="text-align: right;"> <%= tax.tax_name %> </td>
<td><%= tax.st_amount.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Tax </th>
<th><%=@shift.total_taxes %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Rounding Adj </th>
<th><%= @shift.total_rounding.round(2) %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Grand Total </th>
<th><%= @shift.grand_total.round(2) %></th>
</tr>
</table>
</td>
<td colspan="6">
<table width="100%">
<tr>
<th></th>
<th style="text-align: right;">Cash Payment </th>
<th><%=@shift.cash_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Credit Payment </th>
<th><%=@shift.credit_sales %></th>
</tr>
<% @total_amount = 0
@other_payment.each do |other| %>
<tr>
<th></th>
<th style="text-align: right;">Other Payment Detail </th>
<th></th>
</tr>
<tr>
<th></th>
<td style="text-align: right;">MPU Payment </td>
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.mpu_amount rescue 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;">JCB Payment </td>
<td><%=other.master_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;">Master Payment </td>
<td><%=other.jcb_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;">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>
<th></th>
<td style="text-align: right;"><strong>FOC </strong></td>
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;">Total Other Payment </th>
<th><%=@shift.other_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Total Payment </th>
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<br><br><br>
<button id="close_cashier" type="button" class="btn btn-block btn-primary btn-lg"> Close Cashier
</button>
<button id="back" type="button" class="btn btn-block btn-primary btn-lg"><i class="fa fa-home fa-lg"></i> Back
</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#close_cashier').on('click',function(){
window.location.href = '/foodcourt/shift/close';
})
$('#back').on('click',function(){
window.location.href = '/foodcourt';
})
})
</script>

View File

@@ -0,0 +1,282 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class='row clearfix'>
<div class='col-md-10'>
<h1><%= t :close_cashier %></h1>
<br>
<table class='table table-striped'>
<tr>
<td><%= t :shift_started_at %></td>
<td><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></td>
</tr>
<tr>
<td><%= t :cashier_name %></td>
<td><%= @shift.employee.name rescue ''%></td>
</tr>
</table>
<hr>
<div class='row clearfix '>
<div class='col-md-5'>
<span style='font-size:20px;'><b><%= t :closing_balance %></b></span>
</div>
<div class='col-md-6'>
<span style='font-size:20px;'><b><input type='number' class="form-control" id='closing_balance_amount' value='' onkeypress="return isNumberKey(event);" onkeyup="closeCashier(this.value);"></b></span>
</div>
</div><br>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
<button type="button" class="btn bg-blue btn-block green close_cashier"> <%= t("views.btn.close_cashier") %> </button>
<% if @bank_integration == '1' && @cashier_type!="ordering" %>
<button type="button" class="btn bg-blue btn-block green" id="card_settlement"> <%= t("views.btn.card_settle") %> </button>
<% end %>
</div>
</div>
<div class="modal fade" id="cardSettleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="cardSettleModal">Select Device: </h4>
</div>
<div class="modal-body">
<select class="form-control show-tick sel_com_port" id="sel_com_port" >
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect" id="card_settle">OK</button>
</div>
</div>
</div>
</div>
</div>
<script>
// $(document).ready(function(){
// var val = $('#sale_items').val()
// if (val == 1) {
// $('#sale_items').prop( "checked", true );
// }
// })
function closeCashier(val){
var aa = parseInt(val);
if(isNaN(aa)) $("#closing_balance_amount").val("");
}
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
function greaterThanOne(val){
if(parseInt(val)==0) $("#closing_balance_amount").val(1);
}
var cashier_type = '<%= @cashier_type %>';
$('.close_cashier').on('click',function(){
var amount = $('#closing_balance_amount').val();
var shift_id = "<%= @shift.id rescue ""%>"
$.ajax({type: "POST",
url: "<%= foodcourt_close_shift_path %>",
data: "closing_balance="+ amount + "&shift_id="+ shift_id ,
success:function(result){
console.log(result)
window.location.href = '/';
}
});
});
$('#back').on('click',function(){
window.location.href = "<%= foodcourt_food_court_path%>";
});
/** start CB Card Settle process **/
$("#card_settlement").on('click', function(){
if(typeof code2lab != 'undefined'){
$('#cardSettleModal').modal({ keyboard: false, backdrop: false });
code2lab.getCommPorts();
}else{
swal({
title: 'Oops',
text: 'Settlement can not print out in browser!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/shift/'+cashier_type+'/close';
});
}
});
//CB Bank payment settlement ECR integration
function setCommPorts(comPortLists) {
// alert(comPortLists);
$('#sel_com_port').html("");
var jsonPortLists = $.parseJSON(comPortLists);
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
$.each(jsonPortLists,function(key,value){
$('#sel_com_port').append("<option value='"+value+"'>"+value+"</option>");
});
}
else{
swal({
title: 'Oops',
text: 'Payment can not pay in browser!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/shift/'+cashier_type+'/close';
});
}
}
$("#card_settle").on('click', function () {
$("#loading_wrapper").show();
$('#cardSettleModal').modal('hide');
reqCBBankMPUSettlement();
});
//add req data to card_settle_trans table
function reqCardSettleTrans(cmd_type,payment_type,com_port) {
var jobj = {"cmd_type" : cmd_type, "payment_type" : payment_type};
$.ajax({
type: "POST",
url: "/foodcourt/bank_integration/settle_trans",
data: {type:"request", data: jobj},
dataType: "json",
success: function(data) {
if (data.status == "success"){
resCardSettleTrans(data.card_settle_trans_id,cmd_type,payment_type,com_port);
}
}
});
}
//add res data to card_settle_trans table
function resCardSettleTrans(card_settle_trans_id,cmd_type,payment_type,com_port) {
var resMsg = "";
if($("#loading_wrapper").is(':visible')){
resMsg = code2lab.reqBankPayment(cmd_type, payment_type, 1, "", com_port);
}
if(resMsg.includes("STATUS")){
var jobj = $.parseJSON(resMsg);
$.ajax({
type: "POST",
url: "/foodcourt/bank_integration/settle_trans",
data: {type:"response", card_settle_trans_id: card_settle_trans_id, data: jobj},
dataType: "json",
success: function(data) {
if(data.status == "success"){
if(payment_type == "MPU"){
reqCBBankVMJSettlement();
}
else if(payment_type == "VMJ"){
reqCBBankJCBSettlement();
}
else if(payment_type == "JCB"){
reqCBBankCUPSettlement();
}
else if(payment_type == "CUP"){
$("#loading_wrapper").hide();
swal({
title: 'Information!',
text: 'Settlement is successfully.',
type: 'success',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/shift/'+cashier_type+'/close';
});
// reqCBBankAlipaySettlement();
}
// else if(payment_type == "Alipay"){
// reqCBBankIPPSettlement();
// $('#loading').hide();
// }
}
}
});
}
else{
$("#loading_wrapper").hide();
swal ( "Oops" , resMsg.toString() , "error" );
}
}
//settle for MPU / MPU-UPI
function reqCBBankMPUSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "MPU";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for VMJ (VISA, MASTER)
function reqCBBankVMJSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "VMJ"; //VISA,Master and JCB
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for JCB
function reqCBBankJCBSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "JCB";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for International Union Pay (CUP)
function reqCBBankCUPSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "CUP";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for Alipay
function reqCBBankAlipaySettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "Alipay";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for insert/direct swipe (now does not using this state - future one)
function reqCBBankIPPSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "IPP";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
/** end CB Card Settle process **/
</script>

View File

@@ -0,0 +1 @@
json.status true