From 5e1e0cd5b96d6db6dbb3997e79670780dc0bc6b8 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 6 Sep 2017 18:27:58 +0630 Subject: [PATCH] stock_check report template --- .idea/workspace.xml | 1015 +++++++---------- .../inventory/stock_checks_controller.rb | 146 ++- .../reports/stock_check_controller.rb | 50 + app/models/menu_item_instance.rb | 14 +- app/models/stock_check.rb | 2 +- app/pdf/stock_result_pdf.rb | 90 +- .../inventory/_inventory_list.html.erb | 14 +- app/views/inventory/inventory/index.html.erb | 31 +- .../inventory_definitions/_form.html.erb | 3 +- .../inventory_definitions/edit.html.erb | 16 +- .../inventory/stock_checks/index.html.erb | 35 +- .../inventory/stock_checks/show.html.erb | 117 +- .../_stock_check_report_filter.html.erb | 89 ++ app/views/reports/stock_check/index.html.erb | 79 ++ app/views/reports/stock_check/index.xls.erb | 52 + config/routes.rb | 1 + 16 files changed, 940 insertions(+), 814 deletions(-) create mode 100644 app/controllers/reports/stock_check_controller.rb create mode 100644 app/views/reports/stock_check/_stock_check_report_filter.html.erb create mode 100644 app/views/reports/stock_check/index.html.erb create mode 100644 app/views/reports/stock_check/index.xls.erb diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3ddc5623..74609c4e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,27 +2,17 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -38,7 +28,7 @@ - + @@ -64,187 +54,111 @@ <% @inventory_definitions.each do |id| %> - <% item_name = MenuItemInstance.find_by_item_instance_code(id.item_code) %> - + <% end %> @@ -50,7 +56,7 @@
- + @@ -61,6 +67,7 @@
+
@@ -80,13 +87,13 @@ count += 1; product_sku = $('#product_sku').val(); product_qty = $('#product_qty').val(); - product_name = $("#product_sku option:selected").text(); + product_name = $("#product_sku").find("option:selected").text(); var tr = '' - + '' + //+ '' + '' + + product_name + '' + '' - + '' + + '' + ''; $('#stock_item').append(tr); // $('#product_sku').val(''); @@ -101,7 +108,9 @@ for (var i = 1; i <= count; i++) { itemname = $('#item_sku_' + i).val(); itemqty = $('#item_qty_' + i).val(); - arr.push({sku: itemname, qty: itemqty}); + if(itemname !== undefined){ + arr.push({sku: itemname, qty: itemqty}); + } jsonStr = JSON.stringify(arr); } console.log(jsonStr); @@ -113,6 +122,14 @@ window.location.href = '/inventory/stock_checks/' + data['stock_id']; } }) - }) + }); + + $('#back').on('click', function () { + window.location.href = '/inventory'; + }); + + function remove_row(row) { + $("#item_remove_"+row).parent().parent().remove(); + } diff --git a/app/views/inventory/stock_checks/show.html.erb b/app/views/inventory/stock_checks/show.html.erb index 4d0e83d0..f4af6db0 100644 --- a/app/views/inventory/stock_checks/show.html.erb +++ b/app/views/inventory/stock_checks/show.html.erb @@ -3,81 +3,96 @@
- Check by + Check by
- <%= @check.check_by %> + <%= Employee.find(@check.check_by).name rescue '' %>
- Check At + Check At
- <%= @check.created_at %>
+ <%= @check.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %>
- Reason + Reason
- <%= @check.reason %> + <%= @check.reason %>

-
# Product Balance
' + count + '' + count + '' - + '
- - - - - - - - - <% - count = 0 - @check.stock_check_items.each do |item| - count += 1 - %> +
#ProductStock CountStock BalanceDifferentRemark
- - - - - - + + + + + + - <% end %> -
<%= count %><%= item.item_code %><%= item.stock_count %><%= item.stock_balance %><%= item.different %><%= item.remark %>#ProductStock CountStock BalanceDifferentRemark
+ <% + count = 0 + @check.stock_check_items.each do |item| + count += 1 + %> + + <%= count %> + + <% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%> + <% if menu_item.nil? %> + <%= Product.find_by_item_code(item.item_code).name rescue "-" %> + <% else %> + <%= menu_item.menu_item.name rescue "-" %> + - <%= menu_item.item_instance_name rescue "-" %> + <% end %> + + <%= item.stock_count %> + <%= item.stock_balance %> + <%= item.different %> + <%= item.remark %> + + <% end %> + +
-
- - - + + +
diff --git a/app/views/reports/stock_check/_stock_check_report_filter.html.erb b/app/views/reports/stock_check/_stock_check_report_filter.html.erb new file mode 100644 index 00000000..1bd00b7b --- /dev/null +++ b/app/views/reports/stock_check/_stock_check_report_filter.html.erb @@ -0,0 +1,89 @@ +
+
+ <%= form_tag report_path, :method => :get, :id => "frm_report", :class => "form" do %> + <% if period_type != false %> +
+ +
+ + <% if @daterange %> + + <% else %> + + <% end %> +
+
+ + +
+
+ +
+
+ +
+
+ <% end %> + + <% end %> +
+
+ + diff --git a/app/views/reports/stock_check/index.html.erb b/app/views/reports/stock_check/index.html.erb new file mode 100644 index 00000000..07008de8 --- /dev/null +++ b/app/views/reports/stock_check/index.html.erb @@ -0,0 +1,79 @@ + + +
+ <%= render :partial => 'stock_check_report_filter', + :locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %> +
+
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + <% total_qty = 0 %> + <% total_price = 0 %> + <% total_amount = 0 %> + + <% @transaction.each do |result| %> + + + + + + + + + + + <% total_qty += result.qty.to_f %> + <% total_price += result.price.to_f %> + <% total_amount += result.amount.to_f %> + <% end %> + + + + + + + + + +
From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
SaleSale ItemCommissioner NameProduct NameQtyCommission PriceCommission AmountDate
<%= result.sale_id rescue '-' %><%= result.sale_item_id rescue '-' %><%= result.commissioner.name rescue '-' %><%= result.commission.menu_item.name rescue '-' %><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
<%= sprintf("%.2f", total_qty) rescue '-' %><%= sprintf("%.2f", total_price) rescue '-' %><%= sprintf("%.2f", total_amount) rescue '-' %>
+
+
+
+ \ No newline at end of file diff --git a/app/views/reports/stock_check/index.xls.erb b/app/views/reports/stock_check/index.xls.erb new file mode 100644 index 00000000..4ea1f2f0 --- /dev/null +++ b/app/views/reports/stock_check/index.xls.erb @@ -0,0 +1,52 @@ +
+
+
+ + + + + + + + + + + + + + + + <% total_qty = 0 %> + <% total_price = 0 %> + <% total_amount = 0 %> + + <% @transaction.each do |result| %> + + + + + + + + + <% total_qty += result.qty.to_f %> + <% total_price += result.price.to_f %> + <% total_amount += result.amount.to_f %> + <% end %> + + + + + + + + + +
From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
Commissioner NameProduct NameQtyCommission PriceCommission AmountDate
+ <%= result.commissioner.name rescue '-' %> + + <%= result.commission.menu_item.name rescue '-' %> + <%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
<%= sprintf("%.2f", total_qty) rescue '-' %><%= sprintf("%.2f", total_price) rescue '-' %><%= sprintf("%.2f", total_amount) rescue '-' %>
+
+
+
diff --git a/config/routes.rb b/config/routes.rb index 226b7dd5..e979ac5d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -328,6 +328,7 @@ Rails.application.routes.draw do resources :credit_payment, :only => [:index, :show] resources :void_sale, :only => [:index, :show] resources :commission, :only => [:index, :show] + resources :stock_check, :only => [:index, :show] get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date" end