Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
phyusin
2018-08-16 15:52:28 +06:30
17 changed files with 348 additions and 179 deletions

View File

@@ -1,8 +1,27 @@
class Inventory::InventoryController < BaseInventoryController class Inventory::InventoryController < BaseInventoryController
load_and_authorize_resource load_and_authorize_resource
def index def index
@products = InventoryDefinition.all.active.order('created_at desc') @inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
end (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 #Shop Name in Navbor
helper_method :shop_detail helper_method :shop_detail

View File

@@ -24,7 +24,14 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions # POST /inventory_definitions
# POST /inventory_definitions.json # POST /inventory_definitions.json
def create 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 @inventory_definition.created_by = current_user.id
respond_to do |format| respond_to do |format|
if @inventory_definition.save if @inventory_definition.save

View File

@@ -26,15 +26,16 @@ class Origami::SalesController < BaseOrigamiController
dining = params[:dining_id] dining = params[:dining_id]
sale_id = params[:sale_id] sale_id = params[:sale_id]
tax_type = params[:tax_type] tax_type = params[:tax_type]
sale_data = []
table = DiningFacility.find(dining) table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id) existing_booking = Booking.find_by_sale_id(sale_id)
table.bookings.each do |booking| table.bookings.each do |booking|
# if !booking.checkout_at.nil? # if !booking.checkout_at.nil?
# existing_booking.update_attributes(checkout_at: checkout_at) # existing_booking.update_attributes(checkout_at: checkout_at)
# end # end
if booking.sale_id.nil? if booking.sale_id.nil?
order_array = [] order_array = []
booking.booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved' booking.booking_status = 'moved'
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
@@ -49,6 +50,7 @@ class Origami::SalesController < BaseOrigamiController
if !orer_item.set_menu_items.nil? if !orer_item.set_menu_items.nil?
saleobj.add_sub_item(orer_item.set_menu_items) saleobj.add_sub_item(orer_item.set_menu_items)
end end
sale_data.push(orer_item)
end end
# Re-compute for add # Re-compute for add
@@ -75,6 +77,10 @@ class Origami::SalesController < BaseOrigamiController
end end
end end
end end
if !sale_data.empty?
# InventoryJob.perform_now(self.id)
InventoryDefinition.calculate_product_count(nil,sale_data)
end
end end
end end

View File

@@ -2,11 +2,20 @@ class InventoryDefinition < ApplicationRecord
scope :active, -> {where(:is_active => true)} scope :active, -> {where(:is_active => true)}
def self.calculate_product_count(saleObj) def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil)
saleObj.sale_items.each do |item| if !saleObj.nil?
found, inventory_definition = find_product_in_inventory(item) saleObj.sale_items.each do |item|
if found found, inventory_definition = find_product_in_inventory(item)
check_balance(item,inventory_definition) 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 end
end end
@@ -16,7 +25,12 @@ class InventoryDefinition < ApplicationRecord
if product.nil? if product.nil?
return false, nil return false, nil
else 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
end end

View File

@@ -2125,7 +2125,7 @@ end
else 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) 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 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 else
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
@@ -2133,7 +2133,7 @@ end
else 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) 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 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
else else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
@@ -2144,7 +2144,7 @@ end
else 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) 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 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 else
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
@@ -2152,7 +2152,7 @@ end
else 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) 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 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
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
@@ -2164,7 +2164,7 @@ end
else 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) 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 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 else
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
@@ -2172,7 +2172,7 @@ end
else 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) 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 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 end
end end
@@ -2185,7 +2185,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end 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 else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' 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") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
@@ -2194,7 +2194,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end 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 else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil? if !shift.nil?
@@ -2204,7 +2204,7 @@ end
else 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) 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 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 end
end end

View File

@@ -36,10 +36,10 @@ class StockCheckItem < ApplicationRecord
def self.get_transaction(from, to, item_code) def self.get_transaction(from, to, item_code)
transaction = all transaction = all
if !from.nil? && !to.nil? 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 end
if item_code.present? 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 end
transaction transaction
end end

View File

@@ -4,10 +4,11 @@ class StockJournal < ApplicationRecord
STOCK_CHECK_TRANS = "stock_check" STOCK_CHECK_TRANS = "stock_check"
def self.add_to_journal(item, balance, stock_message, inventory_definition) # item => saleObj | balance => Stock journal 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) balance = calculate_balance(balance, item.qty)
journal = StockJournal.new
journal.item_code = item.item_instance_code journal.item_code = item.item_instance_code
journal.inventory_definition_id = inventory_definition.id journal.inventory_definition_id = inventory_definition.id
journal.debit = item.qty journal.debit = item.qty

View File

