Complete refactoring of orders-workflow.

OrderResult tables are removed. Data consistency is now possible through new article.price-history (ArticlePrice).
Balancing-workflow needs to be updated.
This commit is contained in:
Benjamin Meichsner 2009-01-29 01:57:51 +01:00
parent 80287aeea4
commit 9eb2125f15
98 changed files with 1121 additions and 1717 deletions

View file

@ -1,31 +0,0 @@
- if controller.action_name == 'myOrders'
= pagination_links_remote @bookedOrders, :per_page => 10, :params => {:show_all => params[:show_all]}
%table.list
%thead
%tr
%th=_ 'Name'
%th=_ 'Supplier'
%th=_ 'End'
%th=_ 'Sum'
%tbody
- @bookedOrders.each do |order|
- if order.is_a?(GroupOrder) || order.is_a?(GroupOrderResult)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.order.name, :action => 'my_order_result', :id => order.order
%td=h order.order.supplier ? order.order.supplier.name : _("nonexistent")
%td= format_time(order.order.ends)
%td{:class => "currency"}= number_to_currency(order.price)
- else
// check if the Ordergroup has ordered
- if groupOrder = order.group_order(@orderGroup)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.name, :action => 'my_order_result', :id => order
%td=h order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"}= number_to_currency(groupOrder.price)
- else
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders'), :style => "color:grey"}
%td= link_to truncate(order.name), {:action => "my_order_result", :id => order}, :style => "color:grey"
%td= order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"} --

View file

@ -1,32 +0,0 @@
.box_title
%h2=_ "Running orders"
.column_content
- unless @currentOrders.empty?
%table.list
%thead
%tr
%th=_ "Name"
%th=_ "Supplier"
%th=_ "End"
%th=_ "Who ordered?"
%th=_ "Sum"
%tbody
- total = 0
- @currentOrders.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'current_orders')}
%td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order
%td=h order.supplier.name
%td=h format_time(order.ends) unless order.ends.nil?
- if (groupOrder = order.group_orders.find(:first, :conditions => ["ordergroup_id = ?", @orderGroup.id]))
- total += groupOrder.price
%td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})"
%td= number_to_currency(groupOrder.price)
- else
%td
%td
- if total > 0
%p
=_ "Total sum"
%b= number_to_currency(total)
- else
%i=_ "There aren't current orders at the moment."

View file

@ -1,30 +0,0 @@
%table.list
%thead
%tr
%th=_ 'Name'
%th=_ 'Supplier'
%th=_ 'End'
%th=_ 'Sum'
%tbody
- @finishedOrders.each do |order|
- if order.is_a?(GroupOrder) or order.is_a?(GroupOrderResult)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.order.name, :action => 'my_order_result', :id => order.order
%td=h order.order.supplier ? order.order.supplier.name : _("nonexistent")
%td= format_time(order.order.ends)
%td{:class => "currency"}= number_to_currency(order.price)
- else
// check if the Ordergroup has ordered
- if groupOrder = order.group_order(@orderGroup)
%tr{:class=> cycle('even', 'odd', :name => 'finishedOrders')}
%td= link_to order.name, :action => 'my_order_result', :id => order
%td=h order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"}= number_to_currency(groupOrder.price)
- else
%tr{:class=> cycle('even', 'odd', :name => 'finishedOrders'), :style => "color:grey"}
%td= link_to truncate(order.name), {:action => "my_order_result", :id => order}, :style => "color:grey"
%td= order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"} --

View file

@ -1,33 +0,0 @@
%table.list
%thead
%tr
%th{:style => "width:40%"}=_ "Name"
%th=_ "Unit quantity"
%th=_ "Unit price"
%th=_ "Received"
%th=_ "Total price"
%tbody
- for article in @groupOrderResult.group_order_article_results
- price = article.order_article_result.gross_price
- quantity = article.quantity
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%td{:style=>"width:40%"}
=h article.order_article_result.name
- unless article.order_article_result.note.nil?
= image_tag "lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{article.id}').show();", :onmouseout => "$('note_#{article.id}').hide();" }
%td
= article.order_article_result.unit_quantity
x
= article.order_article_result.unit
%td= number_to_currency(price)
%td= quantity
%td= number_to_currency(quantity * price)
- unless article.order_article_result.note.nil?
%tr{:id => "note_#{article.id}", :style => "display:none"}
%td{:colspan => "5"}
Notiz:
=h article.order_article_result.note
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "4"}=_ "Sum"
%th= number_to_currency(@groupOrderResult.price)

