fix missing units calculation, change missing-none background color
This commit is contained in:
parent
75967bad22
commit
d9b3064c2e
2 changed files with 14 additions and 7 deletions
|
@ -118,14 +118,16 @@ function update(item, quantity, tolerance) {
|
||||||
$('#price_' + item + '_display').html(I18n.l("currency", itemTotal[item]));
|
$('#price_' + item + '_display').html(I18n.l("currency", itemTotal[item]));
|
||||||
|
|
||||||
// update missing units
|
// update missing units
|
||||||
var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item]),
|
var missing_units = calcMissingItems(unit[item], quantityOthers[item] + Number(quantity), toleranceOthers[item] + Number(tolerance)),
|
||||||
missing_units_css = '';
|
missing_units_css = '';
|
||||||
if (missing_units < 0) {
|
|
||||||
|
if (missing_units <= 0 || missing_units == unit[item]) {
|
||||||
missing_units = 0;
|
missing_units = 0;
|
||||||
missing_units_css = '';
|
if (units > 0) {
|
||||||
} else if (missing_units == unit[item]) {
|
missing_units_css = 'missing-none';
|
||||||
missing_units = 0;
|
} else {
|
||||||
missing_units_css = 'missing-none';
|
missing_units_css = '';
|
||||||
|
}
|
||||||
} else if (missing_units == 1) {
|
} else if (missing_units == 1) {
|
||||||
missing_units_css = 'missing-few';
|
missing_units_css = 'missing-few';
|
||||||
} else {
|
} else {
|
||||||
|
@ -148,6 +150,11 @@ function calcUnits(unitSize, quantity, tolerance) {
|
||||||
return units + ((remainder > 0) && (remainder + tolerance >= unitSize) ? 1 : 0)
|
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) {
|
function unitCompletedFromTolerance(unitSize, quantity, tolerance) {
|
||||||
var remainder = quantity % unitSize
|
var remainder = quantity % unitSize
|
||||||
return (remainder > 0 && (remainder + tolerance >= unitSize));
|
return (remainder > 0 && (remainder + tolerance >= unitSize));
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.list .missing-none td, .list .missing-none:hover td {
|
.list .missing-none td, .list .missing-none:hover td {
|
||||||
background-color: #cff5be;
|
background-color: #E4EED6;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue