Add CB payment in transactions and reports

This commit is contained in:
San Wai Lwin
2018-08-03 16:01:22 +06:30
parent cbb649c8d5
commit 0abad2b305
13 changed files with 967 additions and 10 deletions

View File

@@ -0,0 +1,138 @@
class Reports::CardSaleTranController < BaseReportController
authorize_resource :class => false
# GET /transactions/sales
# GET /transactions/sales.json
def index
@payment_method = [["All Payments",''],["MPU Payment","mpu"], ["Visa Payment","visa"],
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
["Alipay Payment","alipay"]]
@sales = Sale.all
# byebug
payment_type = params[:payment_type]
# from = params[:from]
# to = params[:to]
from, to = get_date_range_from_params
status = 'Approved'
@shift_sale_range = ''
@shift = ''
if params[:shift_name].to_i != 0
@shift_sale_range = CardSaleTran.get_by_shift_sale_by_card(from,to,status)
@shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else
if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end
end
end
if from.nil? && to.nil? && payment_method.nil? && @shift.nil?
@cardSales = CardSaleTran.where("status = 'Approved'").order("sale_id desc")
@cardSales = Kaminari.paginate_array(@cardSales).page(params[:page]).per(20)
else
cardSale = CardSaleTran.searchReport(from,to,payment_type,@shift_sale_range,@shift)
if cardSale.count > 0
@cardSales = cardSale
@cardSales = Kaminari.paginate_array(@cardSales).page(params[:page]).per(20)
else
@cardSales = 0
end
end
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
# date range
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now.utc.getlocal
if from.present? && to.present?
f_date = DateTime.parse(from)
t_date = DateTime.parse(to)
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -0,0 +1,105 @@
class Transactions::CardSaleTransController < ApplicationController
authorize_resource :class => false
# GET /transactions/sales
# GET /transactions/sales.json
def index
@status = [["All Status",''], ["Approved","Approved"], ["Declined","Declined"]]
@payment_method = [["All Payments",''],["MPU Payment","mpu"], ["Visa Payment","visa"],
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
["Alipay Payment","alipay"]]
@sales = Sale.all
# byebug
payment_type = params[:payment_type]
sale_id = params[:sale_id]
status_type = params[:status_type]
# from = params[:from]
# to = params[:to]
from, to = get_date_range_from_params
if sale_id.nil? && from.nil? && to.nil? && payment_method.nil? && status_type.nil?
@cardSales = CardSaleTran.where("status IS NOT NULL").order("sale_id desc")
@cardSales = Kaminari.paginate_array(@cardSales).page(params[:page]).per(20)
else
cardSale = CardSaleTran.search(sale_id,from,to,payment_type,status_type)
if cardSale.count > 0
@cardSales = cardSale
@cardSales = Kaminari.paginate_array(@cardSales).page(params[:page]).per(20)
else
@cardSales = 0
end
end
end
# date range
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now.utc.getlocal
if from.present? && to.present?
f_date = DateTime.parse(from)
t_date = DateTime.parse(to)
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -1,2 +1,84 @@
class CardSaleTran < ApplicationRecord
end
belongs_to :sale
def self.search(filter,from,to,payment_type,status_type)
if filter.blank?
keyword = ''
else
keyword = " s.cashier_name LIKE ? OR c.name LIKE ? OR s.sale_id LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%"
end
if payment_type.blank?
payment = ''
else
if payment_type == 'unionpay'
payment = " app LIKE 'cup'"
else
payment = " app LIKE '#{payment_type}'"
end
end
if status_type.blank?
status = ''
else
status = " status = '#{status_type}'"
end
if from.present? && to.present?
# cardSale = CardSaleTran.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status IS NULL ", from,to)
from_date = from.strftime("%Y-%m-%d")
to_date = to.strftime("%Y-%m-%d")
query = CardSaleTran.joins("Join sales s ON s.sale_id = card_sale_trans.sale_id"+
" JOIN customers c ON c.customer_id = s.customer_id")
cardSale = query.where("req_date >= ? and req_date <= ? and status is not null",from_date,to_date)
query1 = cardSale.where(keyword)
query2 = query1.where(payment)
query3 = query2.where(status)
end
end
def self.searchReport(from,to,payment_type,shift_sale_range,shift)
if payment_type.blank?
payment = ''
else
if payment_type == 'unionpay'
payment = " app LIKE 'cup'"
else
payment = " app LIKE '#{payment_type}'"
end
end
if from.present? && to.present?
# cardSale = CardSaleTran.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status IS NULL ", from,to)
from_date = from.strftime("%Y-%m-%d")
to_date = to.strftime("%Y-%m-%d")
query = CardSaleTran.joins("Join sales s ON s.sale_id = card_sale_trans.sale_id"+
" JOIN customers c ON c.customer_id = s.customer_id")
cardSale = query.where("req_date >= ? and req_date <= ? and status = 'Approved'",from_date,to_date)
if shift.present?
query1 = cardSale.where("s.shift_sale_id in (?)", shift.to_a)
elsif shift_sale_range.present?
query1 = cardSale.where("s.shift_sale_id in (?)",shift_sale_range.to_a)
else
query1 = cardSale.where("s.receipt_date between ? and ?",from,to)
end
query2 = query1.where(payment)
end
end
def self.get_by_shift_sale_by_card(from,to,status)
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,
shift_closed_at As closing_date,")
.order("shift_sales.id DESC")
return query = query.where("shift_sales.shift_started_at >= ?" , from)
byebug
end
end

