Merge pull request #184 from foodcoop-rostock/article-price-tooltip

Show StockArticle price details to user
This commit is contained in:
wvengen 2013-10-08 02:14:03 -07:00
commit ac3e5cd019
11 changed files with 118 additions and 69 deletions

View file

@ -31,6 +31,11 @@ class StockitController < ApplicationController
end end
end end
def show
@stock_article = StockArticle.find(params[:id])
@stock_changes = @stock_article.stock_changes.order('stock_changes.created_at DESC')
end
def destroy def destroy
@article = StockArticle.find(params[:id]) @article = StockArticle.find(params[:id])
@article.mark_as_deleted @article.mark_as_deleted
@ -55,9 +60,4 @@ class StockitController < ApplicationController
render :partial => 'form', :locals => {:stock_article => stock_article} render :partial => 'form', :locals => {:stock_article => stock_article}
end end
def history
@stock_article = StockArticle.undeleted.find(params[:stock_article_id])
@stock_changes = @stock_article.stock_changes.order('stock_changes.created_at DESC').each {|s| s.readonly!}
end
end end

View file

@ -3,5 +3,6 @@
= form.hidden_field :stock_article_id = form.hidden_field :stock_article_id
= "Menge (#{stock_change.stock_article.quantity_available})" = "Menge (#{stock_change.stock_article.quantity_available})"
= form.text_field :quantity, :size => 5, :autocomplete => 'off' = form.text_field :quantity, :size => 5, :autocomplete => 'off'
%b= stock_change.stock_article.name %span{:data => {:toggle => :tooltip, :title => render(:partial => 'shared/article_price_info', :locals => {:article => stock_change.stock_article})}}
= "(#{number_to_currency(stock_change.stock_article.price)} / #{stock_change.stock_article.unit})" %b= stock_change.stock_article.name
= "(#{number_to_currency(stock_change.stock_article.price)} / #{stock_change.stock_article.unit})"

View file

@ -1,5 +1,20 @@
- title t('.title') - title t('.title')
- content_for :javascript do
:javascript
$(function() {
enablePriceTooltips();
});
function enablePriceTooltips(context) {
$('[data-toggle~="tooltip"]', context).tooltip({
animation: false,
html: true,
placement: 'left',
container: 'body'
});
}
- content_for :sidebar do - content_for :sidebar do
%p %p
%i= t('.text_deviations', inv_link: link_to(t('.temp_inventory'), stock_articles_path)).html_safe %i= t('.text_deviations', inv_link: link_to(t('.temp_inventory'), stock_articles_path)).html_safe

View file

@ -1,17 +0,0 @@
- title t('.stock_changes', :article_name => @stock_article.name)
%table.table.table-hover#stock_changes
%thead
%tr
%th= t '.datetime'
%th= t '.reason'
%th= t '.change_quantity'
%th= t '.new_quantity'
%tbody
- reversed_history = @stock_article.quantity_history.reverse
- @stock_changes.each_with_index do |stock_change, index|
%tr
%td= l stock_change.created_at
%td= link_to_stock_change_reason(stock_change)
%td= stock_change.quantity
%td= reversed_history[index]

View file

@ -45,7 +45,7 @@
%tbody %tbody
- for article in @stock_articles - for article in @stock_articles
%tr{:class => stock_article_classes(article), :id => "stockArticle-#{article.id}"} %tr{:class => stock_article_classes(article), :id => "stockArticle-#{article.id}"}
%td=h article.name %td= link_to article.name, article
%td= article.quantity %td= article.quantity
%td= article.quantity - article.quantity_available %td= article.quantity - article.quantity_available
%th= article.quantity_available %th= article.quantity_available
@ -56,7 +56,6 @@
%td= article.article_category.name %td= article.article_category.name
%td %td
= link_to t('ui.edit'), edit_stock_article_path(article), class: 'btn btn-mini' = link_to t('ui.edit'), edit_stock_article_path(article), class: 'btn btn-mini'
= link_to t('ui.history'), stock_article_history_path(article), class: 'btn btn-mini'
= link_to t('ui.delete'), article, :method => :delete, :confirm => t('.confirm_delete'), = link_to t('ui.delete'), article, :method => :delete, :confirm => t('.confirm_delete'),
class: 'btn btn-mini btn-danger', :remote => true class: 'btn btn-mini btn-danger', :remote => true
%p %p

View file

