sale item report and rebate balance
This commit is contained in:
@@ -25,6 +25,13 @@ $(document).on("focus", "[data-behaviour~='datepicker']", function(e){
|
|||||||
$('.dropdown-toggle').dropdown();
|
$('.dropdown-toggle').dropdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function export_to(path)
|
||||||
|
{
|
||||||
|
var form_params = $("#frm_report").serialize();
|
||||||
|
alert(form_params);
|
||||||
|
window.location = path+"?"+ form_params;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ToDo Move to here from pages
|
* ToDo Move to here from pages
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ $(document).ready(function(){
|
|||||||
control_button(order_status);
|
control_button(order_status);
|
||||||
|
|
||||||
var customer_id=$(this).find(".customer-id").text();
|
var customer_id=$(this).find(".customer-id").text();
|
||||||
show_customer_details(customer_id);
|
//show_customer_details(customer_id);
|
||||||
|
|
||||||
$("#re-print").val(unique_id);
|
$("#re-print").val(unique_id);
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
|
begin
|
||||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||||
dob: dob,
|
dob: dob,
|
||||||
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||||
@@ -103,6 +104,9 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
response = { status: false }
|
||||||
|
end
|
||||||
|
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ end
|
|||||||
merchant_uid = memberaction.merchant_account_id.to_s
|
merchant_uid = memberaction.merchant_account_id.to_s
|
||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
begin
|
||||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||||
dob: dob,
|
dob: dob,
|
||||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||||
@@ -168,7 +172,9 @@ end
|
|||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
response = { status: false }
|
||||||
|
end
|
||||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||||
format.json { render :show, status: :ok, location: @crm_customer }
|
format.json { render :show, status: :ok, location: @crm_customer }
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,6 @@ class Reports::DailySaleController < BaseReportController
|
|||||||
@tax = SaleTax.get_tax(from,to)
|
@tax = SaleTax.get_tax(from,to)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @locations = Location.all
|
|
||||||
|
|
||||||
# branch,from, to, report_type = get_date_range_from_params
|
|
||||||
|
|
||||||
# @location = Location.find_by_id(current_location)
|
|
||||||
# @sale_data = Sale.daily_sales_report(current_location,from,to)
|
|
||||||
# @tax = SaleT.get_tax(current_location,from,to)
|
|
||||||
|
|
||||||
# if @sale_data.blank? && @tax.blank? && request.post?
|
|
||||||
# flash.now[:notice] = "No data available for selected filters"
|
|
||||||
# end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
14
app/controllers/reports/sale_item_controller.rb
Normal file
14
app/controllers/reports/sale_item_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class Reports::SaleItemController < BaseReportController
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
from, to, report_type = get_date_range_from_params
|
||||||
|
|
||||||
|
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -16,6 +16,14 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||||
|
|
||||||
|
REPORT_TYPE = {
|
||||||
|
"daily" => 0,
|
||||||
|
"monthly" => 1,
|
||||||
|
"yearly" => 2
|
||||||
|
}
|
||||||
|
|
||||||
|
SALE_STATUS_COMPLETED = "completed"
|
||||||
|
|
||||||
def generate_invoice_from_booking(booking_id, requested_by)
|
def generate_invoice_from_booking(booking_id, requested_by)
|
||||||
booking = Booking.find(booking_id)
|
booking = Booking.find(booking_id)
|
||||||
status = false
|
status = false
|
||||||
@@ -328,6 +336,40 @@ class Sale < ApplicationRecord
|
|||||||
return daily_total
|
return daily_total
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||||
|
|
||||||
|
query = Sale.select("
|
||||||
|
mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total,
|
||||||
|
SUM(i.qty) as total_item," +
|
||||||
|
" i.unit_price as unit_price,
|
||||||
|
mi.name as product_name,
|
||||||
|
mc.name as menu_category_name,
|
||||||
|
mc.id as menu_category_id ")
|
||||||
|
.group('mi.id')
|
||||||
|
.order("mi.menu_category_id")
|
||||||
|
|
||||||
|
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||||
|
JOIN menu_items mi ON i.product_code = mi.item_code" +
|
||||||
|
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
|
||||||
|
JOIN employees ea ON ea.id = sales.cashier_id")
|
||||||
|
|
||||||
|
|
||||||
|
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case report_type.to_i
|
||||||
|
when REPORT_TYPE["daily"]
|
||||||
|
return query
|
||||||
|
when REPORT_TYPE["monthly"]
|
||||||
|
|
||||||
|
return query.group("MONTH(date)")
|
||||||
|
when REPORT_TYPE["yearly"]
|
||||||
|
return query.group("YEAR(date)")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
all_total(sale_data)
|
all_total(sale_data)
|
||||||
|
|
||||||
if member_info != nil
|
if member_info != nil
|
||||||
member_info(member_info)
|
member_info(member_info,customer_name)
|
||||||
end
|
end
|
||||||
footer
|
footer
|
||||||
end
|
end
|
||||||
@@ -61,14 +61,14 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
# y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
# bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
text "Customer:", :size => self.item_font_size,:align => :left
|
# text "Customer:", :size => self.item_font_size,:align => :left
|
||||||
end
|
# end
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_width) do
|
# bounding_box([self.label_width,y_position], :width =>self.item_width) do
|
||||||
text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
# text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
||||||
end
|
# end
|
||||||
move_down 5
|
# move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
@@ -203,19 +203,32 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
# show member information
|
# show member information
|
||||||
def member_info(member_info)
|
def member_info(member_info,customer_name)
|
||||||
|
|
||||||
move_down 7
|
move_down 7
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Customer", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down 5
|
||||||
|
|
||||||
if member_info["status"] == true
|
if member_info["status"] == true
|
||||||
member_info["data"].each do |res|
|
member_info["data"].each do |res|
|
||||||
|
|
||||||
move_down 5
|
if res["accountable_type"]== "RebateAccount"
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
move_down 5
|
||||||
text "#{ res["accountable_type"] }", :size => self.item_font_size,:align => :left
|
y_position = cursor
|
||||||
end
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
text "Rebate Balance", :size => self.item_font_size,:align => :left
|
||||||
text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -364,7 +364,7 @@
|
|||||||
<td class="item-attr"><strong id="order-grand-total"><%=@selected_item.grand_total rescue 0%></strong></td>
|
<td class="item-attr"><strong id="order-grand-total"><%=@selected_item.grand_total rescue 0%></strong></td>
|
||||||
</tr> -->
|
</tr> -->
|
||||||
|
|
||||||
<tr class="rebate_amount"></tr>
|
<!-- <tr class="rebate_amount"></tr> -->
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -147,4 +147,5 @@ $(function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -32,16 +32,16 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th style='text-align:center;'>Sr.no</th>
|
<th style='text-align:center;'>Sr.no</th>
|
||||||
<th style='text-align:center;'>Date</th>
|
<th style='text-align:center;'>Date</th>
|
||||||
<th style='text-align:center;'>Daily Void Amount</th>
|
<th style='text-align:center;'>Void Amount</th>
|
||||||
<th style='text-align:center;'>Daily mpu Sales</th>
|
<th style='text-align:center;'>Mpu Sales</th>
|
||||||
<th style='text-align:center;'>Daily master Sales</th>
|
<th style='text-align:center;'>Master Sales</th>
|
||||||
<th style='text-align:center;'>Daily visa Sales</th>
|
<th style='text-align:center;'>Visa Sales</th>
|
||||||
<th style='text-align:center;'>Daily jcb Sales</th>
|
<th style='text-align:center;'>Jcb Sales</th>
|
||||||
<th style='text-align:center;'>Daily paypar Sales</th>
|
<th style='text-align:center;'>Paypar Sales</th>
|
||||||
<th style='text-align:center;'>Daily Cash Sales</th>
|
<th style='text-align:center;'>Cash Sales</th>
|
||||||
<th style='text-align:center;'>Daily Credit Sales</th>
|
<th style='text-align:center;'>Credit Sales</th>
|
||||||
<th style='text-align:center;'>Daily FOC Sales</th>
|
<th style='text-align:center;'>FOC Sales</th>
|
||||||
<th style='text-align:center;'>(Daily Discount)</th>
|
<th style='text-align:center;'>(Discount)</th>
|
||||||
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
||||||
<th style='text-align:center;'>Rounding Adj.</th>
|
<th style='text-align:center;'>Rounding Adj.</th>
|
||||||
<th style='text-align:center;'>Grand Total</th>
|
<th style='text-align:center;'>Grand Total</th>
|
||||||
|
|||||||
@@ -10,16 +10,16 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th style='text-align:center;'>Sr.no</th>
|
<th style='text-align:center;'>Sr.no</th>
|
||||||
<th style='text-align:center;'>Date</th>
|
<th style='text-align:center;'>Date</th>
|
||||||
<th style='text-align:center;'>Daily Void Amount</th>
|
<th style='text-align:center;'>Void Amount</th>
|
||||||
<th style='text-align:center;'>Daily mpu Sales</th>
|
<th style='text-align:center;'>Mpu Sales</th>
|
||||||
<th style='text-align:center;'>Daily master Sales</th>
|
<th style='text-align:center;'>Master Sales</th>
|
||||||
<th style='text-align:center;'>Daily visa Sales</th>
|
<th style='text-align:center;'>Visa Sales</th>
|
||||||
<th style='text-align:center;'>Daily jcb Sales</th>
|
<th style='text-align:center;'>Jcb Sales</th>
|
||||||
<th style='text-align:center;'>Daily paypar Sales</th>
|
<th style='text-align:center;'>Paypar Sales</th>
|
||||||
<th style='text-align:center;'>Daily Cash Sales</th>
|
<th style='text-align:center;'>Cash Sales</th>
|
||||||
<th style='text-align:center;'>Daily Credit Sales</th>
|
<th style='text-align:center;'>Credit Sales</th>
|
||||||
<th style='text-align:center;'>Daily FOC Sales</th>
|
<th style='text-align:center;'>FOC Sales</th>
|
||||||
<th style='text-align:center;'>(Daily Discount)</th>
|
<th style='text-align:center;'>(Discount)</th>
|
||||||
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
||||||
<th style='text-align:center;'>Rounding Adj.</th>
|
<th style='text-align:center;'>Rounding Adj.</th>
|
||||||
<th style='text-align:center;'>Grand Total</th>
|
<th style='text-align:center;'>Grand Total</th>
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<div class="page-header">
|
|
||||||
<ul class="breadcrumb">
|
|
||||||
<li><a href="<%= %>">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>
|
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
<option value="9">Last year</option>
|
<option value="9">Last year</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-2">
|
<input type="hidden" name="report_type" value="sale_item" id="sel_sale_type">
|
||||||
|
<!-- <div class="form-group col-md-2">
|
||||||
<label>Select Type</label>
|
<label>Select Type</label>
|
||||||
<select name="sale_type" id="sel_sale_type" class="form-control">
|
<select name="sale_type" id="sel_sale_type" class="form-control">
|
||||||
<option value="0">All Sale Type</option>
|
<option value="0">All Sale Type</option>
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
<option value="4">Taxes Only</option>
|
<option value="4">Taxes Only</option>
|
||||||
<option value="5">Other Amount Only</option>
|
<option value="5">Other Amount Only</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<!-- <label class="">Select Shift Period</label> -->
|
<!-- <label class="">Select Shift Period</label> -->
|
||||||
<label class="">From</label>
|
<label class="">From</label>
|
||||||
@@ -144,68 +145,12 @@ $(function(){
|
|||||||
// window.location = url;
|
// window.location = url;
|
||||||
});
|
});
|
||||||
|
|
||||||
var item = $('#item').val();
|
function export_to(path)
|
||||||
var payment_type = $('#payment_type');
|
{
|
||||||
|
var form_params = $("#frm_report").serialize();
|
||||||
|
window.location = path+"?"+ form_params;
|
||||||
|
}
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//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]%>');
|
|
||||||
|
|
||||||
|
|
||||||
$("#from").val("<%=params[:from]%>");
|
|
||||||
$("#to").val("<%=params[:to]%>");
|
|
||||||
$("#sel_period").val(<%=params[:period]%>);
|
|
||||||
$("#sel_sale_type").val(<%=params[:sale_type]%>);
|
|
||||||
|
|
||||||
<% 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>
|
</script>
|
||||||
141
app/views/reports/sale_item/index.html.erb
Normal file
141
app/views/reports/sale_item/index.html.erb
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<div class="page-header">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="<%= %>">Home</a></li>
|
||||||
|
<li>Daily Sale Report</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<%= render :partial=>'shift_sale_report_filter',
|
||||||
|
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_item_index_path} %>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right">
|
||||||
|
<a href="javascript:export_to('<%=reports_sale_item_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container margin-top-20">
|
||||||
|
<div class="card row">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Date</th>
|
||||||
|
<th id="date"></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Menu Category</th>
|
||||||
|
<th>Code</th>
|
||||||
|
<th>Product</th>
|
||||||
|
<th>Total Item</th>
|
||||||
|
<th>Unit Price</th>
|
||||||
|
<th>Revenue</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
|
||||||
|
var cate = [];
|
||||||
|
var y;
|
||||||
|
var count = 0;
|
||||||
|
var sub_total = 0;
|
||||||
|
var sub_total_arr = [];
|
||||||
|
|
||||||
|
<% @sale_data.each do |result| %>
|
||||||
|
|
||||||
|
count = count + 1;
|
||||||
|
if(count == 1)
|
||||||
|
$('#date').append('<%= result.date_name rescue '-'%>');
|
||||||
|
|
||||||
|
y = $.inArray(<%= result.menu_category_id %>, cate);
|
||||||
|
if(y == -1){
|
||||||
|
//add sub total row
|
||||||
|
sub_total_arr.push(sub_total);
|
||||||
|
var total_row = '<tr><td colspan="4"></td>'+
|
||||||
|
'<td > Sub Total</td> ' +
|
||||||
|
'<td><span class="underline">'+ sub_total +'</span></td>'+
|
||||||
|
'</tr>';
|
||||||
|
|
||||||
|
|
||||||
|
if(count != 1){
|
||||||
|
$('.table').append(total_row);
|
||||||
|
sub_total = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cate.push(<%= result.menu_category_id %>);
|
||||||
|
var th = '<tr><td colspan="6"><%= result.menu_category_name rescue '-'%></td></tr>';
|
||||||
|
var tr = '<tr>'+
|
||||||
|
'<td></td>'+
|
||||||
|
'<td><%= result.code rescue '-'%></td>' +
|
||||||
|
'<td><%= result.product_name rescue '-'%></td>' +
|
||||||
|
'<td><%= result.total_item.to_i rescue '-'%></td>' +
|
||||||
|
'<td><%= number_with_precision(result.unit_price, :precision => 0) rescue '-'%></td>'+
|
||||||
|
'<td><%= number_with_precision(result.grand_total, :precision => 0) rescue '-'%>'+
|
||||||
|
'</td>'+
|
||||||
|
'</tr>';
|
||||||
|
|
||||||
|
|
||||||
|
$('.table').append(th);
|
||||||
|
$('.table').append(tr);
|
||||||
|
|
||||||
|
sub_total = parseInt(sub_total) + parseInt(<%= result.grand_total rescue '-'%>);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
var tr = '<tr>'+
|
||||||
|
'<td></td>'+
|
||||||
|
'<td><%= result.code rescue '-'%></td>' +
|
||||||
|
'<td><%= result.product_name rescue '-'%></td>' +
|
||||||
|
'<td><%= result.total_item.to_i rescue '-'%></td>' +
|
||||||
|
'<td><%= number_with_precision(result.unit_price, :precision => 0) rescue '-'%></td>'+
|
||||||
|
'<td><%= number_with_precision(result.grand_total, :precision => 0) rescue '-'%></td></tr>';
|
||||||
|
$('.table').append(tr);
|
||||||
|
|
||||||
|
sub_total = parseInt(sub_total) + parseInt(<%= result.grand_total rescue '-'%>);
|
||||||
|
}
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
last_line_subtotal(sub_total);
|
||||||
|
sub_total_arr.push(parseInt(sub_total));
|
||||||
|
grand_total(sub_total_arr);
|
||||||
|
})
|
||||||
|
|
||||||
|
function last_line_subtotal(sub_total){
|
||||||
|
|
||||||
|
var total_row = '<tr><td colspan="4"></td>'+
|
||||||
|
'<td > Sub Total</td> ' +
|
||||||
|
'<td><span class="underline">'+ sub_total +'</span></td>'+
|
||||||
|
'</tr>';
|
||||||
|
|
||||||
|
$('.table').append(total_row);
|
||||||
|
}
|
||||||
|
|
||||||
|
function grand_total(sub_total_arr){
|
||||||
|
|
||||||
|
var total = 0;
|
||||||
|
for(var i=0; i< sub_total_arr.length; i++){
|
||||||
|
//total_1 = (total_1) + (sub_total_arr[i]);
|
||||||
|
total = parseInt(total) + parseInt(sub_total_arr[i]);
|
||||||
|
}
|
||||||
|
var row = '<tr><td colspan="4"></td>'+
|
||||||
|
'<td > Grand Total</td> ' +
|
||||||
|
'<td><span class="double_underline">'+ total +'</span></td>'+
|
||||||
|
'</tr>';
|
||||||
|
$('.table').append(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
116
app/views/reports/sale_item/index.xls.erb
Normal file
116
app/views/reports/sale_item/index.xls.erb
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<div class="card row">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<% if params[:from]%>
|
||||||
|
<tr>
|
||||||
|
<th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)</th>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<th style='text-align:center;'>Sr.no</th>
|
||||||
|
<th style='text-align:center;'>Date</th>
|
||||||
|
<th style='text-align:center;'>Daily Void Amount</th>
|
||||||
|
<th style='text-align:center;'>Daily mpu Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily master Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily visa Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily jcb Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily paypar Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily Cash Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily Credit Sales</th>
|
||||||
|
<th style='text-align:center;'>Daily FOC Sales</th>
|
||||||
|
<th style='text-align:center;'>(Daily Discount)</th>
|
||||||
|
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
||||||
|
<th style='text-align:center;'>Rounding Adj.</th>
|
||||||
|
<th style='text-align:center;'>Grand Total</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<% unless @sale_data.empty? %>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% void = 0 %>
|
||||||
|
<% mpu = 0 %>
|
||||||
|
<% master = 0 %>
|
||||||
|
<% visa = 0 %>
|
||||||
|
<% jcb = 0 %>
|
||||||
|
<% paypar = 0 %>
|
||||||
|
<% cash = 0 %>
|
||||||
|
<% credit = 0 %>
|
||||||
|
<% foc = 0 %>
|
||||||
|
<% discount = 0 %>
|
||||||
|
<% total = 0 %>
|
||||||
|
<% grand_total = 0 %>
|
||||||
|
<% count = 1 %> <% rounding_adj = 0 %>
|
||||||
|
<% @sale_data.each do |sale| %>
|
||||||
|
<% void += sale[:void_amount] %>
|
||||||
|
<% mpu += sale[:mpu_amount] %>
|
||||||
|
<% master += sale[:master_amount] %>
|
||||||
|
<% visa += sale[:visa_amount] %>
|
||||||
|
<% jcb += sale[:jcb_amount] %>
|
||||||
|
<% paypar += sale[:paypar_amount] %>
|
||||||
|
<% cash += sale[:cash_amount] %>
|
||||||
|
<% credit += sale[:credit_amount] %>
|
||||||
|
<% foc += sale[:foc_amount] %>
|
||||||
|
<% discount += sale[:total_discount] %>
|
||||||
|
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||||
|
<% grand_total += sale[:grand_total].to_f %>
|
||||||
|
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||||
|
<tr>
|
||||||
|
<td style='text-align:right;'><%= count %></td>
|
||||||
|
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||||
|
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<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[: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>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<% count = count + 1 %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<tr style="font-weight:600;">
|
||||||
|
<td colspan="3" style='text-align:center;'>Total</td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% total_tax = 0 %>
|
||||||
|
<% unless @tax.empty? %>
|
||||||
|
<% @tax.each do |tax| %>
|
||||||
|
<% total_tax += tax.tax_amount.to_f %>
|
||||||
|
<tr style="font-weight:600;">
|
||||||
|
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td colspan="2"> </td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<% net = total - total_tax %>
|
||||||
|
<tr style="font-weight:600;">
|
||||||
|
<td colspan="12" style='text-align:right;'>Net Amount</td>
|
||||||
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
|
||||||
|
<td colspan="2"> </td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -212,6 +212,7 @@ Rails.application.routes.draw do
|
|||||||
namespace :reports do
|
namespace :reports do
|
||||||
resources :receipt_no, :only => [:index, :show]
|
resources :receipt_no, :only => [:index, :show]
|
||||||
resources :daily_sale, :only => [:index, :show]
|
resources :daily_sale, :only => [:index, :show]
|
||||||
|
resources :sale_item, :only => [:index, :show]
|
||||||
# resources :sales, :only => [:index, :show]
|
# resources :sales, :only => [:index, :show]
|
||||||
# resources :orders, :only => [:index, :show]
|
# resources :orders, :only => [:index, :show]
|
||||||
# resources :customers, :only => [:index, :show]
|
# resources :customers, :only => [:index, :show]
|
||||||
|
|||||||
Reference in New Issue
Block a user