View file

@ -0,0 +1,30 @@
.box_title
%h2 Laufende Bestellungen
.column_content
- unless Order.open.empty?
%table.list
%thead
%tr
%th Lieferant
%th Ende
%th Wer hat bestellt?
%th Summe
%tbody
- total = 0
- Order.open.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'open_orders')}
%td= link_to h(order.supplier.name), :controller => 'ordering', :action => 'order', :id => order
%td=h format_time(order.ends) unless order.ends.nil?
- if group_order = order.group_order(@ordergroup)
- total += group_order.price
%td=h "#{group_order.updated_by.nick} (#{format_time(group_order.updated_on)})"
%td= number_to_currency(group_order.price)
- else
%td
%td
- if total > 0
%p
Gesamtsumme:
%b= number_to_currency(total)
- else
%i Derzeit gibt es keine laufenden Bestellungen

View file

@ -0,0 +1,17 @@
- if controller.action_name == 'myOrders'
= pagination_links_remote @closed_orders, :per_page => 10, :update => 'closed_orders'
%table.list
%thead
%tr
%th Lieferant
%th Ende
%th Summe
%tbody
- for order in orders
- group_order = order.group_order(@ordergroup) # Get GroupOrder if possible
- order_class = group_order ? "" : "color:grey"
%tr{:class=> cycle('even', 'odd', :name => 'orders'), :style => order_class}
%td= link_to order.supplier.name, :action => 'my_order_result', :id => order
%td= format_time(order.ends)
%td{:class => "currency"}= group_order ? number_to_currency(group_order.price) : "--"

View file

@ -1,54 +0,0 @@
%table.list
%thead
%tr
%th{:style => "width:40%"} Name
%th Gebinde
%th Einzelpreis
%th
%abbr{:title => "Menge + Toleranz"} Bestellt
%th
%abbr{:title => "Unter Berücksichtigung der anderen Gruppen"} Zugeteilt
%th Gesamtpreis
%tbody
- total = 0 #set counter for order-sum
- for category, order_articles in @order.get_articles
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left;"}=h category
%td{:colspan => "9"}
- for order_article in order_articles
- article = order_article.article
- # get the order-results for the ordergroup
- group_order_article = GroupOrderArticle.find_by_group_order_id_and_order_article_id @group_order.id, order_article.id
- if group_order_article
- quantity = group_order_article.quantity
- tolerance = group_order_article.tolerance
- result = group_order_article.orderResult[:quantity] + group_order_article.orderResult[:tolerance]
- sub_total = article.gross_price * (quantity + tolerance)
- else
- quantity, tolerance, result, sub_total = 0, 0, 0, 0
- total += sub_total
- # give the article different colors, dependent on order-result
- style = "grey"
- if (quantity > 0)
- style = result > 0 ? 'green' : 'red'
%tr{:class => cycle('even', 'odd', :name => 'articles'), :style => "color:#{style}"}
%td{:style => "width:40%"}
=h order_article.article.name
- unless order_article.article.note.empty?
= image_tag("lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{order_article.id}').show();", :onmouseout => "$('note_#{order_article.id}').hide();"})
%td= "#{article.unit_quantity} x #{order_article.article.unit}"
%td= number_to_currency(article.gross_price)
%td
= quantity
= "+ #{tolerance}" if article.unit_quantity > 1
%td= result > 0 ? result : "0"
%td= number_to_currency(sub_total)
- unless order_article.article.note.empty?
%tr{:id => "note_#{order_article.id}", :class => "note even", :style => "display:none"}
%td{:colspan => "6"}=h order_article.article.note
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "5"} Summe
%th= number_to_currency(total)

View file

