stock_check report template
This commit is contained in:
1015
.idea/workspace.xml
generated
1015
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
class Inventory::StockChecksController < BaseInventoryController
|
||||
|
||||
def index
|
||||
@check = StockCheck.new
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
@@ -29,87 +28,86 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
stockcheck = StockCheck.find(stock_id)
|
||||
stockcheck_items = stockcheck.stock_check_items
|
||||
member_info = nil
|
||||
unique_code = "StockPrint"
|
||||
|
||||
unique_code = 'StockPrint'
|
||||
|
||||
shop_details = Shop.find(1)
|
||||
checker = Employee.find(stockcheck.check_by)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker.name, shop_details)
|
||||
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
|
||||
end
|
||||
|
||||
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /stock_checks
|
||||
# GET /stock_checks.json
|
||||
# def index
|
||||
# @stock_checks = StockCheck.all
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1
|
||||
# # GET /stock_checks/1.json
|
||||
# def show
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/new
|
||||
# def new
|
||||
# @stock_check = StockCheck.new
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1/edit
|
||||
# def edit
|
||||
# end
|
||||
#
|
||||
# # POST /stock_checks
|
||||
# # POST /stock_checks.json
|
||||
# def create
|
||||
# @stock_check = StockCheck.new(stock_check_params)
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @stock_check.save
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
|
||||
# format.json { render :show, status: :created, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :new }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # PATCH/PUT /stock_checks/1
|
||||
# # PATCH/PUT /stock_checks/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @stock_check.update(stock_check_params)
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # DELETE /stock_checks/1
|
||||
# # DELETE /stock_checks/1.json
|
||||
# def destroy
|
||||
# @stock_check.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_stock_check
|
||||
# @stock_check = StockCheck.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def stock_check_params
|
||||
# params.fetch(:stock_check, {})
|
||||
# end
|
||||
# def index
|
||||
# @stock_checks = StockCheck.all
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1
|
||||
# # GET /stock_checks/1.json
|
||||
# def show
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/new
|
||||
# def new
|
||||
# @stock_check = StockCheck.new
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1/edit
|
||||
# def edit
|
||||
# end
|
||||
#
|
||||
# # POST /stock_checks
|
||||
# # POST /stock_checks.json
|
||||
# def create
|
||||
# @stock_check = StockCheck.new(stock_check_params)
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @stock_check.save
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
|
||||
# format.json { render :show, status: :created, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :new }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # PATCH/PUT /stock_checks/1
|
||||
# # PATCH/PUT /stock_checks/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @stock_check.update(stock_check_params)
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # DELETE /stock_checks/1
|
||||
# # DELETE /stock_checks/1.json
|
||||
# def destroy
|
||||
# @stock_check.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_stock_check
|
||||
# @stock_check = StockCheck.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def stock_check_params
|
||||
# params.fetch(:stock_check, {})
|
||||
# end
|
||||
end
|
||||
|
||||
50
app/controllers/reports/stock_check_controller.rb
Normal file
50
app/controllers/reports/stock_check_controller.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
class Reports::StockCheckController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
from_date = DateTime.now.beginning_of_day.utc.getlocal
|
||||
to_date = DateTime.now.end_of_day.utc.getlocal
|
||||
unless params[:daterange].blank?
|
||||
from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
|
||||
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
@daterange = params[:daterange]
|
||||
end
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.all
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,14 +6,24 @@ class MenuItemInstance < ApplicationRecord
|
||||
# before_create :generate_menu_item_instance_code
|
||||
|
||||
def self.findParentCategory(item)
|
||||
if item.menu_category_id
|
||||
return item.menu_category_id
|
||||
if item.menu_category_id
|
||||
item.menu_category_id
|
||||
else
|
||||
parentitem = MenuItem.find(item.menu_item_id)
|
||||
findParentCategory(parentitem)
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_item_name(item_code)
|
||||
menu_item = MenuItemInstance.find_by_item_instance_code(item_code)
|
||||
if menu_item.nil?
|
||||
item_name = Product.find_by_item_code(item_code).name
|
||||
else
|
||||
item_name = menu_item.menu_item.name + ' - ' + menu_item.item_instance_name
|
||||
end
|
||||
item_name
|
||||
end
|
||||
|
||||
# private
|
||||
|
||||
# def generate_menu_item_instance_code
|
||||
|
||||
@@ -2,7 +2,7 @@ class StockCheck < ApplicationRecord
|
||||
|
||||
has_many :stock_check_items
|
||||
|
||||
def create(user, eason, item_list)
|
||||
def create(user, reason, item_list)
|
||||
self.reason = reason
|
||||
self.check_by = user.id
|
||||
self.check_start = Time.now
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class StockResultPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
attr_accessor :label_width, :price_column_width, :page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size, :item_height, :qty_width, :total_width, :item_description_width, :text_width
|
||||
|
||||
def initialize(printer_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||
def initialize(printer_settings, stockcheck, stockcheck_items, checker_name, shop_details)
|
||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.margin = 5
|
||||
self.price_width = 40
|
||||
@@ -27,66 +27,68 @@ class StockResultPdf < Prawn::Document
|
||||
self.header_font_size = 10
|
||||
self.item_font_size = 8
|
||||
|
||||
header( shop_details)
|
||||
header(shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
detail(stockcheck,stockcheck_items, checker_name)
|
||||
detail(stockcheck, stockcheck_items, checker_name)
|
||||
end
|
||||
|
||||
def header (shop_details)
|
||||
move_down 7
|
||||
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size, :align => :center
|
||||
move_down 5
|
||||
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||
text "#{shop_details.address}", :size => self.item_font_size, :align => :center
|
||||
# move_down self.item_height
|
||||
move_down 5
|
||||
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||
text "#{shop_details.phone_no}", :size => self.item_font_size, :align => :center
|
||||
move_down 5
|
||||
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
def detail(stockcheck, stockcheck_items, checker_name)
|
||||
move_down 7
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Checker : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{checker_name}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
move_down 7
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "Checker : ", :size => self.item_font_size, :align => :left
|
||||
end
|
||||
bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{checker_name}", :size => self.item_font_size, :align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Check Start Time : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "Check Start Time : ", :size => self.item_font_size, :align => :left
|
||||
end
|
||||
bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }", :size => self.item_font_size, :align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Check End Time ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "Check End Time ", :size => self.item_font_size, :align => :left
|
||||
end
|
||||
bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }", :size => self.item_font_size, :align => :left
|
||||
end
|
||||
|
||||
if stockcheck_items.length > 0
|
||||
stockcheck_items.each do |st|
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "#{ st.item_code }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{st.stock_count.to_i}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
if stockcheck_items.length > 0
|
||||
stockcheck_items.each do |st|
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
y_position = cursor
|
||||
|
||||
item_name = MenuItemInstance.get_item_name(st.item_code)
|
||||
|
||||
bounding_box([0, y_position], :width => self.item_description_width, :height => self.item_height) do
|
||||
text item_name.to_s, :size => self.item_font_size, :align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width, y_position], :width => self.label_width) do
|
||||
text "#{st.stock_count.to_i}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,11 +22,19 @@
|
||||
%>
|
||||
<tr>
|
||||
<td><%= count %></td>
|
||||
<td><%= item.item_code rescue ""%></td>
|
||||
<td>
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
|
||||
<% if menu_item.nil? %>
|
||||
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
|
||||
<% else %>
|
||||
<%= menu_item.menu_item.name rescue "-" %>
|
||||
- <%= menu_item.item_instance_name rescue "-" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= item.min_order_level %></td>
|
||||
<td><%= item.max_stock_level %></td>
|
||||
<td><%= item.created_by %></td>
|
||||
<td><%= item.created_at%></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>
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-lg-10 col-md-10 col-sm-10">
|
||||
<%= render 'inventory_list' %>
|
||||
<%= render 'inventory_list' %>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
|
||||
<button id="back" type="button" class="btn btn-block btn-primary"> Back </button>
|
||||
<%end%>
|
||||
<button id="stock_taking" type="button" class="btn btn-block btn-primary"> New Stock Taking </button>
|
||||
<% if current_login_employee.role == "administrator" || current_login_employee.role == 'manager' %>
|
||||
<button id="back" type="button" class="btn btn-block btn-primary"> Back</button>
|
||||
<% end %>
|
||||
<button id="stock_taking" type="button" class="btn btn-block btn-primary"> New Stock Taking</button>
|
||||
<button id="stock_check_report" type="button" class="btn btn-block btn-primary"> Stock Check Report</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#stock_taking').on('click',function(){
|
||||
window.location.href = '/inventory/stock_checks';
|
||||
})
|
||||
$('#stock_check_report').on('click', function(){
|
||||
window.location.href = '';
|
||||
})
|
||||
$('#stock_taking').on('click', function () {
|
||||
window.location.href = '<%= inventory_stock_checks_path %>';
|
||||
});
|
||||
|
||||
$('#stock_check_report').on('click', function () {
|
||||
window.location.href = '<%= reports_stock_check_index_path %>';
|
||||
});
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '<%= dashboard_path %>';
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
<%= link_to 'Back', inventory_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<h1>Editing Inventory Definition</h1>
|
||||
|
||||
<%= render 'form', inventory_definition: @inventory_definition %>
|
||||
|
||||
<%= link_to 'Show', @inventory_definition %> |
|
||||
<%= link_to 'Back', inventory_definitions_path %>
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= inventory_path %>">Product Inventory</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', inventory: @inventory_definition %>
|
||||
</div>
|
||||
|
||||
@@ -20,8 +20,14 @@
|
||||
<select class='form-control' id='product_sku'>
|
||||
<option value="">Select Product</option>
|
||||
<% @inventory_definitions.each do |id| %>
|
||||
<% item_name = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
|
||||
<option value="<%= id.item_code %>"><%= item_name.item_instance_name %></option>
|
||||
<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 %>
|
||||
</select>
|
||||
</div>
|
||||
@@ -50,7 +56,7 @@
|
||||
<div class="col-md-12">
|
||||
<table class="table table-striped" id='stock_item'>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<!--<th>#</th>-->
|
||||
<th>Product</th>
|
||||
<th>Balance</th>
|
||||
<th></th>
|
||||
@@ -61,6 +67,7 @@
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="row">
|
||||
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='back'> Back</button>
|
||||
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,13 +87,13 @@
|
||||
count += 1;
|
||||
product_sku = $('#product_sku').val();
|
||||
product_qty = $('#product_qty').val();
|
||||
product_name = $("#product_sku option:selected").text();
|
||||
product_name = $("#product_sku").find("option:selected").text();
|
||||
var tr = '<tr>'
|
||||
+ '<td>' + count + '</td>'
|
||||
//+ '<td>' + count + '</td>'
|
||||
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
|
||||
+ '<input type=text value="' + product_name + '" id="item_name_' + count + '" name=' + count + ' disabled/></td>'
|
||||
+ product_name + '</td>'
|
||||
+ '<td><input type=text value="' + product_qty + '" id="item_qty_' + count + '" name=' + count + '/></td>'
|
||||
+ '<td><input type=button value="Remove" id="item_qty_' + count + '" name=' + count + '/></td>'
|
||||
+ '<td><input type=button value="X" id="item_remove_' + count + '" name=' + count + ' onclick="remove_row('+ count +')"/></td>'
|
||||
+ '</tr>';
|
||||
$('#stock_item').append(tr);
|
||||
// $('#product_sku').val('');
|
||||
@@ -101,7 +108,9 @@
|
||||
for (var i = 1; i <= count; i++) {
|
||||
itemname = $('#item_sku_' + i).val();
|
||||
itemqty = $('#item_qty_' + i).val();
|
||||
arr.push({sku: itemname, qty: itemqty});
|
||||
if(itemname !== undefined){
|
||||
arr.push({sku: itemname, qty: itemqty});
|
||||
}
|
||||
jsonStr = JSON.stringify(arr);
|
||||
}
|
||||
console.log(jsonStr);
|
||||
@@ -113,6 +122,14 @@
|
||||
window.location.href = '/inventory/stock_checks/' + data['stock_id'];
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/inventory';
|
||||
});
|
||||
|
||||
function remove_row(row) {
|
||||
$("#item_remove_"+row).parent().parent().remove();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -3,81 +3,96 @@
|
||||
<div class="col-md-10">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
Check by
|
||||
Check by
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<%= @check.check_by %>
|
||||
<%= Employee.find(@check.check_by).name rescue '' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
Check At
|
||||
Check At
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<%= @check.created_at %></div>
|
||||
<%= @check.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
Reason
|
||||
Reason
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<%= @check.reason %>
|
||||
<%= @check.reason %>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<table class="table table-striped col-md-12">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Product</th>
|
||||
<th>Stock Count</th>
|
||||
<th>Stock Balance</th>
|
||||
<th>Different</th>
|
||||
<th>Remark</th>
|
||||
</tr>
|
||||
<%
|
||||
count = 0
|
||||
@check.stock_check_items.each do |item|
|
||||
count += 1
|
||||
%>
|
||||
<table class="table table-striped col-md-12">
|
||||
<tr>
|
||||
<td><%= count %></td>
|
||||
<td><%= item.item_code %></td>
|
||||
<td><%= item.stock_count %></td>
|
||||
<td><%= item.stock_balance %></td>
|
||||
<td><%= item.different %></td>
|
||||
<td><%= item.remark %></td>
|
||||
<th>#</th>
|
||||
<th>Product</th>
|
||||
<th>Stock Count</th>
|
||||
<th>Stock Balance</th>
|
||||
<th>Different</th>
|
||||
<th>Remark</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<%
|
||||
count = 0
|
||||
@check.stock_check_items.each do |item|
|
||||
count += 1
|
||||
%>
|
||||
<tr>
|
||||
<td><%= count %></td>
|
||||
<td>
|
||||
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
|
||||
<% if menu_item.nil? %>
|
||||
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
|
||||
<% else %>
|
||||
<%= menu_item.menu_item.name rescue "-" %>
|
||||
- <%= menu_item.item_instance_name rescue "-" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= item.stock_count %></td>
|
||||
<td><%= item.stock_balance %></td>
|
||||
<td><%= item.different %></td>
|
||||
<td><%= item.remark %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button id="back" type="button" class="btn btn-block btn-primary"> Back </button>
|
||||
<button id="save_to_journal" type="button" class="btn btn-block btn-primary"> Save to Journal </button>
|
||||
<button id="print" type="button" class="btn btn-block btn-primary"> Print </button>
|
||||
<button id="back" type="button" class="btn btn-block btn-primary"> Back</button>
|
||||
<button id="save_to_journal" type="button" class="btn btn-block btn-primary"> Save to Journal</button>
|
||||
<button id="print" type="button" class="btn btn-block btn-primary"> Print</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#save_to_journal').on('click', function(){
|
||||
check_id = $('#stock_check_id').val();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '<%= inventory_save_to_journal_path %>',
|
||||
data: 'data='+ check_id,
|
||||
success: function(){
|
||||
alert('success')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$('#print').on('click',function(){
|
||||
check_id = $('#stock_check_id').val();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '<%= inventory_print_stock_check_path %>',
|
||||
data: 'stock_check_id='+ check_id
|
||||
})
|
||||
})
|
||||
$('#save_to_journal').on('click', function () {
|
||||
check_id = $('#stock_check_id').val();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '<%= inventory_save_to_journal_path %>',
|
||||
data: 'data=' + check_id,
|
||||
success: function () {
|
||||
alert('Successfully saved to journal.');
|
||||
window.location.href = '/inventory';
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$('#print').on('click', function () {
|
||||
check_id = $('#stock_check_id').val();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '<%= inventory_print_stock_check_path %>',
|
||||
data: 'stock_check_id=' + check_id
|
||||
})
|
||||
});
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/inventory';
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= form_tag report_path, :method => :get, :id => "frm_report", :class => "form" do %>
|
||||
<% if period_type != false %>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="">Select Date Range</label>
|
||||
<% if @daterange %>
|
||||
<input class="form-control" name="daterange" id="daterange" value="<%= @daterange %>" type="text" placeholder="Date Range" readonly="true">
|
||||
<% else %>
|
||||
<input class="form-control" name="daterange" id="daterange" type="text" placeholder="Date Range" readonly="true">
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label class="">Definition 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 '-' %>
|
||||
<% end %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
<input type="button" value="Clear Filter" id="clear_filter" class='btn btn-danger'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#item_code').select2({
|
||||
placeholder: 'Select Product',
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
$('#clear_filter').click(function () {
|
||||
$('#daterange').val('');
|
||||
$('#item_code').val('').text('');
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
autoUpdateInput: false,
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
},
|
||||
locale: {
|
||||
format: 'YYYY-MM-DD'
|
||||
}
|
||||
},
|
||||
function (start, end, label) {
|
||||
$('input[name="daterange"]').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').on('apply.daterangepicker', function (ev, picker) {
|
||||
$('input[name="daterange"]').val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
|
||||
|
||||
from_date = picker.startDate.format('YYYY-MM-DD 00:00:00');
|
||||
to_date = picker.endDate.format('YYYY-MM-DD 23:59:59');
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').on('cancel.daterangepicker', function (ev, picker) {
|
||||
$('input[name="daterange"]').val('');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
79
app/views/reports/stock_check/index.html.erb
Normal file
79
app/views/reports/stock_check/index.html.erb
Normal file
@@ -0,0 +1,79 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li>Stock Check Report</li>
|
||||
</ul>
|
||||
</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="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-default">Export to
|
||||
Excel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container margin-top-20">
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sale</th>
|
||||
<th>Sale Item</th>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td><%= result.sale_id rescue '-' %></td>
|
||||
<td><%= result.sale_item_id rescue '-' %></td>
|
||||
<td><%= result.commissioner.name rescue '-' %></td>
|
||||
<td><%= result.commission.menu_item.name rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
|
||||
</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="4"></td>
|
||||
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
52
app/views/reports/stock_check/index.xls.erb
Normal file
52
app/views/reports/stock_check/index.xls.erb
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="container margin-top-20">
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
|
||||
<% @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>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -328,6 +328,7 @@ Rails.application.routes.draw do
|
||||
resources :credit_payment, :only => [:index, :show]
|
||||
resources :void_sale, :only => [:index, :show]
|
||||
resources :commission, :only => [:index, :show]
|
||||
resources :stock_check, :only => [:index, :show]
|
||||
|
||||
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user