Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit 9c55c6c

Browse files
committed
fix: rewrite to use v2 stock count reports
BREAKING CHANGE: no longer supports v1 stock count reports Connects fielded/van-orga#934.
1 parent e048131 commit 9c55c6c

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

dist/bundle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
var stock = stockCount.stock;
119119

120120
var decoratedStock = Object.keys(stock).reduce(function (decorated, product) {
121-
var amount = stock[product];
121+
// v2 stock count report
122+
var amount = stock[product].amount;
122123
var status = void 0;
123124
var allocation = void 0;
124125
var productThresholds = void 0;

dist/bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/state-indicators.service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ class StateIndicatorsService {
103103
const stock = stockCount.stock
104104

105105
const decoratedStock = Object.keys(stock).reduce((decorated, product) => {
106-
let amount = stock[product]
106+
// v2 stock count report
107+
let amount = stock[product].amount
107108
let status
108109
let allocation
109110
let productThresholds

test/state-indicators.service.spec.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ describe('state indicators service', function () {
2727
var lgaStockCounts = [
2828
{
2929
location: { zone: 'nc', state: 'kogi', lga: 'a' },
30-
stock: { 'product:a': 1, 'product:b': 3, 'product:c': 10, 'product:d': 36 },
30+
stock: { 'product:a': { amount: 1 }, 'product:b': { amount: 3 }, 'product:c': { amount: 10 }, 'product:d': { amount: 36 } },
3131
store: { type: 'lga' }
3232
},
3333
{
3434
location: { zone: 'nc', state: 'kogi', lga: 'b' },
35-
stock: { 'product:a': 0, 'product:b': 0, 'product:c': 11, 'product:d': 30 },
35+
stock: { 'product:a': { amount: 0 }, 'product:b': { amount: 0 }, 'product:c': { amount: 11 }, 'product:d': { amount: 30 } },
3636
store: { type: 'lga' }
3737
},
3838
{
3939
location: { zone: 'nc', state: 'kogi', lga: 'c' },
40-
stock: { 'product:a': 0, 'product:b': 0, 'product:c': 0, 'product:d': 75 },
40+
stock: { 'product:a': { amount: 0 }, 'product:b': { amount: 0 }, 'product:c': { amount: 0 }, 'product:d': { amount: 75 } },
4141
store: { type: 'lga' }
4242
},
4343
{
@@ -54,23 +54,23 @@ describe('state indicators service', function () {
5454
var stateStockCounts = [
5555
{
5656
location: { zone: 'nc', state: 'kogi' },
57-
stock: { 'product:a': 0, 'product:b': 1, 'product:c': 10, 'product:d': 40 },
57+
stock: { 'product:a': { amount: 0 }, 'product:b': { amount: 1 }, 'product:c': { amount: 10 }, 'product:d': { amount: 40 } },
5858
store: { type: 'state' }
5959
}
6060
]
6161

6262
var zoneStockCounts = [
6363
{
6464
location: { zone: 'nc' },
65-
stock: { 'product:a': 0, 'product:b': 11, 'product:c': 20, 'product:d': 40 },
65+
stock: { 'product:a': { amount: 0 }, 'product:b': { amount: 11 }, 'product:c': { amount: 20 }, 'product:d': { amount: 40 } },
6666
store: { type: 'zone' }
6767
}
6868
]
6969

7070
var nationalStockCounts = [
7171
{
7272
location: { national: 'national' },
73-
stock: { 'product:a': 1, 'product:b': 3, 'product:c': 10, 'product:d': 36 },
73+
stock: { 'product:a': { amount: 1 }, 'product:b': { amount: 3 }, 'product:c': { amount: 10 }, 'product:d': { amount: 36 } },
7474
store: { type: 'national' }
7575
}
7676
]
@@ -435,7 +435,7 @@ describe('state indicators service', function () {
435435
var noRestockStateStockCounts = [
436436
{
437437
location: { zone: 'nc', state: 'kogi' },
438-
stock: { 'product:a': 5, 'product:b': 10, 'product:c': 20, 'product:d': 30 },
438+
stock: { 'product:a': { amount: 5 }, 'product:b': { amount: 10 }, 'product:c': { amount: 20 }, 'product:d': { amount: 30 } },
439439
store: { type: 'state' }
440440
}
441441
]
@@ -482,7 +482,7 @@ describe('state indicators service', function () {
482482
})
483483
var unknownLgaStockCount = {
484484
location: { zone: 'nc', state: 'kogi', lga: 'unknown' },
485-
stock: { 'product:a': 2, 'product:b': 3, 'product:c': 10, 'product:d': 20 },
485+
stock: { 'product:a': { amount: 2 }, 'product:b': { amount: 3 }, 'product:c': { amount: 10 }, 'product:d': { amount: 20 } },
486486
store: { type: 'lga' }
487487
}
488488
var expected = [
@@ -512,7 +512,7 @@ describe('state indicators service', function () {
512512
it('is true for lgas if any product is below reorder level', function (done) {
513513
var noRestockNeeded = {
514514
location: { zone: 'nc', state: 'kogi', lga: 'b' },
515-
stock: { 'product:a': 3, 'product:b': 3, 'product:c': 3, 'product:d': 3 },
515+
stock: { 'product:a': { amount: 3 }, 'product:b': { amount: 3 }, 'product:c': { amount: 3 }, 'product:d': { amount: 3 } },
516516
store: { type: 'lga' }
517517
}
518518
var stockCounts = [angular.copy(lgaStockCounts[0]), noRestockNeeded]
@@ -527,12 +527,12 @@ describe('state indicators service', function () {
527527
it('is true for states if any product is below max level', function (done) {
528528
var reStockNeeded = {
529529
location: { zone: 'nc', state: 'kogi' },
530-
stock: { 'product:a': 4, 'product:b': 9, 'product:c': 19, 'product:d': 29 },
530+
stock: { 'product:a': { amount: 4 }, 'product:b': { amount: 9 }, 'product:c': { amount: 19 }, 'product:d': { amount: 29 } },
531531
store: { type: 'state' }
532532
}
533533
var noRestockNeeded = {
534534
location: { zone: 'nc', state: 'kogi' },
535-
stock: { 'product:a': 10, 'product:b': 10, 'product:c': 20, 'product:d': 30 },
535+
stock: { 'product:a': { amount: 10 }, 'product:b': { amount: 10 }, 'product:c': { amount: 20 }, 'product:d': { amount: 30 } },
536536
store: { type: 'state' }
537537
}
538538
var stockCounts = [reStockNeeded, noRestockNeeded]
@@ -547,12 +547,12 @@ describe('state indicators service', function () {
547547
it('is true for zones if any product is below max level', function (done) {
548548
var reStockNeeded = {
549549
location: { zone: 'nc' },
550-
stock: { 'product:a': 4, 'product:b': 9, 'product:c': 19, 'product:d': 29 },
550+
stock: { 'product:a': { amount: 4 }, 'product:b': { amount: 9 }, 'product:c': { amount: 19 }, 'product:d': { amount: 29 } },
551551
store: { type: 'zone' }
552552
}
553553
var noRestockNeeded = {
554554
location: { zone: 'nc' },
555-
stock: { 'product:a': 10, 'product:b': 10, 'product:c': 20, 'product:d': 30 },
555+
stock: { 'product:a': { amount: 10 }, 'product:b': { amount: 10 }, 'product:c': { amount: 20 }, 'product:d': { amount: 30 } },
556556
store: { type: 'zone' }
557557
}
558558
var stockCounts = [reStockNeeded, noRestockNeeded]

0 commit comments

Comments
 (0)