View File

@@ -6,6 +6,7 @@ class Sale < ApplicationRecord
#before_create :generate_receipt_no
belongs_to :cashier, :optional => true
belongs_to :customer, :optional => true
belongs_to :employees
has_many :sale_items
has_many :sale_discount_items
has_many :sale_discounts

View File

@@ -123,6 +123,16 @@
<a href="<%= transactions_order_reservations_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_card_sale_trans_path %>"><%= t :cb_payments %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_card_sale_trans_path %>"><%= t :cb_settlement %></a>
</li>
<% end %>
</ul>
</li>
<% if can? :index, :dailysale %>
@@ -174,6 +184,9 @@
<li>
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
</li>
<li>
<a href="<%= reports_card_sale_tran_index_path %>">CB Payments</a>
</li>
</ul>
</li>
<%end%>

View File

@@ -0,0 +1,144 @@
<div class="p-l-15">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<% if defined? @payment_method %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_payments") %></label>
<%= select_tag "payment_type", options_for_select(@payment_method, :selected => params[:payment_type]), :class => "form-control" %>
</div>
<% end %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<% if not defined? payments %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_payments") %></label>
<select name="payment_type" id="payment_type" class="form-control">
<% @payments.each do |pm| %>
<option class="<%=pm[1].downcase%>" 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 %>
</select>
</div>
<% end %>
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.all_shift") %></label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$('#sale_id').val("<%= params[:sale_id] %>");
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
$(".<%=params[:payment_type]%>").attr('selected','selected')
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -0,0 +1,186 @@
<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.cb_payments") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_card_sale_tran_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_card_sale_tran_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_card_sale_tran_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card" style="width:115%;">
<table class="table table-striped" border="0">
<thead>
<tr>
<th colspan="9"> <%= 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>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="9"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th><%= t("views.right_panel.detail.req_date") %></th>
<th><%= t("views.right_panel.detail.req_no") %></th>
<th><%= t("views.right_panel.detail.req_amount") %></th>
<th><%= t("views.right_panel.detail.res_date") %></th>
<th><%= t("views.right_panel.detail.ref_no") %></th>
<th><%= t("views.right_panel.detail.res_amount") %></th>
<th><%= t("views.right_panel.detail.payment_type") %></th>
<th><%= t("views.right_panel.detail.Customer_name") %></th>
<th><%= t("views.right_panel.detail.Cashier_name") %></th>
<th><%= t("views.right_panel.detail.detail") %></th>
<th><%= t("views.right_panel.detail.status") %></th>
</tr>
</thead>
<tbody>
<% if @cardSales != 0 %>
<% @cardSales.each do |cardSale| %>
<tr>
<td><%= cardSale.req_date %> <%= cardSale.req_time.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= cardSale.req_inv_no %></td>
<td><%= cardSale.req_amt %></td>
<td><%= cardSale.res_date %> <%= cardSale.res_time.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= cardSale.ref_no %></td>
<td><%= cardSale.res_amt %></td>
<td><%= cardSale.app %></td>
<td><%= cardSale.sale.customer.name rescue '-' %></td>
<td><%= cardSale.sale.cashier_name rescue '-' %></td>
<td>TID : <%= cardSale.terminal_id %>
<br>
MID : <%= cardSale.trace %>
<br>
Batch : <%= cardSale.batch_no %>
<br>
Trace : <%= cardSale.merchant_id %>
</td>
<td><%= cardSale.status %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="10"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
$(function(){
var check_arr = [];
search_by_period();
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
}
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#from').val(from)
search_by_date();
});
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
});
function search_by_date(){
from = $("#from").val();
to = $("#to").val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
shift.empty();
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
var shift_id = data.message[index].shift_id ;
if(param_shift != ''){
if(shift_id == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}else{
selected = '';
}
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
});
</script>

