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]));
|
||||
|
||||
// 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 = '';
|
||||
if (missing_units < 0) {
|
||||
|
||||
if (missing_units <= 0 || missing_units == unit[item]) {
|
||||
missing_units = 0;
|
||||
missing_units_css = '';
|
||||
} else if (missing_units == unit[item]) {
|
||||
missing_units = 0;
|
||||
missing_units_css = 'missing-none';
|
||||
if (units > 0) {
|
||||
missing_units_css = 'missing-none';
|
||||
} else {
|
||||
missing_units_css = '';
|
||||
}
|
||||
} else if (missing_units == 1) {
|
||||
missing_units_css = 'missing-few';
|
||||
} else {
|
||||
|
@ -148,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));
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
}
|
||||
|
||||
.list .missing-none td, .list .missing-none:hover td {
|
||||
background-color: #cff5be;
|
||||
background-color: #E4EED6;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue