update receipt repoert

This commit is contained in:
Aung Myo
2017-07-08 10:25:22 +06:30
parent 4d3de51e72
commit 8985393535
13 changed files with 751 additions and 208 deletions

View File

@@ -5,6 +5,9 @@ class Reports::DailysaleController < BaseReportController
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
puts from
puts to
puts "sssssssss"
respond_to do |format|
format.html
format.xls

View File

@@ -1,13 +1,34 @@
class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
puts "from..."
puts from
puts "to..."
puts to
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
from, to, report_type = get_date_range_from_params
# if to.blank?
# @shift = ShiftSale.where('shift_started_at <= ? and shift_closed_at is NULL',from).take
# else
# @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take
# end
puts "2017-07-07T10:46:09.000Z - 2017-07-07T11:12:51.000Z"
puts "2017-06-25 17:30:00 UTC 2017-07-02 17:29:59 UTC"
puts params[:shift_name]
puts from.utc
puts to.utc
if params[:shift_name].to_i != 0
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at =?',from,to).take
puts @shift.to_json
@sale_data = Sale.where('shift_sale_id = ? ',@shift.id)
@sale_taxes = Sale.get_separate_tax(from,to)
else
@sale_data = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from.utc,to.utc)
@sale_taxes = Sale.get_separate_tax(from.utc,to.utc)
end
if @shift.present?
@shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
end
respond_to do |format|
format.html
format.xls
@@ -15,6 +36,231 @@ authorize_resource :class => false
end
def show
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
puts "hhhhhhhhhhhhhhhhhhhhh"
puts @sale_data.to_json
puts from
puts to
puts report_type
puts params[:shift_name]
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
str = { :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
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
branch = params[:branch]
report_type = params[:report_type]
shift_name = params[:shift_name]
unless shift_name.nil?
shift_arr = shift_name.split(' - ')
shift_from = shift_arr[0]
shift_to = shift_arr[1]
end
day_ref = day_ref = Time.now.utc.getlocal
if period_type.to_i == 1
### =>search by from and to
unless shift_name.nil?
if shift_name.to_s == '0'
### => all shift
f_date = DateTime.parse(params[:from])
t_date = DateTime.parse(params[: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
unless shift_from == '-'
f_date = DateTime.parse(shift_from)
from = f_date
else
from = ''
end
unless shift_to == '-'
t_date = DateTime.parse(shift_to)
to = t_date
else
to = ''
end
end
else
f_date = DateTime.parse(params[:from])
t_date = DateTime.parse(params[: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
end
else
### => search by Today or yesterday
unless shift_name.nil?
if shift_name.to_s == '0'
### => all shift
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
else
unless shift_from == '-'
f_date = DateTime.parse(shift_from)
#f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
from = f_date.utc
else
from = ''
end
unless shift_to == '-'
t_date = DateTime.parse(shift_to)
#t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
to = t_date.utc
else
to = ''
end
end
else
if params[:report_type].to_i != 0
r_type = params[:report_type].to_s
if r_type == 'shift_item'
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
else
### => report not shift
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
end
end
return from, to,report_type
end
end

View File

@@ -445,6 +445,7 @@ class Sale < ApplicationRecord
total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj")
.where("(sale_status = ? OR sale_status = ?) AND receipt_date between ? and ? AND total_amount != 0", 'completed', 'void', from_date, to_date)
@@ -454,6 +455,7 @@ class Sale < ApplicationRecord
old_grand_total = sale.old_grand_total
total_discount = sale.total_discount
void_amount = sale.void_amount
total_change_amount = sale.total_change_amount
total = {:sale_date => pay.sale_date,
:mpu_amount => pay.mpu_amount,
:master_amount => pay.master_amount,
@@ -464,6 +466,7 @@ class Sale < ApplicationRecord
:credit_amount => pay.credit_amount,
:foc_amount => pay.foc_amount,
:total_discount => total_discount,
:total_change_amount => total_change_amount,
:grand_total => grand_total,
:old_grand_total => old_grand_total,
:void_amount => void_amount,
@@ -514,7 +517,7 @@ def self.get_by_shiftsales(from,to)
return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
# def self.get_by_shiftsales(employee,from,to)
# def self.get_by_shiftsales(from,to)
# shift_sales = ShiftSale.select('shift_sales.id, cs.name as cashier_station_name, shift_sales.shift_started_at as opening_date, shift_sales.shift_closeed_at as closing_date')
# .joins(" INNER JOIN cashier_terminals cs ON cs.id = shift_sales.cashier_terminal_id")
# .where("shift_sales.employee_id = ? and (shift_sales.shift_started_at between ? and ? OR shift_sales.shift_closeed_at between ? and ? )", employee, from, to, from, to)
@@ -529,23 +532,23 @@ end
# void = Sale.select("SUM(sales.grand_total) AS grand_total")
# .joins("join shift_sales sh on sh.id = sales.shift_sale_id")
# .where('sales.sales_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id)
# .where('sales.sale_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id)
# .sum(:grand_total)
# cash = all_total.select('sr.payment_type')
# .where('sr.payment_type = "cash"')
# .sum(:amount)
# credit = all_total.where('sr.payment_type = "credit"')
# credit = all_total.where('sr.payment_type = "creditnote"')
# .sum(:amount)
# accept_credit = all_total.select('ci.amout')
# .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id")
# .where('sr.payment_type = "credit"')
# .where('sr.payment_type = "creditnote"')
# .sum(:amout)
# foc = all_total.where('sales.payment_type = "foc" and sales.sales_status = "completed"')
# foc = all_total.where('sales.payment_type = "foc" and sales.sale_status = "completed"')
# .sum(:grand_total)
# card = all_total.select('payment_type')
@@ -571,6 +574,31 @@ end
# return sale_arr
# end
# def self.get_receipt_no_list(from,to)
# sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
# end
def self.get_by_shift_sale(from,to,status)
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,shift_closed_at As closing_date," +
" grand_total AS grand_total, cash_sales AS cash," +
"total_taxes AS total_tax,total_discounts As total_discount")
.order("shift_sales.id DESC")
return query = query.where("shift_sales.shift_started_at between ? and ?" + " or shift_sales.shift_closed_at between ? and ?",from,to ,from,to )
end
def self.get_separate_tax(from,to,payment_type=nil)
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.joins("INNER JOIN sales ON sales.id = sale_taxes.sale_id")
.group("sale_taxes.tax_name")
return query = query.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
end
def grand_total_after_rounding
return self.grand_total.to_f + self.rounding_adjustment.to_f
end
def get_cash_amount
cash = 0.0
self.sale_payments.each do |pay|
@@ -616,8 +644,4 @@ end
def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
end
def self.get_receipt_no_list(from,to)
sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
end
end

View File

@@ -317,16 +317,16 @@ class ReceiptBillPdf < Prawn::Document
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
# old = balance + redeem
old = balance + redeem
# move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
# text "Old Balance", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
# text "#{number_with_precision(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
# end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
end

View File

@@ -119,7 +119,7 @@
<div class="col-md-4" id="others"><%= @other %></div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" style="line-height:30px;height: 30px;margin-bottom: 0px;" >
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-12">Other Payments</div>
</div>
<% end %>

View File

@@ -19,17 +19,7 @@
</select>
</div>
<input type="hidden" name="report_type" value="daily_sale" id="sel_sale_type">
<!-- <div class="form-group col-md-2">
<label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="0">All Sale Type</option>
<option value="1">Revenue Only</option>
<option value="2">Discount Only</option>
<option value="3">Void Only</option>
<option value="4">Taxes Only</option>
<option value="5">Other Amount Only</option>
</select>
</div> -->
<div class="form-group col-md-3">
<!-- <label class="">Select Shift Period</label> -->
<label class="">From</label>

View File

@@ -70,7 +70,7 @@
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
@@ -86,7 +86,7 @@
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>

View File

@@ -18,6 +18,7 @@
<option value="9">Last year</option>
</select>
</div>
<input type="hidden" name="report_type" value="shift_item" id="sel_receipt_no">
<div class="form-group col-md-2">
<label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
@@ -29,16 +30,20 @@
<option value="5">Other Amount Only</option>
</select>
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-2">
<!-- <label class="">Select Shift Period</label> -->
<label class="">From</label>
<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-2">
<label class="">To</label>
<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
</div>
<div class="form-group col-md-2 margin-top-20">
<div class="form-group col-md-2">
<label class="">All Shift</label>
<select name="shift_name" id="shift_name" class="form-control"></select>
</div>
<div class="form-group col-md-1 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
@@ -70,11 +75,7 @@
<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
<% end %>
<% if defined? shift_name %>
<!-- Temporary no needs
<select name="shift_name" id="shift_name"></select>
-->
<% end %>
<% if defined? cashiers %>
<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
@@ -116,22 +117,6 @@
</div>
</div>
<!--
<div class = "row">
<div class = "span3">
<input type="button" value="Filter by Shift" class='btn' onclick = "select_shift(this)">
</div>
<div class = "span3">
<select name="shift" id="shift">
<option value="">All Shift</option>
</select>
</div>
<div class = "span3">
</div>
</div>
-->
<script type="text/javascript">
$(function(){
@@ -166,19 +151,19 @@ $(function(){
});
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#branch").val(<%=params[:branch] rescue '-'%>);
$("#waiter").val("<%=params[:waiter] rescue '-'%>");
$("#cashier").val(<%=params[:cashier] rescue '-'%>);
$("#product").val(<%=params[:product] rescue '-'%>);
$("#singer").val(<%=params[:singer] rescue '-'%>);
$("#item").val('<%=params[:item] rescue '-'%>');
$("#guest_role").val('<%=params[:guest_role] rescue '-'%>');
$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
@@ -208,4 +193,4 @@ $('#item').change(function(){
}
}
});
</script>
</script>

View File

@@ -1,13 +1,13 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Receipt List Report</li>
</ul>
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Receipt List Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_receipt_no_index_path} %>
<hr />
</div>
@@ -21,95 +21,182 @@
<div class="container margin-top-20">
<div class="card row">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<table class="table table-striped" border="0">
<thead>
<% if !params[:from].blank?%>
<tr>
<th colspan="7">From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%></th>
</tr>
<% end %>
<% if @shift_from %>
<tr>
<% if @shift.employee %>
<% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>
<% end %>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<tr>
<th>Recipt No</th>
<th>Cashier Name</th>
<th>Total Amount</th>
<th>Discount Amount </th>
<th>Tax Amount</th>
<!-- <th>Other Amount</th> -->
<th>Grand Total</th>
<th>Rounding Adj.</th>
<th>Grand Total +<br/>
Rounding Adj.
</th>
</tr>
</thead>
<tbody>
<% grand_total = 0 %>
<% total_tax = 0 %>
<% guest_count = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% other_amt = 0 %>
<% total_nett = 0 %>
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<% @sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
<% rounding_adj += result.rounding_adjustment.to_f %>
<tr>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<td><%= sprintf "%.2f",result.total_tax rescue '-' %></td>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td>
<td><b><%= discount_amt rescue '-'%></b></td>
<td><b><%= sprintf "%.2f",total_tax rescue '-'%></b></td><!--
<td><b><%= sprintf "%.2f",service_charge rescue '-'%></b></td> -->
<!-- <td><b><%= other_amt rescue '-'%></b></td> -->
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>Total Amount</td>
<td>Discount Amount</td>
<td>Tax Amount</td>
<td>Grand Total</td>
<td>Rounding Adj.</td>
<td>Grand Total +<br/>
Rounding Adj.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<%= paginate @sale_data %>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
$(function(){
var check_arr = [];
$('#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');
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var 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 = [];
}
}
}
else{
search_by_date();
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 '-'%>';
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;
if(param_shift != ''){
if(sh_date == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}else{
selected = '';
}
str += '<option value="'+ sh_date +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
}else{
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 = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var 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){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
});
</script>

View File

@@ -1,43 +1,91 @@
<div class="span12">
<div class="table-responsive">
<div class="container margin-top-20">
<div class="card row">
<table class="table table-striped" border="0">
<thead>
<% if !params[:from].blank?%>
<tr>
<th colspan="7">From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%></th>
</tr>
<% end %>
<% if @shift_from %>
<tr>
<% if @shift.employee %>
<% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>
<% end %>
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tr>
<th>Recipt No</th>
<th>Cashier Name</th>
<th>Total Amount</th>
<th>Discount Amount </th>
<th>Tax Amount</th>
<!-- <th>Other Amount</th> -->
<th>Grand Total</th>
<th>Rounding Adj.</th>
<th>Grand Total +<br/>
Rounding Adj.
</th>
</tr>
</thead>
<tbody>
<% grand_total = 0 %>
<% total_tax = 0 %>
<% guest_count = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% other_amt = 0 %>
<% total_nett = 0 %>
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% @sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
<% rounding_adj += result.rounding_adjustment.to_f %>
<tr>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<td><%= sprintf "%.2f",result.total_tax rescue '-' %></td>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td>
<td><b><%= discount_amt rescue '-'%></b></td>
<td><b><%= sprintf "%.2f",total_tax rescue '-'%></b></td><!--
<td><b><%= sprintf "%.2f",service_charge rescue '-'%></b></td> -->
<!-- <td><b><%= other_amt rescue '-'%></b></td> -->
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>Total Amount</td>
<td>Discount Amount</td>
<td>Tax Amount</td>
<td>Grand Total</td>
<td>Rounding Adj.</td>
<td>Grand Total +<br/>
Rounding Adj.
</td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@@ -0,0 +1,115 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Receipt List Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= paginate @sale_data %>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
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 = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var 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){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
</script>

View File

@@ -0,0 +1,43 @@
<div class="span12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@@ -268,10 +268,12 @@ Rails.application.routes.draw do
#--------- Reports Controller Sections ------------#
namespace :reports do
resources :receipt_no, :only => [:index, :show]
resources :receipt_no
resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
# resources :sales, :only => [:index, :show]
# resources :orders, :only => [:index, :show]
# resources :customers, :only => [:index, :show]