Introduced group_order_article.result to save the result for each group/article.
This commit is contained in:
parent
6fd5d825f9
commit
251ced4fa1
27 changed files with 106 additions and 137 deletions
|
|
@ -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"}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue