added receipt no detail report
This commit is contained in:
71
app/controllers/reports/receipt_no_detail_controller.rb
Executable file
71
app/controllers/reports/receipt_no_detail_controller.rb
Executable file
@@ -0,0 +1,71 @@
|
||||
class Reports::ReceiptNoDetailController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
|
||||
@payment_method = PaymentMethodSetting.all
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = ''
|
||||
|
||||
@shift = ''
|
||||
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 = 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
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
|
||||
|
||||
@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
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1061,6 +1061,37 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
|
||||
return query
|
||||
end
|
||||
|
||||
def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type)
|
||||
## => left join -> show all sales although no orders
|
||||
if payment_type.blank?
|
||||
payment_type = ''
|
||||
else
|
||||
payment_type = " and sale_payments.payment_method = '#{payment_type}'"
|
||||
end
|
||||
|
||||
query = Sale.select("sales.*,dining_facilities.name as table_name,dining_facilities.type as table_type")
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.joins("join bookings on bookings.sale_id = sales.sale_id")
|
||||
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
.group("sales.sale_id")
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.joins("join bookings on bookings.sale_id = sales.sale_id")
|
||||
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
.group("sales.sale_id")
|
||||
else
|
||||
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.joins("join bookings on bookings.sale_id = sales.sale_id")
|
||||
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
.group("sales.sale_id")
|
||||
end
|
||||
return query
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
|
||||
query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
|
||||
s.cashier_name as cashier_name")
|
||||
|
||||
140
app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb
Executable file
140
app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb
Executable file
@@ -0,0 +1,140 @@
|
||||
<div class="p-l-15">
|
||||
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
||||
<% if period_type != false %>
|
||||
<div class="row">
|
||||
<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 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-1 col-md-1 col-sm-1 margin-top-20">
|
||||
<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 %>
|
||||
|
||||
$("#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')
|
||||
|
||||
// shift = $(".shift-id").text()
|
||||
// if (shift.length>0) {
|
||||
// $('.shift_name > option[value="'+shift+'"]').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>
|
||||
289
app/views/reports/receipt_no_detail/index.html.erb
Executable file
289
app/views/reports/receipt_no_detail/index.html.erb
Executable file
@@ -0,0 +1,289 @@
|
||||
<div class="container-fluid">
|
||||
<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.receipt_no_report") %> Details</li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_receipt_no_detail_index_path} %>
|
||||
<hr />
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_receipt_no_detail_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">
|
||||
<table class="table table-striped" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> <%= 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="7"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.table") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
|
||||
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |result| %>
|
||||
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td><%= @shift_from %> - <%= @shift_to %></td>
|
||||
<td><%= result.table_type %> - <%= result.table_name %></td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%=result.grand_total%></td>
|
||||
<!-- <td> </td> -->
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><b><%= t("views.right_panel.detail.product") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.qty") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.unit_price") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.total_price") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.created_at") %></b></th>
|
||||
</tr>
|
||||
|
||||
<% result.sale_items.each do |item|%>
|
||||
<tr>
|
||||
<td>
|
||||
<% if item.price.to_i < 0.to_i %>
|
||||
<% if item.qty.to_i < 0.to_i%>
|
||||
[PROMO QTY]<%= item.product_name rescue '-' %>
|
||||
<% else %>
|
||||
[PROMO PRICE]<%= item.product_name rescue '-' %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= item.product_name rescue '-' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= item.qty rescue '-' %></td>
|
||||
<td><%= item.unit_price rescue '-' %></td>
|
||||
<td><%= item.price rescue '-' %></td>
|
||||
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr><td colspan="5"> </td></tr>
|
||||
|
||||
<%survey = Survey.find_by_receipt_no(result.receipt_no)%>
|
||||
<% if !survey.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>No. of Guest</td>
|
||||
<td><%= survey.total_customer rescue '-' %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if !result.total_amount.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= result.total_amount %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if result.total_discount.to_f > 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %>
|
||||
<%= t("views.right_panel.detail.discount") %>
|
||||
<%= t("views.right_panel.detail.amount") %></td>
|
||||
<td> - <%= result.total_discount %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if !result.total_tax.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Tax Amount </td>
|
||||
<td><%= result.total_tax %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if result.sale_payments.count > 0%>
|
||||
<% result.sale_payments.each do |rec| %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= rec.payment_amount %> ( <%= result.payment_status %> )</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= result.amount_changed %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !result.customer_id.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Customer</td>
|
||||
<td><%= result.customer.name.contact_first_name rescue '-'%>
|
||||
(<%= result.customer.company rescue '-' %>)
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><b>Total Nett</b> - <b><%= grand_total %></b></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</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>
|
||||
182
app/views/reports/receipt_no_detail/index.xls.erb
Executable file
182
app/views/reports/receipt_no_detail/index.xls.erb
Executable file
@@ -0,0 +1,182 @@
|
||||
<!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">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> <%= 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="7"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.table") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
|
||||
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |result| %>
|
||||
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td><%= @shift_from %> - <%= @shift_to %></td>
|
||||
<td><%= result.table_type %> - <%= result.table_name %></td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%=result.grand_total%></td>
|
||||
<!-- <td> </td> -->
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><b><%= t("views.right_panel.detail.product") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.qty") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.unit_price") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.total_price") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.created_at") %></b></th>
|
||||
</tr>
|
||||
|
||||
<% result.sale_items.each do |item|%>
|
||||
<tr>
|
||||
<td>
|
||||
<% if item.price.to_i < 0.to_i %>
|
||||
<% if item.qty.to_i < 0.to_i%>
|
||||
[PROMO QTY]<%= item.product_name rescue '-' %>
|
||||
<% else %>
|
||||
[PROMO PRICE]<%= item.product_name rescue '-' %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= item.product_name rescue '-' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= item.qty rescue '-' %></td>
|
||||
<td><%= item.unit_price rescue '-' %></td>
|
||||
<td><%= item.price rescue '-' %></td>
|
||||
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr><td colspan="5"> </td></tr>
|
||||
|
||||
<%survey = Survey.find_by_receipt_no(result.receipt_no)%>
|
||||
<% if !survey.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>No. of Guest</td>
|
||||
<td><%= survey.total_customer rescue '-' %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if !result.total_amount.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= result.total_amount %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if result.total_discount.to_f > 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %>
|
||||
<%= t("views.right_panel.detail.discount") %>
|
||||
<%= t("views.right_panel.detail.amount") %></td>
|
||||
<td> - <%= result.total_discount %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if !result.total_tax.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Tax Amount </td>
|
||||
<td><%= result.total_tax %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if result.sale_payments.count > 0%>
|
||||
<% result.sale_payments.each do |rec| %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= rec.payment_amount %> ( <%= result.payment_status %> )</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= result.amount_changed %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !result.customer_id.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Customer</td>
|
||||
<td><%= result.customer.name.contact_first_name rescue '-'%>
|
||||
(<%= result.customer.company rescue '-' %>)
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><b>Total Nett</b> - <b><%= grand_total %></b></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -443,6 +443,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
#--------- Reports Controller Sections ------------#
|
||||
namespace :reports do
|
||||
resources :receipt_no
|
||||
resources :receipt_no_detail
|
||||
resources :dailysale, :only => [:index, :show]
|
||||
resources :saleitem, :only => [:index, :show]
|
||||
resources :shiftsale, :only => [:index, :show]
|
||||
|
||||
Reference in New Issue
Block a user