stock check report
This commit is contained in:
@@ -9,12 +9,10 @@ class Reports::StockCheckController < BaseReportController
|
||||
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
@daterange = params[:daterange]
|
||||
end
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.all
|
||||
@item_code = params[:item_code]
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
@transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class StockCheck < ApplicationRecord
|
||||
|
||||
has_many :stock_check_items
|
||||
|
||||
def create(user, reason, item_list)
|
||||
@@ -7,11 +6,11 @@ class StockCheck < ApplicationRecord
|
||||
self.check_by = user.id
|
||||
self.check_start = Time.now
|
||||
self.check_end = Time.now
|
||||
self.save
|
||||
save
|
||||
item_list.each do |item|
|
||||
stockItem = StockCheckItem.new
|
||||
stockItem.create(self.id,item)
|
||||
stockItem.create(id, item)
|
||||
end
|
||||
return self
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class StockCheckItem < ApplicationRecord
|
||||
|
||||
belongs_to :stock_check
|
||||
|
||||
def create(stock_id, item)
|
||||
@@ -33,4 +32,15 @@ class StockCheckItem < ApplicationRecord
|
||||
return 'missing stock', stock_check_qty.to_i - journal_balance.to_i
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_transaction(from, to, item_code)
|
||||
transaction = all
|
||||
if !from.nil? && !to.nil?
|
||||
transaction = transaction.where('created_at between ? and ?', from, to)
|
||||
end
|
||||
if item_code.present?
|
||||
transaction = transaction.where(item_code: item_code)
|
||||
end
|
||||
transaction
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<li><%= link_to "Credit Sale Report", reports_credit_payment_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Void Sale Report", reports_void_sale_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commission Report", reports_commission_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Stock Check Report", reports_stock_check_index_path, :tabindex =>"-1" %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="navbar-nav mr-auto">
|
||||
|
||||
@@ -26,46 +26,54 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
<th colspan="8"><i> From Date </i>: <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <i>To Date</i> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sale</th>
|
||||
<th>Sale Item</th>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Stock Check Reason</th>
|
||||
<th>Checked By</th>
|
||||
<th>Item Name</th>
|
||||
<th>Stock Count</th>
|
||||
<th>Stock Balance</th>
|
||||
<th>Different</th>
|
||||
<th>Remark</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
<% total_stock_count = 0 %>
|
||||
<% total_stock_balance = 0 %>
|
||||
<% total_different = 0 %>
|
||||
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td><%= result.sale_id rescue '-' %></td>
|
||||
<td><%= result.sale_item_id rescue '-' %></td>
|
||||
<td><%= result.commissioner.name rescue '-' %></td>
|
||||
<td><%= result.commission.menu_item.name rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
|
||||
<td><%= result.stock_check.reason rescue '-' %></td>
|
||||
<td><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td>
|
||||
<td>
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
|
||||
<% if menu_item.nil? %>
|
||||
<%= Product.find_by_item_code(result.item_code).name rescue "-" %>
|
||||
<% else %>
|
||||
<%= menu_item.menu_item.name rescue "-" %>
|
||||
- <%= menu_item.item_instance_name rescue "-" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= result.stock_count rescue '-' %></td>
|
||||
<td><%= result.stock_balance rescue '-' %></td>
|
||||
<td><%= result.different rescue '-' %></td>
|
||||
<td><%= result.remark rescue '-' %></td>
|
||||
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
|
||||
</tr>
|
||||
<% total_qty += result.qty.to_f %>
|
||||
<% total_price += result.price.to_f %>
|
||||
<% total_amount += result.amount.to_f %>
|
||||
<% !result.stock_count.nil? ? total_stock_count += result.stock_count : total_stock_count += 0 %>
|
||||
<% !result.stock_balance.nil? ? total_stock_balance += result.stock_balance : total_stock_balance += 0 %>
|
||||
<% !result.different.nil? ? total_different += result.different : total_different += 0 %>
|
||||
<% end %>
|
||||
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="4"></td>
|
||||
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
<td colspan="3"></td>
|
||||
<td><b><%= total_stock_count rescue '-' %></b></td>
|
||||
<td><b><%= total_stock_balance rescue '-' %></b></td>
|
||||
<td><b><%= total_different rescue '-' %></b></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user