Introduced StockTaking. TODO: Dry up the stockit/stock_takings/deliveries controllers/views!
This commit is contained in:
parent
2bb4cdb9d6
commit
951d19db6a
30 changed files with 436 additions and 55 deletions
|
@ -82,10 +82,10 @@ class DeliveriesController < ApplicationController
|
|||
page.insert_html :top, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => article.stock_changes.build}
|
||||
|
||||
page.replace_html 'new_stock_article', :partial => 'new_stock_article',
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => @supplier.stock_articles.build}
|
||||
else
|
||||
page.replace_html 'new_stock_article', :partial => 'new_stock_article',
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => article}
|
||||
end
|
||||
end
|
||||
|
@ -100,13 +100,6 @@ class DeliveriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def auto_complete_for_article_name
|
||||
@articles = @supplier.articles.without_deleted.find(:all,
|
||||
:conditions => [ "LOWER(articles.name) LIKE ?", '%' + params[:article][:name].downcase + '%' ],
|
||||
:limit => 8)
|
||||
render :partial => 'shared/auto_complete_articles'
|
||||
end
|
||||
|
||||
def fill_new_stock_article_form
|
||||
article = Article.find(params[:article_id])
|
||||
@supplier = article.supplier
|
||||
|
@ -114,7 +107,7 @@ class DeliveriesController < ApplicationController
|
|||
article.attributes.reject { |attr| attr == ('id' || 'type')}
|
||||
)
|
||||
|
||||
render :partial => 'new_stock_article', :locals => {:stock_article => stock_article}
|
||||
render :partial => 'stock_article_form', :locals => {:stock_article => stock_article}
|
||||
end
|
||||
|
||||
def in_place_edit_for_stock_quantity
|
||||
|
|
112
app/controllers/stock_takings_controller.rb
Normal file
112
app/controllers/stock_takings_controller.rb
Normal file
|
@ -0,0 +1,112 @@
|
|||
class StockTakingsController < ApplicationController
|
||||
|
||||
def index
|
||||
@stock_takings = StockTaking.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @stock_takings }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @stock_taking }
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@stock_taking = StockTaking.new
|
||||
StockArticle.without_deleted.each { |a| @stock_taking.stock_changes.build(:stock_article => a) }
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @stock_taking }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@stock_taking = StockTaking.new(params[:stock_taking])
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_taking.save
|
||||
flash[:notice] = 'StockTaking was successfully created.'
|
||||
format.html { redirect_to(@stock_taking) }
|
||||
format.xml { render :xml => @stock_taking, :status => :created, :location => @stock_taking }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @stock_taking.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_taking.update_attributes(params[:stock_taking])
|
||||
flash[:notice] = 'StockTaking was successfully updated.'
|
||||
format.html { redirect_to(@stock_taking) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @stock_taking.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
@stock_taking.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(stock_takings_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
def fill_new_stock_article_form
|
||||
article = Article.find(params[:article_id])
|
||||
supplier = article.supplier
|
||||
stock_article = supplier.stock_articles.build(
|
||||
article.attributes.reject { |attr| attr == ('id' || 'type')}
|
||||
)
|
||||
|
||||
render :partial => 'stock_article_form', :locals => {:stock_article => stock_article}
|
||||
end
|
||||
|
||||
def add_stock_article
|
||||
article = StockArticle.new(params[:stock_article])
|
||||
render :update do |page|
|
||||
if article.save
|
||||
page.insert_html :top, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => article.stock_changes.build}
|
||||
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => StockArticle.new}
|
||||
else
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => article}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def drop_stock_change
|
||||
stock_change = StockChange.find(params[:stock_change_id])
|
||||
stock_change.destroy
|
||||
|
||||
render :update do |page|
|
||||
page.visual_effect :DropOut, "stock_change_#{stock_change.id}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -8,16 +8,13 @@ class StockitController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@supplier = Supplier.find(params[:supplier_id])
|
||||
@stock_article = @supplier.stock_articles.build(:tax => 7.0)
|
||||
rescue
|
||||
flash[:error] = "Es wurde kein gültiger Lieferant ausgewählt."
|
||||
redirect_to stock_articles_path
|
||||
@stock_article = StockArticle.new
|
||||
end
|
||||
|
||||
def create
|
||||
@stock_article = StockArticle.new(params[:stock_article])
|
||||
if @stock_article.save
|
||||
flash[:notice] = "Lagerartikel wurde gespeichert."
|
||||
redirect_to stock_articles_path
|
||||
else
|
||||
render :action => 'new'
|
||||
|
@ -31,6 +28,7 @@ class StockitController < ApplicationController
|
|||
def update
|
||||
@stock_article = StockArticle.find(params[:id])
|
||||
if @stock_article.update_attributes(params[:stock_article])
|
||||
flash[:notice] = "Lagerartikel wurde gespeichert."
|
||||
redirect_to stock_articles_path
|
||||
else
|
||||
render :action => 'edit'
|
||||
|
@ -46,10 +44,14 @@ class StockitController < ApplicationController
|
|||
end
|
||||
|
||||
def auto_complete_for_article_name
|
||||
conditions = [ "LOWER(articles.name) LIKE ?", '%' + params[:article][:name].downcase + '%' ]
|
||||
|
||||
if params[:supplier_id]
|
||||
@supplier = Supplier.find(params[:supplier_id])
|
||||
@articles = @supplier.articles.without_deleted.find(:all,
|
||||
:conditions => [ "LOWER(articles.name) LIKE ?", '%' + params[:article][:name].downcase + '%' ],
|
||||
:limit => 8)
|
||||
@articles = @supplier.articles.without_deleted.all(:conditions => conditions, :limit => 8)
|
||||
else
|
||||
@articles = Article.without_deleted.not_in_stock.all(:conditions => conditions, :limit => 8)
|
||||
end
|
||||
render :partial => 'shared/auto_complete_articles'
|
||||
end
|
||||
|
||||
|
|
2
app/helpers/stock_takings_helper.rb
Normal file
2
app/helpers/stock_takings_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module StockTakingsHelper
|
||||
end
|
|
@ -35,6 +35,7 @@ class Article < ActiveRecord::Base
|
|||
has_many :article_prices, :order => "created_at"
|
||||
|
||||
named_scope :available, :conditions => {:availability => true}
|
||||
named_scope :not_in_stock, :conditions => {:type => nil}
|
||||
|
||||
# Validations
|
||||
validates_presence_of :name, :unit, :price, :tax, :deposit, :unit_quantity, :supplier_id, :article_category_id
|
||||
|
|
|
@ -30,6 +30,8 @@ class StockArticle < Article
|
|||
|
||||
named_scope :available, :conditions => "quantity > 0"
|
||||
|
||||
before_destroy :check_quantity
|
||||
|
||||
# Update the quantity of items in stock
|
||||
def update_quantity!
|
||||
update_attribute :quantity, stock_changes.collect(&:quantity).sum
|
||||
|
@ -46,4 +48,10 @@ class StockArticle < Article
|
|||
end
|
||||
available
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def check_quantity
|
||||
raise "#{name} kann nicht gelöscht werden. Der Lagerbestand ist nicht null." unless quantity == 0
|
||||
end
|
||||
end
|
||||
|
|
13
app/models/stock_taking.rb
Normal file
13
app/models/stock_taking.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class StockTaking < ActiveRecord::Base
|
||||
|
||||
has_many :stock_changes, :dependent => :destroy
|
||||
has_many :stock_articles, :through => :stock_changes
|
||||
|
||||
validates_presence_of :date
|
||||
|
||||
def stock_change_attributes=(stock_change_attributes)
|
||||
for attributes in stock_change_attributes
|
||||
stock_changes.build(attributes) unless attributes[:quantity].to_i == 0
|
||||
end
|
||||
end
|
||||
end
|
|
@ -43,7 +43,11 @@
|
|||
</div>
|
||||
<div class="box_title"><h2>Gruppenabos</h2></div>
|
||||
<div class="column_content">
|
||||
<%= render :partial => 'shared/user_memberships'%>
|
||||
<% for membership in Membership.find_all_by_user_id(@user.id) -%>
|
||||
<p>
|
||||
<%= link_to(membership.group.name, [:admin, membership.group]) %>
|
||||
</p>
|
||||
<% end -%>
|
||||
<p><%= link_to 'Gruppenübersicht', :action => 'listGroups' %></p>
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,6 @@
|
|||
- remote_form_for stock_article, :url => add_stock_article_supplier_deliveries_path(@supplier) do |form|
|
||||
= form.error_messages
|
||||
= form.hidden_field :supplier_id
|
||||
|
||||
%p
|
||||
= form.label :name
|
||||
|
@ -29,4 +30,4 @@
|
|||
Kategorie:
|
||||
= form.select :article_category_id, ArticleCategory.all(:order => 'name').collect { |c| [c.name, c.id] }
|
||||
%p
|
||||
= submit_tag "Artikel speichern"
|
||||
= submit_tag "Lagerartikel speichern"
|
|
@ -6,4 +6,3 @@
|
|||
- article = stock_change.stock_article
|
||||
%b= article.name
|
||||
= "(#{number_to_currency(article.price)} / #{article.unit})"
|
||||
//= link_to_function "Löschen", "$(this).up('p').remove()"
|
|
@ -23,18 +23,20 @@
|
|||
%p
|
||||
:javascript
|
||||
function fillNewStockArticle(text, li) {
|
||||
new Ajax.Updater('new_stock_article', '/deliveries/fill_new_stock_article_form', {
|
||||
new Ajax.Updater('stock_article_form', '/deliveries/fill_new_stock_article_form', {
|
||||
method: 'get',
|
||||
parameters: {article_id: li.id}
|
||||
});
|
||||
}
|
||||
Suche nach Artikeln aus dem Katalog:
|
||||
Suche nach Artikeln aus dem
|
||||
%i= @supplier.name
|
||||
Katalog:
|
||||
= text_field_with_auto_complete :article, :name, {}, |
|
||||
{:url => {:action => 'auto_complete_for_article_name', :supplier_id => @supplier.id}, |
|
||||
:after_update_element => 'fillNewStockArticle'} |
|
||||
{:url => {:controller => 'stockit', :action => 'auto_complete_for_article_name', :supplier_id => @supplier.id}, |
|
||||
:after_update_element => 'fillNewStockArticle', :method => :get} |
|
||||
%hr/
|
||||
#new_stock_article
|
||||
= render :partial => 'new_stock_article', :locals => {:stock_article => @supplier.stock_articles.build}
|
||||
#stock_article_form
|
||||
= render :partial => 'stock_article_form', :locals => {:stock_article => @supplier.stock_articles.build}
|
||||
|
||||
%p{:style => "clear:both"}
|
||||
= link_to 'Zurück', supplier_deliveries_path(@supplier)
|
|
@ -25,7 +25,7 @@
|
|||
]
|
||||
},
|
||||
{ :name => "Artikel", :url => "/suppliers",
|
||||
:active => ["articles", "suppliers", "deliveries", "article_categories", "stockit"],
|
||||
:active => ["articles", "suppliers", "deliveries", "article_categories", "stockit", "stock_takings"],
|
||||
:access_denied? => (!u.role_article_meta? && !u.role_suppliers?),
|
||||
:subnav => [
|
||||
{ :name => "Artikel", :url => supplier_articles_path(Supplier.first) },
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
%p
|
||||
%b Neuen Kommentar hinzufügen:
|
||||
%br/
|
||||
= form.text_area :comment, :cols => 50, :rows => 6
|
||||
= form.text_area :text, :cols => 50, :rows => 6
|
||||
%br/
|
||||
= submit_tag "Kommentar hinzufügen"
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
%ul.autocomplete
|
||||
- for article in @articles
|
||||
%li{:id => article.id.to_s}= "#{article.name} (#{article.unit_quantity} * #{article.unit} | #{number_to_currency(article.price)})"
|
||||
- supplier = @supplier ? "" : " - #{truncate(article.supplier.name)}"
|
||||
%li{:id => article.id.to_s}= "#{article.name} (#{article.unit_quantity} * #{article.unit} | #{number_to_currency(article.price)}#{supplier})"
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<% for membership in Membership.find_all_by_user_id(@user.id) %>
|
||||
<p>
|
||||
<%= link_to(membership.group.name, :action => 'showGroup', :id => membership.group) %>
|
||||
</p>
|
||||
<% end %>
|
35
app/views/stock_takings/_stock_article_form.html.haml
Normal file
35
app/views/stock_takings/_stock_article_form.html.haml
Normal file
|
@ -0,0 +1,35 @@
|
|||
- remote_form_for stock_article, :url => add_stock_article_stock_takings_path do |form|
|
||||
= form.error_messages
|
||||
%p
|
||||
Lieferant
|
||||
%br/
|
||||
= form.select :supplier_id, Supplier.without_deleted(:order => 'name').collect{ |s| [s.name, s.id] }
|
||||
%p
|
||||
Name
|
||||
%br/
|
||||
= form.text_field :name
|
||||
%p
|
||||
Einheit
|
||||
%br/
|
||||
= form.text_field :unit
|
||||
%p
|
||||
Notiz
|
||||
%br/
|
||||
= form.text_field :note
|
||||
%p
|
||||
Nettopreis
|
||||
%br/
|
||||
= form.text_field :price
|
||||
%p
|
||||
MwSt
|
||||
%br/
|
||||
= form.text_field :tax, :value => (stock_article.tax || 7.0)
|
||||
%p
|
||||
Pfand
|
||||
%br/
|
||||
= form.text_field :deposit
|
||||
%p
|
||||
Kategorie:
|
||||
= form.select :article_category_id, ArticleCategory.all(:order => 'name').collect { |c| [c.name, c.id] }
|
||||
%p
|
||||
= submit_tag "Lagerartikel hinzufügen"
|
9
app/views/stock_takings/_stock_change.html.haml
Normal file
9
app/views/stock_takings/_stock_change.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
%p
|
||||
- fields_for "stock_taking[stock_change_attributes][]", stock_change do |form|
|
||||
- article = stock_change.stock_article
|
||||
|
||||
= form.hidden_field :stock_article_id
|
||||
= "Menge (#{article.quantity_available})"
|
||||
= form.text_field :quantity, :size => 5, :autocomplete => 'off'
|
||||
%b=h truncate(article.name)
|
||||
= "(#{number_to_currency(article.price)} / #{article.unit})"
|
16
app/views/stock_takings/edit.html.haml
Normal file
16
app/views/stock_takings/edit.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
|||
- title "Inventur bearbeiten"
|
||||
|
||||
- form_for(@stock_taking) do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
%b Datum
|
||||
%br/
|
||||
= f.date_select :date
|
||||
%p
|
||||
%b Notiz
|
||||
%br/
|
||||
= f.text_area :note, :size => "28x7"
|
||||
%p
|
||||
= f.submit "Invenur speichern"
|
||||
|
|
||||
= link_to "Abbrechen", stock_takings_path
|
25
app/views/stock_takings/index.html.haml
Normal file
25
app/views/stock_takings/index.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
|||
- title "Inventurübersicht"
|
||||
|
||||
%p
|
||||
= link_to "Neue Iniventur anlegen", new_stock_taking_path
|
||||
|
|
||||
= link_to "Lager", stock_articles_path
|
||||
|
||||
%table.list{:style => "width:50em"}
|
||||
%thead
|
||||
%tr
|
||||
%th Datum
|
||||
%th Notiz
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
%tbody
|
||||
- for stock_taking in @stock_takings
|
||||
%tr
|
||||
%td= link_to format_date(stock_taking.date), stock_taking
|
||||
%td=h truncate stock_taking.note
|
||||
%td= link_to 'Anzeigen', stock_taking
|
||||
%td= link_to 'Bearbeiten', edit_stock_taking_path(stock_taking)
|
||||
%td= link_to 'Löschen', stock_taking, :confirm => 'Are you sure?', :method => :delete
|
||||
|
||||
|
48
app/views/stock_takings/new.html.haml
Normal file
48
app/views/stock_takings/new.html.haml
Normal file
|
@ -0,0 +1,48 @@
|
|||
- title "Neue Inventur anlegen"
|
||||
|
||||
.left_column{:style => "width:40em;"}
|
||||
- form_for(@stock_taking) do |f|
|
||||
.box_title
|
||||
%h2 Lieferung anlegen
|
||||
.column_content
|
||||
= f.error_messages
|
||||
%p
|
||||
%b Datum
|
||||
%br/
|
||||
= f.date_select :date
|
||||
%p
|
||||
%b Notiz
|
||||
%br/
|
||||
= f.text_area :note, :size => "28x7", :value => "#{@current_user.nick}: ..."
|
||||
%h2 Lagerartikel
|
||||
%p
|
||||
%i
|
||||
Bitte trage hier alle gezählten Abweichungen vom
|
||||
= link_to "vorläufigen Lagerbestand", stock_articles_path
|
||||
ein. Bei Schwund benutze einfach ein Minus vor der Zahl.
|
||||
#stock_changes
|
||||
= render :partial => 'stock_change', :collection => @stock_taking.stock_changes
|
||||
%p
|
||||
= f.submit "Invenur anlegen"
|
||||
|
|
||||
= link_to "Abbrechen", stock_takings_path
|
||||
|
||||
.right_column{:style => "width:30em;"}
|
||||
.box_title
|
||||
%h2 Neuen Lagerartikel anlegen
|
||||
.column_content
|
||||
%p
|
||||
:javascript
|
||||
function fillNewStockArticle(text, li) {
|
||||
new Ajax.Updater('stock_article_form', '/stock_takings/fill_new_stock_article_form', {
|
||||
method: 'get',
|
||||
parameters: {article_id: li.id}
|
||||
});
|
||||
}
|
||||
Suche nach Artikeln aus dem allen Katalogen:
|
||||
= text_field_with_auto_complete :article, :name, {}, |
|
||||
{:url => {:controller => 'stockit', :action => 'auto_complete_for_article_name' }, |
|
||||
:after_update_element => 'fillNewStockArticle', :method => :get} |
|
||||
%hr/
|
||||
#stock_article_form
|
||||
= render :partial => 'stock_article_form', :locals => {:stock_article => StockArticle.new}
|
29
app/views/stock_takings/show.html.haml
Normal file
29
app/views/stock_takings/show.html.haml
Normal file
|
@ -0,0 +1,29 @@
|
|||
- title "Inventur anzeigen"
|
||||
|
||||
%p
|
||||
Datum:
|
||||
= format_date @stock_taking.date
|
||||
%p
|
||||
Notiz:
|
||||
= simple_format @stock_taking.note
|
||||
|
||||
%h2 Artikel
|
||||
%table.list{:style => "width:30em"}
|
||||
%tr
|
||||
%th Artikel
|
||||
%th Lieferant
|
||||
%th Einheit
|
||||
%th Menge
|
||||
- for stock_change in @stock_taking.stock_changes.all :include => :stock_article
|
||||
%tr
|
||||
%td= stock_change.stock_article.name
|
||||
%td= stock_change.stock_article.supplier.name
|
||||
%td= stock_change.stock_article.unit
|
||||
%td= stock_change.quantity
|
||||
|
||||
%br/
|
||||
= link_to "Bearbeiten", edit_stock_taking_path(@stock_taking)
|
||||
|
|
||||
= link_to "Inventurübersicht", stock_takings_path
|
||||
|
|
||||
= link_to "Löschen", @stock_taking, :method => :delete, :confirm => "Willst Du wirklich die Inventur löschen?"
|
|
@ -1,6 +1,9 @@
|
|||
- form_for stock_article do |form|
|
||||
= form.error_messages
|
||||
= form.hidden_field :supplier_id
|
||||
%p
|
||||
Lieferant
|
||||
%br/
|
||||
= form.select :supplier_id, Supplier.without_deleted(:order => 'name').collect{ |s| [s.name, s.id] }
|
||||
%p
|
||||
Name
|
||||
%br/
|
||||
|
|
|
@ -13,14 +13,11 @@
|
|||
.box_title
|
||||
.column_content
|
||||
#actions
|
||||
%b Neuen Lagerartikel anlegen für
|
||||
= select_tag :new_stock_article, |
|
||||
options_for_select([[" -- Lieferantin wählen --", ""]] + |
|
||||
Supplier.without_deleted.collect {|s| [ s.name, url_for(new_stock_article_path(:supplier_id => s))] }), |
|
||||
:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" |
|
||||
|
||||
%b= link_to "Neuen Lagerartikel anlegen", new_stock_article_path
|
||||
|
|
||||
= link_to_if @current_user.role_orders?, "Lagerbestellung online stellen", {:controller => 'orders', :action => 'new', :supplier_id => 0}
|
||||
|
|
||||
= link_to "Inventur anlegen", new_stock_taking_path
|
||||
|
||||
#articles{:style => "clear:both;margin-top:1em"}
|
||||
%table.list
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- title "Neuen Lagerartikel für #{@supplier.name} anlegen"
|
||||
- title "Neuen Lagerartikel anlegen"
|
||||
|
||||
:javascript
|
||||
function fillNewStockArticle(text, li) {
|
||||
|
@ -8,9 +8,9 @@
|
|||
}
|
||||
|
||||
%p
|
||||
Suche nach Artikeln aus dem Katalog:
|
||||
Suche nach Artikeln aus allen Katalogen:
|
||||
= text_field_with_auto_complete :article, :name, {}, |
|
||||
{:url => {:action => 'auto_complete_for_article_name', :supplier_id => @supplier.id}, |
|
||||
{:url => {:action => 'auto_complete_for_article_name'}, |
|
||||
:after_update_element => 'fillNewStockArticle'} |
|
||||
#stock_article_form
|
||||
= render :partial => 'form', :locals => {:stock_article => @stock_article}
|
|
@ -20,10 +20,16 @@ ActionController::Routing::Routes.draw do |map|
|
|||
finance.resources :invoices
|
||||
end
|
||||
|
||||
map.resources :stock_articles, :controller => 'stockit', :as => 'stockit'
|
||||
map.resources :stock_takings,
|
||||
:collection => {:fill_new_stock_article_form => :get, :add_stock_article => :post}
|
||||
map.resources :stock_articles,
|
||||
:controller => 'stockit', :as => 'stockit',
|
||||
:collection => {:auto_complete_for_article_name => :get, :fill_new_stock_article_form => :get}
|
||||
|
||||
map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers|
|
||||
suppliers.resources :deliveries, :member => { :drop_stock_change => :post },
|
||||
map.resources :suppliers,
|
||||
:collection => { :shared_suppliers => :get } do |suppliers|
|
||||
suppliers.resources :deliveries,
|
||||
:member => { :drop_stock_change => :post },
|
||||
:collection => {:add_stock_article => :post}
|
||||
suppliers.resources :articles,
|
||||
:collection => { :update_selected => :post, :edit_all => :get, :update_all => :post,
|
||||
|
|
|
@ -144,10 +144,17 @@ class RoadToVersionThree < ActiveRecord::Migration
|
|||
# t.datetime :created_at
|
||||
# end
|
||||
|
||||
# == User
|
||||
# Ativate all Users for notification on upcoming tasks
|
||||
User.all.each { |u| u.settings['notify.upcoming_tasks'] = 1 }
|
||||
# == StockTaking
|
||||
create_table :stock_takings do |t|
|
||||
t.date :date
|
||||
t.text :note
|
||||
t.datetime :created_at
|
||||
end
|
||||
add_column :stock_changes, :stock_taking_id, :integer
|
||||
|
||||
# # == User
|
||||
# # Ativate all Users for notification on upcoming tasks
|
||||
# User.all.each { |u| u.settings['notify.upcoming_tasks'] = 1 }
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20090120184410) do
|
||||
ActiveRecord::Schema.define(:version => 20090119155930) do
|
||||
|
||||
create_table "article_categories", :force => true do |t|
|
||||
t.string "name", :default => "", :null => false
|
||||
|
@ -218,6 +218,13 @@ ActiveRecord::Schema.define(:version => 20090120184410) do
|
|||
t.datetime "created_at"
|
||||
end
|
||||
|
||||
create_table "stock_takings", :force => true do |t|
|
||||
t.date "date"
|
||||
t.text "note"
|
||||
t.integer "created_by"
|
||||
t.datetime "created_at"
|
||||
end
|
||||
|
||||
create_table "suppliers", :force => true do |t|
|
||||
t.string "name", :default => "", :null => false
|
||||
t.string "address", :default => "", :null => false
|
||||
|
|
13
test/fixtures/stock_takings.yml
vendored
Normal file
13
test/fixtures/stock_takings.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
date: 2009-02-12
|
||||
note: MyText
|
||||
created_by: 1
|
||||
created_at: 2009-02-12 14:53:06
|
||||
|
||||
two:
|
||||
date: 2009-02-12
|
||||
note: MyText
|
||||
created_by: 1
|
||||
created_at: 2009-02-12 14:53:06
|
45
test/functional/stock_takings_controller_test.rb
Normal file
45
test/functional/stock_takings_controller_test.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
require 'test_helper'
|
||||
|
||||
class StockTakingsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:stock_takings)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create stock_taking" do
|
||||
assert_difference('StockTaking.count') do
|
||||
post :create, :stock_taking => { }
|
||||
end
|
||||
|
||||
assert_redirected_to stock_taking_path(assigns(:stock_taking))
|
||||
end
|
||||
|
||||
test "should show stock_taking" do
|
||||
get :show, :id => stock_takings(:one).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, :id => stock_takings(:one).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update stock_taking" do
|
||||
put :update, :id => stock_takings(:one).id, :stock_taking => { }
|
||||
assert_redirected_to stock_taking_path(assigns(:stock_taking))
|
||||
end
|
||||
|
||||
test "should destroy stock_taking" do
|
||||
assert_difference('StockTaking.count', -1) do
|
||||
delete :destroy, :id => stock_takings(:one).id
|
||||
end
|
||||
|
||||
assert_redirected_to stock_takings_path
|
||||
end
|
||||
end
|
8
test/unit/stock_taking_test.rb
Normal file
8
test/unit/stock_taking_test.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class StockTakingTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue