This commit is contained in:
Myat Zin Wai Maw
2019-08-30 14:03:48 +06:30
parent 67793b282e
commit f0be0d19a1
7 changed files with 52 additions and 47 deletions

View File

@@ -56,7 +56,10 @@ class Reports::HourlySaleitemController < BaseReportController
@shift_data = sh @shift_data = sh
end end
end end
# @hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
@hourly_total_qty = @sale_data.group_by(&:date_format).map { |k,v|{"date" => k , "total_qty" => v.count }}
puts @hourly_total_qty.to_json
respond_to do |format| respond_to do |format|
format.html format.html
format.xls format.xls

View File

@@ -64,7 +64,7 @@ class Reports::SaleitemController < BaseReportController
def show def show
from, to, report_type = get_date_range_from_params from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
sale_data = @sale_data
date_arr = Array.new date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")

View File

@@ -38,20 +38,20 @@ class Printer::PrinterWorker
end end
def print(file_path,printer_destination = nil ) def print(file_path,printer_destination = nil )
if printer_destination.nil? # if printer_destination.nil?
printer_destination = self.printer_destination # printer_destination = self.printer_destination
end # end
puts printer_destination # puts printer_destination
puts '........Printer Destination..........' # puts '........Printer Destination..........'
copy = self.print_copies # copy = self.print_copies
#Print only when printer information is not null # #Print only when printer information is not null
if !self.printer_destination.nil? # if !self.printer_destination.nil?
(1..copy).each do # (1..copy).each do
page = Cups::PrintJob.new(file_path, printer_destination) # page = Cups::PrintJob.new(file_path, printer_destination)
page.print # page.print
end # end
end # end
end end
end end

View File

@@ -11,7 +11,7 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter', <%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %> :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_hourly_saleitem_index_path} %>
<hr /> <hr />
<div class="text-right"> <div class="text-right">
<a href="javascript:export_to('<%=reports_waste_and_spoilage_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a> <a href="javascript:export_to('<%=reports_waste_and_spoilage_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
@@ -21,6 +21,7 @@
<table class="table table-striped" border="0"> <table class="table table-striped" border="0">
<% time_arr = Array.new %> <% time_arr = Array.new %>
<% sale_item_count =0 %>
<% menu_cat_arr = Array.new %> <% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %> <% footer_arr = Array.new %>
<% count = 0 %> <% count = 0 %>
@@ -29,6 +30,7 @@
<% time_count = 0 %> <% time_count = 0 %>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<% if !time_arr.include?(sale.date_format) %> <% if !time_arr.include?(sale.date_format) %>
<% sale_item_count =1 %>
<% time_count = time_count + 1 %> <% time_count = time_count + 1 %>
<thead> <thead>
<td>&nbsp;</td> <td>&nbsp;</td>
@@ -52,6 +54,9 @@
<% time_arr.push(sale.date_format) %> <% time_arr.push(sale.date_format) %>
<% menu_cat_arr.clear %> <% menu_cat_arr.clear %>
<% count = 0 %> <% count = 0 %>
<% else %>
<%= time_arr %>
<% sale_item_count =sale_item_count +1 %>
<% end %> <% end %>
<tbody> <tbody>
<!-- all total qty sum --> <!-- all total qty sum -->
@@ -85,23 +90,20 @@
<td><%= sale.date_format %></td> <td><%= sale.date_format %></td>
</tr> </tr>
<% end %> <% end %>
<!-- new tr --> <!-- new tr -->
<% count = count + 1 %> <% count = count + 1 %>
<% logger.debug ' normal count+++++++++++++++++++++++++' %> <% @hourly_total_qty.each do |hr| %>
<% logger.debug sale.sale_items.count %> <% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
<% logger.debug 'time_count count------------------------------------' %>
<% logger.debug time_count %>
<% if sale.sale_items.count == count %>
<tr style="border-top:2px solid grey;"> <tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td> <td colspan="2">&nbsp;</td>
<td>Total Qty:</td> <td>Total Qty:</td>
<td><span><%= total_qty%></span></td> <td><span><%= total_qty%></span></td>
<td style="border-bottom:2px solid grey;">Grand Total:</td> <td style="border-bottom:2px solid grey;">Grand Total:</td>
<td style="border-bottom:2px solid grey;"><span></span></td> <td style="border-bottom:2px solid grey;"><span></span></td>
</tr> </tr>
<% footer_arr.push(sale.sale_id) %> <% footer_arr.push(sale.sale_id) %>
<% total_qty =0%>
<% end %>
<% end %> <% end %>
</tbody> </tbody>
<% end %> <% end %>

View File

@@ -21,11 +21,11 @@ class ActionController::Base
end end
else else
# check for license file # check for license file
if check_license # if check_license
current_license(ENV["SX_PROVISION_URL"]) # current_license(ENV["SX_PROVISION_URL"])
else # else
redirect_to activate_path # redirect_to activate_path
end # end
end end
end end

View File

@@ -1,10 +1,10 @@
application_path="#{File.expand_path("../..", __FILE__)}" # application_path="#{File.expand_path("../..", __FILE__)}"
directory application_path # directory application_path
#environment ENV.fetch("RAILS_ENV") { "production" } # #environment ENV.fetch("RAILS_ENV") { "production" }
environment "production" # environment "production"
pidfile "#{application_path}/tmp/puma/pid" # pidfile "#{application_path}/tmp/puma/pid"
state_path "#{application_path}/tmp/puma/state" # state_path "#{application_path}/tmp/puma/state"
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" # stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
port ENV.fetch("PORT") { 62158 } # port ENV.fetch("PORT") { 62158 }
workers 2 # workers 2
preload_app! # preload_app!