ffc-pay-schemes 1.0.14 → 1.1.0

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 (96) hide show
  1. package/README.md +50 -1
  2. package/app/constants/file-masks.js +2 -1
  3. package/app/constants/manual-sources.js +4 -2
  4. package/app/constants/pillars.js +2 -1
  5. package/app/constants/scheme-batch-properties.js +6 -0
  6. package/app/constants/scheme-ids.js +2 -1
  7. package/app/constants/scheme-names.js +16 -15
  8. package/app/constants/schemes.js +8 -0
  9. package/app/constants/sequence-positions.js +2 -1
  10. package/app/constants/siti-agri-schemes.js +2 -2
  11. package/app/constants/source-systems.js +2 -1
  12. package/app/create-invoice-number/index.js +2 -2
  13. package/app/get-account-code-map/index.js +4 -2
  14. package/app/pillar/get-pillar-from-scheme-id.js +11 -0
  15. package/app/pillar/get-pillars.js +9 -0
  16. package/index.js +4 -0
  17. package/package.json +1 -1
  18. package/test/unit/pillar/get-pillar-from-scheme-id.test.js +51 -0
  19. package/test/unit/pillar/get-pillars.test.js +8 -0
  20. package/test-output/cobertura-coverage.xml +97 -54
  21. package/test-output/junit.xml +368 -336
  22. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
  23. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
  24. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
  25. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
  26. package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
  27. package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
  28. package/test-output/lcov-report/ffc-pay-schemes/app/constants/file-masks.js.html +6 -3
  29. package/test-output/lcov-report/ffc-pay-schemes/app/constants/frps-schemes.js.html +1 -1
  30. package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
  31. package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +1 -1
  32. package/test-output/lcov-report/ffc-pay-schemes/app/constants/manual-sources.js.html +10 -4
  33. package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +6 -3
  34. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +20 -2
  35. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +6 -3
  36. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +6 -3
  37. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
  38. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
  39. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +23 -2
  40. package/test-output/lcov-report/ffc-pay-schemes/app/constants/sequence-positions.js.html +6 -3
  41. package/test-output/lcov-report/ffc-pay-schemes/app/constants/siti-agri-schemes.js.html +3 -3
  42. package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +6 -3
  43. package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +2 -2
  44. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
  45. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
  46. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
  47. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  48. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
  49. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
  50. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +3 -3
  51. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
  52. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
  53. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  54. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
  55. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
  56. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
  57. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
  58. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
  59. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
  60. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
  61. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
  62. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +10 -4
  63. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
  64. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
  65. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
  66. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-batch-sequence-from-file-name.js.html +1 -1
  67. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-journal-source-from-pillar.js.html +1 -1
  68. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-reporting-data-filter.js.html +1 -1
  69. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/index.html +1 -1
  70. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-frps.js.html +1 -1
  71. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-siti-agri.js.html +2 -2
  72. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-valid-scheme-id.js.html +3 -3
  73. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-does-not-require-ppas.js.html +2 -2
  74. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-provides-accounting-values.js.html +2 -2
  75. package/test-output/lcov-report/ffc-pay-schemes/app/pillar/get-pillar-from-scheme-id.js.html +118 -0
  76. package/test-output/lcov-report/ffc-pay-schemes/app/pillar/get-pillars.js.html +112 -0
  77. package/test-output/lcov-report/ffc-pay-schemes/app/pillar/index.html +131 -0
  78. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-pillar.js.html +1 -1
  79. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-source-system.js.html +1 -1
  80. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-ids.js.html +1 -1
  81. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/index.html +1 -1
  82. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-name-from-scheme-id.js.html +1 -1
  83. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-names.js.html +1 -1
  84. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/index.html +1 -1
  85. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-batch-properties.js.html +2 -2
  86. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-from-batch-file-name.js.html +1 -1
  87. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-properties.js.html +8 -8
  88. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-schemes.js.html +2 -2
  89. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/index.html +1 -1
  90. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-system-from-scheme-id.js.html +1 -1
  91. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-systems.js.html +1 -1
  92. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/index.html +1 -1
  93. package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
  94. package/test-output/lcov-report/ffc-pay-schemes/index.js.html +16 -4
  95. package/test-output/lcov-report/index.html +24 -9
  96. package/test-output/lcov.info +89 -51