@@ -5,12 +5,14 @@
<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>
<th><%= t("views.right_panel.detail.created_by") %></th> <th><%= t("views.right_panel.detail.balance") %></th>
<th><%= t("views.right_panel.detail.created_time") %></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> </tr>
<% <%
count = 0 count = 0
@products.each do |item| @inventory_definitions.each do |item|
count += 1 count += 1
%> %>
<tr> <tr>
@@ -26,9 +28,20 @@
</td> </td>
<td><%= item.min_order_level %></td> <td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td> <td><%= item.max_stock_level %></td>
<td><%= Employee.find(item.created_by).name rescue '-' %></td> <td><%= item.balance rescue '0' %></td>
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></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> </tr>
<% end %> <% end %>
</table> </table>
<script>
$('.show_track').on('click', function () {
var ID = $(this).attr("data-value");
window.location.href = '/inventory/'+ID+'/show';
});
</script>

View File

@@ -12,10 +12,10 @@
<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-9 col-lg-9">
<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> -->
<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="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("views.btn.new") + " " + (t :inventory) %> <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> </button>
</div> </div>
<div class="card"> <div class="card">
@@ -27,14 +27,14 @@
<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>
<p> <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>
<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> <!-- <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>
@@ -51,12 +51,12 @@
window.location.href = '<%= inventory_stock_checks_path %>'; window.location.href = '<%= inventory_stock_checks_path %>';
}); });
$('#stock_check_report').on('click', function () { // $('#stock_check_report').on('click', function () {
window.location.href = '<%= reports_stock_check_index_path %>'; // window.location.href = '<%= reports_stock_check_index_path %>';
}); // });
$('#new_inventory_product').on('click',function(){ $('#new_inventory_product').on('click',function(){
window.location.href = '/inventory/inventory_definitions/new'; window.location.href = '/inventory/inventory_definitions/new';
}) });
</script> </script>

View 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>

View File