View File

@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<thead>
<tr>
<th colspan="9"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to ? @to.utc.getlocal.strftime("%Y-%b-%d") : '-'%></th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="9"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th><%= t("views.right_panel.detail.req_date") %></th>
<th><%= t("views.right_panel.detail.req_no") %></th>
<th><%= t("views.right_panel.detail.req_amount") %></th>
<th><%= t("views.right_panel.detail.res_date") %></th>
<th><%= t("views.right_panel.detail.ref_no") %></th>
<th><%= t("views.right_panel.detail.res_amount") %></th>
<th><%= t("views.right_panel.detail.payment_type") %></th>
<th><%= t("views.right_panel.detail.Customer_name") %></th>
<th><%= t("views.right_panel.detail.Cashier_name") %></th>
<th><%= t("views.right_panel.detail.detail") %></th>
<th><%= t("views.right_panel.detail.status") %></th>
</tr>
</thead>
<tbody>
<% if @cardSales != 0 %>
<% @cardSales.each do |cardSale| %>
<tr>
<td><%= cardSale.req_date %> <%= cardSale.req_time.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= cardSale.req_inv_no %></td>
<td><%= cardSale.req_amt %></td>
<td><%= cardSale.res_date %> <%= cardSale.res_time.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= cardSale.ref_no %></td>
<td><%= cardSale.res_amt %></td>
<td><%= cardSale.app %></td>
<td><%= cardSale.sale.customer.name rescue '-' %></td>
<td><%= cardSale.sale.cashier_name rescue '-' %></td>
<td>TID : <%= cardSale.terminal_id %>
<br>
MID : <%= cardSale.trace %>
<br>
Batch : <%= cardSale.batch_no %>
<br>
Trace : <%= cardSale.merchant_id %>
</td>
<td><%= cardSale.status %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="10"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -18,7 +18,7 @@
<option value="9">Last year</option>
</select>
</div>
<% if defined? payments %>
<% if not defined? payments %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_payments") %></label>
@@ -47,7 +47,7 @@
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 margin-top-20">
<div class="col-lg-12 col-md-12 col-sm-12 margin-top-20 text-right">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>

View File