@ -1,45 +1,44 @@
%h1= _('Order Overview')
- title "Bestellüberblick"
// Ordergroups Account Balance
.left_column{:style => "width:26%"}
.box_title
%h2=h @orderGroup.name
%h2=h @ordergroup.name
.column_content
%table
%tr
%td= _('Account balance')
%td{:class => "currency", :style => "width:5em"}= number_to_currency(@orderGroup.account_balance)
%td Kontostand:
%td{:class => "currency", :style => "width:5em"}= number_to_currency(@ordergroup.account_balance)
%tr
%td= "- " + _('Current orders')
%td{:class => "currency"}= number_to_currency(@currentOrdersValue)
%td - laufende Bestellungen:
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_open_orders)
%tr
%td= "- " +_('Unrecorded orders')
%td{:class => "currency"}= number_to_currency(@nonbookedOrdersValue)
%td - nicht abgerechnete Bestellungen:
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_finished_orders)
%tr
%th= _('Available')
%th{:class => "currency"}= number_to_currency(@orderGroup.account_balance - @currentOrdersValue - @nonbookedOrdersValue)
%th verfügbares Guthaben:
%th{:class => "currency"}= number_to_currency(@ordergroup.get_available_funds)
.right_column{:style => "width:70%"}
// Current Orders
- if @orderGroup
= render :partial => "currentOrders"
// open orders
= render :partial => "open_orders"
// finished, nonbooked Orders
- unless @finishedOrders.empty?
// finished orders
- unless Order.finished.empty?
.box_title
%h2= _('unrecorded orders')
%h2 Nicht abgerechnete Bestellungen
.column_content
= render :partial => "finishedOrders"
- if @nonbookedOrdersValue > 0
= render :partial => "orders", :locals => {:orders => Order.finished}
- if @ordergroup.value_of_finished_orders > 0
%p
= _('total order value')
%b= number_to_currency(@nonbookedOrdersValue)
Gesamtsumme:
%b= number_to_currency(@ordergroup.value_of_finished_orders)
// bookedOrders
- unless @bookedOrders.empty?
// closed orders
- unless Order.closed.empty?
.box_title
%h2= _('balanced orders')
%h2 Abgerechnete Bestellungen
.column_content
= render :partial => "bookedOrders"
= render :partial => "orders", :locals => {:orders => Order.closed.all(:limit => 5)}
%br/
= link_to _('more...'), :action => "myOrders"
= link_to "mehr...", :action => "myOrders"

View file

@ -1,27 +1,17 @@
%h1
=_ "Orders of"
= @orderGroup.name
- title "Bestellungen der #{@ordergroup.name}"
%p
%i
=_ "See current orders in"
= link_to _("Overview"), :action => "index"
%p
%i{:style => "float:left"}=_ "Also show orders, your ordergroup haven't participated:"
- form_tag({:action => "myOrders"}, :method => "get") do
-unless @show_all
%input{:type => "checkbox", :name => :show_all, :value => "1", :onclick => "submit();"}
-else
%input{:type => "checkbox", :name => :show_all, :value => "0", :checked => "checked", :onclick => "submit();"}
Siehe hier alle
= link_to "laufenden Bestellungen.", :action => "index"
.single_column{:style => "width:50em"}
.box_title
%h2=_ "finished/not balanced"
%h2 beendet/nicht abgerechnet
.column_content
= render :partial => "finishedOrders"
= render :partial => "orders", :locals => {:orders => Order.finished}
.single_column{:style => "width:50em"}
.box_title
%h2=_ "balanced"
%h2 abgerechnet
.column_content
#bookedOrders
= render :partial => "bookedOrders"
#closed_orders
= render :partial => "orders", :locals => {:orders => @closed_orders}

View file

