Introduced group_order_article.result to save the result for each group/article.

This commit is contained in:
Benjamin Meichsner 2009-02-04 16:41:01 +01:00
parent 6fd5d825f9
commit 251ced4fa1
27 changed files with 106 additions and 137 deletions

View file

@ -15,7 +15,7 @@
(Einheit:
= group_order_article.order_article.article.unit
)
= form.text_field :quantity, :size => "6"
= form.text_field :result, :size => "6"
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -16,5 +16,5 @@
%th Pfand
%th{:colspan => "2"}
%tbody#result_table
- for order_article in @order.order_articles.all(:include => [:article, :article_price])
- for order_article in @order.order_articles.ordered.all(:include => [:article, :article_price])
= render :partial => "order_article_result", :locals => {:order_article => order_article}

View file

@ -15,7 +15,7 @@
%td{:style=>"width:50%"}
= group_order_article.group_order.ordergroup.name
%td{:id => "group_order_article_#{group_order_article.id}_quantity"}
= group_order_article.quantity
= group_order_article.result
%td.currency
= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.quantity, :unit => "")
%td.actions{:style=>"width:1em"}

View file

@ -6,11 +6,11 @@
= form.error_messages
%p
Gruppe:
= form.select :ordergroup_id, Ordergroup.all(:order => "name").collect {|og| [og.name, og.id] }
= form.select :ordergroup_id, Ordergroup.all(:order => "name").collect{ |og| [og.name, og.id] }
%p
Menge:
= form.text_field "quantity", :size => 5
= form.hidden_field "order_article_id"
= form.text_field :result, :size => 5
= form.hidden_field :order_article_id
%p
= submit_tag "Speichern"
|

View file

@ -3,7 +3,10 @@
"Element.toggle('group_order_articles_#{order_article.id}'); |
Element.toggleClassName(this.up('td'), 'open')" |
%td= order_article.article.order_number
%td= order_article.units_to_order
%td
= order_article.units_to_order
- unless order_article.ordered_quantities_equal_to_group_orders?
%span{:style => "color:red;font-weight: bold"} !
%td= order_article.price.unit_quantity.to_s + ' * ' + order_article.article.unit.to_s
%td= number_to_currency(order_article.price.price, :unit => "")
%td= number_to_currency(order_article.price.fc_price, :unit => "")

View file

@ -62,11 +62,11 @@
%th
%abbr{:title => "Menge + Toleranz"} Bestellt
%th
%abbr{:title => "Unter Berücksichtigung der anderen Gruppen"} Zugeteilt
%abbr{:title => "Unter Berücksichtigung der anderen Gruppen"} Bekommen
%th Gesamtpreis
%tbody
- total = 0 #set counter for order-sum
- for category_name, order_articles in @order.get_articles
- for category_name, order_articles in @order.articles_grouped_by_category
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left;"}=h category_name
%td{:colspan => "9"}
@ -76,8 +76,11 @@
- if goa
- quantity = goa.quantity
- tolerance = goa.tolerance
- result = goa.result[:total]
- sub_total = oa.price.fc_price * (quantity + tolerance)
- result = goa.result
- if @order.open?
- sub_total = oa.price.fc_price * (quantity + tolerance)
- else
- sub_total = oa.price.fc_price * result
- else
- quantity, tolerance, result, sub_total = 0, 0, 0, 0
- total += sub_total

View file

@ -82,7 +82,7 @@
<%-
total = 0
i = 0
@articles_by_category.each do |category, order_articles|
@articles_grouped_by_category.each do |category, order_articles|
-%>
<tr style="background-color:#EFEFEF">
<td style="text-align:left"><b><%=h category %></b></td>

View file

@ -6,7 +6,7 @@
%th Bestellte Einheiten
%th Volle Gebinde
- total_net, total_gross, counter = 0, 0, 0
- order.get_articles.each do |category_name, order_articles|
- order.articles_grouped_by_category.each do |category_name, order_articles|
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left; color: grey;"}=h category_name
%td{:colspan => "9"}

View file

@ -31,7 +31,7 @@
%option{:value => "-1", :selected => "selected"}=_ "Choose an order..."
- i = -1
- for order in @template_orders
%option{:value => (i += 1)}=h order.supplier.name
%option{:value => (i += 1)}= "#{h(order.supplier.name)} bis #{order.ends.strftime('%d. %b')}"
%table.list
%tr
%th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
@ -41,11 +41,11 @@
%th=_ "Manufacturer"
%th=_ "Unit quantity"
%th=_ "Price"
- for category, articles in Article.group_by_category(@order.supplier.getArticlesAvailableForOrdering)
- for category_name, articles in @order.supplier.get_articles_for_ordering
%tr{:style => "background-color:#EFEFEF"}
%td
%td{:colspan => "6", :style => "text-align:left"}
%b=h category
%b=h category_name
- for article in articles
/ check if the article is selected
- included = @order.order_articles.detect { |order_article| order_article.article_id == article.id }

