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
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]
else
render :inline => "Ein Fehler ist aufgetreten."

View file

@ -1,6 +1,62 @@
class StockitController < ApplicationController
def index
@articles = StockArticle.all
@stock_articles = StockArticle.without_deleted(
:include => [:supplier, :article_category],
:order => 'suppliers.name, article_categories.name, articles.name'
)
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

View file

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

View file

@ -1,18 +1,23 @@
- title "#{@supplier.name}/deliveries"
%table{:style => "width:50em"}
%tr
%th Delivered on
%th Invoice
- for delivery in @deliveries
%table.list{:style => "width:50em"}
%thead
%tr
%td=h delivery.delivered_on
%td=h "invoice ..."
%td= link_to 'Show', [@supplier, delivery]
%td= link_to 'Edit', edit_supplier_delivery_path(@supplier,delivery)
%td= link_to 'Destroy', [@supplier,delivery], :confirm => 'Are you sure?', :method => :delete
%th Geliefert am
%th Rechnungsbetrag
%th
%th
%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/
= 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

View file

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

View file

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

View file

@ -1,33 +1,33 @@
<% title "Invoices" %>
<% title "Rechnungen" %>
<table class="list" style="width:70em">
<thead>
<tr>
<th>Supplier</th>
<th>Number</th>
<th>Date</th>
<th>Paid on</th>
<th>Amount</th>
<th>Delivery</th>
<th>Nummer</th>
<th>Lieferant</th>
<th>Datum</th>
<th>Bezahlt am</th>
<th>Betrag</th>
<th>Lieferung</th>
<th>Bestellung</th>
<th>Note</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% for invoice in @invoices %>
<tr>
<td><%= link_to h(invoice.number), finance_invoice_path(invoice)%></td>
<td><%=h invoice.supplier.name %></td>
<td><%=h invoice.number %></td>
<td><%= invoice.date %></td>
<td><%= invoice.paid_on %></td>
<td><%= invoice.amount %></td>
<td><%= format_date invoice.date %></td>
<td><%= format_date invoice.paid_on %></td>
<td><%= number_to_currency invoice.amount %></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><%= link_to 'Show', finance_invoice_path(invoice) %></td>
<td><%= link_to 'Edit', edit_finance_invoice_path(invoice) %></td>
<td><%= link_to 'Destroy', finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete %></td>
<td><%= link_to icon(:edit), edit_finance_invoice_path(invoice) %></td>
<td><%= link_to icon(:delete), finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</tbody>
@ -35,4 +35,4 @@
<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}"
%p
%b Supplier:
%b Lieferant:
=h @invoice.supplier.name
- if @invoice.delivery
%p
%b Delivery:
%b Lieferung:
="Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft."
%p
%b Number:
%b Rechnungsnummer:
=h @invoice.number
%p
%b Date:
%b Datum:
=h @invoice.date
%p
%b Paid on:
%b Bezahlt am:
=h @invoice.paid_on
%p
%b Amount:
%b Rechnungsbetrag:
=h @invoice.amount
%p
%b Note:
%b Pfand berechnet:
=h @invoice.deposit
%p
%b Pfand gutgeschrieben:
=h @invoice.deposit_credit
%p
%b Notiz:
=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"
%p
- form_tag do
Neue Lieferung anlegen für:
= select_tag :new_delivery, |
options_for_select([[" -- Lieferantin wählen --", ""]] + |
Supplier.without_deleted.collect {|s| [ s.name, url_for(new_supplier_delivery_path(s))] }), |
:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" |
%p
= link_to "Lagerbestellung online stellen", new_order_path(:supplier_id => 0)
%p
%table.list
%thead
%tr
%th Artikel
%th im Lager
%th davon bestellt
%th Einheit
%th Preis
%th Lieferant
%th Kategorie
%tbody
- for article in @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
%div{:style => "padding:0 0 0.5em 0.7em;margin-bottom:2em"}
%span{:style => "float:left"}
- form_tag do
Neue Lieferung anlegen für:
= select_tag :new_delivery, |
options_for_select([[" -- Lieferantin wählen --", ""]] + |
Supplier.without_deleted.collect {|s| [ s.name, url_for(new_supplier_delivery_path(s))] }), |
:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" |
.single_column{:style => 'width:100%; clear:both'}
.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;" |
|
= link_to_if @current_user.role_orders?, "Lagerbestellung online stellen", {:controller => 'orders', :action => 'new', :supplier_id => 0}
#articles{:style => "clear:both;margin-top:1em"}
%table.list
%thead
%tr
%th Artikel
%th im Lager
%th davon bestellt
%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

@ -18,13 +18,15 @@
%th Telefon
%th KundenNr
%th
%th
%tbody
- for supplier in @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.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%"}
.box_title

View file

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

View file

@ -20,6 +20,8 @@ ActionController::Routing::Routes.draw do |map|
finance.resources :invoices
end
map.resources :stock_articles, :controller => 'stockit', :as => 'stockit'
map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers|
suppliers.resources :deliveries, :member => { :drop_stock_change => :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.
ActiveRecord::Schema.define(:version => 20090119155930) do
ActiveRecord::Schema.define(:version => 20090120184410) do
create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false

View file

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

View file

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

View file

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