ffc-pay-schemes 1.0.7 → 1.0.9

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.
Files changed (66) hide show
  1. package/README.md +3 -1
  2. package/app/get-schemes.js +3 -1
  3. package/app/is-valid-scheme-id.js +10 -0
  4. package/index.js +2 -0
  5. package/package.json +1 -1
  6. package/test/unit/get-schemes.test.js +5 -2
  7. package/test/unit/is-valid-scheme-id.test.js +21 -0
  8. package/test-output/cobertura-coverage.xml +20 -3
  9. package/test-output/junit.xml +300 -260
  10. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
  11. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
  12. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
  13. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
  14. package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
  15. package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
  16. package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
  17. package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +1 -1
  18. package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +1 -1
  19. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +1 -1
  20. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +2 -2
  21. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
  22. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
  23. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
  24. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +1 -1
  25. package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
  26. package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +1 -1
  27. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
  28. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
  29. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
  30. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  31. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
  32. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
  33. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
  34. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
  35. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
  36. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  37. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
  38. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
  39. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
  40. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
  41. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
  42. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
  43. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
  44. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
  45. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
  46. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
  47. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
  48. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
  49. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +1 -1
  50. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-pillar.js.html +1 -1
  51. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-source-system.js.html +1 -1
  52. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-ids.js.html +1 -1
  53. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-name-from-scheme-id.js.html +1 -1
  54. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-names.js.html +1 -1
  55. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +1 -1
  56. package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +10 -4
  57. package/test-output/lcov-report/ffc-pay-schemes/app/get-source-system-from-scheme-id.js.html +1 -1
  58. package/test-output/lcov-report/ffc-pay-schemes/app/get-source-systems.js.html +1 -1
  59. package/test-output/lcov-report/ffc-pay-schemes/app/index.html +19 -4
  60. package/test-output/lcov-report/ffc-pay-schemes/app/is-valid-scheme-id.js.html +115 -0
  61. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +1 -1
  62. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.html +1 -1
  63. package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
  64. package/test-output/lcov-report/ffc-pay-schemes/index.js.html +10 -4
  65. package/test-output/lcov-report/index.html +11 -11
  66. package/test-output/lcov.info +20 -3
package/README.md CHANGED
@@ -27,6 +27,7 @@ const {
27
27
  getSchemes,
28
28
  getSourceSystemFromSchemeId,
29
29
  getSourceSystems,
30
+ isValidSchemeId,
30
31
  schemeDoesNotRequirePPAs,
31
32
  schemeProvidesAccountingValues
32
33
  } = require('ffc-pay-schemes')
