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