diff --git a/app/assets/javascripts/ordering.js b/app/assets/javascripts/ordering.js index 38874299..ad2e9de8 100644 --- a/app/assets/javascripts/ordering.js +++ b/app/assets/javascripts/ordering.js @@ -119,7 +119,7 @@ function update(item, quantity, tolerance) { // update missing units var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item]) - if (missing_units < 0) { + if (missing_units < 0 || missing_units == unit[item]) { missing_units = 0; } $('#missing_units_' + item).html(String(missing_units)); diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index 650d2981..e4eaa75d 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -38,6 +38,7 @@ body { // article status @articleUsedColor: green; +@articlePartusedColor: #d50; @articleUnusedColor: red; @articleUnavailColor: #999; @articleUpdatedColor: #468847; @@ -158,6 +159,9 @@ table { .unused { color: @articleUnusedColor; } +.partused { + color: @articlePartusedColor; +} #order-footer, .article-info { text-align: left; @@ -253,6 +257,7 @@ td.symbol, th.symbol { .symbol { color: tint(@textColor, @nonessentialDim); } .used .symbol { color: tint(@articleUsedColor, @nonessentialDim); } .unused .symbol { color: tint(@articleUnusedColor, @nonessentialDim); } +.partused .symbol { color: tint(@articlePartusedColor, @nonessentialDim); } .unavailable .symbol { color: @articleUnavailColor; } // hide symbols completely on small screens to save space @@ -359,6 +364,7 @@ i.package.icon-only { .package { color: tint(@textColor, @nonessentialDim); } .used .package { color: tint(@articleUsedColor, @nonessentialDim); } .unused .package { color: tint(@articleUnusedColor, @nonessentialDim); } +.partused .package { color: tint(@articlePartusedColor, @nonessentialDim); } .unavailable .package { color: @articleUnavailColor; } // very small inputs - need !important for responsive selectors diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb index 053554ac..350e3ac6 100644 --- a/app/helpers/orders_helper.rb +++ b/app/helpers/orders_helper.rb @@ -125,10 +125,14 @@ module OrdersHelper end # @param order_article [OrderArticle] - # @return [String] CSS class for +OrderArticle+ in table for admins + # @return [String] CSS class for +OrderArticle+ in table for admins (+used+, +partused+, +unused+ or +unavailable+). def order_article_class(order_article) if order_article.units > 0 - 'used' + if order_article.missing_units == 0 + 'used' + else + 'partused' + end elsif order_article.quantity > 0 'unused' else diff --git a/app/models/order_article.rb b/app/models/order_article.rb index a2e28fc5..9728ddb6 100644 --- a/app/models/order_article.rb +++ b/app/models/order_article.rb @@ -184,10 +184,11 @@ class OrderArticle < ActiveRecord::Base @update_global_price = (value == true or value == '1') ? true : false end - # Units missing for the next full unit_quantity of the article + # @return [Number] Units missing for the last +unit_quantity+ of the article. def missing_units units = article.unit_quantity - ((quantity % article.unit_quantity) + tolerance) units = 0 if units < 0 + units = 0 if units == article.unit_quantity units end