@ -0,0 +1,47 @@
- title @stock_article.name
.row-fluid
.span6
%dl.dl-horizontal
%dt= StockArticle.human_attribute_name 'supplier'
%dd= link_to @stock_article.supplier.name, @stock_article.supplier
%dt= StockArticle.human_attribute_name 'name'
%dd= @stock_article.name
%dt= StockArticle.human_attribute_name 'unit'
%dd= @stock_article.unit
%dt= StockArticle.human_attribute_name 'price'
%dd= number_to_currency @stock_article.price
%dt= StockArticle.human_attribute_name 'tax'
%dd= number_to_percentage @stock_article.tax
%dt= StockArticle.human_attribute_name 'deposit'
%dd= number_to_currency @stock_article.deposit
%dt= StockArticle.human_attribute_name 'fc_price'
%dd= number_to_currency @stock_article.fc_price
%dt= StockArticle.human_attribute_name 'article_category'
%dd= @stock_article.article_category.name
%dt= StockArticle.human_attribute_name 'note'
%dd= @stock_article.note
%dt= StockArticle.human_attribute_name 'quantity'
%dd= @stock_article.quantity
%dt= StockArticle.human_attribute_name 'quantity_available'
%dd= @stock_article.quantity_available
.form-actions
= link_to t('ui.edit'), edit_stock_article_path(@stock_article), class: 'btn'
.span6
%h2= t('.stock_changes')
%table.table.table-hover#stock_changes
%thead
%tr
%th= t '.datetime'
%th= t '.reason'
%th= t '.change_quantity'
%th= t '.new_quantity'
%tbody
- reversed_history = @stock_article.quantity_history.reverse
- @stock_changes.each_with_index do |stock_change, index|
%tr
%td= l stock_change.created_at
%td= link_to_stock_change_reason(stock_change)
%td= stock_change.quantity
%td= reversed_history[index]

View file

@ -42,7 +42,10 @@ de:
fc_price: Endpreis fc_price: Endpreis
fc_share: FC-Aufschlag fc_share: FC-Aufschlag
gross_price: Bruttopreis gross_price: Bruttopreis
name: Name
note: Notiz
price: Nettopreis price: Nettopreis
supplier: Lieferantin
tax: MwSt tax: MwSt
unit: Einheit unit: Einheit
unit_quantity: Gebindegröße unit_quantity: Gebindegröße
@ -51,6 +54,8 @@ de:
note: Notiz note: Notiz
stock_article: stock_article:
price: Nettopreis price: Nettopreis
quantity: Lagerbestand
quantity_available: Verfügbarer Bestand
user: user:
first_name: Vorname first_name: Vorname
password: Passwort password: Passwort
@ -1733,15 +1738,6 @@ de:
title: Lagerartikel bearbeiten title: Lagerartikel bearbeiten
form: form:
price_hint: Um Chaos zu vermeiden können bis auf weiteres die Preise von angelegten Lagerartikeln nicht mehr verändert werden. price_hint: Um Chaos zu vermeiden können bis auf weiteres die Preise von angelegten Lagerartikeln nicht mehr verändert werden.
history:
change_quantity: Veränderung
datetime: Zeitpunkt
delivery: Lieferung
new_quantity: Neuer Bestand
order: Bestellung
reason: Ereignis
stock_changes: Verlauf anzeigen für »%{article_name}«
stock_taking: Inventur
index: index:
article: article:
article: Artikel article: Artikel
@ -1767,6 +1763,15 @@ de:
new: new:
search_text: ! 'Suche nache Artikeln aus allen Katalogen:' search_text: ! 'Suche nache Artikeln aus allen Katalogen:'
title: Neuen Lagerartikel anlegen title: Neuen Lagerartikel anlegen
show:
change_quantity: Veränderung
datetime: Zeitpunkt
delivery: Lieferung
new_quantity: Neuer Bestand
order: Bestellung
reason: Ereignis
stock_changes: Verlauf des Lagerbestands
stock_taking: Inventur
stock_create: stock_create:
notice: Lagerartikel wurde gespeichert. notice: Lagerartikel wurde gespeichert.
stock_update: stock_update:
@ -1891,7 +1896,6 @@ de:
close: Schließen close: Schließen
delete: Löschen delete: Löschen
edit: Bearbeiten edit: Bearbeiten
history: Verlauf anzeigen
marks: marks:
close: ! '&times;' close: ! '&times;'
success: <i class="icon icon-ok"></i> success: <i class="icon icon-ok"></i>

View file

@ -42,7 +42,10 @@ en:
fc_price: FC price fc_price: FC price
fc_share: FC share fc_share: FC share
gross_price: gross price gross_price: gross price
name: name
note: note
price: price price: price
supplier: supplier
tax: VAT tax: VAT
unit: unit unit: unit
unit_quantity: unit quantity unit_quantity: unit quantity
@ -50,7 +53,9 @@ en:
amount: amount amount: amount
note: note note: note
stock_article: stock_article:
price: Price price: price
quantity: quantity
quantity_available: available quantity
user: user:
first_name: First name first_name: First name
password: Password password: Password
@ -1737,15 +1742,6 @@ en:
title: Edit stock articles title: Edit stock articles
form: form:
price_hint: To avoid choas, it is not possible to edit the prices of already added stock articles until further notice. price_hint: To avoid choas, it is not possible to edit the prices of already added stock articles until further notice.
history:
change_quantity: Change
datetime: Time
delivery: Delivery
new_quantity: New quantity
order: Order
reason: Reason
stock_changes: Stock quantity changes of %{article_name}
stock_taking: Inventory
index: index:
article: article:
article: Article article: Article
@ -1771,6 +1767,15 @@ en:
new: new:
search_text: ! 'Search for articles in all catalogues:' search_text: ! 'Search for articles in all catalogues:'
title: Add new stock article title: Add new stock article
show:
change_quantity: Change
datetime: Time
delivery: Delivery
new_quantity: New quantity
order: Order
reason: Reason
stock_changes: Stock quantity changes
stock_taking: Inventory
stock_create: stock_create:
notice: Stock article was created. notice: Stock article was created.
stock_update: stock_update:
@ -1895,7 +1900,6 @@ en:
close: Close close: Close
delete: Delete delete: Delete
edit: Edit edit: Edit
history: Show history
marks: marks:
close: ! '&times;' close: ! '&times;'
success: <i class="icon icon-ok"></i> success: <i class="icon icon-ok"></i>

View file

@ -1739,15 +1739,6 @@ fr:
title: Modifier l'article title: Modifier l'article
form: form:
price_hint: Pour éviter que ça soit le bazar, les prix des articles en stock ne peuvent plus être modifiés. price_hint: Pour éviter que ça soit le bazar, les prix des articles en stock ne peuvent plus être modifiés.
history:
change_quantity: Modification
datetime: Temps
delivery: Réapprovisionnement
new_quantity: Nouveau stock
order: Commande
reason: Raison
stock_changes: Afficher l'historique pour "%{article_name}"
stock_taking: Inventaire
index: index:
article: article:
article: Article article: Article
@ -1773,6 +1764,15 @@ fr:
new: new:
search_text: ! 'Rechercher des articles dans tous les catalogues:' search_text: ! 'Rechercher des articles dans tous les catalogues:'
title: Ajouter un article au stock title: Ajouter un article au stock
show:
change_quantity: Modification
datetime: Temps
delivery: Réapprovisionnement
new_quantity: Nouveau stock
order: Commande
reason: Raison
stock_changes: Afficher l'historique
stock_taking: Inventaire
stock_create: stock_create:
notice: L'article a été sauvegardé. notice: L'article a été sauvegardé.
stock_update: stock_update:
@ -1905,7 +1905,6 @@ fr:
close: Fermer close: Fermer
delete: Supprimer delete: Supprimer
edit: Modifier edit: Modifier
history: Afficher l'historique
marks: marks:
close: ! '&times;' close: ! '&times;'
success: <i class="icon icon-ok"></i> success: <i class="icon icon-ok"></i>

View file

@ -1665,15 +1665,6 @@ nl:
title: title:
form: form:
price_hint: price_hint:
history:
change_quantity:
datetime:
delivery:
new_quantity:
order:
reason:
stock_changes:
stock_taking:
index: index:
article: article:
article: article:
@ -1699,6 +1690,15 @@ nl:
new: new:
search_text: search_text:
title: title:
show:
change_quantity:
datetime:
delivery:
new_quantity:
order:
reason:
stock_changes:
stock_taking:
stock_create: stock_create:
notice: Voorraadsartikel is opgeslagen. notice: Voorraadsartikel is opgeslagen.
stock_update: stock_update:
@ -1823,7 +1823,6 @@ nl:
close: Sluiten close: Sluiten
delete: Verwijder delete: Verwijder
edit: Bewerk edit: Bewerk
history:
marks: marks:
close: ! '&times;' close: ! '&times;'
success: <i class="icon icon-ok"></i> success: <i class="icon icon-ok"></i>

View file

@ -97,8 +97,6 @@ Foodsoft::Application.routes.draw do
get :articles_search get :articles_search
get :fill_new_stock_article_form get :fill_new_stock_article_form
end end
get :history
end end
resources :suppliers do resources :suppliers do