update filter in sale and order and creditnote
This commit is contained in:
@@ -30,3 +30,15 @@ function export_to(path)
|
|||||||
var form_params = $("#frm_report").serialize();
|
var form_params = $("#frm_report").serialize();
|
||||||
window.location = path+"?"+ form_params;
|
window.location = path+"?"+ form_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
$('.datepicker').datepicker({
|
||||||
|
format : 'dd-mm-yyyy',
|
||||||
|
autoclose: true
|
||||||
|
});
|
||||||
|
$('.datepicker').attr('ReadOnly','true');
|
||||||
|
$('.datepicker').css('cursor','pointer');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,3 +76,5 @@ select.form-control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*--- Reset --- */
|
/*--- Reset --- */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,25 @@ class Transactions::CreditNotesController < ApplicationController
|
|||||||
# GET /transactions/sales.json
|
# GET /transactions/sales.json
|
||||||
def index
|
def index
|
||||||
|
|
||||||
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
@customers = Customer.all
|
||||||
|
|
||||||
|
filter = params[:filter]
|
||||||
|
customer = params[:customer]
|
||||||
|
from = params[:from]
|
||||||
|
to = params[:to]
|
||||||
|
|
||||||
|
if filter.nil? && from.nil? && to.nil? && customer.nil?
|
||||||
|
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
||||||
|
puts "cccccccccccc"
|
||||||
|
else
|
||||||
|
sale = Sale.search_credit_sales(customer,filter,from,to)
|
||||||
|
if sale.count > 0
|
||||||
|
@sales = sale
|
||||||
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
|
else
|
||||||
|
@sales = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
|
|||||||
@@ -3,22 +3,29 @@ class Transactions::OrdersController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
|
|
||||||
filter = params[:filter]
|
filter = params[:filter]
|
||||||
if filter.nil?
|
from = params[:from]
|
||||||
|
to = params[:to]
|
||||||
|
|
||||||
|
if filter.nil? || from.nil? || to.nil?
|
||||||
orders = Order.order("order_id desc")
|
orders = Order.order("order_id desc")
|
||||||
else
|
else
|
||||||
order = Order.search(filter)
|
orders = Order.search(filter,from,to)
|
||||||
if order.count > 0
|
# if order.count > 0
|
||||||
orders = order
|
# orders = order
|
||||||
else
|
# else
|
||||||
orders = Order.order("order_id desc")
|
# orders = Order.order("order_id desc")
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !orders.nil?
|
||||||
|
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
|
||||||
|
else
|
||||||
|
@orders = []
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @orders }
|
||||||
end
|
end
|
||||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # index.html.erb
|
|
||||||
format.json { render json: @orders }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -6,29 +6,42 @@ class Transactions::SalesController < ApplicationController
|
|||||||
# GET /transactions/sales.json
|
# GET /transactions/sales.json
|
||||||
def index
|
def index
|
||||||
|
|
||||||
search_date = params[:date]
|
receipt_no = params[:receipt_no]
|
||||||
receipt_no = params[:receipt_no]
|
from = params[:from]
|
||||||
today = Date.today
|
to = params[:to]
|
||||||
|
|
||||||
if receipt_no.nil? && search_date.nil?
|
if receipt_no.nil? && from.nil? && to.nil?
|
||||||
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
else
|
else
|
||||||
if !search_date.blank? && receipt_no.blank?
|
sale = Sale.search(receipt_no,from,to)
|
||||||
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
|
|
||||||
elsif !search_date.blank? && !receipt_no.blank?
|
|
||||||
sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
|
|
||||||
else
|
|
||||||
sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
|
||||||
end
|
|
||||||
if sale.count > 0
|
if sale.count > 0
|
||||||
@sales = sale
|
@sales = sale
|
||||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
else
|
else
|
||||||
@sales = 0
|
@sales = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# if receipt_no.nil? && search_date.nil?
|
||||||
|
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||||
|
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
|
# else
|
||||||
|
# if !search_date.blank? && receipt_no.blank?
|
||||||
|
# sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||||
|
# elsif !search_date.blank? && !receipt_no.blank?
|
||||||
|
# sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||||
|
# else
|
||||||
|
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
||||||
|
# end
|
||||||
|
# if sale.count > 0
|
||||||
|
# @sales = sale
|
||||||
|
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
|
# else
|
||||||
|
# @sales = 0
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: @sales }
|
format.json { render json: @sales }
|
||||||
|
|||||||
@@ -320,11 +320,12 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search(search)
|
def self.search(filter,from,to)
|
||||||
if search
|
if !from.nil? && !to.nil?
|
||||||
where("order_id LIKE ? OR item_count ='#{search}'","%#{search}%",)
|
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to)
|
||||||
else
|
else
|
||||||
find(:all)
|
# find(:all)
|
||||||
|
where("order_id LIKE ? OR item_count ='#{filter}'","%#{filter}%",)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -378,13 +378,46 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search(search)
|
def self.search(filter,from,to)
|
||||||
if search
|
|
||||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
if filter.blank?
|
||||||
where("receipt_no LIKE ?", "%#{search}%",)
|
keyword = ''
|
||||||
else
|
else
|
||||||
find(:all)
|
keyword = "receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if from.present? && to.present?
|
||||||
|
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
|
||||||
|
query = sale.where(keyword)
|
||||||
|
else
|
||||||
|
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.search_credit_sales(customer,filter,from,to)
|
||||||
|
|
||||||
|
if filter.blank?
|
||||||
|
keyword = ''
|
||||||
|
else
|
||||||
|
keyword = "and receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
|
||||||
|
end
|
||||||
|
|
||||||
|
if customer.blank?
|
||||||
|
custo = ''
|
||||||
|
else
|
||||||
|
custo = "and customer_id = '#{customer}'"
|
||||||
|
end
|
||||||
|
|
||||||
|
if from.present? && to.present?
|
||||||
|
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||||
|
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
|
||||||
|
else
|
||||||
|
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||||
|
.where("sp.payment_method =? #{keyword} #{custo}",'creditnote')
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_rounding_adjustment(num)
|
def self.get_rounding_adjustment(num)
|
||||||
|
|||||||
@@ -16,6 +16,39 @@
|
|||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td colspan="8">
|
||||||
|
<%= form_tag transactions_credit_notes_path, :method => :get do %>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label>Enter Keywords</label>
|
||||||
|
<input type="text" name="receipt_no" class="form-control" placeholder="Receipt No/Cashier Name/Status" style="margin-right: 10px">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-2">
|
||||||
|
<label>Select Customer</label>
|
||||||
|
<select class="selectpicker form-control col-md-12" name="customer" style="height: 40px" >
|
||||||
|
<option value="">Select Customer</option>
|
||||||
|
<% @customers.each do |customer| %>
|
||||||
|
<option value="<%= customer.customer_id %>">
|
||||||
|
<%= customer.name %></option>
|
||||||
|
<%end %>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-2">
|
||||||
|
<label class="">From</label>
|
||||||
|
<input class="form-control datepicker" name="from" id="date" type="text" placeholder="From date">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-2">
|
||||||
|
<label class="">To</label>
|
||||||
|
<input class="form-control datepicker" name="to" id="date" type="text" placeholder="To date">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-1">
|
||||||
|
<label></label>
|
||||||
|
<input type="submit" value="Search" class='btn btn-primary btn-md'>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Sale Id </th>
|
<th>Sale Id </th>
|
||||||
<th>Receipt no </th>
|
<th>Receipt no </th>
|
||||||
@@ -27,6 +60,8 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% if @sales != 0 %>
|
||||||
|
|
||||||
<% @sales.each do |sale| %>
|
<% @sales.each do |sale| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
||||||
@@ -39,7 +74,9 @@
|
|||||||
<td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
|
<td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<tr><td colspan="8"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
|
||||||
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -13,10 +13,28 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
<%= form_tag transactions_orders_path, :method => :get do %>
|
<%= form_tag transactions_orders_path, :method => :get do %>
|
||||||
<div class="input-append col-md-4 form-group pull-right">
|
<div class="form-group col-md-3">
|
||||||
<input type="text" name="filter" placeholder="Order ID" class="form-control input-md col-md-8">
|
<label>Enter Keyword</label>
|
||||||
<button type="submit" class="btn btn-primary btn-md">Search</button>
|
<input type="text" name="filter" placeholder="Order ID" class="form-control input-md">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-md-2">
|
||||||
|
<label>Items Count</label>
|
||||||
|
<input id="number" data-id='numberRangePicker' type="range" data-min="0" data-max="20" data-step="1" data-value="14"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-2">
|
||||||
|
<label class="">From</label>
|
||||||
|
<input class="form-control datepicker" name="from" id="date" type="text" placeholder="From date">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-2">
|
||||||
|
<label class="">To</label>
|
||||||
|
<input class="form-control datepicker" name="to" id="date" type="text" placeholder="To date">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-1">
|
||||||
|
<label></label>
|
||||||
|
<input type="submit" value="Search" class='btn btn-primary btn-md'>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
@@ -49,7 +67,9 @@
|
|||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<%= paginate @orders %>
|
<%if !@order.nil?%>
|
||||||
|
<%= paginate @orders %>
|
||||||
|
<%end%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -59,4 +79,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,22 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="8">
|
<td colspan="8">
|
||||||
<%= form_tag transactions_sales_path, :method => :get do %>
|
<%= form_tag transactions_sales_path, :method => :get do %>
|
||||||
<div class="input-append form-group pull-right col-md-6">
|
<div class="form-group col-md-4">
|
||||||
<input class="datepicker col-md-3 form-control" name="date" id="date" type="text" placeholder="Receipt date" style="margin-right: 10px">
|
<label>Enter Keywords</label>
|
||||||
|
<input type="text" name="receipt_no" class="form-control" placeholder="Receipt No/Cashier Name/Status" style="margin-right: 10px">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-3">
|
||||||
|
<label class="">From</label>
|
||||||
|
<input class="form-control datepicker" name="from" id="date" type="text" placeholder="From date">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-3">
|
||||||
|
<label class="">To</label>
|
||||||
|
<input class="form-control datepicker" name="to" id="date" type="text" placeholder="To date">
|
||||||
|
</div>
|
||||||
|
|
||||||
<input type="text" name="receipt_no" class="col-md-5 form-control" placeholder="Receipt No" style="margin-right: 10px">
|
<div class="form-group col-md-1">
|
||||||
<button type="submit" class="btn btn-primary btn">Search</button>
|
<label></label>
|
||||||
|
<input type="submit" value="Search" class='btn btn-primary btn-md'>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user