change stock check report and some structure
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
class Inventory::InventoryController < BaseInventoryController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@products = InventoryDefinition.all.active.order('created_at desc')
|
||||
end
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
(CASE WHEN sj.credit IS NULL THEN '-' ELSE sj.credit END) as credit,
|
||||
(CASE WHEN sj.debit IS NULL THEN '-' ELSE sj.debit END) as debit,
|
||||
(CASE WHEN sj.balance IS NULL THEN '-' ELSE sj.balance END) as balance")
|
||||
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
|
||||
.where("(CASE WHEN sj.balance > 0 THEN sj.balance=(SELECT MIN(balance) FROM stock_journals WHERE stock_journals.item_code = inventory_definitions.item_code ORDER BY created_at DESC) ELSE 1 END)")
|
||||
.group("inventory_definitions.item_code")
|
||||
.order("(CASE WHEN sj.balance > 0 THEN MIN(sj.balance) ELSE NULL END )")
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||
|
||||
@stock_journals = StockJournal.where(item_code: inventory.item_code)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
|
||||
@@ -24,7 +24,14 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
|
||||
if inventory.nil?
|
||||
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
else
|
||||
@inventory_definition = InventoryDefinition.find(inventory.id)
|
||||
@inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.created_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @inventory_definition.save
|
||||
|
||||
@@ -26,15 +26,16 @@ class Origami::SalesController < BaseOrigamiController
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
tax_type = params[:tax_type]
|
||||
sale_data = []
|
||||
table = DiningFacility.find(dining)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
table.bookings.each do |booking|
|
||||
# if !booking.checkout_at.nil?
|
||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
||||
# end
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
@@ -49,6 +50,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
if !orer_item.set_menu_items.nil?
|
||||
saleobj.add_sub_item(orer_item.set_menu_items)
|
||||
end
|
||||
sale_data.push(orer_item)
|
||||
end
|
||||
|
||||
# Re-compute for add
|
||||
@@ -58,7 +60,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
booking.save
|
||||
|
||||
order_array.push(order.order_id)
|
||||
|
||||
|
||||
end
|
||||
|
||||
receipt_no = Sale.find(sale_id).receipt_no
|
||||
@@ -75,6 +77,10 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
if !sale_data.empty?
|
||||
# InventoryJob.perform_now(self.id)
|
||||
InventoryDefinition.calculate_product_count(nil,sale_data)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,11 +2,20 @@ class InventoryDefinition < ApplicationRecord
|
||||
|
||||
scope :active, -> {where(:is_active => true)}
|
||||
|
||||
def self.calculate_product_count(saleObj)
|
||||
saleObj.sale_items.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil)
|
||||
if !saleObj.nil?
|
||||
saleObj.sale_items.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
end
|
||||
end
|
||||
else
|
||||
saleobj_after_req_bill.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -16,7 +25,12 @@ class InventoryDefinition < ApplicationRecord
|
||||
if product.nil?
|
||||
return false, nil
|
||||
else
|
||||
return true, product
|
||||
stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
|
||||
if stock_check_item.nil?
|
||||
return false, nil
|
||||
else
|
||||
return true, product
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2125,7 +2125,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
else
|
||||
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||
if payment_method == 'card'
|
||||
@@ -2133,7 +2133,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
@@ -2144,7 +2144,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
else
|
||||
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||
if payment_method == 'card'
|
||||
@@ -2152,7 +2152,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@@ -2164,7 +2164,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
else
|
||||
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||
if payment_method == 'card'
|
||||
@@ -2172,7 +2172,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2185,7 +2185,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||
@@ -2194,7 +2194,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
@@ -2204,7 +2204,7 @@ end
|
||||
else
|
||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id)
|
||||
end
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,10 +36,10 @@ class StockCheckItem < ApplicationRecord
|
||||
def self.get_transaction(from, to, item_code)
|
||||
transaction = all
|
||||
if !from.nil? && !to.nil?
|
||||
transaction = transaction.where('created_at between ? and ?', from, to)
|
||||
transaction = transaction.where('created_at between ? and ?', from, to).order("item_code asc, different desc")
|
||||
end
|
||||
if item_code.present?
|
||||
transaction = transaction.where(item_code: item_code)
|
||||
transaction = transaction.where(item_code: item_code).order("item_code asc, different desc")
|
||||
end
|
||||
transaction
|
||||
end
|
||||
|
||||
@@ -4,10 +4,11 @@ class StockJournal < ApplicationRecord
|
||||
STOCK_CHECK_TRANS = "stock_check"
|
||||
|
||||
def self.add_to_journal(item, balance, stock_message, inventory_definition) # item => saleObj | balance => Stock journal
|
||||
journal = StockJournal.new
|
||||
journal.credit = balance
|
||||
|
||||
balance = calculate_balance(balance, item.qty)
|
||||
|
||||
journal = StockJournal.new
|
||||
|
||||
journal.item_code = item.item_instance_code
|
||||
journal.inventory_definition_id = inventory_definition.id
|
||||
journal.debit = item.qty
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
<th><%= t("views.right_panel.detail.product") %></th>
|
||||
<th><%= t("views.right_panel.detail.min_order") %></th>
|
||||
<th><%= t("views.right_panel.detail.max_stock") %></th>
|
||||
<th><%= t("views.right_panel.detail.created_by") %></th>
|
||||
<th><%= t("views.right_panel.detail.created_time") %></th>
|
||||
<th><%= t("views.right_panel.detail.balance") %></th>
|
||||
<th><%= t("views.right_panel.detail.action") %></th>
|
||||
<!-- <th><%= t("views.right_panel.detail.created_by") %></th>
|
||||
<th><%= t("views.right_panel.detail.created_time") %></th> -->
|
||||
</tr>
|
||||
<%
|
||||
count = 0
|
||||
@products.each do |item|
|
||||
@inventory_definitions.each do |item|
|
||||
count += 1
|
||||
%>
|
||||
<tr>
|
||||
@@ -26,9 +28,20 @@
|
||||
</td>
|
||||
<td><%= item.min_order_level %></td>
|
||||
<td><%= item.max_stock_level %></td>
|
||||
<td><%= Employee.find(item.created_by).name rescue '-' %></td>
|
||||
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td>
|
||||
<td><%= item.balance rescue '0' %></td>
|
||||
<td>
|
||||
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"><%= t("views.btn.show") %> <%= t("views.right_panel.detail.stock_check") %></button>
|
||||
</td>
|
||||
<!-- <td><%= Employee.find(item.created_by).name rescue '-' %></td>
|
||||
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td> -->
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
$('.show_track').on('click', function () {
|
||||
var ID = $(this).attr("data-value");
|
||||
window.location.href = '/inventory/'+ID+'/show';
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -12,10 +12,10 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
||||
<div class="m-b-10 clearfix">
|
||||
<button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %>
|
||||
</button>
|
||||
<button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.new_stock_taking") %></button>
|
||||
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= t("views.btn.new") + " " + (t :inventory) %>
|
||||
<!-- <button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %>
|
||||
</button> -->
|
||||
<button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_taking") %></button>
|
||||
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " + (t :inventory) %>
|
||||
</button>
|
||||
</div>
|
||||
<div class="card">
|
||||
@@ -27,14 +27,14 @@
|
||||
<div class="body">
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.btn.new") + " " + (t :inventory) %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %> <br>
|
||||
1) <%= (t :track) +" "+ t("views.btn.new") + " " + (t :inventory) %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %> <br>
|
||||
</p>
|
||||
<p>
|
||||
2) <%= t("views.btn.new") + " " + t("views.right_panel.detail.stock_taking") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_taking_txt") %> <br>
|
||||
2) <%= t("views.right_panel.detail.stock_taking") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_taking_txt") %> <br>
|
||||
</p>
|
||||
<p>
|
||||
<!-- <p>
|
||||
3) <%= t("views.right_panel.detail.stock_check_report") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_report_txt") %> <br>
|
||||
</p>
|
||||
</p> -->
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
@@ -51,12 +51,12 @@
|
||||
window.location.href = '<%= inventory_stock_checks_path %>';
|
||||
});
|
||||
|
||||
$('#stock_check_report').on('click', function () {
|
||||
window.location.href = '<%= reports_stock_check_index_path %>';
|
||||
});
|
||||
// $('#stock_check_report').on('click', function () {
|
||||
// window.location.href = '<%= reports_stock_check_index_path %>';
|
||||
// });
|
||||
|
||||
$('#new_inventory_product').on('click',function(){
|
||||
window.location.href = '/inventory/inventory_definitions/new';
|
||||
})
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
70
app/views/inventory/inventory/show.html.erb
Normal file
70
app/views/inventory/inventory/show.html.erb
Normal file
@@ -0,0 +1,70 @@
|
||||
<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 :inventory %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<table class="table table-responsive table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.type") %></th>
|
||||
<th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t :credit %></th>
|
||||
<th><%= t :debit %></th>
|
||||
<th><%= t("views.right_panel.detail.balance") %></th>
|
||||
<th><%= t("views.right_panel.detail.remark") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_credit = 0 %>
|
||||
<% total_debit = 0 %>
|
||||
<% total_balance = 0 %>
|
||||
|
||||
<% if !@stock_journals.nil? && !@stock_journals.empty? %>
|
||||
<% @stock_journals.each do |result| %>
|
||||
<tr>
|
||||
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
|
||||
<td><%= result.trans_type 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.credit rescue '-' %></td>
|
||||
<td><%= result.debit rescue '-' %></td>
|
||||
<td><%= result.balance rescue '-' %></td>
|
||||
<td><%= result.remark rescue '-' %></td>
|
||||
</tr>
|
||||
<% !result.credit.nil? ? total_credit += result.credit : total_credit += 0 %>
|
||||
<% !result.debit.nil? ? total_debit += result.debit : total_debit += 0 %>
|
||||
<% !result.balance.nil? ? total_balance += result.balance : total_balance += 0 %>
|
||||
<% end %>
|
||||
|
||||
<!-- <tr style="border-top: 3px solid grey;">
|
||||
<td colspan="3"></td>
|
||||
<td><b><%= total_credit rescue '-' %></b></td>
|
||||
<td><b><%= total_debit rescue '-' %></b></td>
|
||||
<td><b><%= total_balance rescue '-' %></b></td>
|
||||
<td colspan="2"></td>
|
||||
</tr> -->
|
||||
<% else %>
|
||||
<tr>
|
||||
<td colspan="8" class="text-center">There is no record...</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,14 +101,25 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
var count = 0;
|
||||
$(document).ready(function(){
|
||||
clearFormData();
|
||||
});
|
||||
|
||||
function clearFormData(){
|
||||
$('#stock_check_reason').val("");
|
||||
$('#product_qty').val("");
|
||||
$('#product_sku').val("");
|
||||
}
|
||||
|
||||
$('#save_to_stock_check').on('click', function () {
|
||||
count += 1;
|
||||
product_sku = $('#product_sku').val();
|
||||
product_qty = $('#product_qty').val();
|
||||
product_name = $("#product_sku").find("option:selected").text();
|
||||
|
||||
// clearFormData();
|
||||
|
||||
var tr = '<tr>'
|
||||
//+ '<td>' + count + '</td>'
|
||||
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
|
||||
|
||||
@@ -21,19 +21,19 @@
|
||||
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label class="font-14">Definition Item</label>
|
||||
<label class="font-14">Select Item</label>
|
||||
<select class="form-control" name="item_code" id="item_code">
|
||||
<option value="">Select Product</option>
|
||||
<% @inventory_definitions.each do |id| %>
|
||||
<option value="<%= id.item_code %>">
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
|
||||
<% if menu_item.nil? %>
|
||||
<%= Product.find_by_item_code(id.item_code).name rescue "-" %>
|
||||
<% else %>
|
||||
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
|
||||
<option value="">Select Item</option>
|
||||
<% @inventory_definitions.each do |id| %>
|
||||
<option value="<%= id.item_code %>">
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
|
||||
<% if menu_item.nil? %>
|
||||
<%= Product.find_by_item_code(id.item_code).name rescue "-" %>
|
||||
<% else %>
|
||||
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
|
||||
<% end %>
|
||||
</option>
|
||||
<% end %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20"><br>
|
||||
|
||||
@@ -3,102 +3,107 @@
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li class="breadcrumb-item active">Stock Check Report</li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', inventory_path %>
|
||||
<%= link_to 'Back', inventory_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<!-- <div class="container"> -->
|
||||
<%= render :partial => 'stock_check_report_filter',
|
||||
:locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %>
|
||||
<hr/>
|
||||
<!-- </div> -->
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
|
||||
<!-- <div class="container"> -->
|
||||
<!-- <div class="row"> -->
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-info wave-effects">Export to
|
||||
Excel</a>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="container"> -->
|
||||
<%= render :partial => 'stock_check_report_filter',
|
||||
:locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %>
|
||||
<hr/>
|
||||
<!-- </div> -->
|
||||
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
<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>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_stock_count = 0 %>
|
||||
<% total_stock_balance = 0 %>
|
||||
<% total_different = 0 %>
|
||||
<!-- <div class="container"> -->
|
||||
<!-- <div class="row"> -->
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-info wave-effects">Export to
|
||||
Excel</a>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<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? %>
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
<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><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.stock_count") %></th>
|
||||
<th><%= t("views.right_panel.detail.stock_balance") %></th>
|
||||
<th><%= t("views.right_panel.detail.different") %></th>
|
||||
<th><%= t("views.right_panel.detail.remark") %></th>
|
||||
<th><%= t("views.right_panel.detail.checked_by") %></th>
|
||||
<th><%= t("views.right_panel.detail.stock_check") %> <%= t("views.right_panel.detail.reason") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_stock_count = 0 %>
|
||||
<% total_stock_balance = 0 %>
|
||||
<% total_different = 0 %>
|
||||
<% arr_item_code = [] %>
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td>
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
|
||||
<% if menu_item.nil? %>
|
||||
<% if !arr_item_code.include?(result.item_code) %>
|
||||
<%= Product.find_by_item_code(result.item_code).name rescue "-" %>
|
||||
<% else %>
|
||||
<% arr_item_code.push(result.item_code) %>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if !arr_item_code.include?(result.item_code) %>
|
||||
<%= menu_item.menu_item.name rescue "-" %>
|
||||
- <%= menu_item.item_instance_name rescue "-" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= result.stock_count rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.stock_balance, precision:precision.to_i,delimiter:delimiter) 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>
|
||||
<% !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 %>
|
||||
<% arr_item_code.push(result.item_code) %>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= result.stock_count rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||
<td><%= result.different rescue '-' %></td>
|
||||
<td><%= result.remark rescue '-' %></td>
|
||||
<td><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td>
|
||||
<td><%= result.stock_check.reason rescue '-' %></td>
|
||||
</tr>
|
||||
<% !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="3"></td>
|
||||
<td><b><%= total_stock_count rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= total_different rescue '-' %></b></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <tr style="border-top: 3px solid grey;">
|
||||
<td colspan="3"></td>
|
||||
<td><b><%= total_stock_count rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= total_different rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -14,44 +14,60 @@
|
||||
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</th>
|
||||
<th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.stock_count") %></th>
|
||||
<th><%= t("views.right_panel.detail.stock_balance") %></th>
|
||||
<th><%= t("views.right_panel.detail.different") %></th>
|
||||
<th><%= t("views.right_panel.detail.remark") %></th>
|
||||
<th><%= t("views.right_panel.detail.checked_by") %></th>
|
||||
<th><%= t("views.right_panel.detail.stock_check") %> <%= t("views.right_panel.detail.reason") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
<% total_stock_count = 0 %>
|
||||
<% total_stock_balance = 0 %>
|
||||
<% total_different = 0 %>
|
||||
<% arr_item_code = [] %>
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td>
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
|
||||
<% if menu_item.nil? %>
|
||||
<% if !arr_item_code.include?(result.item_code) %>
|
||||
<%= Product.find_by_item_code(result.item_code).name rescue "-" %>
|
||||
<% arr_item_code.push(result.item_code) %>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if !arr_item_code.include?(result.item_code) %>
|
||||
<%= menu_item.menu_item.name rescue "-" %>
|
||||
- <%= menu_item.item_instance_name rescue "-" %>
|
||||
<% arr_item_code.push(result.item_code) %>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
<% 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><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td>
|
||||
<td><%= result.stock_check.reason rescue '-' %></td>
|
||||
</tr>
|
||||
<% !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 %>
|
||||
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
<% total_qty += result.qty.to_f %>
|
||||
<% total_price += result.price.to_f %>
|
||||
<% total_amount += result.amount.to_f %>
|
||||
<% end %>
|
||||
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="2"></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>
|
||||
</tr>
|
||||
<!-- <tr style="border-top: 3px solid grey;">
|
||||
<td colspan="3"></td>
|
||||
<td><b><%= total_stock_count rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= total_different rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -84,6 +84,8 @@ en:
|
||||
processed: "Processed"
|
||||
delivery_details: "Delivery Details"
|
||||
credits: "Credits"
|
||||
track: "Track"
|
||||
debit: "Debit"
|
||||
|
||||
views:
|
||||
btn:
|
||||
@@ -494,6 +496,7 @@ en:
|
||||
in_time: "In Time"
|
||||
out_time: "Out Time"
|
||||
transaction_fee: "Transaction Fee"
|
||||
checked_by: "Checked By"
|
||||
|
||||
code_txt: "code "
|
||||
charge_txt: "charge"
|
||||
|
||||
@@ -79,7 +79,9 @@ mm:
|
||||
processed: "Processed"
|
||||
delivery_details: "Delivery Details"
|
||||
credits: "အကြွေးများ"
|
||||
|
||||
track: "Track"
|
||||
debit: "Debit"
|
||||
|
||||
views:
|
||||
btn:
|
||||
create: "အသစ်တည်ဆောက်ရန်"
|
||||
@@ -488,6 +490,7 @@ mm:
|
||||
in_time: "In Time"
|
||||
out_time: "Out Time"
|
||||
transaction_fee: "Transaction Fee"
|
||||
checked_by: "Checked By"
|
||||
|
||||
code_txt: "ကုတ်ဒ် "
|
||||
charge_txt: "ကောက်ခံသည်"
|
||||
|
||||
@@ -513,6 +513,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
# resources :stock_checks
|
||||
resources :stock_journals
|
||||
resources :inventory_definitions
|
||||
get ':inventory_definition_id/show' => 'inventory#show'
|
||||
end
|
||||
#mount_compendium at: '/report' #, controller: 'reports'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user