Skip to content

Commit

Permalink
Allow increasing just tolerance in the boxfill phase
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Nov 13, 2015
1 parent 9d77358 commit 90b21ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/order_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@ def update_ordergroup_prices

# Throws an exception when the changed article decreases the amount of filled boxes.
def enforce_boxfill
# Either nothing changes, or
# missing_units becomes less and the amount doesn't decrease, or
# Either nothing changes, or the tolerance increases,
# missing_units decreases and the amount doesn't decrease, or
# tolerance was moved to quantity. Only then are changes allowed in the boxfill phase.
delta_q = quantity - quantity_was
delta_t = tolerance - tolerance_was
delta_mis = missing_units - missing_units_was
delta_box = units_to_order - units_to_order_was
unless (delta_q == 0 && delta_t == 0) ||
unless (delta_q == 0 && delta_t >= 0) ||
(delta_mis < 0 && delta_box >= 0 && delta_t >= 0) ||
(delta_q > 0 && delta_q == -delta_t)
raise ActiveRecord::RecordNotSaved.new("Change not acceptable in boxfill phase, sorry.", self)
raise ActiveRecord::RecordNotSaved.new("Change not acceptable in boxfill phase for '#{article.name}', sorry.", self)
end
end

Expand Down

0 comments on commit 90b21ec

Please sign in to comment.