diff --git a/dist/bundle.js b/dist/bundle.js index 3e4527a..ceb1ddf 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -133,7 +133,9 @@ var location = getLocation(lgas, states, zones, stockCount); var locationThresholds = void 0; if (location && location.level === 'zone') { - locationThresholds = _this2.thresholdsService.calculateThresholds(location, stockCount, products, requiredAllocations[location._id]); + // Temporary fix for https://github.com/fielded/nav-integrated-national-dashboard/issues/265 + // This should be removed when https://github.com/fielded/nav-etl/issues/136 is fixed + locationThresholds = _this2.thresholdsService.calculateThresholds(location, stockCount, products, requiredAllocations[location._id], { version: 'last' }); } else { locationThresholds = _this2.thresholdsService.calculateThresholds(location, stockCount, products); } diff --git a/dist/bundle.min.js b/dist/bundle.min.js index 9d641b0..7c725b7 100644 --- a/dist/bundle.min.js +++ b/dist/bundle.min.js @@ -1 +1 @@ -!function(t){"use strict";t="default"in t?t["default"]:t;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(){function t(t,e){for(var n=0;n0&&(t[n]+=e[n].allocation),t},t)},a=function(){function t(e,o,r,i,c,a,s,u){n(this,t),this.$q=e,this.smartId=o,this.STOCK_STATUSES=r,this.lgasService=i,this.statesService=c,this.zonesService=a,this.thresholdsService=s,this.productListService=u}return o(t,[{key:"stateRequiredAllocationsByZone",value:function(t){var e=this;return t.reduce(function(t,n){if(n.location&&n.location.state&&!n.location.lga&&n.reStockNeeded){var o=e.smartId.idify({zone:n.location.zone},"locationId");t[o]=t[o]||{},t[o]=c(t[o],n.stock)}return t},{})}},{key:"decorateWithIndicators",value:function(t){var n=this,o=void 0,c=void 0,a=void 0,s=void 0,u=function(t,n,o,i){var c=i.location.lga,a=i.location.state;if(c)return r(t,function(t){return t.id===c});if(a)return r(n,function(t){return t.id===a});var s=function(){var t=i.location.zone;return{v:r(o,function(e){return e.id===t})}}();return"object"===("undefined"==typeof s?"undefined":e(s))?s.v:void 0},l=function(t,e){var i=u(o,c,a,e),l=void 0;l=i&&"zone"===i.level?n.thresholdsService.calculateThresholds(i,e,s,t[i._id]):n.thresholdsService.calculateThresholds(i,e,s);var d=e.stock,f=Object.keys(d).reduce(function(t,e){var n=d[e],o=void 0,i=void 0,c=void 0,a=r(s,function(t){return t._id===e});if(l&&(c=l[e])){o="overstock",n0?u+(a.presentation-f):u}}return t[e]={status:o,amount:n,allocation:i,thresholds:c},t},{});return e.stock=f,e},d=function(t){var e=function(e,n){return t.stock[n].allocation>0&&(e+=t.stock[n].allocation),e};if(t.location&&t.location.lga){var n=i(t.stock);t.reStockNeeded=!!(n.understock.length+n["re-stock"].length)}else if(t.stock){var o=Object.keys(t.stock).reduce(e,0);t.reStockNeeded=o>0}return t},f=function(t){var e=i(t.stock).unknown.length,o=i(t.stock).understock.length;return t.location&&(t.stockLevelStatus=o>=n.STOCK_STATUSES.alert.threshold?n.STOCK_STATUSES.alert.id:o>=n.STOCK_STATUSES.warning.threshold?n.STOCK_STATUSES.warning.id:e?"unknown":n.STOCK_STATUSES.ok.id),t},v=function(t){return t.stock&&Object.keys(t.stock).length},S=function(t){return t.location&&t.location.zone&&!t.location.state},h=function(t){return!S(t)},k=function(t,e,r){return o=r.lgas,c=r.states,a=r.zones||[],s=r.products,t=t.map(l.bind(null,null)).map(d),e=e.map(l.bind(null,n.stateRequiredAllocationsByZone(t))).map(d),t.concat(e).map(f)},y={lgas:this.lgasService.list(),states:this.statesService.list(),products:this.productListService.relevant()};if(t=t.filter(v),!t.length)return this.$q.when(t);var g=t.filter(S),T=t.filter(h);return g.length&&(y.zones=this.zonesService.list()),this.$q.all(y).then(k.bind(null,T,g))}}]),t}();a.$inject=["$q","smartId","STOCK_STATUSES","lgasService","statesService","zonesService","thresholdsService","productListService"],t.module("angularNavStateIndicators",["ngSmartId","angularNavData","angularNavThresholds"]).service("stateIndicatorsService",a)}(angular); \ No newline at end of file +!function(t){"use strict";t="default"in t?t["default"]:t;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(){function t(t,e){for(var n=0;n0&&(t[n]+=e[n].allocation),t},t)},a=function(){function t(e,o,r,i,c,a,s,u){n(this,t),this.$q=e,this.smartId=o,this.STOCK_STATUSES=r,this.lgasService=i,this.statesService=c,this.zonesService=a,this.thresholdsService=s,this.productListService=u}return o(t,[{key:"stateRequiredAllocationsByZone",value:function(t){var e=this;return t.reduce(function(t,n){if(n.location&&n.location.state&&!n.location.lga&&n.reStockNeeded){var o=e.smartId.idify({zone:n.location.zone},"locationId");t[o]=t[o]||{},t[o]=c(t[o],n.stock)}return t},{})}},{key:"decorateWithIndicators",value:function(t){var n=this,o=void 0,c=void 0,a=void 0,s=void 0,u=function(t,n,o,i){var c=i.location.lga,a=i.location.state;if(c)return r(t,function(t){return t.id===c});if(a)return r(n,function(t){return t.id===a});var s=function(){var t=i.location.zone;return{v:r(o,function(e){return e.id===t})}}();return"object"===("undefined"==typeof s?"undefined":e(s))?s.v:void 0},l=function(t,e){var i=u(o,c,a,e),l=void 0;l=i&&"zone"===i.level?n.thresholdsService.calculateThresholds(i,e,s,t[i._id],{version:"last"}):n.thresholdsService.calculateThresholds(i,e,s);var d=e.stock,f=Object.keys(d).reduce(function(t,e){var n=d[e],o=void 0,i=void 0,c=void 0,a=r(s,function(t){return t._id===e});if(l&&(c=l[e])){o="overstock",n0?u+(a.presentation-f):u}}return t[e]={status:o,amount:n,allocation:i,thresholds:c},t},{});return e.stock=f,e},d=function(t){var e=function(e,n){return t.stock[n].allocation>0&&(e+=t.stock[n].allocation),e};if(t.location&&t.location.lga){var n=i(t.stock);t.reStockNeeded=!!(n.understock.length+n["re-stock"].length)}else if(t.stock){var o=Object.keys(t.stock).reduce(e,0);t.reStockNeeded=o>0}return t},f=function(t){var e=i(t.stock).unknown.length,o=i(t.stock).understock.length;return t.location&&(t.stockLevelStatus=o>=n.STOCK_STATUSES.alert.threshold?n.STOCK_STATUSES.alert.id:o>=n.STOCK_STATUSES.warning.threshold?n.STOCK_STATUSES.warning.id:e?"unknown":n.STOCK_STATUSES.ok.id),t},v=function(t){return t.stock&&Object.keys(t.stock).length},S=function(t){return t.location&&t.location.zone&&!t.location.state},h=function(t){return!S(t)},k=function(t,e,r){return o=r.lgas,c=r.states,a=r.zones||[],s=r.products,t=t.map(l.bind(null,null)).map(d),e=e.map(l.bind(null,n.stateRequiredAllocationsByZone(t))).map(d),t.concat(e).map(f)},y={lgas:this.lgasService.list(),states:this.statesService.list(),products:this.productListService.relevant()};if(t=t.filter(v),!t.length)return this.$q.when(t);var g=t.filter(S),T=t.filter(h);return g.length&&(y.zones=this.zonesService.list()),this.$q.all(y).then(k.bind(null,T,g))}}]),t}();a.$inject=["$q","smartId","STOCK_STATUSES","lgasService","statesService","zonesService","thresholdsService","productListService"],t.module("angularNavStateIndicators",["ngSmartId","angularNavData","angularNavThresholds"]).service("stateIndicatorsService",a)}(angular); \ No newline at end of file