@@ -48,12 +48,12 @@ const getFactors = (stockCount, location, options) => {
48
48
return { }
49
49
}
50
50
51
- if ( ! ( location . targetPopulation && location . targetPopulation . length ) ) {
51
+ if ( ! ( location . targetPopulations && location . targetPopulations . length ) ) {
52
52
return { }
53
53
}
54
54
const allocationsVersion = getFactorVersion ( stockCount , 'allocations' , options )
55
55
const plansVersion = getFactorVersion ( stockCount , 'plans' , options )
56
- const targetPopulationVersion = getFactorVersion ( stockCount , 'targetPopulation ' , options )
56
+ const targetPopulationVersion = getFactorVersion ( stockCount , 'targetPopulations ' , options )
57
57
58
58
if ( typeof allocationsVersion === 'undefined' ||
59
59
typeof plansVersion === 'undefined' ||
@@ -62,18 +62,18 @@ const getFactors = (stockCount, location, options) => {
62
62
return { }
63
63
}
64
64
65
- const allocation = getFactor ( location , location . allocations , allocationsVersion )
66
- const targetPopulation = getFactor ( location , location . targetPopulation , targetPopulationVersion )
65
+ const allocations = getFactor ( location , location . allocations , allocationsVersion )
66
+ const targetPopulations = getFactor ( location , location . targetPopulations , targetPopulationVersion )
67
67
68
68
let plans = zonePlans
69
69
if ( location . level !== 'zone' ) {
70
70
plans = getFactor ( location , location . plans , plansVersion )
71
71
}
72
72
73
73
return {
74
- weeklyLevels : allocation && allocation . weeklyLevels ,
74
+ weeklyLevels : allocations && allocations . weeklyLevels ,
75
75
weeksOfStock : plans && plans . weeksOfStock ,
76
- targetPopulation : targetPopulation && targetPopulation . targetPopulation
76
+ targetPopulations : targetPopulations && targetPopulations . monthlyTargetPopulations
77
77
}
78
78
}
79
79
@@ -101,9 +101,9 @@ class ThresholdsService {
101
101
return
102
102
}
103
103
104
- const { weeklyLevels, weeksOfStock, targetPopulation } = getFactors ( stockCount , location , options )
104
+ const { weeklyLevels, weeksOfStock, targetPopulations } = getFactors ( stockCount , location , options )
105
105
106
- if ( ! ( weeklyLevels && weeksOfStock && targetPopulation ) ) {
106
+ if ( ! ( weeklyLevels && weeksOfStock && targetPopulations ) ) {
107
107
return
108
108
}
109
109
@@ -130,7 +130,7 @@ class ThresholdsService {
130
130
return productThresholds
131
131
} , { } )
132
132
133
- index [ productId ] . targetPopulation = targetPopulation [ productId ]
133
+ index [ productId ] . targetPopulation = targetPopulations [ productId ]
134
134
135
135
return index
136
136
} , { } )
@@ -155,8 +155,12 @@ class ThresholdsService {
155
155
const id = this . smartId . idify ( scLocation , locationIdPattern )
156
156
const allocations = stockCount . allocations || { version : 1 }
157
157
const plans = stockCount . plans || { version : 1 }
158
- const targetPopulation = stockCount . targetPopulation || { version : 1 }
159
- index [ id ] = angular . merge ( { } , { allocations : allocations , plans : plans , targetPopulation : targetPopulation } )
158
+ const targetPopulations = stockCount . targetPopulations || { version : 1 }
159
+ index [ id ] = angular . merge ( { } , {
160
+ allocations,
161
+ plans,
162
+ targetPopulations
163
+ } )
160
164
161
165
if ( scLocation . lga ) {
162
166
if ( ! promises . lga ) {
0 commit comments