Merge pull request #365 from akirk/master

Add color marking to items in group orders that have missing items
This commit is contained in:
wvengen 2015-06-04 10:02:09 +02:00
commit 6ded06a8ce
5 changed files with 47 additions and 4 deletions

View file

@ -118,11 +118,27 @@ function update(item, quantity, tolerance) {
$('#price_' + item + '_display').html(I18n.l("currency", itemTotal[item]));
// update missing units
var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item])
if (missing_units < 0 || missing_units == unit[item]) {
var missing_units = calcMissingItems(unit[item], quantityOthers[item] + Number(quantity), toleranceOthers[item] + Number(tolerance)),
missing_units_css = '';
if (missing_units <= 0 || missing_units == unit[item]) {
missing_units = 0;
if (units > 0) {
missing_units_css = 'missing-none';
} else {
missing_units_css = '';
}
$('#missing_units_' + item).html(String(missing_units));
} else if (missing_units == 1) {
missing_units_css = 'missing-few';
} else {
missing_units_css = 'missing-many';
}
$('#missing_units_' + item)
.html(String(missing_units))
.closest('tr')
.removeClass('missing-many missing-few missing-none')
.addClass(missing_units_css);
// update balance
updateBalance();
@ -134,6 +150,11 @@ function calcUnits(unitSize, quantity, tolerance) {
return units + ((remainder > 0) && (remainder + tolerance >= unitSize) ? 1 : 0)
}
function calcMissingItems(unitSize, quantity, tolerance) {
var remainder = quantity % unitSize
return remainder > 0 && remainder + tolerance < unitSize ? unitSize - remainder - tolerance : 0
}
function unitCompletedFromTolerance(unitSize, quantity, tolerance) {
var remainder = quantity % unitSize
return (remainder > 0 && (remainder + tolerance >= unitSize));

View file

@ -4,5 +4,6 @@
*= require token-input-bootstrappy
*= require bootstrap-datepicker
*= require list.unlist
*= require list.missing
*= require recurring_select
*/

View file

@ -0,0 +1,11 @@
.list .missing-many td, .list .missing-many:hover td {
background-color: #ebbebe;
}
.list .missing-few td, .list .missing-few:hover td {
background-color: #ffee75;
}
.list .missing-none td, .list .missing-none:hover td {
background-color: #E4EED6;
}

View file

@ -43,4 +43,14 @@ module GroupOrdersHelper
{group_order_article: goa, quantity: quantity, tolerance: tolerance, result: result, sub_total: sub_total}
end
def get_missing_units_css_class(quantity_missing)
if ( quantity_missing == 1 )
return 'missing-few';
elsif ( quantity_missing == 0 )
return ''
else
return 'missing-many'
end
end
end

View file

@ -88,7 +88,7 @@
%i.icon-tag
%td{colspan: "9"}
- order_articles.each do |order_article|
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article", 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
- if @order.stockit?
%td= truncate order_article.article.supplier.name, length: 15