ffc-pay-schemes 1.0.10 → 1.0.12

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 (76) hide show
  1. package/README.md +22 -0
  2. package/app/constants/siti-agri-schemes.js +3 -0
  3. package/app/create-split-invoice-number/index.js +5 -11
  4. package/app/helpers/is-siti-agri.js +9 -0
  5. package/index.js +2 -0
  6. package/package.json +1 -1
  7. package/test/unit/create-split-invoice-number/index.test.js +26 -24
  8. package/test/unit/helpers/is-siti-agri.test.js +17 -0
  9. package/test-output/cobertura-coverage.xml +20 -20
  10. package/test-output/junit.xml +341 -373
  11. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
  12. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
  13. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
  14. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
  15. package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
  16. package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
  17. package/test-output/lcov-report/ffc-pay-schemes/app/constants/frps-schemes.js.html +1 -1
  18. package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
  19. package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +1 -1
  20. package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +1 -1
  21. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +1 -1
  22. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +2 -2
  23. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
  24. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
  25. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
  26. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +1 -1
  27. package/test-output/lcov-report/ffc-pay-schemes/app/constants/siti-agri-schemes.js.html +94 -0
  28. package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
  29. package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +1 -1
  30. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
  31. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
  32. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
  33. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  34. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
  35. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
  36. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
  37. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
  38. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +5 -5
  39. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +5 -5
  40. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +3 -3
  41. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +11 -29
  42. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
  43. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
  44. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
  45. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
  46. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
  47. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
  48. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
  49. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
  50. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
  51. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
  52. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-reporting-data-filter.js.html +1 -1
  53. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/index.html +1 -1
  54. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-frps.js.html +1 -1
  55. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-siti-agri.js.html +112 -0
  56. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-valid-scheme-id.js.html +1 -1
  57. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-does-not-require-ppas.js.html +1 -1
  58. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-provides-accounting-values.js.html +1 -1
  59. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-pillar.js.html +1 -1
  60. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-source-system.js.html +1 -1
  61. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-ids.js.html +1 -1
  62. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/index.html +1 -1
  63. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-name-from-scheme-id.js.html +1 -1
  64. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-names.js.html +1 -1
  65. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/index.html +1 -1
  66. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-batch-properties.js.html +1 -1
  67. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-properties.js.html +1 -1
  68. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-schemes.js.html +1 -1
  69. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/index.html +1 -1
  70. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-system-from-scheme-id.js.html +1 -1
  71. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-systems.js.html +1 -1
  72. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/index.html +1 -1
  73. package/test-output/lcov-report/ffc-pay-schemes/index.html +1 -1
  74. package/test-output/lcov-report/ffc-pay-schemes/index.js.html +1 -1
  75. package/test-output/lcov-report/index.html +3 -3
  76. package/test-output/lcov.info +19 -24
