show different warning signs for mismatch with ordered and received

This commit is contained in:
wvengen 2013-12-23 12:32:26 +01:00
parent a28c6031a4
commit 03bb83ecc0
2 changed files with 12 additions and 5 deletions

View file

@ -97,9 +97,16 @@ class OrderArticle < ActiveRecord::Base
units_to_order * price.unit_quantity * price.gross_price
end
def ordered_quantities_equal_to_group_orders?
# the rescue is a workaround for units_to_order not being defined in integration tests
(units_to_order * price.unit_quantity) == group_orders_sum[:quantity] rescue false
def ordered_quantities_different_from_group_orders?(ordered_mark="!", billed_mark="?", received_mark="?")
if not units_received.nil?
((units_received * price.unit_quantity) == group_orders_sum[:quantity]) ? false : received_mark
elsif not units_billed.nil?
((units_billed * price.unit_quantity) == group_orders_sum[:quantity]) ? false : billed_mark
elsif not units_to_order.nil?
((units_to_order * price.unit_quantity) == group_orders_sum[:quantity]) ? false : ordered_mark
else
nil # can happen in integration tests
end
end
# redistribute articles over ordergroups

View file

@ -4,8 +4,8 @@
%td{title: units_history_line(order_article)}
= order_article.units
%i.package pkg
- unless order_article.ordered_quantities_equal_to_group_orders?
%span{:style => "color:red;font-weight: bold"} !
- if s=order_article.ordered_quantities_different_from_group_orders?
%span{:style => "color:red;font-weight: bold"}= s
%td #{order_article.price.unit_quantity} &times; #{order_article.article.unit}
%td
= number_to_currency(order_article.price.price, :unit => "")