ffc-pay-schemes 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/app/constants/pillars.js +1 -0
- package/app/constants/schemes.js +1 -1
- package/app/get-scheme-id-from-pillar.js +10 -0
- package/app/is-valid-scheme-id.js +10 -0
- package/index.js +4 -0
- package/package.json +1 -1
- package/test/unit/get-scheme-id-from-pillar.test.js +52 -0
- package/test/unit/is-valid-scheme-id.test.js +21 -0
- package/test-output/cobertura-coverage.xml +48 -9
- package/test-output/junit.xml +334 -284
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +5 -2
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +2 -2
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +2 -2
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +2 -2
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-pillar.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-source-system.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-ids.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-name-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-names.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-source-system-from-scheme-id.js.html +5 -5
- package/test-output/lcov-report/ffc-pay-schemes/app/get-source-systems.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/index.html +38 -8
- package/test-output/lcov-report/ffc-pay-schemes/app/is-valid-scheme-id.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
- package/test-output/lcov-report/ffc-pay-schemes/index.js.html +10 -4
- package/test-output/lcov-report/index.html +13 -13
- package/test-output/lcov.info +51 -13
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
createSplitInvoiceNumber,
|
|
19
19
|
getAccountCodeMap,
|
|
20
20
|
getSchemeBatchProperties,
|
|
21
|
+
getSchemeIdFromPillar,
|
|
21
22
|
getSchemeIdFromSourceSystem,
|
|
22
23
|
getSchemeIds,
|
|
23
24
|
getSchemeNameFromSchemeId,
|
|
@@ -26,6 +27,7 @@ const {
|
|
|
26
27
|
getSchemes,
|
|
27
28
|
getSourceSystemFromSchemeId,
|
|
28
29
|
getSourceSystems,
|
|
30
|
+
isValidSchemeId,
|
|
29
31
|
schemeDoesNotRequirePPAs,
|
|
30
32
|
schemeProvidesAccountingValues
|
|
31
33
|
} = require('ffc-pay-schemes')
|
|
@@ -35,6 +37,7 @@ const {
|
|
|
35
37
|
- `createSplitInvoiceNumber(paymentRequest)` creates a split invoice number for a given `paymentRequest`.
|
|
36
38
|
- `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
|
|
37
39
|
- `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
|
|
40
|
+
- `getSchemeIdFromPillar(pillar)` returns the scheme ID for a given `pillar`.
|
|
38
41
|
- `getSchemeIdFromSourceSystem(sourceSystem)` returns the scheme ID for a given `sourceSystem`.
|
|
39
42
|
- `getSchemeIds()` returns all supported scheme IDs.
|
|
40
43
|
- `getSchemeNameFromSchemeId(schemeId)` returns the scheme name for a given `schemeId`.
|
|
@@ -43,6 +46,7 @@ const {
|
|
|
43
46
|
- `getSchemes()` returns all supported schemes as an array of objects containing `schemeId`, `schemeName` and `sourceSystem`.
|
|
44
47
|
- `getSourceSystemFromSchemeId(schemeId)` returns the source system name for a given `schemeId`.
|
|
45
48
|
- `getSourceSystems()` returns all supported source systems.
|
|
49
|
+
- `isValidSchemeId(schemeId)` returns `true` if the scheme ID is recognised, or `false` if not, including converting the scheme ID to a numeric value first if required.
|
|
46
50
|
- `schemeDoesNotRequirePPAs(schemeId)` returns `true` if Payment Hub does not support Post Payment Adjustments (PPAs) for a given `schemeId`; otherwise, it returns `false`.
|
|
47
51
|
- `schemeProvidesAccountingValues(schemeId)` returns `true` if a given `schemeId` provides accounting values within its payment requests; otherwise, it returns `false`.
|
|
48
52
|
|
package/app/constants/pillars.js
CHANGED
package/app/constants/schemes.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { getSchemes } = require('./get-schemes')
|
|
2
|
+
|
|
3
|
+
const getSchemeIdFromPillar = (pillar) => {
|
|
4
|
+
const matchingScheme = getSchemes().find((scheme) => scheme.pillar === pillar)
|
|
5
|
+
return matchingScheme?.schemeId
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
getSchemeIdFromPillar
|
|
10
|
+
}
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const { createInvoiceNumber } = require('./app/create-invoice-number')
|
|
|
2
2
|
const { createSplitInvoiceNumber } = require('./app/create-split-invoice-number')
|
|
3
3
|
const { getAccountCodeMap } = require('./app/get-account-code-map')
|
|
4
4
|
const { getSchemeBatchProperties } = require('./app/get-scheme-batch-properties')
|
|
5
|
+
const { getSchemeIdFromPillar } = require('./app/get-scheme-id-from-pillar')
|
|
5
6
|
const { getSchemeIdFromSourceSystem } = require('./app/get-scheme-id-from-source-system')
|
|
6
7
|
const { getSchemeIds } = require('./app/get-scheme-ids')
|
|
7
8
|
const { getSchemeNameFromSchemeId } = require('./app/get-scheme-name-from-scheme-id')
|
|
@@ -10,6 +11,7 @@ const { getSchemeProperties } = require('./app/get-scheme-properties')
|
|
|
10
11
|
const { getSchemes } = require('./app/get-schemes')
|
|
11
12
|
const { getSourceSystemFromSchemeId } = require('./app/get-source-system-from-scheme-id')
|
|
12
13
|
const { getSourceSystems } = require('./app/get-source-systems')
|
|
14
|
+
const { isValidSchemeId } = require('./app/is-valid-scheme-id')
|
|
13
15
|
const { schemeDoesNotRequirePPAs } = require('./app/scheme-does-not-require-ppas')
|
|
14
16
|
const { schemeProvidesAccountingValues } = require('./app/scheme-provides-accounting-values')
|
|
15
17
|
|
|
@@ -18,6 +20,7 @@ module.exports = {
|
|
|
18
20
|
createSplitInvoiceNumber,
|
|
19
21
|
getAccountCodeMap,
|
|
20
22
|
getSchemeBatchProperties,
|
|
23
|
+
getSchemeIdFromPillar,
|
|
21
24
|
getSchemeIdFromSourceSystem,
|
|
22
25
|
getSchemeIds,
|
|
23
26
|
getSchemeNameFromSchemeId,
|
|
@@ -26,6 +29,7 @@ module.exports = {
|
|
|
26
29
|
getSchemes,
|
|
27
30
|
getSourceSystemFromSchemeId,
|
|
28
31
|
getSourceSystems,
|
|
32
|
+
isValidSchemeId,
|
|
29
33
|
schemeDoesNotRequirePPAs,
|
|
30
34
|
schemeProvidesAccountingValues
|
|
31
35
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
jest.mock('../../app/get-schemes', () => ({
|
|
2
|
+
getSchemes: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { getSchemes } = require('../../app/get-schemes')
|
|
6
|
+
const { getSchemeIdFromPillar } = require('../../app/get-scheme-id-from-pillar')
|
|
7
|
+
|
|
8
|
+
describe('getSchemeIdFromPillar', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('returns the schemeId for a matching pillar', () => {
|
|
14
|
+
getSchemes.mockReturnValue([
|
|
15
|
+
{
|
|
16
|
+
schemeId: 1,
|
|
17
|
+
schemeName: 'Example Scheme',
|
|
18
|
+
sourceSystem: 'Example Source',
|
|
19
|
+
pillar: 'Example Pillar'
|
|
20
|
+
}
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
expect(getSchemeIdFromPillar('Example Pillar')).toBe(1)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('returns undefined when the pillar is not found', () => {
|
|
27
|
+
getSchemes.mockReturnValue([
|
|
28
|
+
{
|
|
29
|
+
schemeId: 1,
|
|
30
|
+
schemeName: 'Example Scheme',
|
|
31
|
+
sourceSystem: 'Example Source',
|
|
32
|
+
pillar: 'Example Pillar'
|
|
33
|
+
}
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
expect(getSchemeIdFromPillar('Not a real pillar')).toBeUndefined()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('returns undefined when no schemes are available', () => {
|
|
40
|
+
getSchemes.mockReturnValue([])
|
|
41
|
+
|
|
42
|
+
expect(getSchemeIdFromPillar('Not a real source')).toBeUndefined()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('gets schemes before searching for the pillar', () => {
|
|
46
|
+
getSchemes.mockReturnValue([])
|
|
47
|
+
|
|
48
|
+
getSchemeIdFromPillar('Not a real source')
|
|
49
|
+
|
|
50
|
+
expect(getSchemes).toHaveBeenCalledTimes(1)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const schemeIds = require('../../app/constants/scheme-ids')
|
|
2
|
+
const { isValidSchemeId } = require('../../app/is-valid-scheme-id')
|
|
3
|
+
|
|
4
|
+
describe('isValidSchemeId', () => {
|
|
5
|
+
test.each(Object.values(schemeIds))(
|
|
6
|
+
'returns true for valid scheme ID: %i',
|
|
7
|
+
(schemeId) => {
|
|
8
|
+
expect(isValidSchemeId(schemeId)).toBe(true)
|
|
9
|
+
}
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
test('returns true for a valid scheme ID with surrounding whitespace', () => {
|
|
13
|
+
expect(isValidSchemeId(` ${schemeIds.SFI} `)).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('returns false for a scheme ID not included in scheme IDs', () => {
|
|
17
|
+
const invalidSchemeId = Math.max(...Object.values(schemeIds)) + 1
|
|
18
|
+
|
|
19
|
+
expect(isValidSchemeId(invalidSchemeId)).toBe(false)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" ?>
|
|
2
2
|
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
|
|
3
|
-
<coverage lines-valid="
|
|
3
|
+
<coverage lines-valid="248" lines-covered="232" line-rate="0.9354" branches-valid="54" branches-covered="54" branch-rate="1" timestamp="1788366461643" complexity="0" version="0.1">
|
|
4
4
|
<sources>
|
|
5
5
|
<source>/home/samplackett/ffc-pay-schemes</source>
|
|
6
6
|
</sources>
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
<line number="12" hits="0" branch="false"/>
|
|
26
26
|
<line number="13" hits="0" branch="false"/>
|
|
27
27
|
<line number="14" hits="0" branch="false"/>
|
|
28
|
-
<line number="
|
|
28
|
+
<line number="15" hits="0" branch="false"/>
|
|
29
|
+
<line number="17" hits="0" branch="false"/>
|
|
29
30
|
</lines>
|
|
30
31
|
</class>
|
|
31
32
|
</classes>
|
|
@@ -52,6 +53,27 @@
|
|
|
52
53
|
<line number="7" hits="1" branch="false"/>
|
|
53
54
|
</lines>
|
|
54
55
|
</class>
|
|
56
|
+
<class name="get-scheme-id-from-pillar.js" filename="app/get-scheme-id-from-pillar.js" line-rate="1" branch-rate="1">
|
|
57
|
+
<methods>
|
|
58
|
+
<method name="(anonymous_0)" hits="4" signature="()V">
|
|
59
|
+
<lines>
|
|
60
|
+
<line number="3" hits="4"/>
|
|
61
|
+
</lines>
|
|
62
|
+
</method>
|
|
63
|
+
<method name="(anonymous_1)" hits="2" signature="()V">
|
|
64
|
+
<lines>
|
|
65
|
+
<line number="4" hits="2"/>
|
|
66
|
+
</lines>
|
|
67
|
+
</method>
|
|
68
|
+
</methods>
|
|
69
|
+
<lines>
|
|
70
|
+
<line number="1" hits="1" branch="false"/>
|
|
71
|
+
<line number="3" hits="1" branch="false"/>
|
|
72
|
+
<line number="4" hits="4" branch="false"/>
|
|
73
|
+
<line number="5" hits="4" branch="false"/>
|
|
74
|
+
<line number="8" hits="1" branch="false"/>
|
|
75
|
+
</lines>
|
|
76
|
+
</class>
|
|
55
77
|
<class name="get-scheme-id-from-source-system.js" filename="app/get-scheme-id-from-source-system.js" line-rate="1" branch-rate="1">
|
|
56
78
|
<methods>
|
|
57
79
|
<method name="(anonymous_0)" hits="4" signature="()V">
|
|
@@ -191,21 +213,22 @@
|
|
|
191
213
|
<methods>
|
|
192
214
|
<method name="(anonymous_0)" hits="4" signature="()V">
|
|
193
215
|
<lines>
|
|
194
|
-
<line number="
|
|
216
|
+
<line number="4" hits="4"/>
|
|
195
217
|
</lines>
|
|
196
218
|
</method>
|
|
197
219
|
<method name="(anonymous_1)" hits="2" signature="()V">
|
|
198
220
|
<lines>
|
|
199
|
-
<line number="
|
|
221
|
+
<line number="5" hits="2"/>
|
|
200
222
|
</lines>
|
|
201
223
|
</method>
|
|
202
224
|
</methods>
|
|
203
225
|
<lines>
|
|
204
226
|
<line number="1" hits="1" branch="false"/>
|
|
205
|
-
<line number="
|
|
206
|
-
<line number="4" hits="
|
|
227
|
+
<line number="2" hits="1" branch="false"/>
|
|
228
|
+
<line number="4" hits="1" branch="false"/>
|
|
207
229
|
<line number="5" hits="4" branch="false"/>
|
|
208
|
-
<line number="
|
|
230
|
+
<line number="6" hits="4" branch="true" condition-coverage="100% (2/2)"/>
|
|
231
|
+
<line number="9" hits="1" branch="false"/>
|
|
209
232
|
</lines>
|
|
210
233
|
</class>
|
|
211
234
|
<class name="get-source-systems.js" filename="app/get-source-systems.js" line-rate="1" branch-rate="1">
|
|
@@ -223,6 +246,22 @@
|
|
|
223
246
|
<line number="7" hits="1" branch="false"/>
|
|
224
247
|
</lines>
|
|
225
248
|
</class>
|
|
249
|
+
<class name="is-valid-scheme-id.js" filename="app/is-valid-scheme-id.js" line-rate="1" branch-rate="1">
|
|
250
|
+
<methods>
|
|
251
|
+
<method name="(anonymous_0)" hits="19" signature="()V">
|
|
252
|
+
<lines>
|
|
253
|
+
<line number="3" hits="19"/>
|
|
254
|
+
</lines>
|
|
255
|
+
</method>
|
|
256
|
+
</methods>
|
|
257
|
+
<lines>
|
|
258
|
+
<line number="1" hits="1" branch="false"/>
|
|
259
|
+
<line number="3" hits="1" branch="false"/>
|
|
260
|
+
<line number="4" hits="19" branch="false"/>
|
|
261
|
+
<line number="5" hits="19" branch="false"/>
|
|
262
|
+
<line number="8" hits="1" branch="false"/>
|
|
263
|
+
</lines>
|
|
264
|
+
</class>
|
|
226
265
|
<class name="scheme-does-not-require-ppas.js" filename="app/scheme-does-not-require-ppas.js" line-rate="1" branch-rate="1">
|
|
227
266
|
<methods>
|
|
228
267
|
<method name="(anonymous_0)" hits="18" signature="()V">
|
|
@@ -297,7 +336,7 @@
|
|
|
297
336
|
<methods>
|
|
298
337
|
</methods>
|
|
299
338
|
<lines>
|
|
300
|
-
<line number="1" hits="
|
|
339
|
+
<line number="1" hits="10" branch="false"/>
|
|
301
340
|
</lines>
|
|
302
341
|
</class>
|
|
303
342
|
<class name="scheme-names.js" filename="app/constants/scheme-names.js" line-rate="1" branch-rate="1">
|
|
@@ -346,7 +385,7 @@
|
|
|
346
385
|
<methods>
|
|
347
386
|
</methods>
|
|
348
387
|
<lines>
|
|
349
|
-
<line number="1" hits="
|
|
388
|
+
<line number="1" hits="2" branch="false"/>
|
|
350
389
|
</lines>
|
|
351
390
|
</class>
|
|
352
391
|
</classes>
|