package/README.md CHANGED
@@ -19,6 +19,8 @@ const {
19
19
  getAccountCodeMap,
20
20
  getBatchSequenceFromFileName,
21
21
  getJournalSourceFromPillar,
22
+ getPillarFromSchemeId,
23
+ getPillars,
22
24
  getReportingDataFilter,
23
25
  getSchemeBatchProperties,
24
26
  getSchemeFromBatchFileName,
@@ -44,6 +46,8 @@ const {
44
46
  - `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
45
47
  - `getBatchSequenceFromFileName(schemeId, fileName)` returns the sequence as identified in the supplied `fileName`, checking the correct position using the `schemeId`.
46
48
  - `getJournalSourceFromPillar(schemeId, source, pillar)` returns the appropriate manual source used in Payment journals for manual schemes, based on the supplied `pillar`. If `schemeId` is not the MANUAL scheme, or a match is not found, the supplied `source` will be returned.
49
+ - `getPillarFromSchemeId(schemeId)` returns the pillar name for a given `schemeId`.
50
+ - `getPillars()` returns all supported pillars.
47
51
  - `getReportingDataFilter(schemeId)` returns the fields which should be added to any data filters applied in reporting checks, for a given `schemeId`.
48
52
  - `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
49
53
  - `getSchemeFromBatchFileName(fileName)` returns the supported scheme details based on the expected file mask matching the supplied `fileName`.
@@ -95,12 +99,57 @@ The following services are intended to be used with the ffc-pay-schemes package:
95
99
  - ffc-pay-injection
96
100
  - ffc-pay-processing
97
101
  - ffc-pay-request-editor
102
+ - ffc-pay-responses
98
103
  - ffc-pay-submission
99
104
  - ffc-pay-tracking
100
105
  - ffc-pay-web
101
106
 
102
107
  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.
103
108
 
109
+ ## Scheme onboarding process
110
+
111
+ See the linked PR for an example of how to onboard a payment scheme with batch files to the ffc-pay-schemes package:
112
+
113
+ <https://github.com/DEFRA/ffc-pay-schemes/pull/16>
114
+
115
+ The below breakdown details all steps required for a general scheme onboarding:
116
+
117
+ - Add the scheme's pillar name to `app/constants/pillars.js` - this allows the pillar to be recognised for manual payments in `ffc-pay-injection`
118
+ - Add the manual source name for the scheme to `app/constants/manual-sources.js` - this defines the `source` name to use in D365 journals for manual payments for the scheme, created by `ffc-pay-submission`
119
+ - Add the scheme batch properties to `app/constants/scheme-batch-properties.js` - this defines the naming convention for D365 journals for the scheme, created by `ffc-pay-submission`
120
+ - Add the new scheme ID to `app/constants/scheme-ids.js` - this is the glue that holds payment processing together
121
+ - Add the scheme name to `app/constants/scheme-names.js` - this is how the scheme will be referred to in all frontend services, and in system logs
122
+ - Add the default scheme properties to `app/constants/schemes.js` - this is the primary driver for scheme defaults as read by `ffc-pay-enrichment`
123
+ - Add the source system to `app/constants/source-systems.js` - this is how the scheme will be recognised by `ffc-pay-enrichment`, and allow the scheme ID to be determined
124
+ - Add the scheme ID to the correct function in `app/create-invoice-number/index.js` - this is how the D365 formatted invoice number will be calculated in `ffc-pay-enrichment`
125
+ - Add the scheme ID to the mapping in `app/get-account-code-map/index.js` - this is how account codes will be assigned to invoice lines with different description codes in `ffc-pay-processing` - this is only usually called for PPAs, but for good practice it should be determined for all schemes
126
+
127
+ For all schemes supporting batch file ingestion:
128
+
129
+ - Add details of the file mask to `app/constants/file-masks.js` - this should be the file mask as read by `ffc-pay-batch-processor`, and allows the service to recognise the file to be processed.
130
+ - Add the file mask to the default scheme properties in `app/constants/schemes.js` - this is referenced by `ffc-pay-batch-processor`
131
+ - Add the position of the sequence number within the payment file to `app/constants/sequence-positions.js` - as used by `ffc-pay-batch-processor` to determine the correct sequence number of the file for processing
132
+
133
+ > Remember that ffc-pay-gateway must still be updated with the inbound file path, server name, and other configuration. See <https://github.com/DEFRA/ffc-pay-gateway/pull/78> for an example.
134
+
135
+ For all schemes delivered via FRPS:
136
+
137
+ - Add the scheme ID to `app/constants/frps-schemes.js` - this allows services to understand if it has been delivered by FRPS, helping with numerous helpers for FRPS specific behaviours
138
+
139
+ For all schemes delivered via Siti Agri:
140
+
141
+ - Add the scheme ID to `app/constants/siti-agri-schemes.js` - this allows services to understand if it has been delivered by Siti Agri, helping with numerous helpers for Siti Agri specific behaviours
142
+
143
+ For all schemes which do not support PPAs:
144
+
145
+ - Add the scheme ID to `app/constants/schemes-not-requiring-ppas.js` - this tells `ffc-pay-processing` not to calculate PPAs
146
+
147
+ For all schemes which provide accounting values:
148
+
149
+ - Add the scheme ID to `app/constants/schemes-providing-account-values.js` - this tells `ffc-pay-enrichment` to mark the payment request as providing accounting values, and enables correct value reporting in Payment Hub reports
150
+
151
+ Completing all of these steps as required should allow Payment Hub to support payments for a new payment scheme, assuming there are no specific behaviours that differ from a general payment scheme.
152
+
104
153
  ## Licence
105
154
 
106
155
  THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT
@@ -122,4 +171,4 @@ public sector to license the use and re-use of their information under a common
122
171
  open licence.
123
172
 
124
173
  It is designed to encourage use and re-use of information freely and flexibly,
125
- with only a few conditions.
174
+ with only a few conditions.
@@ -10,5 +10,6 @@ module.exports = {
10
10
  SFI23: /^SITISFIA\d{4}_AP_\d*.dat$/,
11
11
  DELINKED: /^SITIDP\d{4}_AP_\d*.dat$/,
12
12
  SFI_EXPANDED: /^ESFIO\d{4}_AP_\d*.dat$/,
13
- COHT_CAPITAL: /^SITICOHTC\d{4}_AP_\d*.dat$/
13
+ COHT_CAPITAL: /^SITICOHTC\d{4}_AP_\d*.dat$/,
14
+ SFI26: /^SITISFI26\d{4}_AP_\d*.dat$/
14
15
  }
@@ -35,7 +35,8 @@ const {
35
35
  COHT_CAPITAL,
36
36
  COHT_REVENUE,
37
37
  FPTT,
38
- WMP
38
+ WMP,
39
+ SFI26
39
40
  } = require('./pillars')
40
41
 
41
42
  module.exports = {
@@ -75,5 +76,6 @@ module.exports = {
75
76
  [COHT_CAPITAL]: 'PMAN_COHTC',
76
77
  [COHT_REVENUE]: 'PMAN_COHTR',
77
78
  [FPTT]: 'PMAN_FPTT',
78
- [WMP]: 'PMAN_WMP'
79
+ [WMP]: 'PMAN_WMP',
80
+ [SFI26]: 'PMAN_SFI26'
79
81
  }
@@ -36,5 +36,6 @@ module.exports = {
36
36
  COHT_REVENUE: 'COHTR',
37
37
  COHT_CAPITAL: 'COHTC',
38
38
  FPTT: 'FPTT',
39
- WMP: 'WMP'
39
+ WMP: 'WMP',
40
+ SFI26: 'SFI26'
40
41
  }
@@ -102,5 +102,11 @@ module.exports = Object.freeze([
102
102
  prefix: 'FFCFALS_WMP',
103
103
  suffix: ' (FALS_WMP)',
104
104
  source: 'FALS_WMP'
105
+ },
106
+ {
107
+ schemeId: schemeIds.SFI26,
108
+ prefix: 'FFCSITISFI26',
109
+ suffix: ' (SITISFI26)',
110
+ source: 'SITISFI26'
105
111
  }
106
112
  ])
@@ -15,5 +15,6 @@ module.exports = {
15
15
  COHT_REVENUE: 15,
16
16
  COHT_CAPITAL: 16,
17
17
  FPTT: 17,
18
- WMP: 18
18
+ WMP: 18,
19
+ SFI26: 19
19
20
  }
@@ -1,19 +1,20 @@
1
1
  module.exports = {
2
- SFI: 'Sustainable Farming Incentive 22',
3
- SFI_PILOT: 'Sustainable Farming Incentive Pilot',
2
+ SFI: 'SFI-22',
3
+ SFI_PILOT: 'SFI-P',
4
4
  LUMP_SUMS: 'Lump Sums',
5
- VET_VISITS: 'Annual Health and Welfare Review',
6
- CS: 'Countryside Stewardship',
7
- BPS: 'Basic Payment Scheme',
8
- MANUAL: 'Manual Injection',
9
- ES: 'Environmental Stewardship',
10
- FC: 'Forestry Commission',
11
- IMPS: 'Internal Market Payment Scheme',
12
- SFI23: 'Sustainable Farming Incentive 23',
5
+ VET_VISITS: 'Vet Visits (AHWR)',
6
+ CS: 'CS',
7
+ BPS: 'BPS',
8
+ MANUAL: 'Manual Payments (Injection)',
9
+ ES: 'Genesis (ES)',
10
+ FC: 'GLOS (FC)',
11
+ IMPS: 'IMPS',
12
+ SFI23: 'SFI-23',
13
13
  DELINKED: 'Delinked Payments',
14
- SFI_EXPANDED: 'Sustainable Farming Incentive Expanded Offer',
15
- COHT_REVENUE: 'Combined Offer Higher Tier (Revenue)',
16
- COHT_CAPITAL: 'Combined Offer Higher Tier (Capital)',
17
- FPTT: 'Farm Payments Technical Test',
18
- WMP: 'Woodland Management Plan'
14
+ SFI_EXPANDED: 'SFI-EO',
15
+ COHT_REVENUE: 'CS-HT (Revenue)',
16
+ COHT_CAPITAL: 'CS-HT (Capital)',
17
+ FPTT: 'FPTT',
18
+ WMP: 'WMP',
19
+ SFI26: 'SFI-26'
19
20
  }
@@ -136,5 +136,13 @@ module.exports = Object.freeze([
136
136
  pillar: pillars.WMP,
137
137
  deliveryBody: RP10,
138
138
  fundCode: DRD10
139
+ },
140
+ {
141
+ schemeId: schemeIds.SFI26,
142
+ sourceSystem: sourceSystems.SFI26,
143
+ pillar: pillars.SFI26,
144
+ deliveryBody: RP00,
145
+ fundCode: DRD10,
146
+ fileMask: fileMasks.SFI26
139
147
  }
140
148
  ])
@@ -9,5 +9,6 @@ module.exports = {
9
9
  SFI23: 8,
10
10
  DELINKED: 6,
11
11
  SFI_EXPANDED: 5,
12
- COHT_CAPITAL: 9
12
+ COHT_CAPITAL: 9,
13
+ SFI26: 9
13
14
  }
@@ -1,3 +1,3 @@
1
- const { SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL } = require('../constants/scheme-ids')
1
+ const { SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL, SFI26 } = require('../constants/scheme-ids')
2
2
 
3
- module.exports = [SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL]
3
+ module.exports = [SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL, SFI26]
@@ -15,5 +15,6 @@ module.exports = {
15
15
  COHT_REVENUE: 'COHTR',
16
16
  COHT_CAPITAL: 'COHTC',
17
17
  FPTT: 'FPTT',
18
- WMP: 'WMP'
18
+ WMP: 'WMP',
19
+ SFI26: 'SFI26'
19
20
  }
@@ -1,5 +1,5 @@
1
1
  const { MANUAL: MANUAL_SOURCE } = require('../constants/source-systems')
2
- const { MANUAL, FC, FPTT, WMP, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL, SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, ES, IMPS } = require('../constants/scheme-ids')
2
+ const { MANUAL, FC, FPTT, WMP, DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL, SFI, SFI_PILOT, LUMP_SUMS, CS, BPS, SFI23, ES, IMPS, SFI26 } = require('../constants/scheme-ids')
3
3
  const { createStandardSchemeInvoiceNumber } = require('./create-standard-scheme-invoice-number')
4
4
  const { createSitiAgriInvoiceNumber } = require('./create-siti-agri-invoice-number')
5
5
  const { createESInvoiceNumber } = require('./create-es-invoice-number')
@@ -12,7 +12,7 @@ const createInvoiceNumber = (paymentRequest) => {
12
12
  if (schemesWithAcceptedInvoiceNumbers.has(paymentRequest.schemeId) || paymentRequest?.sourceSystem === MANUAL_SOURCE) {
13
13
  return paymentRequest.invoiceNumber
14
14
  }
15
- const standardSchemeInvoices = new Set([DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL])
15
+ const standardSchemeInvoices = new Set([DELINKED, SFI_EXPANDED, COHT_REVENUE, COHT_CAPITAL, SFI26])
16
16
  if (standardSchemeInvoices.has(paymentRequest.schemeId)) {
17
17
  return createStandardSchemeInvoiceNumber(paymentRequest)
18
18
  }
@@ -11,7 +11,8 @@ const {
11
11
  COHT_REVENUE,
12
12
  COHT_CAPITAL,
13
13
  FPTT,
14
- WMP
14
+ WMP,
15
+ SFI26
15
16
  } = require('../constants/scheme-ids')
16
17
 
17
18
  const defaultMap = require('./default-map')
@@ -36,7 +37,8 @@ const schemeMap = new Map([
36
37
  [COHT_REVENUE, defaultMap],
37
38
  [COHT_CAPITAL, cohtcMap],
38
39
  [FPTT, sfiFrpsMap],
39
- [WMP, sfiFrpsMap]
40
+ [WMP, sfiFrpsMap],
41
+ [SFI26, sfiFrpsMap]
40
42
  ])
41
43
 
42
44
  const getAccountCodeMap = (schemeId) => {
@@ -0,0 +1,11 @@
1
+ const { UNKNOWN } = require('../constants/unknown')
2
+ const { getSchemes } = require('../scheme-properties/get-schemes')
3
+
4
+ const getPillarFromSchemeId = (schemeId) => {
5
+ const matchingScheme = getSchemes().find((scheme) => scheme.schemeId === schemeId)
6
+ return matchingScheme?.pillar ?? UNKNOWN
7
+ }
8
+
9
+ module.exports = {
10
+ getPillarFromSchemeId
11
+ }
@@ -0,0 +1,9 @@
1
+ const pillars = require('../constants/pillars')
2
+
3
+ const getPillars = () => {
4
+ return pillars
5
+ }
6
+
7
+ module.exports = {
8
+ getPillars
9
+ }
package/index.js CHANGED
@@ -3,6 +3,8 @@ const { createSplitInvoiceNumber } = require('./app/create-split-invoice-number'
3
3
  const { getAccountCodeMap } = require('./app/get-account-code-map')
4
4
  const { getBatchSequenceFromFileName } = require('./app/helpers/get-batch-sequence-from-file-name')
5
5
  const { getJournalSourceFromPillar } = require('./app/helpers/get-journal-source-from-pillar')
6
+ const { getPillarFromSchemeId } = require('./app/pillar/get-pillar-from-scheme-id')
7
+ const { getPillars } = require('./app/pillar/get-pillars')
6
8
  const { getReportingDataFilter } = require('./app/helpers/get-reporting-data-filter')
7
9
  const { getSchemeBatchProperties } = require('./app/scheme-properties/get-scheme-batch-properties')
8
10
  const { getSchemeFromBatchFileName } = require('./app/scheme-properties/get-scheme-from-batch-file-name')
@@ -27,6 +29,8 @@ module.exports = {
27
29
  getAccountCodeMap,
28
30
  getBatchSequenceFromFileName,
29
31
  getJournalSourceFromPillar,
32
+ getPillarFromSchemeId,
33
+ getPillars,
30
34
  getReportingDataFilter,
31
35
  getSchemeBatchProperties,
32
36
  getSchemeFromBatchFileName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-schemes",
3
- "version": "1.0.14",
3
+ "version": "1.1.0",
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": {
@@ -0,0 +1,51 @@
1
+ jest.mock('../../../app/scheme-properties/get-schemes', () => ({
2
+ getSchemes: jest.fn()
3
+ }))
4
+
5
+ const { UNKNOWN } = require('../../../app/constants/unknown')
6
+ const { getSchemes } = require('../../../app/scheme-properties/get-schemes')
7
+ const { getPillarFromSchemeId } = require('../../../app/pillar/get-pillar-from-scheme-id')
8
+
9
+ describe('getPillarFromSchemeId', () => {
10
+ beforeEach(() => {
11
+ jest.clearAllMocks()
12
+ })
13
+
14
+ test('returns the pillar for a matching scheme ID', () => {
15
+ getSchemes.mockReturnValue([
16
+ {
17
+ schemeId: 1,
18
+ schemeName: 'Example Scheme',
19
+ pillar: 'Example Pillar'
20
+ }
21
+ ])
22
+
23
+ expect(getPillarFromSchemeId(1)).toBe('Example Pillar')
24
+ })
25
+
26
+ test('returns unknown when the scheme ID is not found', () => {
27
+ getSchemes.mockReturnValue([
28
+ {
29
+ schemeId: 1,
30
+ schemeName: 'Example Scheme',
31
+ pillar: 'Example Pillar'
32
+ }
33
+ ])
34
+
35
+ expect(getPillarFromSchemeId(2)).toBe(UNKNOWN)
36
+ })
37
+
38
+ test('returns unknown when no schemes are available', () => {
39
+ getSchemes.mockReturnValue([])
40
+
41
+ expect(getPillarFromSchemeId(2)).toBe(UNKNOWN)
42
+ })
43
+
44
+ test('gets schemes before searching for the pillar', () => {
45
+ getSchemes.mockReturnValue([])
46
+
47
+ getPillarFromSchemeId(2)
48
+
49
+ expect(getSchemes).toHaveBeenCalledTimes(1)
50
+ })
51
+ })
@@ -0,0 +1,8 @@
1
+ const { getPillars } = require('../../../app/pillar/get-pillars')
2
+ const pillars = require('../../../app/constants/pillars')
3
+
4
+ describe('getPillars', () => {
5
+ test('returns all pillars', () => {
6
+ expect(getPillars()).toEqual(pillars)
7
+ })
8
+ })