| Line 1615... |
Line 1615... |
| 1615 |
* is left exactly as it was. Stock that is entirely promised is shown as zero with the orders holding it named, which
|
1615 |
* is left exactly as it was. Stock that is entirely promised is shown as zero with the orders holding it named, which
|
| 1616 |
* is what lets someone chase those orders instead of only seeing a smaller number.
|
1616 |
* is what lets someone chase those orders instead of only seeing a smaller number.
|
| 1617 |
*/
|
1617 |
*/
|
| 1618 |
function renderMovementAvailability($row, pricing) {
|
1618 |
function renderMovementAvailability($row, pricing) {
|
| 1619 |
var $icon = $row.find('.mv-avail-icon');
|
1619 |
var $icon = $row.find('.mv-avail-icon');
|
| 1620 |
if (!pricing || typeof pricing.movableOnThisPo === 'undefined') {
|
1620 |
if (!pricing || typeof pricing.movableAltogether === 'undefined') {
|
| 1621 |
$icon.hide();
|
1621 |
$icon.hide();
|
| 1622 |
$row.removeData('movableOnThisPo');
|
1622 |
$row.removeData('movableQty');
|
| 1623 |
return;
|
1623 |
return;
|
| 1624 |
}
|
1624 |
}
|
| 1625 |
|
1625 |
|
| - |
|
1626 |
// Everything that can move: stock at more than one cost is raised as one PO per cost, automatically, on create.
|
| 1626 |
var cap = pricing.movableOnThisPo;
|
1627 |
var cap = pricing.movableAltogether;
|
| 1627 |
$row.data('movableOnThisPo', cap);
|
1628 |
$row.data('movableQty', cap);
|
| 1628 |
|
1629 |
|
| 1629 |
// Reads as a sum - in stock + arriving - promised - so the number that can move is never left unexplained.
|
1630 |
// Reads as a sum - in stock + arriving - promised - so the number that can move is never left unexplained.
|
| 1630 |
var rows = mvAvailLine('In stock', pricing.inStock, '');
|
1631 |
var rows = mvAvailLine('In stock', pricing.inStock, '');
|
| 1631 |
if (pricing.arrivingTotal > 0) {
|
1632 |
if (pricing.arrivingTotal > 0) {
|
| 1632 |
rows += mvAvailLine('Arriving (not yet received)', '+ ' + pricing.arrivingTotal, '');
|
1633 |
rows += mvAvailLine('Arriving (not yet received)', '+ ' + pricing.arrivingTotal, '');
|
| Line 1640... |
Line 1641... |
| 1640 |
$.each(pricing.promised || [], function (i, po) {
|
1641 |
$.each(pricing.promised || [], function (i, po) {
|
| 1641 |
rows += mvAvailLine(mvEscape(po.poNumber) + ' · ' + mvEscape(po.poDate)
|
1642 |
rows += mvAvailLine(mvEscape(po.poNumber) + ' · ' + mvEscape(po.poDate)
|
| 1642 |
+ (po.destination ? ' → ' + mvEscape(po.destination) : ''), po.qty, ' mv-po');
|
1643 |
+ (po.destination ? ' → ' + mvEscape(po.destination) : ''), po.qty, ' mv-po');
|
| 1643 |
});
|
1644 |
});
|
| 1644 |
}
|
1645 |
}
|
| 1645 |
rows += mvAvailLine('Can move on this PO', cap, ' mv-total');
|
1646 |
rows += mvAvailLine('Can move', cap, ' mv-total');
|
| 1646 |
|
1647 |
|
| 1647 |
var note = '';
|
1648 |
var note = '';
|
| 1648 |
if (pricing.costSplit) {
|
1649 |
if (pricing.costSplit) {
|
| 1649 |
note += '<div class="mv-note">' + (pricing.movableAltogether - cap)
|
1650 |
note += '<div class="mv-note">Stock at more than one cost — this will be raised as separate POs'
|
| 1650 |
+ ' more came in at a different cost — raise a separate PO for those.</div>';
|
1651 |
+ ' automatically.</div>';
|
| 1651 |
}
|
1652 |
}
|
| 1652 |
if (cap === 0) {
|
1653 |
if (cap === 0) {
|
| 1653 |
note += '<div class="mv-note">' + (pricing.promisedTotal > 0
|
1654 |
note += '<div class="mv-note">' + (pricing.promisedTotal > 0
|
| 1654 |
? 'Nothing can move until one of the orders above is completed or closed.'
|
1655 |
? 'Nothing can move until one of the orders above is completed or closed.'
|
| 1655 |
: 'Nothing can move from here yet.') + '</div>';
|
1656 |
: 'Nothing can move from here yet.') + '</div>';
|
| Line 1679... |
Line 1680... |
| 1679 |
checkMovableQty($row, parseInt($row.find('.qty').val()));
|
1680 |
checkMovableQty($row, parseInt($row.find('.qty').val()));
|
| 1680 |
}
|
1681 |
}
|
| 1681 |
|
1682 |
|
| 1682 |
/** Flags a quantity that the order cannot take, while it is being typed rather than on submit. */
|
1683 |
/** Flags a quantity that the order cannot take, while it is being typed rather than on submit. */
|
| 1683 |
function checkMovableQty($row, qty) {
|
1684 |
function checkMovableQty($row, qty) {
|
| 1684 |
var cap = $row.data('movableOnThisPo');
|
1685 |
var cap = $row.data('movableQty');
|
| 1685 |
var $qty = $row.find('.qty');
|
1686 |
var $qty = $row.find('.qty');
|
| 1686 |
var $warn = $row.find('.mv-qty-warn');
|
1687 |
var $warn = $row.find('.mv-qty-warn');
|
| 1687 |
|
1688 |
|
| 1688 |
if (typeof cap === 'undefined' || isNaN(qty)) {
|
1689 |
if (typeof cap === 'undefined' || isNaN(qty)) {
|
| 1689 |
$qty.removeClass('mv-over');
|
1690 |
$qty.removeClass('mv-over');
|
| Line 1691... |
Line 1692... |
| 1691 |
return;
|
1692 |
return;
|
| 1692 |
}
|
1693 |
}
|
| 1693 |
|
1694 |
|
| 1694 |
if (qty > cap) {
|
1695 |
if (qty > cap) {
|
| 1695 |
$qty.addClass('mv-over');
|
1696 |
$qty.addClass('mv-over');
|
| 1696 |
$warn.text(cap === 0 ? 'None can move right now' : 'Only ' + cap + ' can move on this PO').show();
|
1697 |
$warn.text(cap === 0 ? 'None can move right now' : 'Only ' + cap + ' can move').show();
|
| 1697 |
} else {
|
1698 |
} else {
|
| 1698 |
$qty.removeClass('mv-over');
|
1699 |
$qty.removeClass('mv-over');
|
| 1699 |
$warn.hide().empty();
|
1700 |
$warn.hide().empty();
|
| 1700 |
}
|
1701 |
}
|
| 1701 |
}
|
1702 |
}
|