@ -1,86 +1,126 @@
%h1= _("Your result for") + " #{@order.name}"
- title "Dein Bestellergebnis für #{@order.supplier.name}"
#element_navigation
= link_to_unless @order.previous == @order, _("Previous order"), :action => "my_order_result", :id => @order.previous
= link_to_unless @order.previous == @order, "<< #{@order.previous.supplier.name}", :action => "my_order_result", :id => @order.previous
|
= link_to _("Overview"), :controller => 'ordering'
|
= link_to_unless @order.next == @order, _("Next order"), :action => "my_order_result", :id => @order.next
= link_to_unless @order.next == @order, "#{@order.next.supplier.name} >>", :action => "my_order_result", :id => @order.next
// Order summary
.left_column{:style => "width:45em"}
.box_title
%h2=_ "Summary"
%h2 Zusammenfassung
.column_content
%table
%tr{:valign => "top"}
%td{:style => "width:50%"}
%p
= _("Name") + ":"
%b=h @order.name
|
= _("Supplier") + ":"
%b=h @order.supplier ? @order.supplier.name : _("nonexistent")
Lieferant:
%b=h @order.supplier.name
- unless @order.note.empty?
%p
= _("Note") + ":"
Notiz:
=h @order.note
%p
= _("End") + ":"
Ende:
%b=h format_time(@order.ends)
%p
= _("Order value") + ":"
- if @order_value
%b=h number_to_currency(@order_value)
Bestellsumme:
- if @group_order
%b=h number_to_currency(@group_order.price)
- else
%b --
%b Du hast nicht bestellt.
%p
- if @finished
= @order.booked ? _("Cleared by") + " #{@order.updated_by.nick}" : "<b>" + _("Order isn't balanced yet") + "</b>"
= link_to _("read/add comments"), "#comments"
= "Abgerechnet von #{@order.updated_by.nick}" if @order.finished?
= "<b>Bestellung</b>" if @order.closed?
= link_to "Kommentare lesen/schreiben", "#comments"
// directly switch to active orders
.right_column{:style => "width:23em;"}
.box_title
%h2= _("Running orders")
%h2 Laufende Bestellungen
.column_content
%table
- @current_orders.each do |order|
- for order in Order.open
%tr
%td= link_to order.name, :action => 'order', :id => order
%td= "("+ time_ago_in_words(order.ends) + ")" if @order.ends
%td= link_to order.supplier.name, :action => 'order', :id => order
%td= "("+ time_ago_in_words(order.ends) + ")" if order.ends
// Article box
// Article box
.single_column{:style => "clear:both; width:70em;"}
.box_title
%h2=_ "Overview of articles"
%h2 Artikelübersicht
.column_content#result
- if @finished
// order is finished, show results ...
- unless @groupOrderResult.nil?
= render :partial => "finished_order_result"
- else
=_ "You haven't ordered"
- if @group_order
%p= link_to("Bestellung ändern", :action => "order", :id => @order) if @order.open?
%table.list
%thead
%tr
%th{:style => "width:40%"} Name
%th Gebinde
%th Einzelpreis
%th
%abbr{:title => "Menge + Toleranz"} Bestellt
%th
%abbr{:title => "Unter Berücksichtigung der anderen Gruppen"} Zugeteilt
%th Gesamtpreis
%tbody
- total = 0 #set counter for order-sum
- for category_name, order_articles in @order.get_articles
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left;"}=h category_name
%td{:colspan => "9"}
- for oa in order_articles
- # get the order-results for the ordergroup
- goa = oa.group_order_articles.first :conditions => {:group_order_id => @group_order.id}
- if goa
- quantity = goa.quantity
- tolerance = goa.tolerance
- result = goa.orderResult[:quantity] + goa.orderResult[:tolerance]
- sub_total = oa.price.fc_price * (quantity + tolerance)
- else
- quantity, tolerance, result, sub_total = 0, 0, 0, 0
- total += sub_total
- # give the article different colors, dependent on order-result
- style = "grey"
- if (quantity > 0)
- style = result > 0 ? 'green' : 'red'
%tr{:class => cycle('even', 'odd', :name => 'articles'), :style => "color:#{style}"}
%td{:style => "width:40%"}
=h oa.article.name
- unless oa.article.note.empty?
= image_tag("lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{oa.id}').show();", :onmouseout => "$('note_#{oa.id}').hide();"})
%td= "#{oa.price.unit_quantity} x #{oa.article.unit}"
%td= number_to_currency(oa.price.fc_price)
%td
= quantity
= "+ #{tolerance}" if oa.price.unit_quantity > 1
%td= result > 0 ? result : "0"
%td= number_to_currency(sub_total)
- unless oa.article.note.empty?
%tr{:id => "note_#{oa.id}", :class => "note even", :style => "display:none"}
%td{:colspan => "6"}=h oa.article.note
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "5"} Summe
%th= number_to_currency(total)
%br/
= link_to_top
- else
// order isn't finished yet, show ordered articles
- if @group_order
%p= link_to("Bestellung ändern", :action => "order", :id => @order) if @order.current?
= render :partial => 'unfinished_order_result'
%br/
= link_to_top
- else
= _("You haven't ordered yet.")
= link_to _("Order now"), :action => "order", :id => @order
Du hast noch nicht bestellt.
= link_to "Das ist Deine Chance!", :action => "order", :id => @order
// Comments box
- if @finished
.single_column{:style => "width:70em;"}
.box_title
%h2=_ "Comments"
.column_content#comments
= render :partial => 'shared/comments'
.single_column{:style => "width:70em;"}
.box_title
%h2=_ "Comments"
.column_content#comments
= render :partial => 'shared/comments', :locals => { :comments => @order.comments }
%p
- form_for :comment, :url => { :action => :add_comment, :id => @order } do |form|
%p
= link_to_remote _("New comment"), :url => {:action => 'newComment', :id => @order}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
#newComment
= link_to_top
%b Neuen Kommentar hinzufügen:
%br/
= form.text_area :text, :cols => 50, :rows => 6
%br/
= submit_tag "Kommentar hinzufügen"
= link_to_top

