check product sale report
This commit is contained in:
@@ -14,19 +14,19 @@ class Oqs::HomeController < BaseOqsController
|
|||||||
@queue_stations = OrderQueueStation.all
|
@queue_stations = OrderQueueStation.all
|
||||||
|
|
||||||
@queue_completed_item = completed_order(@filter)
|
@queue_completed_item = completed_order(@filter)
|
||||||
# if !@queue_completed_item.empty?
|
if !@queue_completed_item.empty?
|
||||||
# @queue_completed_item.each do |queue_item|
|
@queue_completed_item.each do |queue_item|
|
||||||
# if !queue_item.set_menu_items.nil?
|
if !queue_item.set_menu_items.nil?
|
||||||
# instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
|
instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
|
||||||
# arr_instance_item_sets = Array.new
|
arr_instance_item_sets = Array.new
|
||||||
# instance_item_sets.each do |instance_item|
|
instance_item_sets.each do |instance_item|
|
||||||
# item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||||
# arr_instance_item_sets.push(item_instance_name)
|
arr_instance_item_sets.push(item_instance_name)
|
||||||
# end
|
end
|
||||||
# queue_item.set_menu_items = arr_instance_item_sets
|
queue_item.set_menu_items = arr_instance_item_sets
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
if !@filter.nil?
|
if !@filter.nil?
|
||||||
@count = queue_items_count_query(false,@filter)
|
@count = queue_items_count_query(false,@filter)
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, @usercurrent_user.name, cash, "cash")
|
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
||||||
|
|
||||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
|
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
|
|||||||
@@ -2,18 +2,19 @@ class Reports::ProductSaleController < BaseReportController
|
|||||||
authorize_resource :class => false
|
authorize_resource :class => false
|
||||||
|
|
||||||
def index
|
def index
|
||||||
order_by = 'desc'
|
@order_by = 'desc'
|
||||||
if !params[:order_by].nil?
|
if !params[:order_by].nil?
|
||||||
order_by = params[:order_by]
|
@order_by = params[:order_by]
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_data = Sale.get_menu_item_query(order_by)
|
@sale_data = Sale.get_menu_item_query(@order_by)
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
@print_settings = PrintSetting.get_precision_delimiter()
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
format.json
|
||||||
format.xls
|
format.xls
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -877,7 +877,7 @@ def self.get_menu_item_query(order_by)
|
|||||||
" LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" +
|
" LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" +
|
||||||
" LEFT JOIN sales s ON s.sale_id = si.sale_id")
|
" LEFT JOIN sales s ON s.sale_id = si.sale_id")
|
||||||
.group("mc.id, menu_items.name, si.qty, (CASE WHEN si.unit_price > 0 THEN si.unit_price ELSE mii.price END)")
|
.group("mc.id, menu_items.name, si.qty, (CASE WHEN si.unit_price > 0 THEN si.unit_price ELSE mii.price END)")
|
||||||
.order("si.qty #{order_by}, menu_items.menu_category_id desc")
|
.order("si.qty #{order_by}, menu_items.menu_category_id #{order_by}")
|
||||||
end
|
end
|
||||||
#product sale report query
|
#product sale report query
|
||||||
|
|
||||||
|
|||||||
@@ -83,13 +83,13 @@
|
|||||||
<span class="order-qty">
|
<span class="order-qty">
|
||||||
<%= qid.qty %>
|
<%= qid.qty %>
|
||||||
</span> ]
|
</span> ]
|
||||||
<% if !qid.set_menu_items.nil?
|
<% if !qid.set_menu_items.nil? %>
|
||||||
qid.set_menu_items.each do |item_instance|%>
|
<% qid.set_menu_items.each do |item_instance|%>
|
||||||
<br><span class="font-12">
|
<br><span class="font-12">
|
||||||
<%= item_instance %>
|
<%= item_instance %>
|
||||||
</span>
|
</span>
|
||||||
<% end
|
<% end %>
|
||||||
end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||||
|
|||||||
@@ -441,7 +441,7 @@
|
|||||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
||||||
var total = $('#amount_due').text();
|
var total = $('#amount_due').text();
|
||||||
var amt = parseFloat(total) - parseFloat(othertotal);
|
var amt = parseFloat(total) - parseFloat(othertotal);
|
||||||
$('#cash').text(parseFloat(amt).toFixed(1));
|
$('#cash').text(parseFloat(amt).toFixed(2));
|
||||||
update_balance();
|
update_balance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,127 +1,121 @@
|
|||||||
<div class="page-header">
|
<div class="div_product_sale">
|
||||||
<ol class="breadcrumb">
|
<div class="page-header">
|
||||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li>
|
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||||
<span class="float-right">
|
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li>
|
||||||
<%= link_to 'Back', dashboard_path %>
|
<span class="float-right">
|
||||||
</span>
|
<%= link_to 'Back', dashboard_path %>
|
||||||
</ol>
|
</span>
|
||||||
</div>
|
</ol>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="col-md-12">
|
<div class="row">
|
||||||
<div class="text-right">
|
<div class="col-md-12">
|
||||||
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
<div class="text-right">
|
||||||
</div>
|
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="margin-top-20">
|
<div class="margin-top-20">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="p-l-20 p-t-20 p-b-20">
|
<div class="p-l-20 p-t-20 p-b-20">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="font-16" for="order_by">Order by Qty</label>
|
<label class="font-16" for="order_by">Order by Qty</label>
|
||||||
<select name="order_by" id="order_by" class="form-control" style="width:10%">
|
<select name="order_by" id="order_by" class="form-control" style="width:10%">
|
||||||
<option value="asc">ASC</option>
|
<option value="asc">ASC</option>
|
||||||
<option value="desc">DESC</option>
|
<option value="desc">DESC</option>
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped" id="items_table" border="0">
|
<% if @print_settings.precision.to_i > 0
|
||||||
<thead>
|
precision = @print_settings.precision
|
||||||
<tr>
|
else
|
||||||
<th> </th>
|
precision = 0
|
||||||
<th><%= t("views.right_panel.header.menu_category") %></th>
|
end
|
||||||
<th><%= t("views.right_panel.detail.code") %></th>
|
#check delimiter
|
||||||
<th><%= t("views.right_panel.detail.product") %></th>
|
if @print_settings.delimiter
|
||||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
delimiter = ","
|
||||||
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
else
|
||||||
<th><%= t("views.right_panel.detail.total") %></th>
|
delimiter = ""
|
||||||
</tr>
|
end %>
|
||||||
</thead>
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
<tbody>
|
<thead>
|
||||||
<% if @print_settings.precision.to_i > 0
|
<tr>
|
||||||
precision = @print_settings.precision
|
<th> </th>
|
||||||
else
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
precision = 0
|
<th><%= t("views.right_panel.detail.code") %></th>
|
||||||
end
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
#check delimiter
|
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||||
if @print_settings.delimiter
|
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||||
delimiter = ","
|
<th><%= t("views.right_panel.detail.total") %></th>
|
||||||
else
|
</tr>
|
||||||
delimiter = ""
|
</thead>
|
||||||
end
|
<tbody id="tbd_data">
|
||||||
%>
|
<% unless @sale_data.blank? %>
|
||||||
<% unless @sale_data.blank? %>
|
<% acc_arr = Array.new %>
|
||||||
<% acc_arr = Array.new %>
|
<% cate_arr = Array.new %>
|
||||||
<% cate_arr = Array.new %>
|
|
||||||
|
|
||||||
<% grand_total = 0 %>
|
<% grand_total = 0 %>
|
||||||
<% total_qty = 0 %>
|
<% total_qty = 0 %>
|
||||||
|
|
||||||
<% @sale_data.each do |sale| %>
|
<% @sale_data.each do |sale| %>
|
||||||
<% if sale.status_type != "Discount" && sale.status_type != "foc"
|
<% if sale.status_type != "Discount" && sale.status_type != "foc"
|
||||||
total_qty += sale.total_item
|
total_qty += sale.total_item
|
||||||
grand_total += sale.grand_total
|
grand_total += sale.grand_total
|
||||||
end %>
|
end %>
|
||||||
<% if sale.status_type == "foc" && sale.price > 0
|
<% if sale.status_type == "foc" && sale.price > 0
|
||||||
total_qty += sale.total_item
|
total_qty += sale.total_item
|
||||||
grand_total += sale.grand_total
|
grand_total += sale.grand_total
|
||||||
end %>
|
end %>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
<td><%= sale.menu_category_name %></td>
|
<td><%= sale.menu_category_name %></td>
|
||||||
<% cate_arr.push(sale.menu_category_id) %>
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= sale.item_code rescue '-' %></td>
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
<td><%= sale.product_name rescue '-' %></td>
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
<td><%= sale.total_item rescue '-' %></td>
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- sub total -->
|
<!-- sub total -->
|
||||||
<!-- end sub total -->
|
<!-- end sub total -->
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3"></td>
|
<td colspan="3"></td>
|
||||||
<td><strong>Total</strong></td>
|
<td><strong>Total</strong></td>
|
||||||
<td><strong><%= total_qty %></strong></td>
|
<td><strong><%= total_qty %></strong></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
var order_status = '';
|
|
||||||
$(function(){
|
$(function(){
|
||||||
if(order_status == ''){
|
$('#order_by').val('<%= @order_by %>');
|
||||||
$('#order_by').val('desc');
|
|
||||||
}else{
|
|
||||||
$('#order_by').val(''+order_status+'');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#order_by').on('change', function(){
|
$('#order_by').on('change', function(){
|
||||||
var order_by = $("#order_by").val();
|
var order_by = $("#order_by").val();
|
||||||
order_status = order_by;
|
$('.div_product_sale').html("");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
data: {'order_by' : order_by},
|
url: '?order_by='+order_by,
|
||||||
datatype: 'JSON',
|
|
||||||
url: '?',
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// window.location.reload();
|
$('.div_product_sale').html(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user