package/README.md CHANGED
@@ -29,6 +29,7 @@ const {
29
29
  getSourceSystemFromSchemeId,
30
30
  getSourceSystems,
31
31
  isFRPS,
32
+ isSitiAgri,
32
33
  isValidSchemeId,
33
34
  schemeDoesNotRequirePPAs,
34
35
  schemeProvidesAccountingValues
@@ -50,6 +51,7 @@ const {
50
51
  - `getSourceSystemFromSchemeId(schemeId)` returns the source system name for a given `schemeId`.
51
52
  - `getSourceSystems()` returns all supported source systems.
52
53
  - `isFRPS(schemeId)` returns `true` if the scheme ID comes from FRPS, or `false` if not.
54
+ - `isSitiAgri(schemeId)` returns `true` if the scheme ID comes from Siti Agri, or `false` if not.
53
55
  - `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.
54
56
  - `schemeDoesNotRequirePPAs(schemeId)` returns `true` if Payment Hub does not support Post Payment Adjustments (PPAs) for a given `schemeId`; otherwise, it returns `false`.
55
57
  - `schemeProvidesAccountingValues(schemeId)` returns `true` if a given `schemeId` provides accounting values within its payment requests; otherwise, it returns `false`.
@@ -73,6 +75,26 @@ const doesNotRequirePPAs = schemeDoesNotRequirePPAs(schemeIds.BPS)
73
75
  const providesAccountingValues = schemeProvidesAccountingValues(schemeIds.BPS)
74
76
  ```
75
77
 
78
+ ## Payment Hub usage
79
+
80
+ The following services are intended to be used with the ffc-pay-schemes package:
81
+
82
+ - ffc-pay-alerting
83
+ - ffc-pay-batch-processor
84
+ - ffc-pay-dps
85
+ - ffc-pay-enrichment
86
+ - ffc-pay-event-hub
87
+ - ffc-pay-gateway
88
+ - ffc-pay-injection
89
+ - ffc-pay-processing
90
+ - ffc-pay-request-editor
91
+ - ffc-pay-submission
92
+ - ffc-pay-tracking
93
+ - ffc-pay-web
94
+ - ffc-pay-xb
95
+
96
+ In the event a new payment scheme is added to the package, all of the above services must be bumped to the latest package version to ensure that Payment Hub can process associated payments.
97
+
76
98
  ## Licence
77
99
 
78
100
  THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT
@@ -0,0 +1,3 @@
1
+ const { SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL } = require('../constants/scheme-ids')
2
+
3
+ module.exports = [SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL]
@@ -1,19 +1,13 @@
1
- const { SFI, LUMP_SUMS, SFI_PILOT, SFI23, DELINKED, SFI_EXPANDED } = require('../constants/scheme-ids')
1
+ const { isSitiAgri } = require('../helpers/is-siti-agri')
2
2
  const { createDefaultInvoiceNumber } = require('./create-default-invoice-number')
3
3
  const { createSitiAgriInvoiceNumber } = require('./create-siti-agri-invoice-number')
4
4
 
5
5
  const createSplitInvoiceNumber = (invoiceNumber, splitId, schemeId) => {
6
- switch (schemeId) {
7
- case SFI:
8
- case SFI_PILOT:
9
- case LUMP_SUMS:
10
- case SFI23:
11
- case DELINKED:
12
- case SFI_EXPANDED:
13
- return createSitiAgriInvoiceNumber(invoiceNumber, splitId)
14
- default:
15
- return createDefaultInvoiceNumber(invoiceNumber, splitId)
6
+ if (isSitiAgri(schemeId)) {
7
+ return createSitiAgriInvoiceNumber(invoiceNumber, splitId)
16
8
  }
9
+
10
+ return createDefaultInvoiceNumber(invoiceNumber, splitId)
17
11
  }
18
12
 
19
13
  module.exports = {
@@ -0,0 +1,9 @@
1
+ const sitiAgriSchemes = require('../constants/siti-agri-schemes')
2
+
3
+ const isSitiAgri = (schemeId) => {
4
+ return sitiAgriSchemes.includes(schemeId)
5
+ }
6
+
7
+ module.exports = {
8
+ isSitiAgri
9
+ }
package/index.js CHANGED
@@ -13,6 +13,7 @@ const { getSchemes } = require('./app/scheme-properties/get-schemes')
13
13
  const { getSourceSystemFromSchemeId } = require('./app/source-system/get-source-system-from-scheme-id')
14
14
  const { getSourceSystems } = require('./app/source-system/get-source-systems')
15
15
  const { isFRPS } = require('./app/helpers/is-frps')
16
+ const { isSitiAgri } = require('./app/helpers/is-siti-agri')
16
17
  const { isValidSchemeId } = require('./app/helpers/is-valid-scheme-id')
17
18
  const { schemeDoesNotRequirePPAs } = require('./app/helpers/scheme-does-not-require-ppas')
18
19
  const { schemeProvidesAccountingValues } = require('./app/helpers/scheme-provides-accounting-values')
@@ -33,6 +34,7 @@ module.exports = {
33
34
  getSourceSystemFromSchemeId,
34
35
  getSourceSystems,
35
36
  isFRPS,
37
+ isSitiAgri,
36
38
  isValidSchemeId,
37
39
  schemeDoesNotRequirePPAs,
38
40
  schemeProvidesAccountingValues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-schemes",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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,34 +1,36 @@
1
+ jest.mock('../../../app/helpers/is-siti-agri', () => ({
2
+ isSitiAgri: jest.fn()
3
+ }))
4
+
5
+ const { isSitiAgri } = require('../../../app/helpers/is-siti-agri')
1
6
  const { createSplitInvoiceNumber } = require('../../../app/create-split-invoice-number')
2
7
  const { createDefaultInvoiceNumber } = require('../../../app/create-split-invoice-number/create-default-invoice-number')
3
8
  const { createSitiAgriInvoiceNumber } = require('../../../app/create-split-invoice-number/create-siti-agri-invoice-number')
4
- const schemeIds = require('../../../app/constants/scheme-ids')
5
9
 
6
10
  describe('createSplitInvoiceNumber', () => {
7
11
  const invoiceNumber = '1234567890123'
8
12
  const splitId = 'A'
9
- const sitiAgriSchemes = [
10
- 'SFI',
11
- 'SFI_PILOT',
12
- 'LUMP_SUMS',
13
- 'SFI23',
14
- 'DELINKED',
15
- 'SFI_EXPANDED'
16
- ]
17
-
18
- test.each(Object.entries(schemeIds))(
19
- 'uses the correct invoice format for %s',
20
- (schemeKey, schemeId) => {
21
- const expectedInvoiceNumber = sitiAgriSchemes.includes(schemeKey)
22
- ? createSitiAgriInvoiceNumber(invoiceNumber, splitId)
23
- : createDefaultInvoiceNumber(invoiceNumber, splitId)
24
-
25
- expect(createSplitInvoiceNumber(invoiceNumber, splitId, schemeId))
26
- .toBe(expectedInvoiceNumber)
27
- }
28
- )
29
-
30
- test('uses the default format for an unknown schemeId', () => {
31
- expect(createSplitInvoiceNumber(invoiceNumber, splitId, 'unknown-scheme'))
13
+ const schemeId = 'SFI'
14
+
15
+ beforeEach(() => {
16
+ jest.clearAllMocks()
17
+ })
18
+
19
+ test('uses the Siti Agri invoice format when the scheme is Siti Agri', () => {
20
+ isSitiAgri.mockReturnValue(true)
21
+
22
+ expect(createSplitInvoiceNumber(invoiceNumber, splitId, schemeId))
23
+ .toBe(createSitiAgriInvoiceNumber(invoiceNumber, splitId))
24
+
25
+ expect(isSitiAgri).toHaveBeenCalledWith(schemeId)
26
+ })
27
+
28
+ test('uses the default invoice format when the scheme is not Siti Agri', () => {
29
+ isSitiAgri.mockReturnValue(false)
30
+
31
+ expect(createSplitInvoiceNumber(invoiceNumber, splitId, schemeId))
32
32
  .toBe(createDefaultInvoiceNumber(invoiceNumber, splitId))
33
+
34
+ expect(isSitiAgri).toHaveBeenCalledWith(schemeId)
33
35
  })
34
36
  })
@@ -0,0 +1,17 @@
1
+ const sitiAgriSchemes = require('../../../app/constants/siti-agri-schemes')
2
+ const { isSitiAgri } = require('../../../app/helpers/is-siti-agri')
3
+
4
+ describe('isSitiAgri', () => {
5
+ test.each(sitiAgriSchemes)('returns true for SITI scheme: %s', (schemeId) => {
6
+ expect(isSitiAgri(schemeId)).toBe(true)
7
+ })
8
+
9
+ test.each([
10
+ 'unknown-scheme',
11
+ '',
12
+ null,
13
+ undefined
14
+ ])('returns false for non-SITI scheme: %s', (schemeId) => {
15
+ expect(isSitiAgri(schemeId)).toBe(false)
16
+ })
17
+ })
@@ -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="269" lines-covered="250" line-rate="0.9293" branches-valid="60" branches-covered="60" branch-rate="1" timestamp="1788452069348" complexity="0" version="0.1">
3
+ <coverage lines-valid="269" lines-covered="250" line-rate="0.9293" branches-valid="55" branches-covered="55" branch-rate="1" timestamp="1788777087732" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/home/samplackett/ffc-pay-schemes</source>
6
6
  </sources>
@@ -84,7 +84,7 @@
84
84
  <methods>
85
85
  </methods>
86
86
  <lines>
87
- <line number="1" hits="12" branch="false"/>
87
+ <line number="1" hits="11" branch="false"/>
88
88
  </lines>
89
89
  </class>
90
90
  <class name="scheme-names.js" filename="app/constants/scheme-names.js" line-rate="1" branch-rate="1">
@@ -306,43 +306,43 @@
306
306
  <classes>
307
307
  <class name="create-default-invoice-number.js" filename="app/create-split-invoice-number/create-default-invoice-number.js" line-rate="1" branch-rate="1">
308
308
  <methods>
309
- <method name="(anonymous_0)" hits="27" signature="()V">
309
+ <method name="(anonymous_0)" hits="5" signature="()V">
310
310
  <lines>
311
- <line number="1" hits="27"/>
311
+ <line number="1" hits="5"/>
312
312
  </lines>
313
313
  </method>
314
314
  </methods>
315
315
  <lines>
316
316
  <line number="1" hits="2" branch="false"/>
317
- <line number="4" hits="27" branch="false"/>
318
- <line number="5" hits="27" branch="false"/>
319
- <line number="6" hits="27" branch="false"/>
320
- <line number="7" hits="27" branch="false"/>
317
+ <line number="4" hits="5" branch="false"/>
318
+ <line number="5" hits="5" branch="false"/>
319
+ <line number="6" hits="5" branch="false"/>
320
+ <line number="7" hits="5" branch="false"/>
321
321
  <line number="10" hits="2" branch="false"/>
322
322
  </lines>
323
323
  </class>
324
324
  <class name="create-siti-agri-invoice-number.js" filename="app/create-split-invoice-number/create-siti-agri-invoice-number.js" line-rate="1" branch-rate="1">
325
325
  <methods>
326
- <method name="(anonymous_0)" hits="15" signature="()V">
326
+ <method name="(anonymous_0)" hits="5" signature="()V">
327
327
  <lines>
328
- <line number="1" hits="15"/>
328
+ <line number="1" hits="5"/>
329
329
  </lines>
330
330
  </method>
331
331
  </methods>
332
332
  <lines>
333
333
  <line number="1" hits="2" branch="false"/>
334
- <line number="4" hits="15" branch="false"/>
335
- <line number="5" hits="15" branch="false"/>
336
- <line number="6" hits="15" branch="false"/>
337
- <line number="7" hits="15" branch="false"/>
334
+ <line number="4" hits="5" branch="false"/>
335
+ <line number="5" hits="5" branch="false"/>
336
+ <line number="6" hits="5" branch="false"/>
337
+ <line number="7" hits="5" branch="false"/>
338
338
  <line number="10" hits="2" branch="false"/>
339
339
  </lines>
340
340
  </class>
341
341
  <class name="index.js" filename="app/create-split-invoice-number/index.js" line-rate="1" branch-rate="1">
342
342
  <methods>
343
- <method name="(anonymous_0)" hits="18" signature="()V">
343
+ <method name="(anonymous_0)" hits="2" signature="()V">
344
344
  <lines>
345
- <line number="5" hits="18"/>
345
+ <line number="5" hits="2"/>
346
346
  </lines>
347
347
  </method>
348
348
  </methods>
@@ -351,10 +351,10 @@
351
351
  <line number="2" hits="1" branch="false"/>
352
352
  <line number="3" hits="1" branch="false"/>
353
353
  <line number="5" hits="1" branch="false"/>
354
- <line number="6" hits="18" branch="true" condition-coverage="100% (7/7)"/>
355
- <line number="13" hits="6" branch="false"/>
356
- <line number="15" hits="12" branch="false"/>
357
- <line number="19" hits="1" branch="false"/>
354
+ <line number="6" hits="2" branch="true" condition-coverage="100% (2/2)"/>
355
+ <line number="7" hits="1" branch="false"/>
356
+ <line number="10" hits="1" branch="false"/>
357
+ <line number="13" hits="1" branch="false"/>
358
358
  </lines>
359
359
  </class>
360
360
  </classes>