ffc-pay-schemes 1.0.1

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 (133) hide show
  1. package/.github/workflows/secret-scanner.yml +16 -0
  2. package/.gitleaks-shared/.gitleaks.toml +139 -0
  3. package/.gitleaks.toml +15 -0
  4. package/.gitleaksignore +0 -0
  5. package/.husky/pre-commit +30 -0
  6. package/LICENCE +8 -0
  7. package/README.md +34 -0
  8. package/app/constants/account-codes/ap.js +48 -0
  9. package/app/constants/account-codes/ar-admin.js +48 -0
  10. package/app/constants/account-codes/ar-irregular.js +47 -0
  11. package/app/constants/delivery-bodies.js +6 -0
  12. package/app/constants/description-codes.js +34 -0
  13. package/app/constants/fund-codes.js +8 -0
  14. package/app/constants/pillars.js +18 -0
  15. package/app/constants/scheme-batch-properties.js +106 -0
  16. package/app/constants/scheme-ids.js +19 -0
  17. package/app/constants/scheme-names.js +19 -0
  18. package/app/constants/schemes-not-requiring-ppas.js +3 -0
  19. package/app/constants/schemes-providing-account-values.js +3 -0
  20. package/app/constants/schemes.js +127 -0
  21. package/app/constants/source-systems.js +19 -0
  22. package/app/create-invoice-number/create-default-invoice-number.js +11 -0
  23. package/app/create-invoice-number/create-es-invoice-number.js +7 -0
  24. package/app/create-invoice-number/create-imps-invoice-number.js +14 -0
  25. package/app/create-invoice-number/create-siti-agri-invoice-number.js +12 -0
  26. package/app/create-invoice-number/create-standard-scheme-invoice-number.js +12 -0
  27. package/app/create-invoice-number/index.js +38 -0
  28. package/app/create-invoice-number/use-invoice-number-as-is.js +7 -0
  29. package/app/create-split-invoice-number/create-default-invoice-number.js +12 -0
  30. package/app/create-split-invoice-number/create-siti-agri-invoice-number.js +12 -0
  31. package/app/create-split-invoice-number/index.js +21 -0
  32. package/app/get-account-code-map/bps-map.js +141 -0
  33. package/app/get-account-code-map/cohtc-map.js +21 -0
  34. package/app/get-account-code-map/cs-map.js +174 -0
  35. package/app/get-account-code-map/default-map.js +46 -0
  36. package/app/get-account-code-map/delinked-map.js +31 -0
  37. package/app/get-account-code-map/index.js +57 -0
  38. package/app/get-account-code-map/lump-sums-map.js +11 -0
  39. package/app/get-account-code-map/sfi-frps-map.js +15 -0
  40. package/app/get-account-code-map/vet-visits-map.js +11 -0
  41. package/app/get-scheme-batch-properties.js +9 -0
  42. package/app/get-scheme-properties.js +31 -0
  43. package/app/get-schemes.js +12 -0
  44. package/app/scheme-does-not-require-ppas.js +9 -0
  45. package/app/scheme-provides-accounting-values.js +9 -0
  46. package/azure-pipelines.yml +45 -0
  47. package/eslint.config.js +3 -0
  48. package/index.js +21 -0
  49. package/jest.config.js +40 -0
  50. package/jest.setup.js +2 -0
  51. package/package.json +34 -0
  52. package/sonar-project.properties +3 -0
  53. package/test/unit/create-invoice-number/create-default-invoice-number.test.js +15 -0
  54. package/test/unit/create-invoice-number/create-es-invoice-number.test.js +10 -0
  55. package/test/unit/create-invoice-number/create-imps-invoice-number.test.js +27 -0
  56. package/test/unit/create-invoice-number/create-siti-agri-invoice-number.test.js +26 -0
  57. package/test/unit/create-invoice-number/create-standard-scheme-invoice-number.test.js +31 -0
  58. package/test/unit/create-invoice-number/index.test.js +113 -0
  59. package/test/unit/create-invoice-number/use-invoice-number-as-is.test.js +9 -0
  60. package/test/unit/create-split-invoice-number/create-default-invoice-number.test.js +15 -0
  61. package/test/unit/create-split-invoice-number/create-siti-agri-invoice-number.test.js +15 -0
  62. package/test/unit/create-split-invoice-number/index.test.js +34 -0
  63. package/test/unit/get-account-code-map/bps-map.test.js +58 -0
  64. package/test/unit/get-account-code-map/cohtc-map.test.js +32 -0
  65. package/test/unit/get-account-code-map/cs-map.test.js +62 -0
  66. package/test/unit/get-account-code-map/default-map.test.js +60 -0
  67. package/test/unit/get-account-code-map/delinked-map.test.js +42 -0
  68. package/test/unit/get-account-code-map/index.test.js +53 -0
  69. package/test/unit/get-account-code-map/lump-sums-map.test.js +16 -0
  70. package/test/unit/get-account-code-map/sfi-frps-map.test.js +31 -0
  71. package/test/unit/get-account-code-map/vet-visits-map.test.js +16 -0
  72. package/test/unit/get-scheme-batch-properties.test.js +16 -0
  73. package/test/unit/get-scheme-properties.test.js +54 -0
  74. package/test/unit/get-schemes.test.js +24 -0
  75. package/test/unit/scheme-does-not-require-ppas.test.js +17 -0
  76. package/test/unit/scheme-provides-accounting-values.test.js +17 -0
  77. package/test-output/cobertura-coverage.xml +577 -0
  78. package/test-output/junit.xml +589 -0
  79. package/test-output/lcov-report/base.css +224 -0
  80. package/test-output/lcov-report/block-navigation.js +87 -0
  81. package/test-output/lcov-report/favicon.png +0 -0
  82. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +229 -0
  83. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +229 -0
  84. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +226 -0
  85. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +146 -0
  86. package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +103 -0
  87. package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +187 -0
  88. package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +109 -0
  89. package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +266 -0
  90. package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +139 -0
  91. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +403 -0
  92. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +142 -0
  93. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +142 -0
  94. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +94 -0
  95. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +94 -0
  96. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +466 -0
  97. package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +142 -0
  98. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +118 -0
  99. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +106 -0
  100. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +127 -0
  101. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +121 -0
  102. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +121 -0
  103. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +206 -0
  104. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +199 -0
  105. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +106 -0
  106. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +121 -0
  107. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +121 -0
  108. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +146 -0
  109. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +148 -0
  110. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +508 -0
  111. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +148 -0
  112. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +607 -0
  113. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +223 -0
  114. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +178 -0
  115. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +236 -0
  116. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +256 -0
  117. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +118 -0
  118. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +130 -0
  119. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +118 -0
  120. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +112 -0
  121. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +178 -0
  122. package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +121 -0
  123. package/test-output/lcov-report/ffc-pay-schemes/app/index.html +176 -0
  124. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +112 -0
  125. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.html +112 -0
  126. package/test-output/lcov-report/ffc-pay-schemes/index.html +116 -0
  127. package/test-output/lcov-report/ffc-pay-schemes/index.js.html +148 -0
  128. package/test-output/lcov-report/index.html +206 -0
  129. package/test-output/lcov-report/prettify.css +1 -0
  130. package/test-output/lcov-report/prettify.js +2 -0
  131. package/test-output/lcov-report/sort-arrow-sprite.png +0 -0
  132. package/test-output/lcov-report/sorter.js +210 -0
  133. package/test-output/lcov.info +644 -0