View file

@ -1,7 +1,7 @@
<h1>Bestellen</h1>
<div class="left_column" style="width:49em">
<div class="box_title"><h2><%=h @order.name %></h2></div>
<div class="box_title"><h2><%=h @order.supplier.name %></h2></div>
<div class="column_content">
<table>
<tr valign="top">
@ -28,7 +28,7 @@
<% end %>
<p>
<b><%=_ "Order quanitity so far" %>:</b>
<%= number_to_currency @order.sumPrice %>
<%= number_to_currency @order.sum %>
</p>
</td>
</tr>
@ -46,7 +46,7 @@
<% for order in @other_orders -%>
<tr>
<td>
<%= link_to_function order.name, "if (confirmSwitchOrder()) (window.location = '#{ url_for(:action => 'order', :id => order) }' )" %>
<%= link_to_function order.supplier.name, "if (confirmSwitchOrder()) (window.location = '#{ url_for(:action => 'order', :id => order) }' )" %>
</td>
<td>noch <%= time_ago_in_words(order.ends) if order.ends -%></td>
</tr>
@ -125,7 +125,7 @@
<%= button_to_function('-', "decreaseTolerance(#{i})") %>
<% end -%>
</td>
<td id="td_price_<%= i %>" style="text-align:right; padding-right:10px; width:4em"><span id="price_<%= i %>_display"><%= number_to_currency(article_total, :unit => "") %></span> <%= L18n.number.currency.format.unit %></td>
<td id="td_price_<%= i %>" style="text-align:right; padding-right:10px; width:4em"><span id="price_<%= i %>_display"><%= number_to_currency(article_total, :unit => "") %></span> </td>
</tr>
<% unless order_article.article.note.empty? -%>
<tr id="note_<%= i %>" class="note" style="display:none">
@ -139,7 +139,7 @@
<tfoot>
<tr>
<td colspan="6"></td>
<td colspan="3" class="currency"><%=_ "Total amount" %>: <span id="total_price"><%= total %></span> <%= L18n.number.currency.format.unit %></td>
<td colspan="3" class="currency"><%=_ "Total amount" %>: <span id="total_price"><%= total %></span> </td>
</tr>
<tr>
<td colspan="6"></td>
@ -147,7 +147,7 @@
</tr>
<tr>
<td colspan="6"></td>
<td colspan="3" class="currency"><%=_ "New account balance"%>: <strong><span id="new_balance"><%= @ordergroup.account_balance - total %></span> <%= L18n.number.currency.format.unit %></strong></td>
<td colspan="3" class="currency"><%=_ "New account balance"%>: <strong><span id="new_balance"><%= @ordergroup.account_balance - total %></span> </strong></td>
</tr>
<tr>
<td style="text-align:left;"><%= link_to_top %></td>
@ -171,7 +171,7 @@
setGroupBalance(<%= @availableFunds %>);
// localization
setDecimalSeparator("<%= L18n.number.currency.format.separator %>");
setDecimalSeparator(",");
// initialize javascript
updateBalance();