|
3 | 3 |
|
4 | 4 | angular$1 = 'default' in angular$1 ? angular$1['default'] : angular$1;
|
5 | 5 |
|
| 6 | + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { |
| 7 | + return typeof obj; |
| 8 | + } : function (obj) { |
| 9 | + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; |
| 10 | + }; |
| 11 | + |
6 | 12 | var classCallCheck = function (instance, Constructor) {
|
7 | 13 | if (!(instance instanceof Constructor)) {
|
8 | 14 | throw new TypeError("Cannot call a class as a function");
|
|
71 | 77 | key: 'calculateThresholds',
|
72 | 78 | value: function calculateThresholds(location, stockCount, products) {
|
73 | 79 | var requiredStateStoresAllocation = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
|
| 80 | + var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; |
| 81 | + |
| 82 | + if (!location || !location.allocations || !location.allocations.length || !location.plans || !location.plans.length || !location.level) { |
| 83 | + return; |
| 84 | + } |
74 | 85 |
|
75 |
| - if (!location || !location.allocations || !location.plans || !location.level) { |
| 86 | + if (!stockCount) { |
76 | 87 | return;
|
77 | 88 | }
|
78 | 89 |
|
79 |
| - if (!stockCount || !stockCount.allocations || !stockCount.allocations.version || !stockCount.plans || !stockCount.plans.version) { |
| 90 | + if (options.version !== 'last' && !(stockCount.allocations && _typeof(stockCount.allocations.version) !== undefined && stockCount.plans && _typeof(stockCount.plans.version) !== undefined)) { |
80 | 91 | return;
|
81 | 92 | }
|
82 | 93 |
|
83 | 94 | if (!products || !products.length) {
|
84 | 95 | return;
|
85 | 96 | }
|
86 | 97 |
|
87 |
| - var allocation = find(location.allocations, isVersion.bind(null, stockCount.allocations.version)); |
| 98 | + var allocation = void 0; |
| 99 | + if (options.version === 'last') { |
| 100 | + allocation = location.allocations[location.allocations.length - 1]; |
| 101 | + } else { |
| 102 | + allocation = find(location.allocations, isVersion.bind(null, stockCount.allocations.version)); |
| 103 | + } |
| 104 | + |
88 | 105 | if (!(allocation && allocation.weeklyLevels)) {
|
89 | 106 | return;
|
90 | 107 | }
|
91 | 108 |
|
92 | 109 | var weeklyLevels = allocation.weeklyLevels;
|
| 110 | + |
93 | 111 | var weeksOfStock = zonesPlan;
|
94 | 112 |
|
95 | 113 | if (location.level !== 'zone') {
|
96 |
| - var plan = find(location.plans, isVersion.bind(null, stockCount.plans.version)); |
| 114 | + var plan = void 0; |
| 115 | + if (options.version === 'last') { |
| 116 | + plan = location.plans[location.plans.length - 1]; |
| 117 | + } else { |
| 118 | + plan = find(location.plans, isVersion.bind(null, stockCount.plans.version)); |
| 119 | + } |
| 120 | + |
97 | 121 | if (!(plan && plan.weeksOfStock)) {
|
98 | 122 | return;
|
99 | 123 | }
|
|
0 commit comments