Merge branch 'staging' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-07-31 13:15:23 +06:30
22 changed files with 868 additions and 63 deletions

View File

@@ -15,7 +15,7 @@ class Origami::HomeController < BaseOrigamiController
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@shop = Shop.find_by_id(1)
@status_order = ""
@status_sale = ""
@sale_array = Array.new

View File

@@ -166,7 +166,14 @@ class Origami::PaymentsController < BaseOrigamiController
def rounding_adj
saleObj = Sale.find(params[:sale_id])
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@shop = Shop.find_by_id(1)
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
else
new_total = saleObj.grand_total
end
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)

View File

@@ -0,0 +1,61 @@
class Reports::CreditPaymentController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
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
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to)
@from = from
@to = to
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(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

View File

@@ -0,0 +1,60 @@
class Reports::VoidSaleController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
# @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
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
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@sale_data = Sale.get_void_sale(@shift,from,to)
@from = from
@to = to
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(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

View File

@@ -3,6 +3,7 @@ class Transactions::ManualSalesController < ApplicationController
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }

View File

@@ -69,6 +69,8 @@ class Ability
can :overall_void, :void
elsif user.role == "cashier"
# can :overall_void, :void
can :read, Order
can :update, Order

View File

@@ -7,8 +7,8 @@ class Customer < ApplicationRecord
has_many :sales
validates_presence_of :name, :contact_no, :email,:card_no
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
validates :contact_no, uniqueness: true, numericality: true
validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
validates :card_no, uniqueness: true
validates :paypar_account_no, uniqueness: true

View File

@@ -91,7 +91,7 @@ class Sale < ApplicationRecord
add_item(item)
end
link_order_sale(order.id)
# link_order_sale(order.id)
end
self.save!
@@ -352,7 +352,7 @@ class Sale < ApplicationRecord
if saleOrder.nil?
sale_order = SaleOrder.new
sale_order.create_sale_order(self.id, order_id)
sale = sale_order.create_sale_order(self.id, order_id)
end
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
@@ -642,10 +642,42 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
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")
.group("sales.sale_id")
end
end
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")
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
if shift.present?
query = query.where("payment_method= 'creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a)
elsif shift_sale_range.present?
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a)
else
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
end
end
def self.get_void_sale(shift,from,to)
sale_arr = Array.new
query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
# .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
# .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
# OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
if shift.present?
query = query.where("sales.sale_status = 'void' and sales.shift_sale_id in (?)",shift.to_a)
else
query = query.where("sales.sale_status = 'void' and sales.receipt_date between ? and ? ",from,to)
end
out = {:items => query}
sale_arr.push(out)
return sale_arr
end
def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
if payment_type.blank?
@@ -680,18 +712,6 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
end
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
# .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id")
# .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
# .group("sale_taxes.tax_name")
# .order("sale_taxes.sale_tax_id asc")
# if shift.present?
# query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed'", shift.to_a)
# else
# query = query.where("sales.receipt_date between ? and ? #{payment_type} and sale_status= 'completed' ",from,to)
# end
end
# def self.get_separate_tax(from,to,payment_method=nil)

View File

@@ -35,7 +35,7 @@ class SeedGenerator < ApplicationRecord
else
current_no = seed.next
seed.next = seed.next + seed.increase_by
seed.next = seed.next
seed.current = current_no
seed.save
end

View File

@@ -6,7 +6,7 @@
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
@@ -32,11 +32,12 @@
<label>Mdm</label>
<%= f.radio_button :salutation,"Mdm", :class => "salutation mdm", :value=>"Mdm", :style=>"width: 30px"%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
<% flash.each do |test, msg| %>
<%
str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
@@ -80,7 +81,7 @@
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
<% str="[\"#{msg['email']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>

View File

@@ -192,7 +192,7 @@
<!-- OQS Buttons -->
<button type="button" title="Print Order Item" id="print_order_item" class="btn btn-primary btn-lg btn-block">Print</a>
<button type="button" class="btn btn-primary btn-lg btn-block" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true" aria-expanded="false"> Back </a>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true"> Back </a>
<!-- <button type="button" class="" id="print_order_summary">Print <br/>Order<br/>Summary</button> -->
</div>

View File

@@ -110,6 +110,12 @@
<!-- Temporary Disabled -->
<!-- <button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Sammary</button> -->
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
<button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back
</button>
<%end%>
</div>
</div>
<!-- Column One -->
@@ -218,4 +224,7 @@ $('#cash_out').on('click',function(){
$('#close_cashier').on('click',function(){
window.location.href = '/origami/shift/close';
})
$('#back').on('click',function(){
window.location.href = '/dashboard';
})
</script>

View File

@@ -20,7 +20,6 @@
</li>
</ul>
<!-- Nav tabs - End -->
<input type="hidden" id="rounding_adj" value="<%= @shop.is_rounding_adj %>">
<div class="tab-content">
<!--- Panel 0 - Completed Orders -->
@@ -305,27 +304,27 @@
<% if @dining.bookings.length >= 1 %>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn btn-primary btn-block" >Add Order</button> -->
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
<% else %>
<!-- <button type="button" class="btn btn-primary btn-block" disabled>Add Order</button> -->
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
<% end %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn btn-primary btn-block" >Add Order</button> -->
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
<% else %>
<!-- <button type="button" class="btn btn-primary btn-block" disabled>Add Order</button> -->
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
<% end %>
<!-- Cashier Buttons -->
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button> -->
@@ -452,9 +451,7 @@ $("#first_bill").on('click', function(){
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
var rounding_adj = $('#rounding_adj').val();
if(rounding_adj == "true"){
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
$.ajax({
type: "POST",
@@ -463,9 +460,7 @@ $('#pay').on('click',function() {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
});
}else{
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
});

View File

@@ -0,0 +1,125 @@
<div class="row">
<div class="col-md-12">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="form-group col-md-2">
<label>Select Period</label>
<select name="period" id="sel_period" class="form-control">
<option value="">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>
<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-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-3">
<label class="">All Shift</label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="form-group col-md-1 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
</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 '-'%>);
// 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>

View File

@@ -0,0 +1,150 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Credit Payment List Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_credit_payment_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_credit_payment_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<% unless @sale_data.blank? %>
<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 %>
<tr>
<th> Shift Name </th>
<th> Receive No</th>
<th> Cashier Name</th>
<th> Customer Name</th>
<th> Credit Amount </th>
</tr>
</thead>
<tbody>
<% @sale_data.each do |credit| %>
<tr>
<% if @shift_from.nil? && @shift_to.nil? %>
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
<% else %>
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
<% end %>
<td><%= credit.receipt_no rescue '-' %></td>
<td><%= credit.cashier_name rescue '-' %></td>
<td><%= credit.sale.customer.name rescue '-' %></td>
<td><%= credit.payment_amount rescue '-' %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>
<script>
$(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 = [];
}
}
}
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;
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,39 @@
<div class="container margin-top-20">
<div class="card row">
<% unless @sale_data.blank? %>
<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 %>
<tr>
<th> Shift Name </th>
<th> Receive No</th>
<th> Cashier Name</th>
<th> Customer Name</th>
<th> Credit Amount </th>
</tr>
</thead>
<tbody>
<% @sale_data.each do |credit| %>
<tr>
<% if @shift_from.nil? && @shift_to.nil? %>
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
<% else %>
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
<% end %>
<td><%= credit.receipt_no rescue '-' %></td>
<td><%= credit.cashier_name rescue '-' %></td>
<td><%= credit.sale.customer.name rescue '-' %></td>
<td><%= credit.payment_amount rescue '-' %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,125 @@
<div class="row">
<div class="col-md-12">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="form-group col-md-2">
<label>Select Period</label>
<select name="period" id="sel_period" class="form-control">
<option value="">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>
<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-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-3">
<label class="">All Shift</label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="form-group col-md-1 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
</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 '-'%>);
// 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>

View File

@@ -0,0 +1,175 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Credit Payment List Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_void_sale_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_void_sale_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<% if @sale_data.count > 0 %>
<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 %>
<% cashier_name = !@shift.nil? ? @shift[0].employee.name : '-' %>
<% end %>
<th colspan="3">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>
<% end %>
<tr>
<th>Receipt No</th>
<th>Sale Date</th>
<th>Total Amount</th>
<th>Grand Total</th>
<th>Rounding Adj.</th>
<th>Grand Total + <br/>Rounding Adj.</th>
<th>Sale Status</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<% total_amount = 0.0 %>
<% grand_total = 0.0 %>
<% rounding_adjustment = 0.0 %>
<% grand_rounding_adjustment = 0.0 %>
<% @sale_data.each do |result| %>
<% result[:items].each do |item| %>
<tr>
<td><%= item.receipt_no rescue '-' %> </td>
<td><%= item.date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-' %></td>
<td><%= item.total_amount.to_f rescue '-'%> </td>
<td><%= item.grand_total.to_f rescue '-'%> </td>
<td><%= item.rounding_adjustment.to_f rescue '-' %></td>
<td><%= item.grand_total.to_f + item.rounding_adjustment.to_f rescue '-'%> </td>
<td><%= item.sales_status rescue '-' %> </td>
<td><%= item.remarks rescue '-' %> </td>
</tr>
<% total_amount = total_amount.to_f + item.total_amount.to_f %>
<% grand_total = grand_total.to_f + item.grand_total.to_f %>
<% rounding_adjustment = rounding_adjustment.to_f + item.rounding_adjustment.to_f %>
<% grand_rounding_adjustment = grand_rounding_adjustment.to_f + item.grand_total.to_f + item.rounding_adjustment.to_f %>
<% end %>
<% end %>
<tr style="border-top:4px double #666;font-weight:600;">
<td colspan="2" style="text-align:center;">Total Void Amount :</td>
<td><%= total_amount rescue '-' %></td>
<td><%= grand_total rescue '-' %></td>
<td><%= rounding_adjustment rescue '-'%></td>
<td colspan="3"><%= grand_rounding_adjustment rescue '-'%></td>
</tr>
</tbody>
</table>
<% end %>
</div>
</div>
<script>
$(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 = [];
}
}
}
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;
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,39 @@
<div class="container margin-top-20">
<div class="card row">
<% unless @sale_data.blank? %>
<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 %>
<tr>
<th> Shift Name </th>
<th> Receive No</th>
<th> Cashier Name</th>
<th> Customer Name</th>
<th> Credit Amount </th>
</tr>
</thead>
<tbody>
<% @sale_data.each do |credit| %>
<tr>
<% if @shift_from.nil? && @shift_to.nil? %>
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
<% else %>
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
<% end %>
<td><%= credit.receipt_no rescue '-' %></td>
<td><%= credit.cashier_name rescue '-' %></td>
<td><%= credit.sale.customer.name rescue '-' %></td>
<td><%= credit.payment_amount rescue '-' %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>

View File

@@ -13,13 +13,13 @@
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
<!--
<a href="<%= transactions_void_path(@sale)%>" class="btn btn-danger btn-sm">
<i class="fa fa-trash fa-lg"></i> Void Sale
</a>
<a href="<%= transactions_manual_complete_sale_path(@sale)%>" class="btn btn-success btn-sm" disabled>
<i class="fa fa-invoice fa-lg"></i> Complete Sale
</a>
</a> -->
</span>
</ol>
</div>

View File

@@ -277,14 +277,10 @@ Rails.application.routes.draw do
resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]
resources :credit_payment, :only => [:index, :show]
resources :void_sale, :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]
# resources :products, :only => [:index, :show]
# resources :inventory, :only => [:index, :show]
# resources :employees, :only => [:index, :show]
end
#mount_compendium at: '/report' #, controller: 'reports'

View File

@@ -924,7 +924,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
{membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_account_data",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"member_discount",gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:6},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_member_campaign",gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:6},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},