View file

@ -1,18 +1,20 @@
<script type="text/javascript">
//<![CDATA[
// Preset selected order articles per template order:
var template = new Array();
var template = new Array();
<% current_article_ids = @order.supplier.articles.available.map(&:id) -%>
<% i = -1; for order in @template_orders -%>
template[<%= i += 1 %>] = new Array(<%= @order.supplier.getArticlesAvailableForOrdering.collect{|a| !order.order_article_results.detect{|t| t.name == a.name }.nil?}.join(', ') %>);
template[<%= i += 1 %>] = new Array(<%= current_article_ids.collect { |id| order.article_ids.include?(id) }.join(', ') %>);
<% end -%>
// Call with index into template-array to select order articles from template.
function useTemplate(id) {
if (id >= 0 && id < template.length) {
<% i = -1; for article in @order.supplier.getArticlesAvailableForOrdering -%>
var status = template[id][<%= i += 1 %>]
$('checkbox_<%= article.id %>').checked = status;
highlightRow('<%= article.id %>',status);
<% end -%>}
}
<% i = -1; for article_id in current_article_ids -%>
var status = template[id][<%= i += 1 %>]
$('checkbox_<%= article_id %>').checked = status;
highlightRow('<%= article_id %>',status);
<% end -%>
}
}
//]]>
</script>

View file

@ -20,8 +20,8 @@ for order_article in @order.order_articles.ordered
data = []
for goa in order_article.group_order_articles
data << [goa.group_order.ordergroup.name,
goa.quantity,
number_with_precision(order_article.price.fc_price * goa.quantity)]
goa.result,
number_with_precision(order_article.price.fc_price * goa.result)]
end
pdf.table data,

View file

@ -24,11 +24,10 @@ for group_order in @order.group_orders
data = []
group_order.group_order_articles.ordered.each do |goa|
price = goa.order_article.price.fc_price
quantity = goa.quantity
sub_total = price * quantity
sub_total = price * goa.result
total += sub_total
data << [goa.order_article.article.name,
quantity, number_with_precision(price),
goa.result, number_with_precision(price),
goa.order_article.price.unit_quantity,
goa.order_article.article.unit,
number_with_precision(sub_total)]

View file

@ -59,7 +59,7 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
for order_article in current_order_articles
# get the Ordergroup result for this order_article
goa = order_article.group_order_articles.first :conditions => { :group_order_id => group_order.id }
group_result << ((goa.nil? || goa == 0) ? "" : goa.quantity.to_i)
group_result << ((goa.nil? || goa == 0) ? "" : goa.result.to_i)
end
groups_data << group_result
end

View file

@ -4,7 +4,7 @@
%th{:colspan => '3'} Legende
%tr
%th{:style => 'width:70%'} Bestellgruppe
%th Bestellt
%th Bestellt (Menge + Toleranz)
%th Bekommen
%th Gesamtpreis
@ -19,8 +19,8 @@
- for goa in order_article.group_order_articles
%tr{:class => cycle('even', 'odd', :name => 'groups')}
%td{:style => "width:70%"}=h goa.group_order.ordergroup.name
%td= "#{goa.quantity} (#{goa.tolerance})"
%td= "#{goa.quantity} + #{goa.tolerance}"
%td
%b= "#{goa.quantity_result} + #{goa.tolerance_result}"
%td= number_to_currency(order_article.price.fc_price * goa.quantity)
%b= goa.result
%td= number_to_currency(order_article.price.fc_price * goa.result)
- reset_cycle('groups')

View file

@ -3,7 +3,7 @@
%tr
%th{:style => "width:40%"} Name
%th
%acronym{:title => "zugeteilte Einheiten (davon aus Toleranzmenge)"} Menge
%acronym{:title => "zugeteilte Einheiten"} Menge
%th
%acronym{:title => "Preis incl. MwSt, Pfand und Foodcoop-Aufschlag"} FC-Preis
%th
@ -20,11 +20,11 @@
- total = 0
- for goa in group_order.group_order_articles.ordered.all(:include => :order_article)
- fc_price = goa.order_article.price.fc_price
- subTotal = fc_price * goa.quantity
- subTotal = fc_price * goa.result
- total += subTotal
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%td{:style => "width:40%"}=h goa.order_article.article.name
%td= "#{goa.result[:quantity]} (#{goa.result[:tolerance]})"
%td= goa.result
%td= number_to_currency(fc_price)
%td= goa.order_article.price.unit_quantity
%td= goa.order_article.article.unit