update inventory form and list
This commit is contained in:
@@ -12,13 +12,34 @@ class Inventory::InventoryController < BaseInventoryController
|
|||||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||||
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
||||||
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
|
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
|
||||||
(#{least_stock}) as balance")
|
(#{least_stock}) as balance,"+
|
||||||
|
"acc.title as account_name,mi.name as item_name,
|
||||||
|
mii.item_instance_name as instance_name," +
|
||||||
|
"mc.name as menu_category_name,mc.id as menu_category_id "
|
||||||
|
)
|
||||||
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
|
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
|
||||||
.group("inventory_definitions.item_code")
|
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||||
.order("balance ASC")
|
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||||
|
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||||
|
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||||
|
.group("mi.menu_category_id,inventory_definitions.item_code")
|
||||||
|
.order("acc.title desc,mi.menu_category_id desc,balance ASC")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def self.get_item_query(type)
|
||||||
|
|
||||||
|
# query = Sale.select("acc.title as account_name,mi.name as item_name,mii.item_instance_name as instance_name" +
|
||||||
|
# "mc.name as menu_category_name,mc.id as menu_category_id ")
|
||||||
|
|
||||||
|
# query = query.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||||
|
# " JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||||
|
# " JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||||
|
# query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||||
|
# query = query.group("acc.title,mi.account_id,mi.menu_category_id")
|
||||||
|
# .order("acc.title desc, mi.account_id desc, mi.menu_category_id desc")
|
||||||
|
# end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
inventory_definition_id = params[:inventory_definition_id]
|
inventory_definition_id = params[:inventory_definition_id]
|
||||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class Inventory::StockChecksController < BaseInventoryController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@check = StockCheck.find(params[:id])
|
@check = StockCheck.find(params[:id])
|
||||||
|
|
||||||
|
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_to_journal
|
def save_to_journal
|
||||||
|
|||||||
@@ -43,4 +43,18 @@ class StockCheckItem < ApplicationRecord
|
|||||||
end
|
end
|
||||||
transaction
|
transaction
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_items_with_category(id)
|
||||||
|
query = StockCheckItem.select("stock_check_items.*,acc.title as account_name,mi.name as item_name,
|
||||||
|
mii.item_instance_name as instance_name," +
|
||||||
|
"mc.name as menu_category_name,mc.id as menu_category_id ")
|
||||||
|
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = stock_check_items.item_code" +
|
||||||
|
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||||
|
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||||
|
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||||
|
.where("stock_check_items.stock_check_id=#{id}")
|
||||||
|
.group("mi.menu_category_id,stock_check_items.item_code")
|
||||||
|
.order("acc.title desc,mi.menu_category_id desc")
|
||||||
|
return query
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
<th><%= t("views.right_panel.detail.product") %></th>
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
<th><%= t("views.right_panel.detail.min_order") %></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.max_stock") %></th>
|
||||||
@@ -10,12 +10,36 @@
|
|||||||
<!-- <th><%= t("views.right_panel.detail.created_by") %></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.created_time") %></th> -->
|
||||||
</tr>
|
</tr>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
<%
|
<%
|
||||||
count = 0
|
count = 0
|
||||||
@inventory_definitions.each do |item|
|
@inventory_definitions.each do |item|
|
||||||
count += 1
|
count += 1
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
|
<% if !cate_arr.include?(item.menu_category_id) %>
|
||||||
|
<td><%= item.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(item.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td>
|
||||||
|
<td><%= item.min_order_level %></td>
|
||||||
|
<td><%= item.max_stock_level %></td>
|
||||||
|
<td>
|
||||||
|
<% if item.balance.nil? %>
|
||||||
|
0
|
||||||
|
<% else %>
|
||||||
|
<%= item.balance rescue 0 %>
|
||||||
|
<% end %>
|
||||||
|
</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>
|
||||||
|
</tr>
|
||||||
|
<!-- <tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
<td>
|
<td>
|
||||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
|
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
|
||||||
@@ -38,9 +62,7 @@
|
|||||||
<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>
|
<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>
|
||||||
<!-- <td><%= Employee.find(item.created_by).name rescue '-' %></td>
|
</tr> -->
|
||||||
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td> -->
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
<div class="m-b-10 clearfix">
|
<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 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> -->
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<%= render 'inventory_list' %>
|
<%= render 'inventory_list' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
<!-- <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||||
@@ -32,9 +32,9 @@
|
|||||||
<p>
|
<p>
|
||||||
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>
|
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>
|
<<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>
|
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>
|
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||||
<p>
|
<p>
|
||||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -84,28 +84,31 @@
|
|||||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" for="attribute">Menu Item</label>
|
<label class="control-label" for="attribute">Menu Item</label>
|
||||||
<input class="form-control col-md-6" type="text" value="" id="item_name" readonly="true">
|
<input class="form-control col-md-6" type="text" value="" id="item_name" readonly="true">
|
||||||
<input type="hidden" value="" id="item_code">
|
|
||||||
<input type="hidden" value="" id="instance_code">
|
|
||||||
</div>
|
</div>
|
||||||
|
<%= f.input :item_code , :as => :hidden,:input_html=>{:id=>"instance_code"} %>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" for="attribute">Instances</label>
|
<label class="control-label" for="attribute">Instances</label>
|
||||||
<div class="attributes-list col-md-6"></div>
|
<div class="attributes-list col-md-6"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<%= f.input :min_order_level,:input_html=>{:value=>"1",:class=>"col-md-5"} %>
|
||||||
<label class="control-label" for="min_qty">Min Qty</label>
|
<%= f.input :max_stock_level,:input_html=>{:value=>"1",:class=>"col-md-5"} %>
|
||||||
<input class="form-control col-md-6" type="number" value="1" id="min_qty">
|
<div class="form-actions">
|
||||||
|
<%= f.submit t("views.btn.submit"), class: 'btn bg-blue waves-effect' %>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label" for="max_qty">Max Qty</label>
|
<% end %>
|
||||||
<input class="form-control col-md-6" type="number" value="1" id="max_qty">
|
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- <div class="modal-footer">
|
||||||
<div class="modal-footer">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<button type="button" class="btn btn-default " data-dismiss="modal" id="close">Close</button>
|
<button type="button" class="btn btn-default " data-dismiss="modal" id="close">Close</button>
|
||||||
@@ -114,7 +117,7 @@
|
|||||||
<button type="button" class="btn btn-primary submit " data-dismiss="modal" id="submit">Submit</button>
|
<button type="button" class="btn btn-primary submit " data-dismiss="modal" id="submit">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -467,7 +470,7 @@
|
|||||||
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
||||||
disabled = "disabled";
|
disabled = "disabled";
|
||||||
}
|
}
|
||||||
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
row +="<button type='button' id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
||||||
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||||
+ status +" "+ type +" '"+ disabled +" >"
|
+ status +" "+ type +" '"+ disabled +" >"
|
||||||
+value[i]
|
+value[i]
|
||||||
@@ -556,10 +559,21 @@
|
|||||||
|
|
||||||
// click select option icon for add
|
// click select option icon for add
|
||||||
$(document).on('click', '.submit', function(event){
|
$(document).on('click', '.submit', function(event){
|
||||||
var params = {'order_source': type, 'order_type': "dine_in",
|
var params = { 'item_code': $("#item_code").val(),
|
||||||
'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id,
|
'min_order_level': $("#min_qty").val(),
|
||||||
'table_id': table_id,
|
'max_stock_level': $("#max_qty").val()
|
||||||
'order_items': order_items,'create_type' : "create_only" };
|
};
|
||||||
|
var ajax_url = '<%=inventory_inventory_definitions_path%>';
|
||||||
|
console.log(ajax_url)
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: ajax_url,
|
||||||
|
data: params,
|
||||||
|
dataType: "json",
|
||||||
|
success:function(result){
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,28 +44,28 @@
|
|||||||
<table class="table table-striped col-md-12">
|
<table class="table table-striped col-md-12">
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
<th><%= t("views.right_panel.detail.product") %></th>
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
<th><%= t("views.right_panel.detail.stock_count") %></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.stock_balance") %></th>
|
||||||
<th><%= t("views.right_panel.detail.different") %></th>
|
<th><%= t("views.right_panel.detail.different") %></th>
|
||||||
<th><%= t("views.right_panel.detail.remark") %></th>
|
<th><%= t("views.right_panel.detail.remark") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
<%
|
<%
|
||||||
count = 0
|
count = 0
|
||||||
@check.stock_check_items.each do |item|
|
@stock_check_items.each do |item|
|
||||||
count += 1
|
count += 1
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
<td>
|
<% if !cate_arr.include?(item.menu_category_id) %>
|
||||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
|
<td><%= item.menu_category_name %></td>
|
||||||
<% if menu_item.nil? %>
|
<% cate_arr.push(item.menu_category_id) %>
|
||||||
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= menu_item.menu_item.name rescue "-" %>
|
<td> </td>
|
||||||
- <%= menu_item.item_instance_name rescue "-" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
<td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td>
|
||||||
<td><%= item.stock_count %></td>
|
<td><%= item.stock_count %></td>
|
||||||
<td><%= item.stock_balance %></td>
|
<td><%= item.stock_balance %></td>
|
||||||
<td><%= item.different %></td>
|
<td><%= item.different %></td>
|
||||||
|
|||||||
Reference in New Issue
Block a user