@@ -0,0 +1,34 @@
1
+ const { createSplitInvoiceNumber } = require('../../../app/create-split-invoice-number')
2
+ const { createDefaultInvoiceNumber } = require('../../../app/create-split-invoice-number/create-default-invoice-number')
3
+ const { createSitiAgriInvoiceNumber } = require('../../../app/create-split-invoice-number/create-siti-agri-invoice-number')
4
+ const schemeIds = require('../../../app/constants/scheme-ids')
5
+
6
+ describe('createSplitInvoiceNumber', () => {
7
+ const invoiceNumber = '1234567890123'
8
+ 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'))
32
+ .toBe(createDefaultInvoiceNumber(invoiceNumber, splitId))
33
+ })
34
+ })
@@ -0,0 +1,58 @@
1
+ const bpsMap = require('../../../app/get-account-code-map/bps-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ const expectedMappings = {
8
+ G00: ['SOS210', 'SOS330', 'SOS310'],
9
+ P01: ['SOS404', 'SOS465', 'SOS445'],
10
+ P02: ['SOS362', 'SOS450', 'SOS430'],
11
+ P03: ['SOS351', 'SOS451', 'SOS431'],
12
+ P04: ['SOS363', 'SOS452', 'SOS432'],
13
+ P05: ['SOS367', 'SOS453', 'SOS433'],
14
+ P06: ['SOS368', 'SOS454', 'SOS434'],
15
+ P07: ['SOS369', 'SOS455', 'SOS435'],
16
+ P08: ['SOS361', 'SOS456', 'SOS436'],
17
+ P09: ['SOS400', 'SOS457', 'SOS437'],
18
+ P10: ['SOS402', 'SOS458', 'SOS438'],
19
+ P11: ['SOS260', 'SOS466', 'SOS446'],
20
+ P12: ['SOS266', 'SOS267', 'SOS268'],
21
+ P13: ['SOS410', 'SOS459', 'SOS439'],
22
+ P14: ['SOS350', 'SOS464', 'SOS444'],
23
+ P15: ['SOS364', 'SOS336', 'SOS316'],
24
+ P16: ['SOS415', 'SOS460', 'SOS440'],
25
+ P17: ['SOS416', 'SOS461', 'SOS441'],
26
+ P18: ['SOS417', 'SOS462', 'SOS442'],
27
+ P19: ['SOS420', 'SOS463', 'SOS443'],
28
+ P20: ['SOS420', 'SOS463', 'SOS443'],
29
+ P21: ['SOS420', 'SOS463', 'SOS443'],
30
+ R00: ['SOS216', 'SOS217', 'SOS218'],
31
+ X01: ['SOS471', 'SOS471', 'SOS471'],
32
+ X02: ['SOS472', 'SOS472', 'SOS472'],
33
+ X03: ['SOS473', 'SOS473', 'SOS473'],
34
+ X04: ['SOS474', 'SOS474', 'SOS474']
35
+ }
36
+
37
+ describe('BPS account code map', () => {
38
+ test('contains all expected line codes', () => {
39
+ expect(bpsMap).toHaveLength(Object.keys(expectedMappings).length)
40
+
41
+ expect(bpsMap.map(item => item.lineCode)).toEqual(
42
+ Object.keys(expectedMappings).map(lineCode => descriptionCodes[lineCode])
43
+ )
44
+ })
45
+
46
+ test.each(Object.entries(expectedMappings))(
47
+ 'returns the correct account codes for %s',
48
+ (lineCode, [apCode, arAdminCode, arIrregularCode]) => {
49
+ expect(bpsMap.find(item => item.lineCode === descriptionCodes[lineCode]))
50
+ .toEqual({
51
+ lineCode: descriptionCodes[lineCode],
52
+ ap: ap[apCode],
53
+ arAdmin: arAdmin[arAdminCode],
54
+ arIrregular: arIrregular[arIrregularCode]
55
+ })
56
+ }
57
+ )
58
+ })
@@ -0,0 +1,32 @@
1
+ const cohtcMap = require('../../../app/get-account-code-map/cohtc-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ describe('COHTC account code map', () => {
8
+ test.each([
9
+ ['G00', 'SOS710', 'SOS750', 'SOS770'],
10
+ ['P02', 'SOS920', 'SOS940', 'SOS960'],
11
+ ['P24', 'SOS929', 'SOS949', 'SOS969']
12
+ ])(
13
+ 'returns the correct account codes for %s',
14
+ (lineCode, apCode, arAdminCode, arIrregularCode) => {
15
+ expect(cohtcMap).toContainEqual({
16
+ lineCode: descriptionCodes[lineCode],
17
+ ap: ap[apCode],
18
+ arAdmin: arAdmin[arAdminCode],
19
+ arIrregular: arIrregular[arIrregularCode]
20
+ })
21
+ }
22
+ )
23
+
24
+ test('contains exactly the expected mappings', () => {
25
+ expect(cohtcMap).toHaveLength(3)
26
+ expect(cohtcMap.map(item => item.lineCode)).toEqual([
27
+ descriptionCodes.G00,
28
+ descriptionCodes.P02,
29
+ descriptionCodes.P24
30
+ ])
31
+ })
32
+ })
@@ -0,0 +1,62 @@
1
+ const csMap = require('../../../app/get-account-code-map/cs-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ const expectedMappings = [
8
+ ['G00', 'SOS710', 'SOS750', 'SOS770', true, true, false],
9
+ ['G00', 'SOS228', 'SOS352', 'SOS352', true, true, true],
10
+ ['G00', 'SOS229', 'SOS352', 'SOS352', true, true, true],
11
+ ['P02', 'SOS929', 'SOS949', 'SOS969', true, false, false],
12
+ ['P02', 'SOS928', 'SOS948', 'SOS968', false, true, false],
13
+ ['P02', 'SOS231', 'SOS553', 'SOS553', true, true, true],
14
+ ['P05', 'SOS921', 'SOS941', 'SOS961', true, true, false],
15
+ ['P05', 'SOS233', 'SOS555', 'SOS555', true, true, true],
16
+ ['P06', 'SOS922', 'SOS942', 'SOS962', true, true, false],
17
+ ['P06', 'SOS234', 'SOS556', 'SOS556', true, true, true],
18
+ ['P08', 'SOS923', 'SOS943', 'SOS963', true, true, false],
19
+ ['P08', 'SOS239', 'SOS557', 'SOS557', true, true, true],
20
+ ['P14', 'SOS924', 'SOS944', 'SOS964', true, true, false],
21
+ ['P14', 'SOS236', 'SOS558', 'SOS558', true, true, true],
22
+ ['P22', 'SOS925', 'SOS945', 'SOS965', true, true, false],
23
+ ['P22', 'SOS237', 'SOS559', 'SOS559', true, true, true],
24
+ ['P23', 'SOS926', 'SOS946', 'SOS966', true, true, false],
25
+ ['P23', 'SOS238', 'SOS560', 'SOS560', true, true, true],
26
+ ['P24', 'SOS920', 'SOS940', 'SOS960', true, false, false],
27
+ ['P24', 'SOS927', 'SOS947', 'SOS967', false, true, false],
28
+ ['P24', 'SOS232', 'SOS554', 'SOS554', true, true, true]
29
+ ]
30
+
31
+ describe('CS account code map', () => {
32
+ test('contains all expected mappings', () => {
33
+ const expected = expectedMappings.map(
34
+ ([lineCode, apCode, arAdminCode, arIrregularCode, capital, revenue, stateAid]) => ({
35
+ lineCode: descriptionCodes[lineCode],
36
+ ap: ap[apCode],
37
+ arAdmin: arAdmin[arAdminCode],
38
+ arIrregular: arIrregular[arIrregularCode],
39
+ capital,
40
+ revenue,
41
+ stateAid
42
+ })
43
+ )
44
+
45
+ expect(csMap).toEqual(expected)
46
+ })
47
+
48
+ test.each(expectedMappings)(
49
+ 'contains the expected mapping for %s',
50
+ (lineCode, apCode, arAdminCode, arIrregularCode, capital, revenue, stateAid) => {
51
+ expect(csMap).toContainEqual({
52
+ lineCode: descriptionCodes[lineCode],
53
+ ap: ap[apCode],
54
+ arAdmin: arAdmin[arAdminCode],
55
+ arIrregular: arIrregular[arIrregularCode],
56
+ capital,
57
+ revenue,
58
+ stateAid
59
+ })
60
+ }
61
+ )
62
+ })
@@ -0,0 +1,60 @@
1
+ const defaultMap = require('../../../app/get-account-code-map/default-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ describe('default account code map', () => {
8
+ test('contains the expected account code mappings', () => {
9
+ expect(defaultMap).toEqual([
10
+ {
11
+ lineCode: descriptionCodes.G00,
12
+ ap: ap.SOS710,
13
+ arAdmin: arAdmin.SOS750,
14
+ arIrregular: arIrregular.SOS770
15
+ },
16
+ {
17
+ lineCode: descriptionCodes.P05,
18
+ ap: ap.SOS921,
19
+ arAdmin: arAdmin.SOS941,
20
+ arIrregular: arIrregular.SOS961
21
+ },
22
+ {
23
+ lineCode: descriptionCodes.P06,
24
+ ap: ap.SOS922,
25
+ arAdmin: arAdmin.SOS942,
26
+ arIrregular: arIrregular.SOS962
27
+ },
28
+ {
29
+ lineCode: descriptionCodes.P08,
30
+ ap: ap.SOS923,
31
+ arAdmin: arAdmin.SOS943,
32
+ arIrregular: arIrregular.SOS963
33
+ },
34
+ {
35
+ lineCode: descriptionCodes.P14,
36
+ ap: ap.SOS924,
37
+ arAdmin: arAdmin.SOS944,
38
+ arIrregular: arIrregular.SOS964
39
+ },
40
+ {
41
+ lineCode: descriptionCodes.P22,
42
+ ap: ap.SOS925,
43
+ arAdmin: arAdmin.SOS945,
44
+ arIrregular: arIrregular.SOS965
45
+ },
46
+ {
47
+ lineCode: descriptionCodes.P23,
48
+ ap: ap.SOS926,
49
+ arAdmin: arAdmin.SOS946,
50
+ arIrregular: arIrregular.SOS966
51
+ },
52
+ {
53
+ lineCode: descriptionCodes.P24,
54
+ ap: ap.SOS927,
55
+ arAdmin: arAdmin.SOS947,
56
+ arIrregular: arIrregular.SOS967
57
+ }
58
+ ])
59
+ })
60
+ })
@@ -0,0 +1,42 @@
1
+ const delinkedMap = require('../../../app/get-account-code-map/delinked-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ describe('Delinked account code map', () => {
8
+ test('contains the expected account code mappings', () => {
9
+ expect(delinkedMap).toEqual([
10
+ {
11
+ lineCode: descriptionCodes.G00,
12
+ ap: ap.SOS210,
13
+ arAdmin: arAdmin.SOS330,
14
+ arIrregular: arIrregular.SOS310
15
+ },
16
+ {
17
+ lineCode: descriptionCodes.X01,
18
+ ap: ap.SOS471,
19
+ arAdmin: arAdmin.SOS471,
20
+ arIrregular: arIrregular.SOS471
21
+ },
22
+ {
23
+ lineCode: descriptionCodes.X02,
24
+ ap: ap.SOS472,
25
+ arAdmin: arAdmin.SOS472,
26
+ arIrregular: arIrregular.SOS472
27
+ },
28
+ {
29
+ lineCode: descriptionCodes.X03,
30
+ ap: ap.SOS473,
31
+ arAdmin: arAdmin.SOS473,
32
+ arIrregular: arIrregular.SOS473
33
+ },
34
+ {
35
+ lineCode: descriptionCodes.X04,
36
+ ap: ap.SOS474,
37
+ arAdmin: arAdmin.SOS474,
38
+ arIrregular: arIrregular.SOS474
39
+ }
40
+ ])
41
+ })
42
+ })
@@ -0,0 +1,53 @@
1
+ const { getAccountCodeMap } = require('../../../app/get-account-code-map')
2
+ const schemeIds = require('../../../app/constants/scheme-ids')
3
+
4
+ const defaultMap = require('../../../app/get-account-code-map/default-map')
5
+ const sfiFrpsMap = require('../../../app/get-account-code-map/sfi-frps-map')
6
+ const lumpSumsMap = require('../../../app/get-account-code-map/lump-sums-map')
7
+ const vetVisitsMap = require('../../../app/get-account-code-map/vet-visits-map')
8
+ const csMap = require('../../../app/get-account-code-map/cs-map')
9
+ const bpsMap = require('../../../app/get-account-code-map/bps-map')
10
+ const delinkedMap = require('../../../app/get-account-code-map/delinked-map')
11
+ const cohtcMap = require('../../../app/get-account-code-map/cohtc-map')
12
+
13
+ const expectedMaps = {
14
+ SFI: sfiFrpsMap,
15
+ SFI_PILOT: sfiFrpsMap,
16
+ LUMP_SUMS: lumpSumsMap,
17
+ VET_VISITS: vetVisitsMap,
18
+ CS: csMap,
19
+ BPS: bpsMap,
20
+ SFI23: sfiFrpsMap,
21
+ DELINKED: delinkedMap,
22
+ SFI_EXPANDED: sfiFrpsMap,
23
+ COHT_REVENUE: defaultMap,
24
+ COHT_CAPITAL: cohtcMap,
25
+ FPTT: sfiFrpsMap,
26
+ WMP: sfiFrpsMap
27
+ }
28
+
29
+ describe('getAccountCodeMap', () => {
30
+ test.each(Object.entries(expectedMaps))(
31
+ 'returns the correct map for %s',
32
+ (schemeKey, expectedMap) => {
33
+ expect(getAccountCodeMap(schemeIds[schemeKey])).toBe(expectedMap)
34
+ }
35
+ )
36
+
37
+ test.each(['MANUAL', 'ES', 'FC', 'IMPS'])(
38
+ 'throws an error for the unmapped %s scheme',
39
+ (schemeKey) => {
40
+ expect(() => getAccountCodeMap(schemeIds[schemeKey]))
41
+ .toThrow(`No account codes found for scheme ${schemeIds[schemeKey]}`)
42
+ }
43
+ )
44
+
45
+ test('throws an error when schemeId is not provided', () => {
46
+ expect(() => getAccountCodeMap()).toThrow('schemeId is required')
47
+ })
48
+
49
+ test('throws an error for an unknown schemeId', () => {
50
+ expect(() => getAccountCodeMap(999))
51
+ .toThrow('No account codes found for scheme 999')
52
+ })
53
+ })
@@ -0,0 +1,16 @@
1
+ const lumpSumsMap = require('../../../app/get-account-code-map/lump-sums-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ describe('Lump Sums account code map', () => {
8
+ test('contains the expected mapping', () => {
9
+ expect(lumpSumsMap).toEqual([{
10
+ lineCode: descriptionCodes.G00,
11
+ ap: ap.SOS210,
12
+ arAdmin: arAdmin.SOS330,
13
+ arIrregular: arIrregular.SOS310
14
+ }])
15
+ })
16
+ })
@@ -0,0 +1,31 @@
1
+ const sfiFrpsMap = require('../../../app/get-account-code-map/sfi-frps-map')
2
+ const defaultMap = require('../../../app/get-account-code-map/default-map')
3
+ const ap = require('../../../app/constants/account-codes/ap')
4
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
5
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
6
+ const descriptionCodes = require('../../../app/constants/description-codes')
7
+
8
+ describe('SFI FRPS account code map', () => {
9
+ const p02Entry = {
10
+ lineCode: descriptionCodes.P02,
11
+ ap: ap.SOS920,
12
+ arAdmin: arAdmin.SOS940,
13
+ arIrregular: arIrregular.SOS960
14
+ }
15
+
16
+ test('contains the complete expected map', () => {
17
+ expect(sfiFrpsMap).toEqual([
18
+ defaultMap[0],
19
+ p02Entry,
20
+ ...defaultMap.slice(1)
21
+ ])
22
+ })
23
+
24
+ test.each(defaultMap)('contains default mapping %#', (entry) => {
25
+ expect(sfiFrpsMap).toContainEqual(entry)
26
+ })
27
+
28
+ test('contains the P02 mapping', () => {
29
+ expect(sfiFrpsMap).toContainEqual(p02Entry)
30
+ })
31
+ })
@@ -0,0 +1,16 @@
1
+ const vetVisitsMap = require('../../../app/get-account-code-map/vet-visits-map')
2
+ const ap = require('../../../app/constants/account-codes/ap')
3
+ const arAdmin = require('../../../app/constants/account-codes/ar-admin')
4
+ const arIrregular = require('../../../app/constants/account-codes/ar-irregular')
5
+ const descriptionCodes = require('../../../app/constants/description-codes')
6
+
7
+ describe('Vet Visits account code map', () => {
8
+ test('contains the expected mapping', () => {
9
+ expect(vetVisitsMap).toEqual([{
10
+ lineCode: descriptionCodes.G00,
11
+ ap: ap.SOS210,
12
+ arAdmin: arAdmin.SOS330,
13
+ arIrregular: arIrregular.SOS310
14
+ }])
15
+ })
16
+ })
@@ -0,0 +1,16 @@
1
+ const { getSchemeBatchProperties } = require('../../app/get-scheme-batch-properties')
2
+ const schemeBatchProperties = require('../../app/constants/scheme-batch-properties')
3
+
4
+ describe('get scheme batch properties', () => {
5
+ test.each(schemeBatchProperties)(
6
+ 'returns the batch properties for schemeId $schemeId',
7
+ (expectedProperties) => {
8
+ expect(getSchemeBatchProperties(expectedProperties.schemeId))
9
+ .toEqual(expectedProperties)
10
+ }
11
+ )
12
+
13
+ test('returns undefined for an unknown schemeId', () => {
14
+ expect(getSchemeBatchProperties('unknown-scheme')).toBeUndefined()
15
+ })
16
+ })
@@ -0,0 +1,54 @@
1
+ const { getSchemeProperties } = require('../../app/get-scheme-properties')
2
+ const schemes = require('../../app/constants/schemes')
3
+ const { MANUAL } = require('../../app/constants/scheme-ids')
4
+
5
+ describe('getSchemeProperties', () => {
6
+ test.each(schemes)(
7
+ 'returns the properties for schemeId $schemeId',
8
+ (expectedScheme) => {
9
+ expect(getSchemeProperties(expectedScheme.schemeId))
10
+ .toEqual(expectedScheme)
11
+ }
12
+ )
13
+
14
+ test.each(schemes)(
15
+ 'returns the properties for schemeId $schemeId, even if sourceSystem does not match',
16
+ (expectedScheme) => {
17
+ expect(getSchemeProperties(expectedScheme.schemeId, 'made up source system'))
18
+ .toEqual(expectedScheme)
19
+ }
20
+ )
21
+
22
+ test.each(schemes)(
23
+ 'returns the properties for sourceSystem $sourceSystem when schemeId is not present',
24
+ (expectedScheme) => {
25
+ expect(getSchemeProperties(null, expectedScheme.sourceSystem))
26
+ .toEqual(expectedScheme)
27
+ }
28
+ )
29
+
30
+ test('throws an error for an unknown schemeId and sourceSystem', () => {
31
+ expect(() => getSchemeProperties('unknown-scheme', 'unknown-source'))
32
+ .toThrow('Scheme with ID unknown-scheme, sourceSystem unknown-source not found')
33
+ })
34
+
35
+ test('uses the pillar delivery body and fund code for a manual scheme', () => {
36
+ const manualScheme = schemes.find(scheme => scheme.schemeId === MANUAL)
37
+ const pillarScheme = schemes.find(scheme => scheme.pillar)
38
+
39
+ expect(getSchemeProperties(MANUAL, null, pillarScheme.pillar))
40
+ .toEqual({
41
+ ...manualScheme,
42
+ pillar: pillarScheme.pillar,
43
+ deliveryBody: pillarScheme.deliveryBody,
44
+ fundCode: pillarScheme.fundCode
45
+ })
46
+ })
47
+
48
+ test('returns the manual scheme unchanged for an unknown pillar', () => {
49
+ const manualScheme = schemes.find(scheme => scheme.schemeId === MANUAL)
50
+
51
+ expect(getSchemeProperties(MANUAL, null, 'unknown-pillar'))
52
+ .toEqual(manualScheme)
53
+ })
54
+ })
@@ -0,0 +1,24 @@
1
+ const { getSchemes } = require('../../app/get-schemes')
2
+ const schemeIds = require('../../app/constants/scheme-ids')
3
+ const schemeNames = require('../../app/constants/scheme-names')
4
+
5
+ describe('getSchemes', () => {
6
+ test('returns all schemes with their IDs and names', () => {
7
+ expect(getSchemes()).toEqual(
8
+ Object.keys(schemeIds).map((schemeKey) => ({
9
+ schemeId: schemeIds[schemeKey],
10
+ schemeName: schemeNames[schemeKey]
11
+ }))
12
+ )
13
+ })
14
+
15
+ test.each(Object.keys(schemeIds))(
16
+ 'returns the correct details for %s',
17
+ (schemeKey) => {
18
+ expect(getSchemes()).toContainEqual({
19
+ schemeId: schemeIds[schemeKey],
20
+ schemeName: schemeNames[schemeKey]
21
+ })
22
+ }
23
+ )
24
+ })
@@ -0,0 +1,17 @@
1
+ const { schemeDoesNotRequirePPAs } = require('../../app/scheme-does-not-require-ppas')
2
+ const schemeIds = require('../../app/constants/scheme-ids')
3
+ const schemesNotRequiringPPAs = require('../../app/constants/schemes-not-requiring-ppas')
4
+
5
+ describe('schemeDoesNotRequirePPAs', () => {
6
+ test.each(Object.entries(schemeIds))(
7
+ 'returns the expected result for %s',
8
+ (schemeKey, schemeId) => {
9
+ expect(schemeDoesNotRequirePPAs(schemeId))
10
+ .toBe(schemesNotRequiringPPAs.includes(schemeId))
11
+ }
12
+ )
13
+
14
+ test('returns false for an unknown schemeId', () => {
15
+ expect(schemeDoesNotRequirePPAs(999)).toBe(false)
16
+ })
17
+ })
@@ -0,0 +1,17 @@
1
+ const { schemeProvidesAccountingValues } = require('../../app/scheme-provides-accounting-values')
2
+ const schemeIds = require('../../app/constants/scheme-ids')
3
+ const schemesProvidingAccountingValues = require('../../app/constants/schemes-providing-account-values')
4
+
5
+ describe('schemeProvidesAccountingValues', () => {
6
+ test.each(Object.entries(schemeIds))(
7
+ 'returns the expected result for %s',
8
+ (schemeKey, schemeId) => {
9
+ expect(schemeProvidesAccountingValues(schemeId))
10
+ .toBe(schemesProvidingAccountingValues.includes(schemeId))
11
+ }
12
+ )
13
+
14
+ test('returns false for an unknown schemeId', () => {
15
+ expect(schemeProvidesAccountingValues(999)).toBe(false)
16
+ })
17
+ })