@@ -0,0 +1,211 @@
<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 :sale %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<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="table-responsive">
<table class="table table-">
<tbody>
<tr>
<td colspan="8">
<%= form_tag transactions_card_sale_trans_path, :method => :get do %>
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label><%= t("views.right_panel.detail.enter_keyboards") %></label>
<input type="text" id="sale_id" name="sale_id" class="form-control" placeholder="Sale ID/ Customer Name/ Cashier Name" style="margin-right: 10px;height: 34px;">
</div>
<% if defined? @payment_method %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_payments") %></label>
<%= select_tag "payment_type", options_for_select(@payment_method, :selected => params[:payment_type]), :class => "form-control" %>
</div>
<% end %>
<% if not defined? status %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_status") %></label>
<select name="status_type" id="status_type" class="form-control">
<% @status.each do |pm| %>
<option class="<%=pm[1].downcase%>" value="<%=pm[1].downcase%>"><%=pm[0]%></option>
<%end %>
</select>
</div>
<% end %>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<label class=""><%= t("views.right_panel.detail.from") %></label>
<input class="form-control datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 34px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<label class=""><%= t("views.right_panel.detail.to") %></label>
<input class="form-control datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 34px;">
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
<label></label>
<br><input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
</div>
<% end %>
</td>
</tr>
</tbody>
</table>
</div>
<div class="card" style="width:122%;">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.sale_id") %></th>
<th><%= t("views.right_panel.detail.req_date") %></th>
<th><%= t("views.right_panel.detail.req_no") %></th>
<th><%= t("views.right_panel.detail.req_amount") %></th>
<th><%= t("views.right_panel.detail.res_date") %></th>
<th><%= t("views.right_panel.detail.ref_no") %></th>
<th><%= t("views.right_panel.detail.res_amount") %></th>
<th><%= t("views.right_panel.detail.payment_type") %></th>
<th><%= t("views.right_panel.detail.Customer_name") %></th>
<th><%= t("views.right_panel.detail.Cashier_name") %></th>
<th><%= t("views.right_panel.detail.detail") %></th>
<th><%= t("views.right_panel.detail.status") %></th>
</tr>
</thead>
<tbody>
<% if @cardSales != 0 %>
<% @cardSales.each do |cardSale| %>
<tr>
<td><%= link_to cardSale.sale_id, transactions_sale_path(cardSale.sale_id) rescue '-' %></td>
<td><%= cardSale.req_date %> <%= cardSale.req_time.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= cardSale.req_inv_no %></td>
<td><%= cardSale.req_amt %></td>
<td><%= cardSale.res_date %> <%= cardSale.res_time.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= cardSale.ref_no %></td>
<td><%= cardSale.res_amt %></td>
<td><%= cardSale.app %></td>
<td><%= cardSale.sale.customer.name rescue '-' %></td>
<td><%= cardSale.sale.cashier_name rescue '-' %></td>
<td>TID : <%= cardSale.terminal_id %>
<br>
MID : <%= cardSale.trace %>
<br>
Batch : <%= cardSale.batch_no %>
<br>
Trace : <%= cardSale.merchant_id %>
</td>
<td><%= cardSale.status %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="10"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
<% end %>
</tbody>
</table>
<br>
<% if @cardSales != 0 %>
<%= paginate @cardSales %>
<% end %>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var item = $('#item').val();
var payment_type = $('#payment_type');
var status_type = $('#status_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
if(status_type){
$('#status_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
$(function(){
$('#sale_id').val("<%= params[:sale_id] %>");
$('#from').val("<%= params[:from] %>");
$('#to').val("<%= params[:to] %>");
$('#payment_type').val("<%= params[:payment_type] %>");
$('#status_type').val("<%= params[:status_type] %>");
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#from').val(from);
search_by_date();
});
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to);
search_by_date();
});
function search_by_date(){
from = $("#from").val();
to = $("#to").val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
console.log(check_arr.length)
if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
</script>

View File

@@ -0,0 +1 @@
json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale

View File

@@ -18,13 +18,13 @@ class ActionController::Base
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
# check for license file
if check_license
current_license(ENV["SX_PROVISION_URL"])
else
redirect_to activate_path
end
# else
# # check for license file
# if check_license
# current_license(ENV["SX_PROVISION_URL"])
# else
# redirect_to activate_path
# end
end
end

View File

@@ -464,6 +464,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :shift_sales
resources :surveys
resources :order_reservations
resources :card_sale_trans
get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" => "manual_sales#void", :as => "void"
@@ -487,6 +488,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :product_sale, :only => [:index, :show]
resources :order_reservation, :only => [:index, :show]
resources :induty, :only => [:index, :show]
resources :card_sale_tran
get "saleitem/get_shift_by_date", to: "saleitem#show", as: "get_shift_by_sale_item"
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"