@@ -101,14 +101,25 @@
</div> </div>
<script> <script>
var count = 0; 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 () { $('#save_to_stock_check').on('click', function () {
count += 1; count += 1;
product_sku = $('#product_sku').val(); product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val(); product_qty = $('#product_qty').val();
product_name = $("#product_sku").find("option:selected").text(); product_name = $("#product_sku").find("option:selected").text();
// clearFormData();
var tr = '<tr>' var tr = '<tr>'
//+ '<td>' + count + '</td>' //+ '<td>' + count + '</td>'
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>' + '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'

View File

@@ -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;"> <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>
<div class="form-group col-md-4"> <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"> <select class="form-control" name="item_code" id="item_code">
<option value="">Select Product</option> <option value="">Select Item</option>
<% @inventory_definitions.each do |id| %> <% @inventory_definitions.each do |id| %>
<option value="<%= id.item_code %>"> <option value="<%= id.item_code %>">
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %> <% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
<% if menu_item.nil? %> <% if menu_item.nil? %>
<%= Product.find_by_item_code(id.item_code).name rescue "-" %> <%= Product.find_by_item_code(id.item_code).name rescue "-" %>
<% else %> <% else %>
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %> <%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
<% end %>
</option>
<% end %> <% end %>
</option>
<% end %>
</select> </select>
</div> </div>
<div class="form-group col-md-2 margin-top-20"><br> <div class="form-group col-md-2 margin-top-20"><br>

View File

@@ -3,102 +3,107 @@
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li> <li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item active">Stock Check Report</li> <li class="breadcrumb-item active">Stock Check Report</li>
<span class="float-right"> <span class="float-right">
<%= link_to 'Back', inventory_path %> <%= link_to 'Back', inventory_path %>
</span> </span>
</ol> </ol>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<!-- <div class="container"> --> <!-- <div class="container"> -->
<%= render :partial => 'stock_check_report_filter', <%= render :partial => 'stock_check_report_filter',
:locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %> :locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %>
<hr/> <hr/>
<!-- </div> --> <!-- </div> -->
<!-- <div class="container"> --> <!-- <div class="container"> -->
<!-- <div class="row"> --> <!-- <div class="row"> -->
<div class="text-right"> <div class="text-right">
<a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-info wave-effects">Export to <a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-info wave-effects">Export to
Excel</a> Excel</a>
</div> </div>
<!-- </div> --> <!-- </div> -->
<!-- </div> --> <!-- </div> -->
<div class="margin-top-20"> <div class="margin-top-20">
<div class="card"> <div class="card">
<div class="table-responsive"> <div class="table-responsive">
<% if @print_settings.precision.to_i > 0 <% if @print_settings.precision.to_i > 0
precision = @print_settings.precision precision = @print_settings.precision
else else
precision = 0 precision = 0
end end
#check delimiter #check delimiter
if @print_settings.delimiter if @print_settings.delimiter
delimiter = "," delimiter = ","
else else
delimiter = "" delimiter = ""
end end
%> %>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <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> <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>
<tr> <tr>
<th>Stock Check Reason</th> <th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
<th>Checked By</th> <th><%= t("views.right_panel.detail.stock_count") %></th>
<th>Item Name</th> <th><%= t("views.right_panel.detail.stock_balance") %></th>
<th>Stock Count</th> <th><%= t("views.right_panel.detail.different") %></th>
<th>Stock Balance</th> <th><%= t("views.right_panel.detail.remark") %></th>
<th>Different</th> <th><%= t("views.right_panel.detail.checked_by") %></th>
<th>Remark</th> <th><%= t("views.right_panel.detail.stock_check") %> <%= t("views.right_panel.detail.reason") %></th>
<th>Date</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <% total_stock_count = 0 %>
<% total_stock_count = 0 %> <% total_stock_balance = 0 %>
<% total_stock_balance = 0 %> <% total_different = 0 %>
<% total_different = 0 %> <% arr_item_code = [] %>
<% @transaction.each do |result| %>
<% @transaction.each do |result| %> <tr>
<tr> <td>
<td><%= result.stock_check.reason rescue '-' %></td> <% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
<td><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td> <% if menu_item.nil? %>
<td> <% if !arr_item_code.include?(result.item_code) %>
<% 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 "-" %> <%= Product.find_by_item_code(result.item_code).name rescue "-" %>
<% else %> <% arr_item_code.push(result.item_code) %>
<% else %>
&nbsp;
<% end %>
<% else %>
<% if !arr_item_code.include?(result.item_code) %>
<%= menu_item.menu_item.name rescue "-" %> <%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %> - <%= menu_item.item_instance_name rescue "-" %>
<% end %> <% arr_item_code.push(result.item_code) %>
</td> <% else %>
<td><%= result.stock_count rescue '-' %></td> &nbsp;
<td><%= number_with_precision(result.stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td> <% end %>
<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 %>
<% 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;"> <!-- <tr style="border-top: 3px solid grey;">
<td colspan="3"></td> <td colspan="3"></td>
<td><b><%= total_stock_count rescue '-' %></b></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><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
<td><b><%= total_different rescue '-' %></b></td> <td><b><%= total_different rescue '-' %></b></td>
<td colspan="2"></td> <td></td>
</tr> </tr> -->
</tbody> </tbody>
</table> </table>
</div>
</div>
</div> </div>
<script> </div>
$(function () { </div>
</div>
}); </div>
</script>

View File

@@ -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> <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>
<tr> <tr>
<th>Commissioner Name</th> <th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
<th>Product Name</th> <th><%= t("views.right_panel.detail.stock_count") %></th>
<th>Qty</th> <th><%= t("views.right_panel.detail.stock_balance") %></th>
<th>Commission Price</th> <th><%= t("views.right_panel.detail.different") %></th>
<th>Commission Amount</th> <th><%= t("views.right_panel.detail.remark") %></th>
<th>Date</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> </tr>
</thead> </thead>
<tbody> <tbody>
<% total_qty = 0 %> <% total_stock_count = 0 %>
<% total_price = 0 %> <% total_stock_balance = 0 %>
<% total_amount = 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 %>
&nbsp;
<% 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 %>
&nbsp;
<% 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 style="border-top: 3px solid grey;">
<tr> <td colspan="3"></td>
<td> <td><b><%= total_stock_count rescue '-' %></b></td>
<%= result.commissioner.name rescue '-' %> <td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
</td> <td><b><%= total_different rescue '-' %></b></td>
<td> <td></td>
<%= result.commission.menu_item.name rescue '-' %> </tr> -->
</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>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@@ -84,6 +84,8 @@ en:
processed: "Processed" processed: "Processed"
delivery_details: "Delivery Details" delivery_details: "Delivery Details"
credits: "Credits" credits: "Credits"
track: "Track"
debit: "Debit"
views: views:
btn: btn:
@@ -494,6 +496,7 @@ en:
in_time: "In Time" in_time: "In Time"
out_time: "Out Time" out_time: "Out Time"
transaction_fee: "Transaction Fee" transaction_fee: "Transaction Fee"
checked_by: "Checked By"
code_txt: "code " code_txt: "code "
charge_txt: "charge" charge_txt: "charge"

View File

@@ -79,6 +79,8 @@ mm:
processed: "Processed" processed: "Processed"
delivery_details: "Delivery Details" delivery_details: "Delivery Details"
credits: "အကြွေးများ" credits: "အကြွေးများ"
track: "Track"
debit: "Debit"
views: views:
btn: btn:
@@ -488,6 +490,7 @@ mm:
in_time: "In Time" in_time: "In Time"
out_time: "Out Time" out_time: "Out Time"
transaction_fee: "Transaction Fee" transaction_fee: "Transaction Fee"
checked_by: "Checked By"
code_txt: "ကုတ်ဒ် " code_txt: "ကုတ်ဒ် "
charge_txt: "ကောက်ခံသည်" charge_txt: "ကောက်ခံသည်"

View File

@@ -513,6 +513,7 @@ scope "(:locale)", locale: /en|mm/ do
# resources :stock_checks # resources :stock_checks
resources :stock_journals resources :stock_journals
resources :inventory_definitions resources :inventory_definitions
get ':inventory_definition_id/show' => 'inventory#show'
end end
#mount_compendium at: '/report' #, controller: 'reports' #mount_compendium at: '/report' #, controller: 'reports'