wip
This commit is contained in:
parent
b808f83931
commit
32547e495f
2 changed files with 13 additions and 5 deletions
|
@ -63,7 +63,10 @@ class GroupOrder < ApplicationRecord
|
||||||
# add counts from the previous group order
|
# add counts from the previous group order
|
||||||
if previous_group_order
|
if previous_group_order
|
||||||
previous_group_order.group_order_articles.each do |goa|
|
previous_group_order.group_order_articles.each do |goa|
|
||||||
order_article_id = OrderArticle.find_by!(order: order, article: goa.order_article.article)&.id
|
order_article_id = OrderArticle.find_by(order: order, article: goa.order_article.article)&.id
|
||||||
|
puts " order ID: #{order.id}"
|
||||||
|
puts " article ID: #{goa.order_article.article.id}"
|
||||||
|
puts "ID: #{order_article_id}"
|
||||||
data[:order_articles][order_article_id] ||= {}
|
data[:order_articles][order_article_id] ||= {}
|
||||||
data[:order_articles][order_article_id][:previous_quantity] = goa.quantity
|
data[:order_articles][order_article_id][:previous_quantity] = goa.quantity
|
||||||
data[:order_articles][order_article_id][:previous_tolerance] = goa.tolerance
|
data[:order_articles][order_article_id][:previous_tolerance] = goa.tolerance
|
||||||
|
@ -76,7 +79,7 @@ class GroupOrder < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def previous_group_order
|
def previous_group_order
|
||||||
previous_order = ordergroup.orders.where.not(id: order.id).recent.first
|
previous_order = ordergroup.orders.where(supplier: order.supplier).where.not(id: order.id).recent.first
|
||||||
return nil unless previous_order
|
return nil unless previous_order
|
||||||
|
|
||||||
ordergroup.group_orders.find_by(order_id: previous_order.id)
|
ordergroup.group_orders.find_by(order_id: previous_order.id)
|
||||||
|
|
|
@ -95,7 +95,14 @@
|
||||||
%td{colspan: "9"}
|
%td{colspan: "9"}
|
||||||
- order_articles.each do |order_article|
|
- order_articles.each do |order_article|
|
||||||
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id][:missing_units])}", valign: "top"}
|
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id][:missing_units])}", valign: "top"}
|
||||||
%td.name= order_article.article.name
|
%td.name
|
||||||
|
= order_article.article.name
|
||||||
|
- if @ordering_data[:order_articles][order_article.id][:previous_quantity]
|
||||||
|
%span.label
|
||||||
|
last time:
|
||||||
|
= @ordering_data[:order_articles][order_article.id][:previous_quantity]
|
||||||
|
+
|
||||||
|
= @ordering_data[:order_articles][order_article.id][:previous_tolerance]
|
||||||
- if @order.stockit?
|
- if @order.stockit?
|
||||||
%td= truncate order_article.article.supplier.name, length: 15
|
%td= truncate order_article.article.supplier.name, length: 15
|
||||||
%td= h order_article.article.origin
|
%td= h order_article.article.origin
|
||||||
|
@ -109,8 +116,6 @@
|
||||||
|
|
||||||
%td.quantity
|
%td.quantity
|
||||||
%input{id: "q_#{order_article.id}", name: "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", type: "hidden", value: @ordering_data[:order_articles][order_article.id][:quantity], 'data-min' => (@ordering_data[:order_articles][order_article.id][:quantity] if @order.boxfill?), 'data-max' => (@ordering_data[:order_articles][order_article.id][:quantity]+@ordering_data[:order_articles][order_article.id][:missing_units] if @order.boxfill?)}/
|
%input{id: "q_#{order_article.id}", name: "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", type: "hidden", value: @ordering_data[:order_articles][order_article.id][:quantity], 'data-min' => (@ordering_data[:order_articles][order_article.id][:quantity] if @order.boxfill?), 'data-max' => (@ordering_data[:order_articles][order_article.id][:quantity]+@ordering_data[:order_articles][order_article.id][:missing_units] if @order.boxfill?)}/
|
||||||
= @ordering_data[:order_articles][order_article.id][:previous_quantity]
|
|
||||||
hello
|
|
||||||
%span.used{id: "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
|
%span.used{id: "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||||
+
|
+
|
||||||
%span.unused{id: "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
|
%span.unused{id: "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||||
|
|
Loading…
Reference in a new issue