Improved stockit: Creating/updating of stock_articles.\nTranslated deliveries and invoices.

This commit is contained in:
Benjamin Meichsner 2009-02-11 18:09:04 +01:00
parent 325d47b22f
commit 86b2b28dc9
19 changed files with 248 additions and 86 deletions

View file

@ -119,7 +119,7 @@ class DeliveriesController < ApplicationController
def in_place_edit_for_stock_quantity def in_place_edit_for_stock_quantity
stock_change = StockChange.find(params[:editorId]) stock_change = StockChange.find(params[:editorId])
if stock_change.update_attribute(:quantity, params[:value]) if stock_change.update_attributes(:quantity => params[:value])
render :inline => params[:value] render :inline => params[:value]
else else
render :inline => "Ein Fehler ist aufgetreten." render :inline => "Ein Fehler ist aufgetreten."

View file

@ -1,6 +1,62 @@
class StockitController < ApplicationController class StockitController < ApplicationController
def index def index
@articles = StockArticle.all @stock_articles = StockArticle.without_deleted(
:include => [:supplier, :article_category],
:order => 'suppliers.name, article_categories.name, articles.name'
)
end end
def new
@supplier = Supplier.find(params[:supplier_id])
@stock_article = @supplier.stock_articles.build(:tax => 7.0)
end
def create
@stock_article = StockArticle.new(params[:stock_article])
if @stock_article.save
redirect_to stock_articles_path
else
render :action => 'new'
end
end
def edit
@stock_article = StockArticle.find(params[:id])
end
def update
@stock_article = StockArticle.find(params[:id])
if @stock_article.update_attributes(params[:stock_article])
redirect_to stock_articles_path
else
render :action => 'edit'
end
end
def destroy
StockArticle.find(params[:id]).destroy
redirect_to stock_articles_path
rescue => error
flash[:error] = "Ein Fehler ist aufgetreten: " + error.message
redirect_to stock_articles_path
end
def auto_complete_for_article_name
@supplier = Supplier.find(params[:supplier_id])
@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
stock_article = @supplier.stock_articles.build(
article.attributes.reject { |attr| attr == ('id' || 'type')}
)
render :partial => 'form', :locals => {:stock_article => stock_article}
end
end end

View file

@ -3,6 +3,9 @@
%p %p
%b Lieferant: %b Lieferant:
= @supplier.name = @supplier.name
%p
%b Rechnungsbetrag:
= link_to_invoice(@delivery)
- form_for([@supplier,@delivery]) do |f| - form_for([@supplier,@delivery]) do |f|
= f.error_messages = f.error_messages
@ -12,6 +15,7 @@
= f.date_select :delivered_on = f.date_select :delivered_on
%h2 Artikel %h2 Artikel
%i Um die Mengen anzupassen einfach auf die Anzahl klicken.
#stock_changes #stock_changes
%table.list{:style => "width:40em"} %table.list{:style => "width:40em"}
%tr %tr
@ -22,10 +26,10 @@
%tr[stock_change] %tr[stock_change]
%td= stock_change.stock_article.name %td= stock_change.stock_article.name
%td %td
%span{:id => stock_change.id, :style => "width:5em"}= stock_change.quantity %span.click-me{:id => stock_change.id, :style => "width:5em"}= stock_change.quantity
= javascript_tag "new Ajax.InPlaceEditor('#{stock_change.id}', | = javascript_tag "new Ajax.InPlaceEditor('#{stock_change.id}', |
'/deliveries/in_place_edit_for_stock_quantity', | '/deliveries/in_place_edit_for_stock_quantity', |
{size: 5, });" | {size: 5});" |
%td %td
= link_to_remote "Artikel entfernen", | = link_to_remote "Artikel entfernen", |
:url => drop_stock_change_supplier_delivery_path(@supplier, @delivery, :stock_change_id => stock_change), | :url => drop_stock_change_supplier_delivery_path(@supplier, @delivery, :stock_change_id => stock_change), |

View file

@ -1,18 +1,23 @@
- title "#{@supplier.name}/deliveries" - title "#{@supplier.name}/deliveries"
%table{:style => "width:50em"} %table.list{:style => "width:50em"}
%tr %thead
%th Delivered on
%th Invoice
- for delivery in @deliveries
%tr %tr
%td=h delivery.delivered_on %th Geliefert am
%td=h "invoice ..." %th Rechnungsbetrag
%td= link_to 'Show', [@supplier, delivery] %th
%td= link_to 'Edit', edit_supplier_delivery_path(@supplier,delivery) %th
%td= link_to 'Destroy', [@supplier,delivery], :confirm => 'Are you sure?', :method => :delete %th
%tbody
- for delivery in @deliveries
%tr
%td=h delivery.delivered_on
%td= link_to_invoice(delivery)
%td= link_to 'Anzeigen', [@supplier, delivery]
%td= link_to 'Bearbeiten', edit_supplier_delivery_path(@supplier,delivery)
%td= link_to 'Löschen', [@supplier,delivery], :confirm => 'Are you sure?', :method => :delete
%br/ %br/
= link_to 'New delivery', new_supplier_delivery_path(@supplier) = link_to "Neue Lieferung für #{@supplier.name} anlegen", new_supplier_delivery_path(@supplier)
| |
= link_to "Lieferantenübersicht", suppliers_path = link_to "Lieferantenübersicht", suppliers_path

View file

@ -8,36 +8,36 @@
- if @invoice.order - if @invoice.order
%p= "Diese Rechnung ist mit einer #{link_to "Bestellung", @invoice.order} verknüpft." %p= "Diese Rechnung ist mit einer #{link_to "Bestellung", @invoice.order} verknüpft."
%p %p
= f.label :supplier_id Lieferant
%br/ %br/
= f.select :supplier_id, Supplier.all.collect { |s| [s.name, s.id] } = f.select :supplier_id, Supplier.all.collect { |s| [s.name, s.id] }
%p %p
= f.label :number Rechnungsnummer
%br/ %br/
= f.text_field :number = f.text_field :number
%p %p
= f.label :date Rechnungsdatum
%br/ %br/
= f.date_select :date = f.date_select :date
%p %p
= f.label :paid_on Bezahlt am
%br/ %br/
= f.date_select :paid_on, :include_blank => true = f.date_select :paid_on, :include_blank => true
%p %p
= f.label :amount Rechnungsbetrag
%br/ %br/
= f.text_field :amount = f.text_field :amount
%p %p
= f.label :deposit Pfand berechnet
%br/ %br/
= f.text_field :deposit = f.text_field :deposit
%p %p
= f.label :deposit_credit Pfand gutgeschrieben
%br/ %br/
= f.text_field :deposit_credit = f.text_field :deposit_credit
%p %p
= f.label :note Notiz
%br/ %br/
= f.text_area :note = f.text_area :note, :size => "28x8"
%p %p
= f.submit "Speichern" = f.submit "Speichern"

View file

@ -1,6 +1,6 @@
<h1>Editing invoice</h1> <% title "Rechnung bearbeiten" %>
<%= render :partial => 'form' %> <%= render :partial => 'form' %>
<%= link_to 'Show', [:finance, @invoice] %> | <%= link_to "Anzeigen", [:finance, @invoice] %> |
<%= link_to 'Back', finance_invoices_path %> <%= link_to 'Zurück', finance_invoices_path %>

View file

@ -1,33 +1,33 @@
<% title "Invoices" %> <% title "Rechnungen" %>
<table class="list" style="width:70em"> <table class="list" style="width:70em">
<thead> <thead>
<tr> <tr>
<th>Supplier</th> <th>Nummer</th>
<th>Number</th> <th>Lieferant</th>
<th>Date</th> <th>Datum</th>
<th>Paid on</th> <th>Bezahlt am</th>
<th>Amount</th> <th>Betrag</th>
<th>Delivery</th> <th>Lieferung</th>
<th>Bestellung</th>
<th>Note</th> <th>Note</th>
<th></th> <th></th>
<th></th> <th></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% for invoice in @invoices %> <% for invoice in @invoices %>
<tr> <tr>
<td><%= link_to h(invoice.number), finance_invoice_path(invoice)%></td>
<td><%=h invoice.supplier.name %></td> <td><%=h invoice.supplier.name %></td>
<td><%=h invoice.number %></td> <td><%= format_date invoice.date %></td>
<td><%= invoice.date %></td> <td><%= format_date invoice.paid_on %></td>
<td><%= invoice.paid_on %></td> <td><%= number_to_currency invoice.amount %></td>
<td><%= invoice.amount %></td>
<td><%= link_to "Lieferung", [invoice.supplier,invoice.delivery] if invoice.delivery %></td> <td><%= link_to "Lieferung", [invoice.supplier,invoice.delivery] if invoice.delivery %></td>
<td><%= link_to format_date(invoice.order.ends), :controller => 'balancing', :action => 'new', :id => invoice.order if invoice.order %></td>
<td><%=h truncate(invoice.note) %></td> <td><%=h truncate(invoice.note) %></td>
<td><%= link_to 'Show', finance_invoice_path(invoice) %></td> <td><%= link_to icon(:edit), edit_finance_invoice_path(invoice) %></td>
<td><%= link_to 'Edit', edit_finance_invoice_path(invoice) %></td> <td><%= link_to icon(:delete), finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete %></td>
<td><%= link_to 'Destroy', finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -35,4 +35,4 @@
<br /> <br />
<%= link_to 'New invoice', new_finance_invoice_path %> <%= link_to 'Neue Rechnung anlegen', new_finance_invoice_path %>

View file

@ -1,28 +1,34 @@
- title "Rechnung #{@invoice.number}" - title "Rechnung #{@invoice.number}"
%p %p
%b Supplier: %b Lieferant:
=h @invoice.supplier.name =h @invoice.supplier.name
- if @invoice.delivery - if @invoice.delivery
%p %p
%b Delivery: %b Lieferung:
="Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft." ="Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft."
%p %p
%b Number: %b Rechnungsnummer:
=h @invoice.number =h @invoice.number
%p %p
%b Date: %b Datum:
=h @invoice.date =h @invoice.date
%p %p
%b Paid on: %b Bezahlt am:
=h @invoice.paid_on =h @invoice.paid_on
%p %p
%b Amount: %b Rechnungsbetrag:
=h @invoice.amount =h @invoice.amount
%p %p
%b Note: %b Pfand berechnet:
=h @invoice.deposit
%p
%b Pfand gutgeschrieben:
=h @invoice.deposit_credit
%p
%b Notiz:
=h @invoice.note =h @invoice.note
= link_to 'Edit', edit_finance_invoice_path(@invoice) = link_to "Bearbeiten", edit_finance_invoice_path(@invoice)
| |
= link_to 'Back', finance_invoices_path = link_to "Zurück", finance_invoices_path

View file

@ -0,0 +1,41 @@
- form_for stock_article do |form|
= form.error_messages
= form.hidden_field :supplier_id
%p
Name
%br/
= form.text_field :name
%p
Einheit
%br/
= form.text_field :unit
%p
Notiz
%br/
= form.text_field :note
- if stock_article.new_record?
%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
- else
%p
Preis:
%br/
Um Chaos zu vermeiden können bis auf weiteres die Preise von angelegten
Lagerartikeln nicht mehr verändert werden.
%p
Kategorie:
= form.select :article_category_id, ArticleCategory.all(:order => 'name').collect { |c| [c.name, c.id] }
%p
= submit_tag "Lagerartikel speichern"
|
= link_to "Abbrechen", stock_articles_path

View file

@ -0,0 +1,3 @@
- title "Lagerartikel bearbeiten"
= render :partial => 'form', :locals => {:stock_article => @stock_article}

View file

@ -1,32 +1,50 @@
- title "Lagerübersicht" - title "Lagerübersicht"
%p %div{:style => "padding:0 0 0.5em 0.7em;margin-bottom:2em"}
- form_tag do %span{:style => "float:left"}
Neue Lieferung anlegen für: - form_tag do
= select_tag :new_delivery, | Neue Lieferung anlegen für:
options_for_select([[" -- Lieferantin wählen --", ""]] + | = select_tag :new_delivery, |
Supplier.without_deleted.collect {|s| [ s.name, url_for(new_supplier_delivery_path(s))] }), | options_for_select([[" -- Lieferantin wählen --", ""]] + |
:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" | Supplier.without_deleted.collect {|s| [ s.name, url_for(new_supplier_delivery_path(s))] }), |
%p :onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" |
= link_to "Lagerbestellung online stellen", new_order_path(:supplier_id => 0)
%p .single_column{:style => 'width:100%; clear:both'}
%table.list .box_title
%thead .column_content
%tr #actions
%th Artikel %b Neuen Lagerartikel anlegen für
%th im Lager = select_tag :new_stock_article, |
%th davon bestellt options_for_select([[" -- Lieferantin wählen --", ""]] + |
%th Einheit Supplier.without_deleted.collect {|s| [ s.name, url_for(new_stock_article_path(:supplier_id => s))] }), |
%th Preis :onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" |
%th Lieferant
%th Kategorie |
%tbody = link_to_if @current_user.role_orders?, "Lagerbestellung online stellen", {:controller => 'orders', :action => 'new', :supplier_id => 0}
- for article in @articles
%tr{:class => cycle("even", "odd")} #articles{:style => "clear:both;margin-top:1em"}
%td=h article.name %table.list
%td= article.quantity %thead
%td= article.quantity - article.quantity_available %tr
%td= article.unit %th Artikel
%td= article.price %th im Lager
%td= link_to article.supplier.name, article.supplier %th davon bestellt
%td= article.article_category.name %th Einheit
%th Preis
%th Lieferant
%th Kategorie
%th
%tbody
- for article in @stock_articles
%tr{:class => cycle("even", "odd")}
%td=h article.name
%td= article.quantity
%td= article.quantity - article.quantity_available
%td= article.unit
%td= article.price
%td= link_to article.supplier.name, article.supplier
%td= article.article_category.name
%td
= link_to icon(:edit), edit_stock_article_path(article)
= link_to icon(:delete), article, :method => :delete, :confirm => "Bist Du sicher?"

View file

@ -0,0 +1,16 @@
- title "Neuen Lagerartikel für #{@supplier.name} anlegen"
:javascript
function fillNewStockArticle(text, li) {
new Ajax.Updater('stock_article_form', '/stockit/fill_new_stock_article_form', {
parameters: {article_id: li.id}
});
}
%p
Suche nach Artikeln aus dem Katalog:
= text_field_with_auto_complete :article, :name, {}, |
{:url => {:action => 'auto_complete_for_article_name', :supplier_id => @supplier.id}, |
:after_update_element => 'fillNewStockArticle'} |
#stock_article_form
= render :partial => 'form', :locals => {:stock_article => @stock_article}

View file

@ -17,14 +17,16 @@
%th Name %th Name
%th Telefon %th Telefon
%th KundenNr %th KundenNr
%th %th
%th
%tbody %tbody
- for supplier in @suppliers - for supplier in @suppliers
%tr{:class => cycle('even','odd', :name => 'suppliers')} %tr{:class => cycle('even','odd', :name => 'suppliers')}
%td= link_to "<b>#{h(supplier.name)}</b> (#{supplier.articles.count})", supplier_articles_path(supplier) %td= link_to h(supplier.name) , supplier
%td=h supplier.phone %td=h supplier.phone
%td=h supplier.customer_number %td=h supplier.customer_number
%td= link_to "Anzeigen", supplier %td= link_to "Artikel (#{supplier.articles.count})", supplier_articles_path(supplier)
%td= link_to "Lieferungen", supplier_deliveries_path(supplier)
.right_column{:style => "width:47%"} .right_column{:style => "width:47%"}
.box_title .box_title

View file

@ -119,6 +119,7 @@ de:
even: "muss gerade sein" even: "muss gerade sein"
models: models:
article: Artikel article: Artikel
supplier: Lieferant
user: Benutzerinnen user: Benutzerinnen
workgroup: Arbeitsgruppe workgroup: Arbeitsgruppe
ordergroup: Bestellgruppe ordergroup: Bestellgruppe

View file

@ -20,6 +20,8 @@ ActionController::Routing::Routes.draw do |map|
finance.resources :invoices finance.resources :invoices
end end
map.resources :stock_articles, :controller => 'stockit', :as => 'stockit'
map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers| map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers|
suppliers.resources :deliveries, :member => { :drop_stock_change => :post }, suppliers.resources :deliveries, :member => { :drop_stock_change => :post },
:collection => {:add_stock_article => :post} :collection => {:add_stock_article => :post}

View file

@ -9,7 +9,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20090119155930) do ActiveRecord::Schema.define(:version => 20090120184410) do
create_table "article_categories", :force => true do |t| create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false t.string "name", :default => "", :null => false

View file

@ -76,6 +76,9 @@ option {
border-top: 1px solid #D7D7D7; border-top: 1px solid #D7D7D7;
margin: .2em 0; } margin: .2em 0; }
span.click-me {
cursor: pointer; }
#login { #login {
margin: auto; margin: auto;
width: 27em; width: 27em;

View file

@ -76,6 +76,9 @@ option {
border-top: 1px solid #D7D7D7; border-top: 1px solid #D7D7D7;
margin: .2em 0; } margin: .2em 0; }
span.click-me {
cursor: pointer; }
#login { #login {
margin: auto; margin: auto;
width: 27em; width: 27em;

View file

@ -86,6 +86,8 @@ option
border-top: 1px solid #D7D7D7 border-top: 1px solid #D7D7D7
margin: .2em 0 margin: .2em 0
span.click-me
cursor: pointer
// ********************************* loginpage // ********************************* loginpage
#login #login