end
redirect_to :controller => "products", :action => "index"
end
-
+
+ #在庫管理履歴プレビュー
+ def stock_histories
+ product_style_id = params[:id]
+ if !product_style_id.blank? && product_style_id=~ /^\d*$/
+ @product_style = ProductStyle.find_by_id(product_style_id.to_i)
+ if !@product_style.blank?
+ @stock_histories = @product_style.stock_histories
+ end
+ else
+ raise "Parameter Invalid"
+ end
+ end
+
protected
def set_style_category
end
if product_style[:id]
product_style.update_attributes({:sell_price=>value[:sell_price],
- :actual_count=>value[:actual_count],
:code=>value[:code],
:manufacturer_id=>value[:manufacturer_id]})
else
- [:sell_price, :actual_count, :code ,:manufacturer_id].each do |column|
+ [:sell_price, :code ,:manufacturer_id].each do |column|
product_style[column] = value[column]
end
product_style[:position] = idx.to_i + 1
--- /dev/null
+#在庫管理の親クラス
+#共通ロジック
+class Admin::StockBaseController < Admin::BaseController
+ before_filter :admin_permission_check_stock
+
+ #検索
+ def search
+ @condition = StockSearchForm.new(params[:condition])
+ unless @condition.valid?
+ render :action => "index"
+ return
+ end
+ @condition, @search_list = Product.get_conditions(@condition, params, true)
+ find_options = {
+ :page => params[:page],
+ :per_page => @condition.per_page || 10,
+ :conditions => flatten_conditions(@search_list),
+ :joins => "LEFT JOIN products ON products.id = product_styles.product_id ",
+ :order => "product_styles.id"
+ }
+ @product_styles = ProductStyle.paginate(find_options)
+ end
+
+ #入庫数、在庫数を更新
+ def stock_update(stock_type)
+ #1.初期データ取得
+ init(stock_type)
+ #2-1.入力チェック
+ unless @stock_history.valid?
+ render :action => "edit"
+ return
+ end
+ #2-2.値チェック
+ result,err_msg = check_parameter
+ unless result
+ flash.now[:error] = err_msg
+ render :action => "edit"
+ return
+ end
+ #3.値設定
+ set_parameter
+ #4-1. 商品規格保存
+ if @product_style.save!
+ #4-2.作業履歴保存
+ set_stock_history
+ @stock_history.save
+ flash[:stock_update] = "データを保存しました"
+ redirect_to :action => "index"
+ else
+ flash[:stock_update_e] = "データ保存に失敗しました"
+ render :action => "edit"
+ return
+ end
+ end
+
+ protected
+ def init(stock_type)
+ if !params[:id].blank? && params[:id]=~ /^\d*$/
+ @product_style = ProductStyle.find_by_id(params[:id].to_i)
+ if !@product_style.blank?
+ @stock_history = StockHistory.new(params[:stock_history])
+ @stock_history.stock_type = stock_type
+ else
+ raise ActiveRecord::RecordNotFound
+ end
+ else
+ raise "Parameter Invalid"
+ end
+ end
+
+ #保存したい作業履歴値設定
+ def set_stock_history
+ @stock_history.admin_user_id = session[:admin_user].id
+ @stock_history.product_id = @product_style.product_id
+ @stock_history.product_style_id = @product_style.id
+ @stock_history.actual_count = @product_style.actual_count
+ @stock_history.orderable_count = @product_style.orderable_count
+ @stock_history.broken_count = @product_style.broken_count
+ @stock_history.moved_at = DateTime.now
+ end
+end
--- /dev/null
+#棚卸用CSV出力
+require 'csv'
+class Admin::StockCsvController < Admin::BaseController
+ before_filter :admin_permission_check_stock
+ caches_page :csv
+
+ def index
+ dir = Pathname.new(page_cache_directory).join(params[:controller], 'csv')
+ unless FileTest.exist?(dir.to_s)
+ FileUtils.mkdir_p(dir.to_s)
+ @dates = []
+ @urls = []
+ return
+ end
+
+ limit = 1.year.ago
+ pairs = dir.enum_for(:each_entry).map do |path|
+ dir.join(path)
+ end.select do |path|
+ path.extname == page_cache_extension or path.extname == '.csv'
+ end.map do |path|
+ path.basename(path.extname).to_s
+ end.map do |id|
+ [id, id.to_time(:local)]
+ end.select do |_, time|
+ time >= limit
+ end.sort_by do |_, time|
+ time
+ end.reverse
+
+ @dates = pairs.map do |_, time|
+ time
+ end
+ @urls = pairs.map do |id, _|
+ url_for(:action => :csv, :id => id,:format => "csv")
+ end
+ end
+
+ def new
+ redirect_to(url_for_date(DateTime.now))
+ end
+
+ def csv
+ # params[:id] はページキャッシュのキーにするだけで抽出条件にはしない
+ if params[:id].blank?
+ render :status => :not_found
+ end
+ date = DateTime.now
+ rows = ProductStyle.find(:all).map do |ps|
+ a = []
+ a << ps.code
+ a << ps.product.name
+ a << ps.product.supplier_name
+ a << ps.actual_count
+ a << ps.broken_count
+ a
+ end
+
+ # CSV に吐く
+ f = StringIO.new('', 'w')
+ title = %w(商品コード 商品名 仕入先名 実在庫数 不良在庫数)
+
+ CSV::Writer.generate(f) do | writer |
+ writer << title
+ rows.each do |row|
+ writer << row
+ end
+ end
+ name = params[:id]
+ filename = '%s.csv' % name
+ headers['Content-Type'] = "application/octet-stream; name=#{filename}"
+ headers['Content-Disposition'] = "attachment; filename=#{filename}"
+ render :text => Iconv.conv('cp932', 'UTF-8', f.string)
+ end
+
+ def url_for_date(date)
+ url_for(:action => :csv, :id => date.strftime('%Y%m%d_%H%M%S'),:format => "csv")
+ end
+end
--- /dev/null
+#入庫、在庫調整作業履歴
+class Admin::StockHistoriesController < Admin::BaseController
+ resource_controller
+ before_filter :admin_permission_check_stock
+
+ def search
+ @condition = StockSearchForm.new(params[:condition])
+ unless @condition.valid?
+ render :action => "index"
+ return
+ end
+
+ @search_list = StockSearchForm.get_conditions(@condition)
+ find_options = {
+ :page => params[:page],
+ :per_page => @condition.per_page || 10,
+ :conditions => flatten_conditions(@search_list),
+ :order => "id"
+ }
+ @stock_histories = StockHistory.paginate(find_options)
+ end
+end
--- /dev/null
+#入庫管理
+class Admin::StockInController < Admin::StockBaseController
+ before_filter :admin_permission_check_stock
+
+ def index
+ @condition = StockSearchForm.new(params[:condition])
+ end
+
+ def edit
+ init(StockHistory::STOCK_IN)
+ end
+
+ def update
+ stock_update(StockHistory::STOCK_IN)
+ end
+
+ #各調整数チェック
+ def check_parameter
+ result = false
+ err_msg = nil
+
+ actual_count = @product_style.actual_count.to_i + @stock_history.storaged_count.to_i
+
+ if actual_count >= 0
+ result = true
+ else
+ err_msg = "実在庫数が「-」になっています。ご確認ください"
+ end
+ [result,err_msg]
+ end
+ #値設定
+ def set_parameter
+ @product_style.actual_count = @product_style.actual_count.to_i + @stock_history.storaged_count.to_i
+ end
+end
--- /dev/null
+#在庫調整
+class Admin::StockModifyController < Admin::StockBaseController
+ before_filter :admin_permission_check_stock
+
+ def index
+ @condition = StockSearchForm.new(params[:condition])
+ end
+
+ def edit
+ init(StockHistory::STOCK_MODIFY)
+ end
+
+ def update
+ stock_update(StockHistory::STOCK_MODIFY)
+ end
+
+ #各調整数チェック
+ def check_parameter
+ result = false
+ err_msg = nil
+
+ actual_count = @product_style.actual_count.to_i + @stock_history.actual_adjustment.to_i
+ orderable_count = @product_style.orderable_count.to_i + @stock_history.orderable_adjustment.to_i
+ broken_count = @product_style.broken_count.to_i + @stock_history.broken_adjustment.to_i
+
+ if [actual_count,orderable_count,broken_count].all? {|v| v >= 0}
+ result = true
+ else
+ err = []
+ if actual_count < 0
+ err << "実在庫数"
+ end
+ if orderable_count < 0
+ err << "販売可能数"
+ end
+ if broken_count < 0
+ err << "不良在庫数"
+ end
+ err_msg = err.join("、") + "が「-」になっています。ご確認ください。"
+ end
+ [result,err_msg]
+ end
+ #値設定
+ def set_parameter
+ @product_style.actual_count = @product_style.actual_count.to_i + @stock_history.actual_adjustment.to_i unless @stock_history.actual_adjustment.blank?
+ @product_style.orderable_count = @product_style.orderable_count.to_i + @stock_history.orderable_adjustment.to_i unless @stock_history.orderable_adjustment.blank?
+ @product_style.broken_count = @product_style.broken_count.to_i + @stock_history.broken_adjustment.to_i unless @stock_history.broken_adjustment.blank?
+ end
+end
new_quantity = cart.quantity + value
cart.quantity = cart.product_style.available?(new_quantity)
if cart.quantity < new_quantity
- flash.now[:notice] = '購入できる上限を超えています'
+ flash[:notice] = '購入できる上限を超えています'
end
redirect_to :action => 'show'
end
@login_customer.point = params[:point_after_operation]
@order = @login_customer.orders.build
end
-
@order.received_at = DateTime.now
@order_delivery = @order.order_deliveries.build(params[:order_delivery])
@order_delivery.status = OrderDelivery::JUTYUU
# 受注発注商品が一つでもあるか
product_styles = @carts.map(&:product_style)
- if product_styles.any?{|ps| ps.actual_count == 0}
+ #販売可能数で判断
+ if product_styles.any?{|ps| ps.orderable_count.to_i == 0}
# 販売開始日が未来の物が一つでもあれば予約
products = product_styles.map(&:product)
today = Date.today
--- /dev/null
+module Admin::StockBaseHelper
+end
--- /dev/null
+module Admin::StockCsvHelper
+end
--- /dev/null
+module Admin::StockHistoriesHelper
+end
--- /dev/null
+module Admin::StockInHelper
+end
--- /dev/null
+module Admin::StockModifyHelper
+end
def category_options_internal(tree, indent='')
tree.inject([]) do |array, item|
if item.instance_of? Category
- array << ['%s%s' % [indent, item.name], item.id]
+ array << ['%s%s' % [indent, item.name], item.id.to_s]
else
array += category_options_internal(item, indent + '>')
end
def have_zaiko?
product_styles or return false
product_styles.any? do |ps|
- !ps.actual_count.blank? && ps.actual_count > 0
+ #販売可能数で判断
+ ps.orderable_count.to_i > 0
end
end
:conditions => code_condition )
ids = product_styles.map{|p| p.product_id}.join(",")
ids = id_change_to_i(ids)
-# ids = "0" if ids.blank?
search_list << ["products.id in (?) ", ids]
end
end
+ unless search.manufacturer.blank?
+ code_condition = ["product_styles.manufacturer_id like ? ", "%#{search.manufacturer}%"]
+ if actual_count_list_flg
+ search_list << code_condition
+ else
+ product_styles = ProductStyle.find(:all, :select => "product_styles.product_id",
+ :conditions => code_condition )
+ ids = product_styles.map{|p| p.product_id}.join(",")
+ ids = id_change_to_i(ids)
+ search_list << ["products.id in (?) ", ids]
+ end
+ end
unless search.style.blank?
product_styles = ProductStyle.find(:all, :select => "product_styles.product_id",
:joins => "left join style_categories on product_styles.style_category_id1 = style_categories.id left join style_categories as style_categories2 on style_category_id2 = style_categories2.id ",
search_list << ["products.supplier_id = ?", search.supplier.to_i]
end
unless search.category.blank?
- search.category = search.category.to_i
- category = Category.find_by_id search.category
- ids = category.get_child_category_ids
- search_list << ["products.category_id in (?)", ids] unless ids.empty?
+ category = Category.find_by_id search.category.to_i
+ unless category.blank?
+ ids = category.get_child_category_ids
+ search_list << ["products.category_id in (?)", ids] unless ids.empty?
+ end
end
unless search.permit.blank?
search_list << ["products.permit = ?", search.permit]
belongs_to :style2,
:class_name => "Style",
:foreign_key => "style_id2"
+ has_many :stock_histories
validates_format_of :code, :with => /^[a-zA-Z0-9]*$/
validates_format_of :manufacturer_id, :with => /^[a-zA-Z0-9]*$/, :allow_blank=>true
- DEFAULT_DATA = {:actual_count => 0}
- alias initialize_old initialize
-
- def initialize(attributes = nil)
- initialize_old(attributes)
- if @new_record && defined? DEFAULT_DATA
- DEFAULT_DATA.each do | column, value |
- @attributes[column.to_s] = value unless @attributes[column.to_s] && ! @attributes[column.to_s].blank?
- end
- end
- end
=begin rdoc
* INFO
引数 [size] が購入可能な個数を超過する場合は、 購入可能な最大数 を返す。
=end
def available?(size)
- actual_count.to_i > 0 ? (check = actual_count) : (check = 0)
+ #販売可能数で判断
+ orderable_count.to_i > 0 ? (check = orderable_count.to_i) : (check = 0)
limit = [check, size].min
product.sell_limit ? [limit, product.sell_limit].min : limit
end
# 受注する
def order(number)
- if actual_count > 0
+ #販売可能数で判断
+ if orderable_count.to_i > 0
+ self.orderable_count -= number
self.actual_count -= number
else
- raise 'å®\9få\9c¨å\80\8bæ\95°ã\81\8c0ã\81§ã\81\99'
+ raise 'å\9c¨åº«ä¸\8d足ã\81§ã\81\99ã\80\82'
end
end
def product_name
product && product.name
end
-
+ # 規格分類名称
+ def style_name(delimiter=' ')
+ [style_category_name1, style_category_name2].inject([]) do | xs, x |
+ x.blank? and break xs
+ xs << x
+ end.join(delimiter)
+ end
end
--- /dev/null
+class StockHistory < ActiveRecord::Base
+ acts_as_paranoid
+
+ belongs_to :product
+ belongs_to :product_style
+ belongs_to :admin_user
+
+ validates_presence_of :comment
+ validates_length_of :comment, :maximum => 10000 , :allow_blank => true
+ validates_presence_of :storaged_count ,:if => :stock_in?
+
+ STOCK_IN ,STOCK_MODIFY = 1 , 2
+ STOCK_TYPE_NAMES = {STOCK_IN=>"入庫",STOCK_MODIFY=>"在庫調整"}
+
+ def stock_in?
+ stock_type == STOCK_IN
+ end
+end
--- /dev/null
+# 在庫管理で商品検索条件を格納するフォーム
+class StockSearchForm < SearchForm
+ set_field_names :product_id => '商品ID'
+ set_field_names :code => '商品コード'
+ set_field_names :name => '商品名'
+ set_field_names :manufacturer => '型番'
+ set_field_names :supplier => '仕入先名'
+ set_field_names :category => 'カテゴリ'
+
+ validates_numericality_of :product_id, :allow_blank=>true, :message => 'は半角数字のみを入力してください。'
+ validates_format_of :code, :with => /^[a-zA-Z0-9]*$/, :allow_blank => true, :message => 'は半角英数字のみを入力してください。'
+ validates_format_of :manufacturer, :with => /^[a-zA-Z0-9]*$/, :allow_blank => true, :message => 'は半角英数字のみを入力してください。'
+
+ def self.get_conditions(search)
+ search_list = []
+ if search
+ #商品ID
+ unless search.product_id.blank?
+ search_list << ["stock_histories.product_id = ?", search.product_id.to_i]
+ end
+ #商品コード
+ unless search.code.blank?
+ ps = ProductStyle.find(:all,:conditions=>"code like '%#{search.code}'")
+ ids = []
+ ids = ps.map{|p| p.id.to_i} unless ps.blank?
+ search_list << ["stock_histories.product_style_id in (?) ", ids] unless ids.blank?
+ end
+ #商品名
+ unless search.name.blank?
+ ps = Product.find(:all,:conditions=>"name like '%#{search.name}'")
+ ids = []
+ ids = ps.map{|p| p.id.to_i} unless ps.blank?
+ search_list << ["stock_histories.product_id in (?) ", ids] unless ids.blank?
+ end
+ #型番
+ unless search.manufacturer.blank?
+ ps = ProductStyle.find(:all,:conditions=>"manufacturer_id like '%#{search.manufacturer}'")
+ ids = []
+ ids = ps.map{|p| p.id.to_i} unless ps.blank?
+ search_list << ["stock_histories.product_style_id in (?) ", ids] unless ids.blank?
+ end
+ #操作者
+ unless search.operator.blank?
+ search_list << ["stock_histories.admin_user_id = ?", search.operator.to_i]
+ end
+ #在庫移動日
+ unless search.moved_at_from.blank?
+ search_list << ["stock_histories.moved_at >= ?", search.moved_at_from]
+ end
+ unless search.moved_at_to.blank?
+ search_list << ["stock_histories.moved_at <= ?", search.moved_at_to]
+ end
+ end
+ search_list
+ end
+end
<li><%= link_to '仕入先登録', {:controller => 'suppliers', :action => 'new'} %></li>\r
</ul>\r
<%end%>\r
+ <p><a href="JavaScript:onClick=Tree('display2');ImgC('img2');"><img src="/images/menu_icon.gif" width="36" height="36" alt="" id="img2" /><span>在庫管理</span></a></p>\r
+ <ul id="display2" style="display:block">\r
+ <li><%= link_to '入庫管理', {:controller => 'stock_in', :action => 'index'} %></li>\r
+ <li><%= link_to '在庫管理', {:controller => 'stock_modify', :action => 'index'} %></li>\r
+ <li><%= link_to '棚卸用CSV出力', {:controller => 'stock_csv', :action => 'index'} %></li>\r
+ <li><%= link_to '作業履歴', {:controller => 'stock_histories', :action => 'index'} %></li>\r
+ </ul>\r
</div><!-- /g_menu -->\r
</div><!-- /サブメニュー -->\r
<% if @system.supplier_use_flag %>
<a href="/admin/suppliers"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
<%else%>
- <a href="#"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
+ <a href="/admin/stock_in"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
<%end%>
</div><!-- /カテゴリ選択 -->
<%= flash[:notice] %>
<th>規格1</th>
<th>規格2</th>
<th>商品コード</th>
- <th>在庫</th>
<th>価格(円)</th>
<th>型番</th>
+ <th>在庫履歴</th>
</tr>
<% idx = 0 %>
<% @style_category1.each do | style_category1 | %>
<% @style_category2.each do | style_category2 | %>
<% product_style = @product_styles["#{style_category1 && style_category1.id}_#{style_category2 && style_category2.id}"]%>
- <% logger.debug "#{style_category1 && style_category1.id}_#{style_category2 && style_category2.id}" %>
<tr>
<td>
<% if product_style.nil? || @new_flg %>
<%= text_field_tag "product_styles[#{idx}][code]", product_style && product_style.code %>
</td>
<td>
- <%= text_field_tag "product_styles[#{idx}][actual_count]", product_style && product_style.actual_count %>
- </td>
- <td>
<%= text_field_tag "product_styles[#{idx}][sell_price]", product_style && product_style.sell_price %>
</td>
<td>
<%= text_field_tag "product_styles[#{idx}][manufacturer_id]", product_style && product_style.manufacturer_id %>
</td>
+ <td>
+ <% unless product_style.nil?%>
+ <%= link_to("在庫履歴",{:action=>"stock_histories" ,:id=>product_style},{:target=>"_blank"})%>
+ <% end%>
+ </td>
</tr>
<% idx += 1 %>
<% end %>
<th>規格1</th>
<th>規格2</th>
<th>商品コード</th>
- <th>在庫</th>
<th>価格(円)</th>
<th>型番</th>
</tr>
<%= hidden_field_tag "product_styles[#{idx.to_s}][code]", params["product_styles"][idx.to_s] && params["product_styles"][idx.to_s]["code"] %>
</td>
<td>
- <%= h params["product_styles"][idx.to_s] && params["product_styles"][idx.to_s]["actual_count"] %>
- <%= hidden_field_tag "product_styles[#{idx.to_s}][actual_count]", params["product_styles"][idx.to_s] && params["product_styles"][idx.to_s]["actual_count"] %>
- </td>
- <td>
<%= h params["product_styles"][idx.to_s] && params["product_styles"][idx.to_s]["sell_price"] %>
<%= hidden_field_tag "product_styles[#{idx.to_s}][sell_price]", params["product_styles"][idx.to_s] && params["product_styles"][idx.to_s]["sell_price"] %>
</td>
--- /dev/null
+<%= render :partial => "submenu" %>
+
+<div id="main"><!-- メイン -->
+
+<h2>在庫管理作業履歴</h2>
+<%unless @product_style.blank?%>
+<h3>現在在庫状況</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>現在実在庫数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.actual_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在受注可能数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.orderable_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在不良在庫数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.broken_count.to_i) %>
+ </td>
+ </tr>
+</table>
+<h3>作業履歴</h3>
+<% unless @stock_histories.blank?%>
+ <table class="data2 clear" cellspacing="1">
+ <tr>
+ <th>操作者</th>
+ <th>移動日</th>
+ <th>作業区分</th>
+ <th>入庫数</th>
+ <th>実在庫調整数</th>
+ <th>当時実在庫数</th>
+ <th>販売可能調整数</th>
+ <th>当時販売可能数</th>
+ <th>不良在庫調整数</th>
+ <th>当時不良在庫数</th>
+ <th>備考</th>
+ </tr>
+ <% @stock_histories.each do | sh | %>
+ <tr>
+ <td><%= h sh.admin_user.name %></td>
+ <td><%= date_time(sh.moved_at) %></td>
+ <td><%= h(StockHistory::STOCK_TYPE_NAMES[sh.stock_type]) %></td>
+ <td><%= number_with_delimiter(sh.storaged_count) %></td>
+ <td><%= number_with_delimiter(sh.actual_adjustment) %></td>
+ <td><%= number_with_delimiter(sh.actual_count.to_i) %></td>
+ <td><%= number_with_delimiter(sh.orderable_adjustment) %></td>
+ <td><%= number_with_delimiter(sh.orderable_count.to_i) %></td>
+ <td><%= number_with_delimiter(sh.broken_adjustment) %></td>
+ <td><%= number_with_delimiter(sh.broken_count.to_i) %></td>
+ <td><%= h sh.comment %></td>
+ </tr>
+ <% end %>
+</table>
+<%else%>
+<br/><p>在庫作業履歴はありません。</p>
+<%end%>
+<%else%>
+<p>商品規格は存在しません。</p>
+<%end%>
+</div><!-- /メイン -->
+
<tr>
<th>仕入先名</th>
<td><%suppliers = Supplier.find(:all,:order=>'id')%>
- <%=f.select :supplier,suppliers.map{|s| [s.name,s.id.to_s]}, :include_blank => '全て' %>
+ <%=f.select :supplier,suppliers.map{|s| [s.name,s.id.to_s]}, :include_blank => true %>
</td>
</tr>
<% end %>
+++ /dev/null
-<%= render :partial => "/admin/stock_in/submenu" %>
\ No newline at end of file
+++ /dev/null
-<h1>Admin::Stock#confirm</h1>
-<p>Find me in app/views/admin/stock/confirm.html.erb</p>
+++ /dev/null
-<%= stylesheet_link_tag "stock/stock" %>
-
-<%= render :partial => "submenu" %>
-
-<div class="set">
-<div class="contents_area">
-
-<h2>在庫管理</h2>
-<p><%= flash[:notice] %>
-<% form_for :search, :url => {:action => 'search'} do |f| %>
- <table class="product_info" cellspacing="1">
- <tr>
- <th>商品ID</th>
- <td><%= f.text_field :product_id %></td>
- <th>規格名称</th>
- <td><%= f.text_field 'style_category_name' %></td>
- </tr>
- <tr>
- <th>商品コード</th>
- <td><%= f.text_field :code %></td>
- <th>商品名</th>
- <td><%= f.text_field 'product_name' %></td>
- </tr>
- <tr>
- <th>カテゴリ</th>
- <td><%= f.category_select 'product_category_id', :include_blank => true %></td>
- <th>種別</th>
- <td>
- <%= f.select :permit, Product.permit_select, :include_blank => '全体' %>
- </td>
- </tr>
- <tr>
- <th>登録・更新日</th>
- <td colspan="3" style="width:580px;">
- <%= f.date_select 'updated_at_from', :use_month_numbers => true, :include_blank => true %>
- ~
- <%= f.date_select 'updated_at_to', :use_month_numbers => true, :include_blank => true %>
- </td>
- </tr>
- </table>
- <p class="submit">
- 検索結果表示件数
- <%= f.select :per_page, (10..100).step(10).map(&:to_s) %>件
- <%= submit_tag "この条件で検索する" %>
- </p>
-<% end %>
-<% if @records %>
- <p>検索結果一覧 <%= @records.total_entries %> 件が該当しました。</p>
- <table class="result" cellspacing="1">
- <tr>
- <th>商品名</th><th>商品コード</th><th>規格名称</th><th>会社名</th><th>登録更新日</th><th>発注予定数</th><th>発注済み数</th><th>受注可能数</th><th>実在庫数</th><th>在庫移動</th>
- </tr>
- <% @records.each do |record| %>
- <tr>
- <td><%=h record.product.name %></td>
- <td><%=h record.code %></td>
- <td>
- <%=h record.style_category_name1 %>
- <%=h record.style_category_name2 %>
- </td>
- <td><%=h record.product.supplier_name %></td>
- <td><%=date record.updated_at %></td>
- <td><%=h record.scheduled_count %></td>
- <td><%=h record.purchased_count %></td>
- <td><%=h record.orderable_count %></td>
- <td><%=h record.actual_count %></td>
- <td><%= link_to '在庫移動', :action=>'new', :id=>record.id %></td>
- </tr>
- <% end %>
-</table>
-<%= will_paginate @records, :params=>{:search => params[:search]} %>
-<% end %>
-
-</div>
-</div>
+++ /dev/null
-<%= stylesheet_link_tag "stock/stock" %>
-
-<%= render :partial => "submenu" %>
-
-<div class="set">
-<div class="contents_area">
-
-<h2>在庫移動</h2>
-
-<h3>商品情報</h3>
-
-<%= error_messages_for :record %>
-<% form_for :record, :url => {:action => 'create' } do |f| %>
- <table class="product_info" cellspacing="1">
- <tr>
- <th>商品ID</th>
- <td><%=h @record.product_id %></td>
- <th>商品コード</th>
- <td><%=h @record.product_code %></td>
- </tr>
- <tr>
- <th>商品名</th>
- <td><%=h @record.product_name %></td>
- <th>登録・更新日</th>
- <td><%= date @record.product_style.updated_at %></td>
- </tr>
- <tr>
- <th>規格名称</th>
- <td>
- <%=h @record.product_style.style_category_name1 %>
- <%=h @record.product_style.style_category_name2 %>
- </td>
- </tr>
- </table>
-
-<h3>移動内容入力</h3>
-
- <table class="move" cellspacing="1">
- <tr>
- <th>移動理由</th>
- <td colspan="3">
- <%= f.collection_select :reason, Constant.list(Constant::MOVEMENT_REASON), :id, :value %>
- </td>
- </tr>
- <tr>
- <th>受注コード</th>
- <td>
- <%= f.text_field :order_code %>
- </td>
- <th>返品コード</th>
- <td>
- <%= f.text_field :recall_code %>
- </td>
- </tr>
- <tr>
- <th>発注コード</th>
- <td colspan="3">
- <%= f.text_field :purchase_code %>
- </td>
- </tr>
- </table>
-
- <p>※調整数には移動させる数量を入力してください。
- 例:実在庫数を1つ減らす場合、「-1」を入力
- </p>
-
- <table cellspacing="1">
- <tr>
- <th>発注予定数</th>
- <td><%=h @record.product_style.scheduled_count %></td>
- <th>発注済数</th>
- <td><%=h @record.product_style.purchased_count %></td>
- <th>受注可能数</th>
- <td><%=h @record.product_style.orderable_count %></td>
- <th>実在庫数</th>
- <td><%=h @record.product_style.actual_count %></td>
- <th>不良在庫数</th>
- <td><%=h @record.product_style.broken_count %></td>
- <!--<th>引当可能数</th>
- <td><%=h @record.product_style.assignable_count %></td>-->
- </tr>
- <tr>
- <th>調整数</th>
- <td><%= f.number_field :scheduled_adjustment, :size=>4 %></td>
- <th>調整数</th>
- <td><%= f.number_field :purchased_adjustment, :size=>4 %></td>
- <th>調整数</th>
- <td><%= f.number_field :orderable_adjustment, :size=>4 %></td>
- <th>調整数</th>
- <td><%= f.number_field :actual_adjustment, :size=>4 %></td>
- <th>調整数</th>
- <td><%= f.number_field :broken_adjustment, :size=>4 %></td>
- <!--<th> </th>
- <td> </td>-->
- </tr>
- </table>
-
- <p>
- コメント
- <%= f.text_area :comment, :cols=>"50", :rows=>"5" %>
- </p>
-
- <p>
- <%= f.hidden_field :product_style_id %>
- <%= submit_tag '反映する' %>
- </p>
-
- <h3>未発送受注一覧</h3>
- <% if @active_orders %>
- <table cellspacing="1">
- <tr>
- <th>受注番号</th>
- <th>ステータス</th>
- <th>個数</th>
- </tr>
- <% @active_orders.each do |ao| %>
- <tr>
- <td>
- <%= link_to ao.order_code, :controller=>'admin/order', :action=>:edit, :id=>ao.order_id %>
- </td>
- <td>
- <%=h ao.status %>
- </td>
- <td>
- <%= number_with_delimiter ao.count %>
- </td>
- </tr>
- <% end %>
- <tr>
- <th colspan="2">合計</th>
- <td><%= number_with_delimiter @active_orders_sum %></td>
- </tr>
- </table>
- <% else %>
- <table cellspacing="1" width="100%"><tr><td>なし</td></tr></table>
- <% end %>
-
-<% end %>
-</div>
-</div>
--- /dev/null
+<%= render :partial => '/admin/base/depot_submenu' %>
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>棚卸用 CSV 出力</h2>\r
+<h3>棚卸データ出力</h3><br/>\r
+<% form_tag :action => 'new' do %>\r
+ <p>現在時刻時点での在庫情報を出力</p>\r
+ <div class="btn_box space20_bottom">\r
+ <%= submit_tag 'CSV DOWNLOAD', :class=>"btn" %>\r
+ <img class="btn_side" width="6" height="34" src="/images/btn_side.gif">\r
+ </div>\r
+<% end %><br/><br/><br/><br/><br/>\r
+\r
+<h3>再出力</h3><br/>\r
+<%unless @dates.blank?%>\r
+<table class="data" cellspacing="1">\r
+ <tr>\r
+ <th>対象年月</th>\r
+ <th>再出力</th>\r
+ </tr>\r
+<% @dates.zip(@urls).each do |date, url| %>\r
+ <tr>\r
+ <td><%= date.strftime('%Y/%m/%d %H:%M:%S') %></td>\r
+ <td><%= link_to 'CSV DOWNLOAD', url %></td>\r
+ </tr>\r
+<% end %>\r
+</table>\r
+<% end %>\r
+</div><!-- /メイン -->
\ No newline at end of file
--- /dev/null
+ <table class="data" cellspacing="1">
+ <tr>
+ <th>商品ID</th>
+ <td><%= f.text_field :product_id, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品コード</th>
+ <td><%= f.text_field :code, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品名</th>
+ <td><%= f.text_field :name, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品型番</th>
+ <td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>操作者</th>
+ <td><%operators = AdminUser.find(:all,:order=>'id')%>
+ <%=f.select :operator,operators.map{|o| [o.name,o.id.to_s]}, :include_blank => true %>
+ </td>
+ </tr>
+ <tr>
+ <th>在庫移動日</th>
+ <td>
+ <%= f.date_select :moved_at_from ,:use_month_numbers => true, :include_blank=>true %>~
+ <%= f.date_select :moved_at_to, :use_month_numbers => true, :include_blank=>true %>
+ </td>
+ </tr>
+ <tr>
+ <td class="submit" colspan="4">
+ 検索結果表示件数
+ <%= select_tag "condition[per_page]", options_for_select((10..100).step(10).map(&:to_s)) %>
+ 件
+ <%= submit_tag "この条件で検索する", :class=>"btn_s" %></td>
+ </tr>
+ </table>
--- /dev/null
+<%= render :partial => '/admin/base/depot_submenu' %>
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>作業履歴</h2>\r
+<%= error_messages_for :condition %>\r
+\r
+<% form_for :condition, :url => {:action => 'search'}, :html => {:method => :get} do |f| %>\r
+ <%= render :partial => "search", :locals=>{:f => f}%>\r
+<% end %>\r
+</div><!-- /メイン -->\r
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>操作履歴</h2>\r
+<%= error_messages_for :condition %>\r
+<% form_for :condition, :url => {:action => 'search'}, :html => {:method => :get} do |f| %>\r
+ <%= render :partial => "search", :locals=>{:f => f}%>\r
+<% end %>\r
+<br />\r
+\r
+<p>>>検索結果一覧 <%=@stock_histories.total_entries %>件 が該当しました。</p><br/>\r
+ <table class="data2 clear" cellspacing="1">\r
+ <tr>\r
+ <th>商品ID</th>\r
+ <th>商品コード</th>\r
+ <th>商品名</th>\r
+ <th>規格名称</th>\r
+ <th>商品型番</th>\r
+ <th>操作者</th>\r
+ <th>詳細</th>\r
+ </tr>\r
+<%unless @stock_histories.blank?%> \r
+ <% @stock_histories.each do | sh | %>\r
+ <tr>\r
+ <td><%= h sh.product_style.product_id %></td>\r
+ <td><%= h sh.product_style.code %></td>\r
+ <td><%= h sh.product_style.product_name %></td>\r
+ <td><%= h sh.product_style.style_name %></td>\r
+ <td><%= h sh.product_style.manufacturer_id %></td>\r
+ <td><%= h sh.admin_user.name %></td>\r
+ <td class="t_center">\r
+ <%= link_to "作業詳細", :action=>"show" ,:id=>sh.id %>\r
+ </td>\r
+ </tr>\r
+ <% end %>\r
+<%end%>\r
+</table>\r
+<%= will_paginate @stock_histories %>\r
+\r
+</div><!-- /メイン -->\r
--- /dev/null
+<%= render :partial => "submenu" %>
+
+<div id="main"><!-- メイン -->
+
+<h2>作業履歴詳細</h2>
+<h3>商品情報</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>商品ID</th>
+ <td>
+ <%= h(@stock_history.product_id) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品名</th>
+ <td>
+ <%= h(@stock_history.product.name) %>
+ </td>
+ </tr>
+ <%if @system.supplier_use_flag%>
+ <tr>
+ <th>仕入先名</th>
+ <td><%= h(@stock_history.product.supplier_name) %></td>
+ </tr>
+ <% end %>
+ <tr>
+ <th>カテゴリー名</th>
+ <td>
+ <%= h(@stock_history.product.category_name) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品コード</th>
+ <td>
+ <%= h(@stock_history.product_style.code) %>
+ </td>
+ </tr>
+ <tr>
+ <th>規格名称</th>
+ <td>
+ <%= h(@stock_history.product_style.style_name) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品型番</th>
+ <td>
+ <%= h(@stock_history.product_style.manufacturer_id) %>
+ </td>
+ </tr>
+ <tr>
+ <th>価格</th>
+ <td>
+ <%= number_with_delimiter(@stock_history.product_style.sell_price) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在実在庫数</th>
+ <td>
+ <%= number_with_delimiter(@stock_history.product_style.actual_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在受注可能数</th>
+ <td>
+ <%= number_with_delimiter(@stock_history.product_style.orderable_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在不良在庫数</th>
+ <td>
+ <%= number_with_delimiter(@stock_history.product_style.broken_count.to_i) %>
+ </td>
+ </tr>
+</table>
+<h3>作業内容</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>操作者</th>
+ <td>
+ <%= @stock_history.admin_user.name %>
+ </td>
+ </tr>
+ <tr>
+ <th>移動日</th>
+ <td>
+ <%= date_time(@stock_history.moved_at) %>
+ </td>
+ </tr>
+ <tr>
+ <th>作業区分</th>
+ <td>
+ <%= h(StockHistory::STOCK_TYPE_NAMES[@stock_history.stock_type]) %>
+ </td>
+ </tr>
+ <% if @stock_history.stock_type == StockHistory::STOCK_IN%>
+ <tr>
+ <th>入庫数</th>
+ <td><%= number_with_delimiter(@stock_history.storaged_count) %></td>
+ </tr>
+ <tr>
+ <th>当時実在庫数</th>
+ <td><%= number_with_delimiter(@stock_history.actual_count.to_i) %></td>
+ </tr>
+ <tr>
+ <th>当時販売可能数</th>
+ <td><%= number_with_delimiter(@stock_history.orderable_count) %></td>
+ </tr>
+ <tr>
+ <th>当時不良在庫数</th>
+ <td><%= number_with_delimiter(@stock_history.broken_count.to_i) %></td>
+ </tr>
+ <% else%>
+ <tr>
+ <th>実在庫調整数</th>
+ <td><%= number_with_delimiter(@stock_history.actual_adjustment) %></td>
+ </tr>
+ <tr>
+ <th>当時実在庫数</th>
+ <td><%= number_with_delimiter(@stock_history.actual_count.to_i) %></td>
+ </tr>
+ <tr>
+ <th>販売可能調整数</th>
+ <td>
+ <%= number_with_delimiter(@stock_history.orderable_adjustment) %>
+ </td>
+ </tr>
+ <tr>
+ <th>当時販売可能数</th>
+ <td><%= number_with_delimiter(@stock_history.orderable_count.to_i) %></td>
+ </tr>
+ <tr>
+ <th>不良在庫調整数</th>
+ <td><%= number_with_delimiter(@stock_history.broken_adjustment) %></td>
+ </tr>
+ <tr>
+ <th>当時不良在庫数</th>
+ <td><%= number_with_delimiter(@stock_history.broken_count.to_i) %></td>
+ </tr>
+ <% end%>
+ <tr>
+ <th>備考</th>
+ <td>
+ <%= h(@stock_history.comment) %>
+ </td>
+ </tr>
+</table>
+</div><!-- /メイン -->
+\r
--- /dev/null
+<h3>入庫情報</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>実入庫数<span class="pnt">※</span></th>
+ <td>
+ <%= f.text_field :storaged_count, {:class=>"data_s",:style=>"ime-mode:inactive"} %>
+ </td>
+ </tr>
+ <tr>
+ <th>備考<span class="pnt">※</span></th>
+ <td>
+ <%= f.text_area :comment,{:size=>"60x10",:style=>"ime-mode:active" }%>
+ </td>
+ </tr>
+</table>
\ No newline at end of file
--- /dev/null
+<!--商品情報-->
+<h3>商品情報</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>商品ID</th>
+ <td>
+ <%= h(@product_style.product_id) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品名</th>
+ <td>
+ <%= h(@product_style.product_name) %>
+ </td>
+ </tr>
+ <%if @system.supplier_use_flag%>
+ <tr>
+ <th>仕入先名</th>
+ <td><%= h(@product_style.product.supplier_name) %></td>
+ </tr>
+ <% end %>
+ <tr>
+ <th>カテゴリー名</th>
+ <td>
+ <%= h(@product_style.product.category_name) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品コード</th>
+ <td>
+ <%= h(@product_style.code) %>
+ </td>
+ </tr>
+ <tr>
+ <th>規格名称</th>
+ <td>
+ <%= h(@product_style.style_name) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品型番</th>
+ <td>
+ <%= h(@product_style.manufacturer_id) %>
+ </td>
+ </tr>
+ <tr>
+ <th>価格</th>
+ <td>
+ <%= number_with_delimiter(@product_style.sell_price) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在実在庫数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.actual_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在受注可能数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.orderable_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在不良在庫数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.broken_count.to_i) %>
+ </td>
+ </tr>
+</table>
--- /dev/null
+ <table class="data" cellspacing="1">
+ <tr>
+ <th>商品ID</th>
+ <td><%= f.text_field :product_id, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品コード</th>
+ <td><%= f.text_field :code, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品名</th>
+ <td><%= f.text_field :name, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品型番</th>
+ <td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
+ </tr>
+ <%if @system.supplier_use_flag%>
+ <tr>
+ <th>仕入先名</th>
+ <td><%suppliers = Supplier.find(:all,:order=>'id')%>
+ <%=f.select :supplier,suppliers.map{|s| [s.name,s.id.to_s]}, :include_blank => true %>
+ </td>
+ </tr>
+ <% end %>
+ <tr>
+ <th>カテゴリ</th>
+ <td><%= category_select :condition, :category, :include_blank => true %></td>
+ </tr>
+ <tr>
+ <th>登録日・更新日</th>
+ <td>
+ <%= f.date_select :updated_at_from ,:use_month_numbers => true, :include_blank=>true %>~
+ <%= f.date_select :updated_at_to, :use_month_numbers => true, :include_blank=>true %>
+ </td>
+ </tr>
+ <tr>
+ <td class="submit" colspan="4">
+ 検索結果表示件数
+ <%= select_tag "condition[per_page]", options_for_select((10..100).step(10).map(&:to_s)) %>
+ 件
+ <%= submit_tag "この条件で検索する", :class=>"btn_s" %></td>
+ </tr>
+ </table>
--- /dev/null
+<%= render :partial => '/admin/base/depot_submenu' %>
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>入庫登録/編集</h2>\r
+<p class="req"><span class="pnt">※</span>は必須入力です</p>\r
+<span class="pnt"><%= flash[:error] %></span>\r
+<%= error_messages_for :stock_history %>\r
+<% form_for :stock_history, :url => {:action => 'update', :id=> @product_style } do |f| %>\r
+ <%= render :partial => "info"%>\r
+ <%= render :partial => "form", :locals => {:f => f} %>\r
+ <div class="btn_box">\r
+ <%= submit_tag "この内容で登録する", :onclick => "return #{confirm_javascript_function("登録しても宜しいですか")}", :class=>"btn" %>\r
+ <img class="btn_side" width="6" height="34" src="/images/btn_side.gif">\r
+ </div>\r
+<% end %>\r
+\r
+</div><!-- /メイン -->
--- /dev/null
+<%= render :partial => "submenu" %>
+
+<div id="main"><!-- メイン -->
+
+<h2>入庫管理</h2>
+<%=h flash[:stock_update] %>
+<%=h flash[:stock_update_e] %>
+<%= error_messages_for :condition %>
+
+<% form_for :condition, :url => {:action => 'search'}, :html => {:method => :get} do |f| %>
+ <%= render :partial => "search", :locals=>{:f => f}%>
+<% end %>
+</div><!-- /メイン -->
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>入庫管理</h2>\r
+<%=h flash[:notice] %>\r
+<%=h flash[:error] %>\r
+<%= error_messages_for :condition %>\r
+<% form_for :condition, :url => {:action => 'search'}, :html => {:method => :get} do |f| %>\r
+ <%= render :partial => "search", :locals=>{:f => f}%>\r
+<% end %>\r
+<br />\r
+\r
+<p>>>検索結果一覧 <%=@product_styles.total_entries %>件 が該当しました。</p><br/>\r
+ <table class="data2 clear" cellspacing="1">\r
+ <tr>\r
+ <th>商品ID</th>\r
+ <th>商品コード</th>\r
+ <th>商品名</th>\r
+ <th>規格名称</th>\r
+ <th>商品型番</th>\r
+ <th>実在庫数</th>\r
+ <th>入庫登録<br/>/編集</th>\r
+ </tr>\r
+<%unless @product_styles.blank?%> \r
+ <% @product_styles.each do | ps | %>\r
+ <tr>\r
+ <td><%= h ps.product_id %></td>\r
+ <td><%= h ps.code %></td>\r
+ <td><%= h ps.product_name %></td>\r
+ <td><%= h ps.style_name %></td>\r
+ <td><%= h ps.manufacturer_id %></td>\r
+ <td><%= number_with_delimiter(ps.actual_count.to_i) %></td>\r
+ <td class="t_center">\r
+ <%= link_to "登録/編集", :action=>"edit" ,:id=>ps.id %>\r
+ </td>\r
+ </tr>\r
+ <% end %>\r
+</table>\r
+<%end%>\r
+<%= will_paginate @product_styles %>\r
+</div><!-- /メイン -->\r
--- /dev/null
+<h3>在庫調整</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>実在庫数</th>
+ <td><%= number_with_delimiter(@product_style.actual_count.to_i) %></td>
+ <th>実在庫調整数</th>
+ <td><%= f.text_field :actual_adjustment, {:class=>"data_s",:style=>"ime-mode:inactive"} %></td>
+ </tr>
+ <tr>
+ <th>販売可能数</th>
+ <td><%= number_with_delimiter(@product_style.orderable_count.to_i) %></td>
+ <th>販売可能調整数</th>
+ <td><%= f.text_field :orderable_adjustment, {:class=>"data_s",:style=>"ime-mode:inactive"} %></td>
+ </tr>
+ <tr>
+ <th>不良在庫数</th>
+ <td><%= number_with_delimiter(@product_style.broken_count.to_i) %></td>
+ <th>不良在庫調整数</th>
+ <td><%= f.text_field :broken_adjustment, {:class=>"data_s",:style=>"ime-mode:inactive"} %></td>
+ </tr>
+ <tr>
+ <th>備考<span class="pnt">※</span></th>
+ <td colspan="3">
+ <%= f.text_area :comment,{:size=>"60x10",:style=>"ime-mode:active" }%>
+ </td>
+ </tr>
+</table>
\ No newline at end of file
--- /dev/null
+<!--商品情報-->
+<h3>商品情報</h3>
+<table class="data" cellspacing="1">
+ <tr>
+ <th>商品ID</th>
+ <td>
+ <%= h(@product_style.product_id) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品名</th>
+ <td>
+ <%= h(@product_style.product_name) %>
+ </td>
+ </tr>
+ <%if @system.supplier_use_flag%>
+ <tr>
+ <th>仕入先名</th>
+ <td><%= h(@product_style.product.supplier_name) %></td>
+ </tr>
+ <% end %>
+ <tr>
+ <th>カテゴリー名</th>
+ <td>
+ <%= h(@product_style.product.category_name) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品コード</th>
+ <td>
+ <%= h(@product_style.code) %>
+ </td>
+ </tr>
+ <tr>
+ <th>規格名称</th>
+ <td>
+ <%= h(@product_style.style_name) %>
+ </td>
+ </tr>
+ <tr>
+ <th>商品型番</th>
+ <td>
+ <%= h(@product_style.manufacturer_id) %>
+ </td>
+ </tr>
+ <tr>
+ <th>価格</th>
+ <td>
+ <%= number_with_delimiter(@product_style.sell_price) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在実在庫数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.actual_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在受注可能数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.orderable_count.to_i) %>
+ </td>
+ </tr>
+ <tr>
+ <th>現在不良在庫数</th>
+ <td>
+ <%= number_with_delimiter(@product_style.broken_count.to_i) %>
+ </td>
+ </tr>
+</table>
--- /dev/null
+ <table class="data" cellspacing="1">
+ <tr>
+ <th>商品ID</th>
+ <td><%= f.text_field :product_id, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品コード</th>
+ <td><%= f.text_field :code, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品名</th>
+ <td><%= f.text_field :name, :class=>"data_m" %></td>
+ </tr>
+ <tr>
+ <th>商品型番</th>
+ <td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
+ </tr>
+ <%if @system.supplier_use_flag%>
+ <tr>
+ <th>仕入先名</th>
+ <td><%suppliers = Supplier.find(:all,:order=>'id')%>
+ <%=f.select :supplier,suppliers.map{|s| [s.name,s.id.to_s]}, :include_blank => true %>
+ </td>
+ </tr>
+ <% end %>
+ <tr>
+ <th>カテゴリ</th>
+ <td><%= category_select :condition, :category, :include_blank => true %></td>
+ </tr>
+ <tr>
+ <th>登録日・更新日</th>
+ <td>
+ <%= f.date_select :updated_at_from ,:use_month_numbers => true, :include_blank=>true %>~
+ <%= f.date_select :updated_at_to, :use_month_numbers => true, :include_blank=>true %>
+ </td>
+ </tr>
+ <tr>
+ <td class="submit" colspan="4">
+ 検索結果表示件数
+ <%= select_tag "condition[per_page]", options_for_select((10..100).step(10).map(&:to_s)) %>
+ 件
+ <%= submit_tag "この条件で検索する", :class=>"btn_s" %></td>
+ </tr>
+ </table>
--- /dev/null
+<%= render :partial => '/admin/base/depot_submenu' %>
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>在庫調整</h2>\r
+<p class="req"><span class="pnt">※</span>は必須入力です</p>\r
+<span class="pnt"><%= flash[:error] %></span>\r
+<%= error_messages_for :stock_history %>\r
+<% form_for :stock_history, :url => {:action => 'update', :id=> @product_style } do |f| %>\r
+ <%= render :partial => "info"%>\r
+ <%= render :partial => "form", :locals => {:f => f} %>\r
+ <div class="btn_box">\r
+ <%= submit_tag "この内容で登録する", :onclick => "return #{confirm_javascript_function("登録しても宜しいですか")}", :class=>"btn" %>\r
+ <img class="btn_side" width="6" height="34" src="/images/btn_side.gif">\r
+ </div>\r
+<% end %>\r
+\r
+</div><!-- /メイン -->
--- /dev/null
+<%= render :partial => "submenu" %>
+
+<div id="main"><!-- メイン -->
+
+<h2>在庫管理</h2>
+<%=h flash[:stock_update] %>
+<%=h flash[:stock_update_e] %>
+<%= error_messages_for :condition %>
+
+<% form_for :condition, :url => {:action => 'search'}, :html => {:method => :get} do |f| %>
+ <%= render :partial => "search", :locals=>{:f => f}%>
+<% end %>
+</div><!-- /メイン -->
--- /dev/null
+<%= render :partial => "submenu" %>\r
+\r
+<div id="main"><!-- メイン -->\r
+\r
+<h2>在庫管理</h2>\r
+<%=h flash[:notice] %>\r
+<%=h flash[:error] %>\r
+<%= error_messages_for :condition %>\r
+<% form_for :condition, :url => {:action => 'search'}, :html => {:method => :get} do |f| %>\r
+ <%= render :partial => "search", :locals=>{:f => f}%>\r
+<% end %>\r
+<br />\r
+\r
+<p>>>検索結果一覧 <%=@product_styles.total_entries %>件 が該当しました。</p><br/>\r
+ <table class="data2 clear" cellspacing="1">\r
+ <tr>\r
+ <th>商品ID</th>\r
+ <th>商品コード</th>\r
+ <th>商品名</th>\r
+ <th>規格名称</th>\r
+ <th>商品型番</th>\r
+ <th>実在庫数</th>\r
+ <th>在庫調整</th>\r
+ </tr>\r
+<%unless @product_styles.blank?%> \r
+ <% @product_styles.each do | ps | %>\r
+ <tr>\r
+ <td><%= h ps.product_id %></td>\r
+ <td><%= h ps.code %></td>\r
+ <td><%= h ps.product_name %></td>\r
+ <td><%= h ps.style_name %></td>\r
+ <td><%= h ps.manufacturer_id %></td>\r
+ <td><%= number_with_delimiter(ps.actual_count.to_i) %></td>\r
+ <td class="t_center">\r
+ <%= link_to "在庫調整", :action=>"edit" ,:id=>ps.id %>\r
+ </td>\r
+ </tr>\r
+ <% end %>\r
+<%end%>\r
+</table>\r
+<%= will_paginate @product_styles %>\r
+\r
+</div><!-- /メイン -->\r
<dd>価格:<%=h @product.price_label %>円</dd>
<dd>販売期間:<%=h print_date(@product.sale_start_at) %> ~ <%=h print_date(@product.sale_end_at) %></dd>
<% if @product.arrival_expected_date && @product.arrival_expected_date < Date.today %>
- <% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| !p_s.actual_count.blank? && p_s.actual_count > 0} -%>
+ <% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| p_s.orderable_count.to_i > 0} -%>
<dd>お届け:<%= @product.delivery_dates_label %></dd>
<% else %>
<dd>入荷未定</dd>
<dd>入荷予定日:<%= @product.arrival_date.blank? ? date_jp(@product.arrival_expected_date) : @product.arrival_date %></dd>
<% end %>
</dl>
+ <% if @campaign.product.have_zaiko? %>
<%= render :partial => "base/add_cart", :locals => {:product => @campaign.product, :campaign_id => @campaign.id} %>
+ <%else%>
+ 品切れ中<br/>
+ <%end%>
<% if @campaign.repeat_application %>
<div id="campaign_caption">
当キャンペーンはお一人様につき1回のみご応募いただくことが出来ます。
<p><%= h_br @product.medium_resource_comment unless @product.medium_resource_comment.blank? %><br />
</p>
+ <% if @campaign.product.have_zaiko? %>
<p style="text-align:center;">
<%= render :partial => "base/add_cart_mobile", :locals => {:product => @campaign.product, :campaign_id => @campaign.id} %>
</p>
+ <%else%>
+ <p>品切れ中<br/></p>
+ <%end%>
<p>
<% if @campaign.repeat_application %>
当キャンペーンはお一人様につき1回のみご応募いただくことが出来ます。<br/>
<% end %>
<hr />
-<%= link_to_mobile 'カゴを見る', {:controller => 'cart', :action => 'show'}, :accesskey => "9" %><br />
-<%= link_to_mobile 'TOPページへ', {:controller=>'/'}, :accesskey => "0" %><br />
-
<% if @system.supplier_use_flag %>
<li><a href="/admin/suppliers" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
<%else%>
- <li><a href="#" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
+ <li><a href="/admin/stock_in" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
<%end%>
<li><a href="/"><img src="/images/site_btn.gif" width="122" height="51" alt="サイトを表示" class="hoverImg" /></a></li>
</ul>
<dt><%=@product.url.blank? ? h( @product.name ) : link_to(@product.name, @product.url) %></dt>
<dd>価格:<%=h @product.price_label %>円</dd>
<dd>販売期間:<%=h print_date(@product.sale_start_at) %> ~ <%=h print_date(@product.sale_end_at) %></dd>
- <% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| !p_s.actual_count.blank? && p_s.actual_count > 0} -%>
+ <% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| p_s.orderable_count.to_i > 0} -%>
<%- unless @product.delivery_dates_label.blank? %>
<dd>お届け:<%= @product.delivery_dates_label %></dd>
<%- end %>
<div style="text-align:center;"><%= product_image_tag(@product, :medium, {:width=>"220",:height=>"220",:style=>"margin:2px; border:1px solid #6666666;"}) %></div>
<%= h_br @product.medium_resource_comment unless @product.medium_resource_comment.blank? %><br />
-<% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| !p_s.actual_count.blank? && p_s.actual_count > 0} -%>
+<% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| p_s.orderable_count.to_i > 0} -%>
お届け:<%= @product.delivery_dates_label %>
<% else %>
<% if @product.arrival_expected_date && @product.arrival_expected_date < Date.today %>
<td><%=h ps.style_category_name2 %></td>\r
<%- end -%>\r
<td><%= number_with_delimiter ps.sell_price.to_i %></td>\r
- <td><%=h stock_mark(ps.actual_count) %></td>\r
+ <td><%=h stock_mark(ps.orderable_count.to_i) %></td>\r
</tr>\r
<%- end -%>\r
</table> \r
session: "セッション"
shop: "ショップ"
status: "地位"
- stock_history: "株式の歴史"
+ stock history: "入庫/在庫情報"
stock_table: "在庫表"
stock_table_entry: "在庫テーブルのエントリ"
style: "規格"
created_at: "で作成された"
updated_at: "で更新"
deleted_at: "で削除"
+ stock_history:
+ storaged_count: "入庫数"
+ orderable_count: "販売可能数"
+ orderable_adjustment: "販売可能調整数"
+ actual_count: "実在庫数"
+ actual_adjustment: "実在庫調整数"
+ broken_count: "不良在庫数"
+ broken_adjustment: "不良在庫調整数"
+ comment: "備考"
stock_table:
target_date: "データ出力日"
created_at: "で作成された"
--- /dev/null
+class AddDataFunctionsVer3 < ActiveRecord::Migration
+ def self.up
+ Function.delete_all
+ Authority.delete_all
+ execute("delete from authorities_functions")
+
+
+ directory = File.join(File.dirname(__FILE__), "fixed_data")
+ Fixtures.create_fixtures(directory, "authorities")
+ Fixtures.create_fixtures(directory, "functions")
+ Fixtures.create_fixtures(directory, "authorities_functions")
+ end
+
+ def self.down
+ Function.delete_all
+ execute("delete from authorities_functions")
+ Authority.delete_all
+ end
+end
--- /dev/null
+class UpdateDataProductStylesOrderableCount < ActiveRecord::Migration
+ def self.up
+ ProductStyle.update_all("orderable_count = actual_count")
+ end
+
+ def self.down
+ ProductStyle.update_all("orderable_count = null")
+ end
+end
--- /dev/null
+class CreateStockHistories < ActiveRecord::Migration
+ def self.up
+ create_table :stock_histories do |t|
+ t.column :admin_user_id ,:integer,:comment =>'登録更新者ID'
+ t.column :product_id , :integer,:comment =>'商品ID'
+ t.column :product_style_id , :integer,:comment =>'商品規格ID'
+ t.column :moved_at ,:datetime, :comment =>'移動日時'
+ t.column :storaged_count ,:integer,:comment =>'入庫数'
+ t.column :orderable_count ,:integer,:comment =>'受注可能数'
+ t.column :orderable_adjustment ,:integer,:comment =>'受注可能数調整数'
+ t.column :actual_count ,:integer,:comment =>'実在庫数'
+ t.column :actual_adjustment ,:integer,:comment =>'実在庫調整数'
+ t.column :broken_count ,:integer,:comment =>'不良在庫数'
+ t.column :broken_adjustment ,:integer,:comment =>'不良在庫調整数'
+ t.column :comment ,:text,:comment =>'移動理由コメント'
+ t.column :stock_type ,:integer,:comment =>'作業区分(0:入庫、1:移動)'
+ t.column :deleted_at ,:datetime, :comment =>'削除日'
+ end
+ add_index :stock_histories, :deleted_at
+ add_index :stock_histories, :product_id
+ add_index :stock_histories, :product_style_id
+ end
+
+ def self.down
+ remove_index :stock_histories, :deleted_at
+ remove_index :stock_histories, :product_id
+ remove_index :stock_histories, :product_style_id
+ drop_table :stock_histories
+ end
+end
1,34\r
1,40\r
1,41\r
+1,42\r
id: 41\r
name: 仕入先マスタ\r
code: "supplier"\r
- position: 901
\ No newline at end of file
+ position: 901\r
+F902:\r
+ id: 42\r
+ name: 在庫管理\r
+ code: "stock"\r
+ position: 902
\ No newline at end of file
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockBaseController do
+ fixtures :admin_users,:products,:product_styles,:suppliers
+ before do
+ session[:admin_user] = admin_users(:admin10)
+ @controller.class.skip_before_filter @controller.class.before_filter
+ @controller.class.skip_after_filter @controller.class.after_filter
+ end
+ describe "GET 'search'" do
+
+ it "should be successful" do
+ get 'search'
+ response.should be_success
+ end
+
+ it "商品ID" do
+ get 'search', :condition => {:product_id => '16'}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 1
+ assigns[:product_styles][0].attributes.should == product_styles(:valid_product).attributes
+ end
+
+ it "商品コード" do
+ get 'search', :condition => {:code => '001'}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 2
+ assigns[:product_styles][0].attributes.should == product_styles(:valid_product).attributes
+ assigns[:product_styles][1].attributes.should == product_styles(:campaign_product).attributes
+ end
+
+ it "商品名" do
+ get 'search', :condition => {:name => "スカート"}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 5
+ assigns[:product_styles][0].attributes.should == product_styles(:campaign_product).attributes
+ assigns[:product_styles][1].attributes.should == product_styles(:sell_stop_product).attributes
+ assigns[:product_styles][2].attributes.should == product_styles(:multi_styles_product_1).attributes
+ assigns[:product_styles][3].attributes.should == product_styles(:multi_styles_product_2).attributes
+ assigns[:product_styles][4].attributes.should == product_styles(:multi_styles_product_3).attributes
+ end
+
+ it "商品型番" do
+ get 'search', :condition => {:manufacturer => "001"}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 0
+ end
+
+ it "仕入先名" do
+ get 'search', :condition => {:supplier => "2"}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 1
+ assigns[:product_styles][0].attributes.should == product_styles(:valid_product).attributes
+ end
+ it "カテゴリ" do
+ get 'search', :condition => {:category => "16"}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 1
+ assigns[:product_styles][0].attributes.should == product_styles(:valid_product).attributes
+ end
+ it "登録日・更新日" do
+ get 'search', :condition => {:updated_at_from => "2009-10-01",:updated_at_to=>"2009-10-01"}
+ response.should be_success
+ # 結果の中に含まれているか見る
+ assigns[:product_styles].size.should == 1
+ assigns[:product_styles][0].attributes.should == product_styles(:valid_product).attributes
+ end
+ end
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockCsvController do
+
+ #Delete this example and add some real ones
+ it "should use Admin::StockCsvController" do
+ controller.should be_an_instance_of(Admin::StockCsvController)
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockHistoriesController do
+
+ #Delete this example and add some real ones
+ it "should use Admin::StockHistoriesController" do
+ controller.should be_an_instance_of(Admin::StockHistoriesController)
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockInController do
+ fixtures :admin_users,:products,:product_styles,:suppliers,:stock_histories
+ before do
+ session[:admin_user] = admin_users(:admin10)
+ @controller.class.skip_before_filter @controller.class.before_filter
+ @controller.class.skip_after_filter @controller.class.after_filter
+ @ps = product_styles(:valid_product)
+ end
+
+ describe "GET 'index'" do
+ it "成功する" do
+ get 'index'
+ response.should be_success
+ end
+ end
+ describe "GET 'edit'" do
+ it "成功するパターン" do
+ get 'edit', :id => @ps.id
+ assigns[:product_style].should_not be_nil
+ assigns[:stock_history].should_not be_nil
+ assigns[:stock_history].stock_type.should == StockHistory::STOCK_IN
+ end
+
+ it "失敗するパターン" do
+ lambda { get 'edit', :id => 1000 }.should raise_error(ActiveRecord::RecordNotFound)
+ assigns[:product_style].should be_nil
+ assigns[:stock_history].should be_nil
+ end
+ end
+ describe "POST 'update'" do
+ it "正常に更新できるパターン" do
+ before = ProductStyle.find_by_id(@ps.id).actual_count.to_i
+ max_id = StockHistory.maximum(:id)
+ sh = StockHistory.new(:storaged_count=>10,:comment=>"テスト")
+ post 'update', :id => @ps.id, :stock_history => sh.attributes
+ flash[:stock_update].should == "データを保存しました"
+ #更新後
+ #商品規格
+ check = ProductStyle.find_by_id(@ps.id).actual_count.to_i
+ check.should == before + 10
+ #操作履歴
+ StockHistory.maximum(:id).should > max_id
+ response.should redirect_to(:action => :index)
+ end
+ #入力チェックエラー
+ #必須項目が未入力
+ it "StockHistoryが不正なパターン" do
+ sh = StockHistory.new(:storaged_count=>10)
+ post 'update', :id => @ps.id, :stock_history => sh.attributes
+ check = ProductStyle.find_by_id(@ps.id).actual_count.to_i
+ check.should == @ps.actual_count
+ response.should_not be_redirect
+ response.should render_template("admin/stock_in/edit.html.erb")
+ end
+ #入力値エラー
+ #例、現実在庫数+入庫数 < 0
+ it "StockHistoryが不正なパターン" do
+ sh = StockHistory.new(:storaged_count=>-10000,:comment=>"テスト")
+ post 'update', :id => @ps.id, :stock_history => sh.attributes
+ check = ProductStyle.find_by_id(@ps.id).actual_count.to_i
+ check.should == @ps.actual_count
+ response.should_not be_redirect
+ response.should render_template("admin/stock_in/edit.html.erb")
+ end
+ end
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockModifyController do
+
+ fixtures :admin_users,:products,:product_styles,:suppliers,:stock_histories
+ before do
+ session[:admin_user] = admin_users(:admin10)
+ @controller.class.skip_before_filter @controller.class.before_filter
+ @controller.class.skip_after_filter @controller.class.after_filter
+ @ps = product_styles(:valid_product)
+ end
+
+ describe "GET 'index'" do
+ it "成功する" do
+ get 'index'
+ response.should be_success
+ end
+ end
+ describe "GET 'edit'" do
+ it "成功するパターン" do
+ get 'edit', :id => @ps.id
+ assigns[:product_style].should_not be_nil
+ assigns[:stock_history].should_not be_nil
+ assigns[:stock_history].stock_type.should == StockHistory::STOCK_MODIFY
+ end
+
+ it "失敗するパターン" do
+ lambda { get 'edit', :id => 1000 }.should raise_error(ActiveRecord::RecordNotFound)
+ assigns[:product_style].should be_nil
+ assigns[:stock_history].should be_nil
+ end
+ end
+ describe "POST 'update'" do
+ it "正常に更新できるパターン" do
+ before = ProductStyle.find_by_id(@ps.id)
+ max_id = StockHistory.maximum(:id)
+ sh = StockHistory.new(:actual_adjustment=>10,:orderable_adjustment=>5,:broken_adjustment=>1,:comment=>"テスト")
+ post 'update', :id => @ps.id, :stock_history => sh.attributes
+ flash[:stock_update].should == "データを保存しました"
+ #更新後
+ #商品規格
+ check = ProductStyle.find_by_id(@ps.id)
+ check.actual_count.should == before.actual_count.to_i + 10
+ check.orderable_count.should == before.orderable_count.to_i + 5
+ check.broken_count.should == before.broken_count.to_i + 1
+ #操作履歴
+ StockHistory.maximum(:id).should > max_id
+ response.should redirect_to(:action => :index)
+ end
+ #入力チェックエラー
+ #必須項目が未入力
+ it "StockHistoryが不正なパターン" do
+ sh = StockHistory.new
+ post 'update', :id => @ps.id, :stock_history => sh.attributes
+ check = ProductStyle.find_by_id(@ps.id)
+ check.attributes.should == @ps.attributes
+ response.should_not be_redirect
+ response.should render_template("admin/stock_modify/edit.html.erb")
+ end
+ #入力値エラー
+ #販売可能数+販可能調整数 < 0 あるいは 実在庫数+実在庫調整数 < 0 あるいは 不良在庫数 + 不良在庫調整数 < 0
+ it "StockHistoryが不正なパターン" do
+ sh = StockHistory.new(:actual_adjustment=>-1000,:orderable_adjustment=>-10,:broken_adjustment=>-1,:comment=>"テスト")
+ post 'update', :id => @ps.id, :stock_history => sh.attributes
+ check = ProductStyle.find_by_id(@ps.id)
+ check.attributes.should == @ps.attributes
+ response.should_not be_redirect
+ response.should render_template("admin/stock_modify/edit.html.erb")
+ end
+ end
+end
end
describe "GET 'search'" do
- before do
- end
-
+
it "should be successful" do
get 'search'
response.should be_success
flash[:error].should be_nil
end
- it "戻るボタン" do
- post 'complete', :cancel => 'zzz'
- response.should render_template('purchase')
- end
+# it "戻るボタン" do
+# post 'complete', :cancel => 'zzz'
+# response.should render_template('purchase')
+# end
it "カート内容が無効(個数超過等)" do
session[:carts] = [carts(:invalid).attributes]
post 'complete', @params
response.should render_template('purchase')
end
-
- it "should not be successful" do
- @params[:order_delivery] = {}
- post 'complete', @params
- response.should render_template('purchase')
- end
+#
+# it "should not be successful" do
+# @params[:order_delivery] = {}
+# post 'complete', @params
+# response.should render_template('purchase')
+# end
it "受注の中身" do
post 'complete', @params
name: cannotincriment
product_id: 5
actual_count: 1
+ orderable_count: 1
sell_price: 200
can_decriment:
style_category_id2: 30
actual_count: 1000
sell_price: 10000
+ orderable_count: 100
+ created_at: 2009-10-01 00:00:00
+ updated_at: 2009-10-01 00:00:00
#未公開商品
not_permit_product:
id: 15
style_category_id1: 60
style_category_id2: 30
actual_count: 1000
+ orderable_count: 100
sell_price: 10000
#販売終了商品
sell_stop_product:
style_category_id1: 60
style_category_id2: 30
actual_count: 1000
- sell_price: 10500
+ sell_price: 10500
+ orderable_count: 900
multi_styles_product_2:
id: 19
product_id: 20
--- /dev/null
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+stock_in:
+ id: 1
+ admin_user_id: 1
+ product_id: 16
+ product_style_id: 14
+ moved_at: '2010-01-01 00:00:00'
+ storaged_count: 100
+ actual_count: 100
+ comment: '入庫'
+ stock_type: 1
+stock_modify:
+ id: 2
+ admin_user_id: 1
+ product_id: 16
+ product_style_id: 14
+ moved_at: '2010-01-15 00:00:00'
+ actual_adjustment: -5
+ actual_count: 100
+ orderable_adjustment: 80
+ orderable_count: 80
+ broken_adjustment: 5
+ broken_count: 5
+ comment: '在庫調整'
+ stock_type: 2
+
+
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockCsvHelper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(Admin::StockCsvHelper)
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockHistoriesHelper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(Admin::StockHistoriesHelper)
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockInHelper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(Admin::StockInHelper)
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe Admin::StockModifyHelper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(Admin::StockModifyHelper)
+ end
+
+end
end
end
describe "その他" do
- it "データ初期化" do
- #実際在庫数
- product_style = ProductStyle.new(:sell_price => 15000)
- product_style.actual_count.should == 0
- product_style = ProductStyle.new(product_styles(:valid_product).attributes)
- product_style.actual_count.should == product_styles(:valid_product).actual_count
- end
+# it "データ初期化" do
+# #実際在庫数
+# product_style = ProductStyle.new(:sell_price => 15000)
+# product_style.actual_count.should == 0
+# product_style = ProductStyle.new(product_styles(:valid_product).attributes)
+# product_style.actual_count.should == product_styles(:valid_product).actual_count
+# end
it "購入可能数を戻る" do
#購入制限あり
- #購入上限 = 5,実際在庫 = 3,購入数 = Parameter
- product_style = ProductStyle.new(:product_id=>products(:limited_in_sep).id,:sell_price => 15000,:actual_count=>3)
+ #購入上限 = 5,実際在庫 = 10,販売可能数 = 3,購入数 = Parameter
+ product_style = ProductStyle.new(:product_id=>products(:limited_in_sep).id,:sell_price => 15000,:actual_count=>10,:orderable_count=>3)
- #ケース1: 実際在庫 < 購入上限 < 購入数 の場合、実際在庫数を戻る
- product_style.available?(10).should == product_style.actual_count
- #ケース2:購入上限 < 実際在庫 < 購入数 の場合、購入制限数を戻る
- product_style.actual_count = 6
+ #ケース1: 販売可能数 < 購入上限 < 購入数 の場合、実際在庫数を戻る
+ product_style.available?(10).should == product_style.orderable_count
+ #ケース2:購入上限 < 販売可能数 < 購入数 の場合、購入制限数を戻る
+ product_style.orderable_count = 6
product_style.available?(10).should == product_style.product.sell_limit
- #ケース3:購入数< 購入上限 < 実際在庫の場合、購入数を戻る
+ #ケース3:購入数< 購入上限 < 販売可能数の場合、購入数を戻る
product_style.available?(2).should == 2
- #ケース4:購入数< 実際在庫 < 購入上限 の場合、購入数を戻る
- product_style.actual_count = 3
+ #ケース4:購入数< 販売可能数 < 購入上限 の場合、購入数を戻る
+ product_style.orderable_count = 3
product_style.available?(2).should == 2
product_style.available?(3).should == 3
#購入制限なし
#テストデータの在庫数:1000
- #ケース1:購入数< 実際在庫数
- @product_style.available?(@product_style.actual_count-1).should == @product_style.actual_count-1
- #ケース2購入数 > 実際在庫数
- @product_style.available?(@product_style.actual_count+1).should == @product_style.actual_count
- @product_style.available?(@product_style.actual_count).should == @product_style.actual_count
+ #ケース1:購入数< 販売可能数
+ @product_style.available?(@product_style.orderable_count-1).should == @product_style.orderable_count-1
+ #ケース2購入数 > 販売可能数
+ @product_style.available?(@product_style.orderable_count+1).should == @product_style.orderable_count
+ @product_style.available?(@product_style.orderable_count).should == @product_style.orderable_count
+
+ #販売可能数がnilの時、「0」として
+ #ケース1:購入制限あり
+ p_s1 = ProductStyle.new(:product_id=>products(:limited_in_sep).id,:sell_price => 15000,:actual_count=>10)
+ p_s1.available?(1).should == 0
+ #ケース2:購入制限なし
+ p_s2 = ProductStyle.new(:product_id=>@product_style.id,:sell_price => 15000,:actual_count=>10)
+ p_s2.available?(1).should == 0
end
it "受注により在庫数が変わる" do
- #在庫数1000
+ #在庫数1000、販売可能数100
+ #購入後、在庫数と販売可能数とも引く
cnt_b = @product_style.actual_count
+ orderable_cnt_b = @product_style.orderable_count
@product_style.order(2)
@product_style.actual_count.should == cnt_b-2
+ @product_style.orderable_count.should == orderable_cnt_b - 2
#在庫数0
product_style = product_styles(:multi_styles_product_3)
#例外が発生する箇所を、lambdaでくくる必要がある
lambda{
product_style.order(1)
- }.should raise_error(RuntimeError,"å®\9få\9c¨å\80\8bæ\95°ã\81\8c0ã\81§ã\81\99")
+ }.should raise_error(RuntimeError,"å\9c¨åº«ä¸\8d足ã\81§ã\81\99ã\80\82")
end
end
end
--- /dev/null
+require 'spec_helper'
+
+describe StockHistory do
+ fixtures :stock_histories
+ before(:each) do
+ @sh = stock_histories(:stock_in)
+ end
+
+ describe "validateチェック" do
+ it "should be_valid" do
+ @sh.should be_valid
+ end
+ it "備考" do
+ @sh.comment = nil
+ @sh.should_not be_valid
+ #文字数(1000以下)
+ @sh.comment = "a" * 10000
+ @sh.should be_valid
+ @sh.comment = "a" * 10001
+ @sh.should_not be_valid
+ end
+ it "入庫数" do
+ #入庫の場合、入庫数必須
+ sh_in = StockHistory.new(:comment=>"test",:stock_type=>1)
+ sh_in.should have(1).errors_on(:storaged_count)
+ #在庫調整の場合、入庫調整数、販売調整数、不良調整数は非必須
+ sh_m = StockHistory.new(:comment=>"test",:stock_type=>2)
+ sh_m.should be_valid
+ end
+ end
+ describe "その他" do
+ it "入庫かどうか" do
+ sh_in = StockHistory.new(:comment=>"test",:stock_type=>1)
+ sh_in.stock_in?.should be_true
+ sh_m = StockHistory.new(:comment=>"test",:stock_type=>2)
+ sh_m.stock_in?.should be_false
+ sh = StockHistory.new
+ sh.stock_in?.should be_false
+ end
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe StockSearchForm do
+ before(:each) do
+ @search_form = StockSearchForm.new
+ end
+ describe "validateチェック" do
+ it "データがただしい" do
+ @search_form.should be_valid
+ end
+ it "商品ID" do
+ #数字
+ @search_form.product_id = 123456
+ @search_form.should be_valid
+ @search_form.product_id = "abc"
+ @search_form.should_not be_valid
+ end
+ it "商品コード" do
+ #英数字
+ @search_form.code = "abc"
+ @search_form.should be_valid
+ @search_form.code = "あああ"
+ @search_form.should_not be_valid
+ end
+ it "型番" do
+ #英数字
+ @search_form.manufacturer = "abc"
+ @search_form.should be_valid
+ @search_form.manufacturer = "123$%&"
+ @search_form.should_not be_valid
+ end
+ end
+end