@@ -42,9 +43,10 @@ const {
42
43
  - `getSchemeNameFromSchemeId(schemeId)` returns the scheme name for a given `schemeId`.
43
44
  - `getSchemeNames()` returns all supported scheme names.
44
45
  - `getSchemeProperties(schemeId, sourceSystem, pillar)` returns the default payment properties for a scheme. A scheme can be identified by its ID or source system. The optional `pillar` can be used for manual payments.
45
- - `getSchemes()` returns all supported schemes as an array of objects containing `schemeId`, `schemeName` and `sourceSystem`.
46
+ - `getSchemes()` returns all supported schemes as an array of objects containing `schemeId`, `schemeName`, `sourceSystem` and `pillar`.
46
47
  - `getSourceSystemFromSchemeId(schemeId)` returns the source system name for a given `schemeId`.
47
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.
48
50
  - `schemeDoesNotRequirePPAs(schemeId)` returns `true` if Payment Hub does not support Post Payment Adjustments (PPAs) for a given `schemeId`; otherwise, it returns `false`.
49
51
  - `schemeProvidesAccountingValues(schemeId)` returns `true` if a given `schemeId` provides accounting values within its payment requests; otherwise, it returns `false`.
50
52
 
@@ -1,3 +1,4 @@
1
+ const pillars = require('./constants/pillars')
1
2
  const schemeIds = require('./constants/scheme-ids')
2
3
  const schemeNames = require('./constants/scheme-names')
3
4
  const sourceSystems = require('./constants/source-systems')
@@ -6,7 +7,8 @@ const getSchemes = () =>
6
7
  Object.keys(schemeIds).map((schemeKey) => ({
7
8
  schemeId: schemeIds[schemeKey],
8
9
  schemeName: schemeNames[schemeKey],
9
- sourceSystem: sourceSystems[schemeKey]
10
+ sourceSystem: sourceSystems[schemeKey],
11
+ pillar: pillars[schemeKey]
10
12
  }))
11
13
 
12
14
  module.exports = {
@@ -0,0 +1,10 @@
1
+ const schemeIds = require('./constants/scheme-ids')
2
+
3
+ const isValidSchemeId = (schemeId) => {
4
+ const numericSchemeId = Number(schemeId)
5
+ return Object.values(schemeIds).includes(numericSchemeId)
6
+ }
7
+
8
+ module.exports = {
9
+ isValidSchemeId
10
+ }
package/index.js CHANGED
@@ -11,6 +11,7 @@ const { getSchemeProperties } = require('./app/get-scheme-properties')
11
11
  const { getSchemes } = require('./app/get-schemes')
12
12
  const { getSourceSystemFromSchemeId } = require('./app/get-source-system-from-scheme-id')
13
13
  const { getSourceSystems } = require('./app/get-source-systems')
14
+ const { isValidSchemeId } = require('./app/is-valid-scheme-id')
14
15
  const { schemeDoesNotRequirePPAs } = require('./app/scheme-does-not-require-ppas')
15
16
  const { schemeProvidesAccountingValues } = require('./app/scheme-provides-accounting-values')
16
17
 
@@ -28,6 +29,7 @@ module.exports = {
28
29
  getSchemes,
29
30
  getSourceSystemFromSchemeId,
30
31
  getSourceSystems,
32
+ isValidSchemeId,
31
33
  schemeDoesNotRequirePPAs,
32
34
  schemeProvidesAccountingValues
33
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-schemes",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Module for defining and providing details for the payment schemes supported by the Payment Hub.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  const { getSchemes } = require('../../app/get-schemes')
2
+ const pillars = require('../../app/constants/pillars')
2
3
  const schemeIds = require('../../app/constants/scheme-ids')
3
4
  const schemeNames = require('../../app/constants/scheme-names')
4
5
  const sourceSystems = require('../../app/constants/source-systems')
@@ -9,7 +10,8 @@ describe('getSchemes', () => {
9
10
  Object.keys(schemeIds).map((schemeKey) => ({
10
11
  schemeId: schemeIds[schemeKey],
11
12
  schemeName: schemeNames[schemeKey],
12
- sourceSystem: sourceSystems[schemeKey]
13
+ sourceSystem: sourceSystems[schemeKey],
14
+ pillar: pillars[schemeKey]
13
15
  }))
14
16
  )
15
17
  })
@@ -20,7 +22,8 @@ describe('getSchemes', () => {
20
22
  expect(getSchemes()).toContainEqual({
21
23
  schemeId: schemeIds[schemeKey],
22
24
  schemeName: schemeNames[schemeKey],
23
- sourceSystem: sourceSystems[schemeKey]
25
+ sourceSystem: sourceSystems[schemeKey],
26
+ pillar: pillars[schemeKey]
24
27
  })
25
28
  }
26
29
  )
@@ -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="243" lines-covered="227" line-rate="0.9340999999999999" branches-valid="54" branches-covered="54" branch-rate="1" timestamp="1788362739771" complexity="0" version="0.1">
3
+ <coverage lines-valid="249" lines-covered="232" line-rate="0.9317" branches-valid="54" branches-covered="54" branch-rate="1" timestamp="1788437541242" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/home/samplackett/ffc-pay-schemes</source>
6
6
  </sources>
@@ -26,7 +26,8 @@
26
26
  <line number="13" hits="0" branch="false"/>
27
27
  <line number="14" hits="0" branch="false"/>
28
28
  <line number="15" hits="0" branch="false"/>
29
- <line number="17" hits="0" branch="false"/>
29
+ <line number="16" hits="0" branch="false"/>
30
+ <line number="18" hits="0" branch="false"/>
30
31
  </lines>
31
32
  </class>
32
33
  </classes>
@@ -246,6 +247,22 @@
246
247
  <line number="7" hits="1" branch="false"/>
247
248
  </lines>
248
249
  </class>
250
+ <class name="is-valid-scheme-id.js" filename="app/is-valid-scheme-id.js" line-rate="1" branch-rate="1">
251
+ <methods>
252
+ <method name="(anonymous_0)" hits="19" signature="()V">
253
+ <lines>
254
+ <line number="3" hits="19"/>
255
+ </lines>
256
+ </method>
257
+ </methods>
258
+ <lines>
259
+ <line number="1" hits="1" branch="false"/>
260
+ <line number="3" hits="1" branch="false"/>
261
+ <line number="4" hits="19" branch="false"/>
262
+ <line number="5" hits="19" branch="false"/>
263
+ <line number="8" hits="1" branch="false"/>
264
+ </lines>
265
+ </class>
249
266
  <class name="scheme-does-not-require-ppas.js" filename="app/scheme-does-not-require-ppas.js" line-rate="1" branch-rate="1">
250
267
  <methods>
251
268
  <method name="(anonymous_0)" hits="18" signature="()V">
@@ -320,7 +337,7 @@
320
337
  <methods>
321
338
  </methods>
322
339
  <lines>
323
- <line number="1" hits="9" branch="false"/>
340
+ <line number="1" hits="10" branch="false"/>
324
341
  </lines>
325
342
  </class>
326
343
  <class name="scheme-names.js" filename="app/constants/scheme-names.js" line-rate="1" branch-rate="1">