ffc-pay-schemes 1.0.8 → 1.0.10

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 (121) hide show
  1. package/README.md +5 -1
  2. package/app/constants/frps-schemes.js +3 -0
  3. package/app/helpers/get-reporting-data-filter.js +23 -0
  4. package/app/helpers/is-frps.js +9 -0
  5. package/app/{is-valid-scheme-id.js → helpers/is-valid-scheme-id.js} +1 -1
  6. package/app/{scheme-does-not-require-ppas.js → helpers/scheme-does-not-require-ppas.js} +1 -1
  7. package/app/{scheme-provides-accounting-values.js → helpers/scheme-provides-accounting-values.js} +1 -1
  8. package/app/{get-scheme-id-from-pillar.js → scheme-id/get-scheme-id-from-pillar.js} +1 -1
  9. package/app/{get-scheme-id-from-source-system.js → scheme-id/get-scheme-id-from-source-system.js} +1 -1
  10. package/app/{get-scheme-ids.js → scheme-id/get-scheme-ids.js} +1 -1
  11. package/app/{get-scheme-name-from-scheme-id.js → scheme-name/get-scheme-name-from-scheme-id.js} +2 -2
  12. package/app/{get-scheme-names.js → scheme-name/get-scheme-names.js} +1 -1
  13. package/app/{get-scheme-batch-properties.js → scheme-properties/get-scheme-batch-properties.js} +1 -1
  14. package/app/{get-scheme-properties.js → scheme-properties/get-scheme-properties.js} +2 -2
  15. package/app/scheme-properties/get-schemes.js +16 -0
  16. package/app/{get-source-system-from-scheme-id.js → source-system/get-source-system-from-scheme-id.js} +2 -2
  17. package/app/{get-source-systems.js → source-system/get-source-systems.js} +1 -1
  18. package/index.js +17 -13
  19. package/package.json +1 -1
  20. package/test/unit/helpers/get-reporting-data-filter.test.js +44 -0
  21. package/test/unit/helpers/is-frps.test.js +17 -0
  22. package/test/unit/{is-valid-scheme-id.test.js → helpers/is-valid-scheme-id.test.js} +2 -2
  23. package/test/unit/{scheme-does-not-require-ppas.test.js → helpers/scheme-does-not-require-ppas.test.js} +3 -3
  24. package/test/unit/{scheme-provides-accounting-values.test.js → helpers/scheme-provides-accounting-values.test.js} +3 -3
  25. package/test/unit/{get-scheme-id-from-pillar.test.js → scheme-id/get-scheme-id-from-pillar.test.js} +3 -3
  26. package/test/unit/{get-scheme-id-from-source-system.test.js → scheme-id/get-scheme-id-from-source-system.test.js} +3 -3
  27. package/test/unit/scheme-id/get-scheme-ids.test.js +8 -0
  28. package/test/unit/{get-scheme-name-from-scheme-id.test.js → scheme-name/get-scheme-name-from-scheme-id.test.js} +4 -4
  29. package/test/unit/scheme-name/get-scheme-names.test.js +8 -0
  30. package/test/unit/{get-scheme-batch-properties.test.js → scheme-properties/get-scheme-batch-properties.test.js} +2 -2
  31. package/test/unit/{get-scheme-properties.test.js → scheme-properties/get-scheme-properties.test.js} +3 -3
  32. package/test/unit/{get-schemes.test.js → scheme-properties/get-schemes.test.js} +9 -6
  33. package/test/unit/{get-source-system-from-scheme-id.test.js → source-system/get-source-system-from-scheme-id.test.js} +4 -4
  34. package/test/unit/source-system/get-source-systems.test.js +8 -0
  35. package/test-output/cobertura-coverage.xml +328 -263
  36. package/test-output/junit.xml +338 -312
  37. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
  38. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
  39. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
  40. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
  41. package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
  42. package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
  43. package/test-output/lcov-report/ffc-pay-schemes/app/constants/frps-schemes.js.html +94 -0
  44. package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
  45. package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +18 -3
  46. package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +2 -2
  47. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +1 -1
  48. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +2 -2
  49. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
  50. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
  51. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
  52. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +1 -1
  53. package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
  54. package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +1 -1
  55. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
  56. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
  57. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
  58. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  59. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
  60. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
  61. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
  62. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
  63. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
  64. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  65. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
  66. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
  67. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
  68. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
  69. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
  70. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
  71. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
  72. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
  73. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
  74. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
  75. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
  76. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
  77. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +1 -1
  78. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-pillar.js.html +1 -1
  79. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-source-system.js.html +1 -1
  80. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-ids.js.html +1 -1
  81. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-name-from-scheme-id.js.html +22 -22
  82. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-names.js.html +1 -1
  83. package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +1 -1
  84. package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +12 -6
  85. package/test-output/lcov-report/ffc-pay-schemes/app/get-source-system-from-scheme-id.js.html +1 -1
  86. package/test-output/lcov-report/ffc-pay-schemes/app/get-source-systems.js.html +1 -1
  87. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-reporting-data-filter.js.html +154 -0
  88. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/index.html +176 -0
  89. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-frps.js.html +112 -0
  90. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-valid-scheme-id.js.html +115 -0
  91. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-does-not-require-ppas.js.html +112 -0
  92. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-provides-accounting-values.js.html +112 -0
  93. package/test-output/lcov-report/ffc-pay-schemes/app/index.html +21 -186
  94. package/test-output/lcov-report/ffc-pay-schemes/app/is-valid-scheme-id.js.html +1 -1
  95. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +1 -1
  96. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-pillar.js.html +115 -0
  97. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-source-system.js.html +115 -0
  98. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-ids.js.html +112 -0
  99. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/index.html +146 -0
  100. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/is-valid-scheme-id.js.html +115 -0
  101. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-name-from-scheme-id.js.html +118 -0
  102. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-names.js.html +112 -0
  103. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/index.html +131 -0
  104. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-batch-properties.js.html +112 -0
  105. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-properties.js.html +178 -0
  106. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-schemes.js.html +133 -0
  107. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/index.html +146 -0
  108. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/scheme-does-not-require-ppas.js.html +112 -0
  109. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/scheme-provides-accounting-values.js.html +112 -0
  110. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.html +1 -1
  111. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-system-from-scheme-id.js.html +118 -0
  112. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-systems.js.html +112 -0
  113. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/index.html +131 -0
  114. package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
  115. package/test-output/lcov-report/ffc-pay-schemes/index.js.html +34 -16
  116. package/test-output/lcov-report/index.html +86 -26
  117. package/test-output/lcov.info +307 -249
  118. package/app/get-schemes.js +0 -14
  119. package/test/unit/get-scheme-ids.test.js +0 -8
  120. package/test/unit/get-scheme-names.test.js +0 -8
  121. package/test/unit/get-source-systems.test.js +0 -8
package/README.md CHANGED
@@ -17,6 +17,7 @@ const {
17
17
  createInvoiceNumber,
18
18
  createSplitInvoiceNumber,
19
19
  getAccountCodeMap,
20
+ getReportingDataFilter,
20
21
  getSchemeBatchProperties,
21
22
  getSchemeIdFromPillar,
22
23
  getSchemeIdFromSourceSystem,
@@ -27,6 +28,7 @@ const {
27
28
  getSchemes,
28
29
  getSourceSystemFromSchemeId,
29
30
  getSourceSystems,
31
+ isFRPS,
30
32
  isValidSchemeId,
31
33
  schemeDoesNotRequirePPAs,
32
34
  schemeProvidesAccountingValues
@@ -36,6 +38,7 @@ const {
36
38
  - `createInvoiceNumber(paymentRequest)` creates an invoice number for a given `paymentRequest`.
37
39
  - `createSplitInvoiceNumber(paymentRequest)` creates a split invoice number for a given `paymentRequest`.
38
40
  - `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
41
+ - `getReportingDataFilter(schemeId)` returns the fields which should be added to any data filters applied in reporting checks, for a given `schemeId`.
39
42
  - `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
40
43
  - `getSchemeIdFromPillar(pillar)` returns the scheme ID for a given `pillar`.
41
44
  - `getSchemeIdFromSourceSystem(sourceSystem)` returns the scheme ID for a given `sourceSystem`.
@@ -43,9 +46,10 @@ const {
43
46
  - `getSchemeNameFromSchemeId(schemeId)` returns the scheme name for a given `schemeId`.
44
47
  - `getSchemeNames()` returns all supported scheme names.
45
48
  - `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.
46
- - `getSchemes()` returns all supported schemes as an array of objects containing `schemeId`, `schemeName` and `sourceSystem`.
49
+ - `getSchemes()` returns all supported schemes as an array of objects containing `schemeId`, `schemeName`, `sourceSystem` and `pillar`.
47
50
  - `getSourceSystemFromSchemeId(schemeId)` returns the source system name for a given `schemeId`.
48
51
  - `getSourceSystems()` returns all supported source systems.
52
+ - `isFRPS(schemeId)` returns `true` if the scheme ID comes from FRPS, or `false` if not.
49
53
  - `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.
50
54
  - `schemeDoesNotRequirePPAs(schemeId)` returns `true` if Payment Hub does not support Post Payment Adjustments (PPAs) for a given `schemeId`; otherwise, it returns `false`.
51
55
  - `schemeProvidesAccountingValues(schemeId)` returns `true` if a given `schemeId` provides accounting values within its payment requests; otherwise, it returns `false`.
@@ -0,0 +1,3 @@
1
+ const { FPTT, WMP } = require('./scheme-ids')
2
+
3
+ module.exports = [FPTT, WMP]
@@ -0,0 +1,23 @@
1
+ const { BPS, DELINKED, CS } = require('../constants/scheme-ids')
2
+ const { isFRPS } = require('./is-frps')
3
+
4
+ const getReportingDataFilter = (schemeId) => {
5
+ const defaultFilter = ['marketingYear', 'agreementNumber']
6
+ switch (schemeId) {
7
+ case BPS:
8
+ case DELINKED:
9
+ return ['marketingYear']
10
+ case CS:
11
+ return ['contractNumber']
12
+ default:
13
+ if (isFRPS(schemeId)) {
14
+ return [...defaultFilter, 'correlationId']
15
+ } else {
16
+ return defaultFilter
17
+ }
18
+ }
19
+ }
20
+
21
+ module.exports = {
22
+ getReportingDataFilter
23
+ }
@@ -0,0 +1,9 @@
1
+ const frpsSchemes = require('../constants/frps-schemes')
2
+
3
+ const isFRPS = (schemeId) => {
4
+ return frpsSchemes.includes(schemeId)
5
+ }
6
+
7
+ module.exports = {
8
+ isFRPS
9
+ }
@@ -1,4 +1,4 @@
1
- const schemeIds = require('./constants/scheme-ids')
1
+ const schemeIds = require('../constants/scheme-ids')
2
2
 
3
3
  const isValidSchemeId = (schemeId) => {
4
4
  const numericSchemeId = Number(schemeId)
@@ -1,4 +1,4 @@
1
- const schemesNotRequiringPPAs = require('./constants/schemes-not-requiring-ppas')
1
+ const schemesNotRequiringPPAs = require('../constants/schemes-not-requiring-ppas')
2
2
 
3
3
  const schemeDoesNotRequirePPAs = (schemeId) => {
4
4
  return schemesNotRequiringPPAs.includes(schemeId)
@@ -1,4 +1,4 @@
1
- const schemesProvidingAccountingValues = require('./constants/schemes-providing-account-values')
1
+ const schemesProvidingAccountingValues = require('../constants/schemes-providing-account-values')
2
2
 
3
3
  const schemeProvidesAccountingValues = (schemeId) => {
4
4
  return schemesProvidingAccountingValues.includes(schemeId)
@@ -1,4 +1,4 @@
1
- const { getSchemes } = require('./get-schemes')
1
+ const { getSchemes } = require('../scheme-properties/get-schemes')
2
2
 
3
3
  const getSchemeIdFromPillar = (pillar) => {
4
4
  const matchingScheme = getSchemes().find((scheme) => scheme.pillar === pillar)
@@ -1,4 +1,4 @@
1
- const { getSchemes } = require('./get-schemes')
1
+ const { getSchemes } = require('../scheme-properties/get-schemes')
2
2
 
3
3
  const getSchemeIdFromSourceSystem = (sourceSystem) => {
4
4
  const matchingScheme = getSchemes().find((scheme) => scheme.sourceSystem === sourceSystem)
@@ -1,4 +1,4 @@
1
- const schemeIds = require('./constants/scheme-ids')
1
+ const schemeIds = require('../constants/scheme-ids')
2
2
 
3
3
  const getSchemeIds = () => {
4
4
  return schemeIds
@@ -1,5 +1,5 @@
1
- const { UNKNOWN } = require('./constants/unknown')
2
- const { getSchemes } = require('./get-schemes')
1
+ const { UNKNOWN } = require('../constants/unknown')
2
+ const { getSchemes } = require('../scheme-properties/get-schemes')
3
3
 
4
4
  const getSchemeNameFromSchemeId = (schemeId) => {
5
5
  const matchingScheme = getSchemes().find((scheme) => scheme.schemeId === schemeId)
@@ -1,4 +1,4 @@
1
- const schemeNames = require('./constants/scheme-names')
1
+ const schemeNames = require('../constants/scheme-names')
2
2
 
3
3
  const getSchemeNames = () => {
4
4
  return schemeNames
@@ -1,4 +1,4 @@
1
- const schemeBatchProperties = require('./constants/scheme-batch-properties')
1
+ const schemeBatchProperties = require('../constants/scheme-batch-properties')
2
2
 
3
3
  const getSchemeBatchProperties = (schemeId) => {
4
4
  return schemeBatchProperties.find(scheme => scheme.schemeId === schemeId)
@@ -1,5 +1,5 @@
1
- const schemes = require('./constants/schemes')
2
- const { MANUAL } = require('./constants/scheme-ids')
1
+ const schemes = require('../constants/schemes')
2
+ const { MANUAL } = require('../constants/scheme-ids')
3
3
 
4
4
  const getSchemeProperties = (schemeId, sourceSystem, pillar) => {
5
5
  let scheme = schemeId
@@ -0,0 +1,16 @@
1
+ const pillars = require('../constants/pillars')
2
+ const schemeIds = require('../constants/scheme-ids')
3
+ const schemeNames = require('../constants/scheme-names')
4
+ const sourceSystems = require('../constants/source-systems')
5
+
6
+ const getSchemes = () =>
7
+ Object.keys(schemeIds).map((schemeKey) => ({
8
+ schemeId: schemeIds[schemeKey],
9
+ schemeName: schemeNames[schemeKey],
10
+ sourceSystem: sourceSystems[schemeKey],
11
+ pillar: pillars[schemeKey]
12
+ }))
13
+
14
+ module.exports = {
15
+ getSchemes
16
+ }
@@ -1,5 +1,5 @@
1
- const { UNKNOWN } = require('./constants/unknown')
2
- const { getSchemes } = require('./get-schemes')
1
+ const { UNKNOWN } = require('../constants/unknown')
2
+ const { getSchemes } = require('../scheme-properties/get-schemes')
3
3
 
4
4
  const getSourceSystemFromSchemeId = (schemeId) => {
5
5
  const matchingScheme = getSchemes().find((scheme) => scheme.schemeId === schemeId)
@@ -1,4 +1,4 @@
1
- const sourceSystems = require('./constants/source-systems')
1
+ const sourceSystems = require('../constants/source-systems')
2
2
 
3
3
  const getSourceSystems = () => {
4
4
  return sourceSystems
package/index.js CHANGED
@@ -1,24 +1,27 @@
1
1
  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
- const { getSchemeBatchProperties } = require('./app/get-scheme-batch-properties')
5
- const { getSchemeIdFromPillar } = require('./app/get-scheme-id-from-pillar')
6
- const { getSchemeIdFromSourceSystem } = require('./app/get-scheme-id-from-source-system')
7
- const { getSchemeIds } = require('./app/get-scheme-ids')
8
- const { getSchemeNameFromSchemeId } = require('./app/get-scheme-name-from-scheme-id')
9
- const { getSchemeNames } = require('./app/get-scheme-names')
10
- const { getSchemeProperties } = require('./app/get-scheme-properties')
11
- const { getSchemes } = require('./app/get-schemes')
12
- const { getSourceSystemFromSchemeId } = require('./app/get-source-system-from-scheme-id')
13
- const { getSourceSystems } = require('./app/get-source-systems')
14
- const { isValidSchemeId } = require('./app/is-valid-scheme-id')
15
- const { schemeDoesNotRequirePPAs } = require('./app/scheme-does-not-require-ppas')
16
- const { schemeProvidesAccountingValues } = require('./app/scheme-provides-accounting-values')
4
+ const { getReportingDataFilter } = require('./app/helpers/get-reporting-data-filter')
5
+ const { getSchemeBatchProperties } = require('./app/scheme-properties/get-scheme-batch-properties')
6
+ const { getSchemeIdFromPillar } = require('./app/scheme-id/get-scheme-id-from-pillar')
7
+ const { getSchemeIdFromSourceSystem } = require('./app/scheme-id/get-scheme-id-from-source-system')
8
+ const { getSchemeIds } = require('./app/scheme-id/get-scheme-ids')
9
+ const { getSchemeNameFromSchemeId } = require('./app/scheme-name/get-scheme-name-from-scheme-id')
10
+ const { getSchemeNames } = require('./app/scheme-name/get-scheme-names')
11
+ const { getSchemeProperties } = require('./app/scheme-properties/get-scheme-properties')
12
+ const { getSchemes } = require('./app/scheme-properties/get-schemes')
13
+ const { getSourceSystemFromSchemeId } = require('./app/source-system/get-source-system-from-scheme-id')
14
+ const { getSourceSystems } = require('./app/source-system/get-source-systems')
15
+ const { isFRPS } = require('./app/helpers/is-frps')
16
+ const { isValidSchemeId } = require('./app/helpers/is-valid-scheme-id')
17
+ const { schemeDoesNotRequirePPAs } = require('./app/helpers/scheme-does-not-require-ppas')
18
+ const { schemeProvidesAccountingValues } = require('./app/helpers/scheme-provides-accounting-values')
17
19
 
18
20
  module.exports = {
19
21
  createInvoiceNumber,
20
22
  createSplitInvoiceNumber,
21
23
  getAccountCodeMap,
24
+ getReportingDataFilter,
22
25
  getSchemeBatchProperties,
23
26
  getSchemeIdFromPillar,
24
27
  getSchemeIdFromSourceSystem,
@@ -29,6 +32,7 @@ module.exports = {
29
32
  getSchemes,
30
33
  getSourceSystemFromSchemeId,
31
34
  getSourceSystems,
35
+ isFRPS,
32
36
  isValidSchemeId,
33
37
  schemeDoesNotRequirePPAs,
34
38
  schemeProvidesAccountingValues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-schemes",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
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,44 @@
1
+ jest.mock('../../../app/helpers/is-frps', () => ({
2
+ isFRPS: jest.fn()
3
+ }))
4
+
5
+ const { BPS, DELINKED, CS } = require('../../../app/constants/scheme-ids')
6
+ const { isFRPS } = require('../../../app/helpers/is-frps')
7
+ const { getReportingDataFilter } = require('../../../app/helpers/get-reporting-data-filter')
8
+
9
+ describe('getReportingDataFilter', () => {
10
+ beforeEach(() => {
11
+ jest.clearAllMocks()
12
+ })
13
+
14
+ test('returns marketing year for BPS', () => {
15
+ expect(getReportingDataFilter(BPS)).toEqual(['marketingYear'])
16
+ })
17
+
18
+ test('returns marketing year for DELINKED', () => {
19
+ expect(getReportingDataFilter(DELINKED)).toEqual(['marketingYear'])
20
+ })
21
+
22
+ test('returns contract number for CS', () => {
23
+ expect(getReportingDataFilter(CS)).toEqual(['contractNumber'])
24
+ })
25
+
26
+ test('returns the FRPS filter including correlation ID', () => {
27
+ isFRPS.mockReturnValue(true)
28
+
29
+ expect(getReportingDataFilter('frps-scheme')).toEqual([
30
+ 'marketingYear',
31
+ 'agreementNumber',
32
+ 'correlationId'
33
+ ])
34
+ })
35
+
36
+ test('returns the default filter for non-FRPS schemes', () => {
37
+ isFRPS.mockReturnValue(false)
38
+
39
+ expect(getReportingDataFilter('unknown-scheme')).toEqual([
40
+ 'marketingYear',
41
+ 'agreementNumber'
42
+ ])
43
+ })
44
+ })
@@ -0,0 +1,17 @@
1
+ const frpsSchemes = require('../../../app/constants/frps-schemes')
2
+ const { isFRPS } = require('../../../app/helpers/is-frps')
3
+
4
+ describe('isFRPS', () => {
5
+ test.each(frpsSchemes)('returns true for FRPS scheme: %s', (schemeId) => {
6
+ expect(isFRPS(schemeId)).toBe(true)
7
+ })
8
+
9
+ test.each([
10
+ 'unknown-scheme',
11
+ '',
12
+ null,
13
+ undefined
14
+ ])('returns false for non-FRPS scheme: %s', (schemeId) => {
15
+ expect(isFRPS(schemeId)).toBe(false)
16
+ })
17
+ })
@@ -1,5 +1,5 @@
1
- const schemeIds = require('../../app/constants/scheme-ids')
2
- const { isValidSchemeId } = require('../../app/is-valid-scheme-id')
1
+ const schemeIds = require('../../../app/constants/scheme-ids')
2
+ const { isValidSchemeId } = require('../../../app/helpers/is-valid-scheme-id')
3
3
 
4
4
  describe('isValidSchemeId', () => {
5
5
  test.each(Object.values(schemeIds))(
@@ -1,6 +1,6 @@
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')
1
+ const { schemeDoesNotRequirePPAs } = require('../../../app/helpers/scheme-does-not-require-ppas')
2
+ const schemeIds = require('../../../app/constants/scheme-ids')
3
+ const schemesNotRequiringPPAs = require('../../../app/constants/schemes-not-requiring-ppas')
4
4
 
5
5
  describe('schemeDoesNotRequirePPAs', () => {
6
6
  test.each(Object.entries(schemeIds))(
@@ -1,6 +1,6 @@
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')
1
+ const { schemeProvidesAccountingValues } = require('../../../app/helpers/scheme-provides-accounting-values')
2
+ const schemeIds = require('../../../app/constants/scheme-ids')
3
+ const schemesProvidingAccountingValues = require('../../../app/constants/schemes-providing-account-values')
4
4
 
5
5
  describe('schemeProvidesAccountingValues', () => {
6
6
  test.each(Object.entries(schemeIds))(
@@ -1,9 +1,9 @@
1
- jest.mock('../../app/get-schemes', () => ({
1
+ jest.mock('../../../app/scheme-properties/get-schemes', () => ({
2
2
  getSchemes: jest.fn()
3
3
  }))
4
4
 
5
- const { getSchemes } = require('../../app/get-schemes')
6
- const { getSchemeIdFromPillar } = require('../../app/get-scheme-id-from-pillar')
5
+ const { getSchemes } = require('../../../app/scheme-properties/get-schemes')
6
+ const { getSchemeIdFromPillar } = require('../../../app/scheme-id/get-scheme-id-from-pillar')
7
7
 
8
8
  describe('getSchemeIdFromPillar', () => {
9
9
  beforeEach(() => {
@@ -1,9 +1,9 @@
1
- jest.mock('../../app/get-schemes', () => ({
1
+ jest.mock('../../../app/scheme-properties/get-schemes', () => ({
2
2
  getSchemes: jest.fn()
3
3
  }))
4
4
 
5
- const { getSchemes } = require('../../app/get-schemes')
6
- const { getSchemeIdFromSourceSystem } = require('../../app/get-scheme-id-from-source-system')
5
+ const { getSchemes } = require('../../../app/scheme-properties/get-schemes')
6
+ const { getSchemeIdFromSourceSystem } = require('../../../app/scheme-id/get-scheme-id-from-source-system')
7
7
 
8
8
  describe('getSchemeIdFromSourceSystem', () => {
9
9
  beforeEach(() => {
@@ -0,0 +1,8 @@
1
+ const { getSchemeIds } = require('../../../app/scheme-id/get-scheme-ids')
2
+ const schemeIds = require('../../../app/constants/scheme-ids')
3
+
4
+ describe('getSchemeIds', () => {
5
+ test('returns all scheme IDs', () => {
6
+ expect(getSchemeIds()).toEqual(schemeIds)
7
+ })
8
+ })
@@ -1,10 +1,10 @@
1
- jest.mock('../../app/get-schemes', () => ({
1
+ jest.mock('../../../app/scheme-properties/get-schemes', () => ({
2
2
  getSchemes: jest.fn()
3
3
  }))
4
4
 
5
- const { getSchemes } = require('../../app/get-schemes')
6
- const { getSchemeNameFromSchemeId } = require('../../app/get-scheme-name-from-scheme-id')
7
- const { UNKNOWN } = require('../../app/constants/unknown')
5
+ const { getSchemes } = require('../../../app/scheme-properties/get-schemes')
6
+ const { getSchemeNameFromSchemeId } = require('../../../app/scheme-name/get-scheme-name-from-scheme-id')
7
+ const { UNKNOWN } = require('../../../app/constants/unknown')
8
8
 
9
9
  describe('getSchemeNameFromSchemeId', () => {
10
10
  beforeEach(() => {
@@ -0,0 +1,8 @@
1
+ const { getSchemeNames } = require('../../../app/scheme-name/get-scheme-names')
2
+ const schemeNames = require('../../../app/constants/scheme-names')
3
+
4
+ describe('getSchemeNames', () => {
5
+ test('returns all scheme names', () => {
6
+ expect(getSchemeNames()).toEqual(schemeNames)
7
+ })
8
+ })
@@ -1,5 +1,5 @@
1
- const { getSchemeBatchProperties } = require('../../app/get-scheme-batch-properties')
2
- const schemeBatchProperties = require('../../app/constants/scheme-batch-properties')
1
+ const { getSchemeBatchProperties } = require('../../../app/scheme-properties/get-scheme-batch-properties')
2
+ const schemeBatchProperties = require('../../../app/constants/scheme-batch-properties')
3
3
 
4
4
  describe('get scheme batch properties', () => {
5
5
  test.each(schemeBatchProperties)(
@@ -1,6 +1,6 @@
1
- const { getSchemeProperties } = require('../../app/get-scheme-properties')
2
- const schemes = require('../../app/constants/schemes')
3
- const { MANUAL } = require('../../app/constants/scheme-ids')
1
+ const { getSchemeProperties } = require('../../../app/scheme-properties/get-scheme-properties')
2
+ const schemes = require('../../../app/constants/schemes')
3
+ const { MANUAL } = require('../../../app/constants/scheme-ids')
4
4
 
5
5
  describe('getSchemeProperties', () => {
6
6
  test.each(schemes)(
@@ -1,7 +1,8 @@
1
- const { getSchemes } = require('../../app/get-schemes')
2
- const schemeIds = require('../../app/constants/scheme-ids')
3
- const schemeNames = require('../../app/constants/scheme-names')
4
- const sourceSystems = require('../../app/constants/source-systems')
1
+ const { getSchemes } = require('../../../app/scheme-properties/get-schemes')
2
+ const pillars = require('../../../app/constants/pillars')
3
+ const schemeIds = require('../../../app/constants/scheme-ids')
4
+ const schemeNames = require('../../../app/constants/scheme-names')
5
+ const sourceSystems = require('../../../app/constants/source-systems')
5
6
 
6
7
  describe('getSchemes', () => {
7
8
  test('returns all schemes with their IDs and names', () => {
@@ -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
  )
@@ -1,10 +1,10 @@
1
- jest.mock('../../app/get-schemes', () => ({
1
+ jest.mock('../../../app/scheme-properties/get-schemes', () => ({
2
2
  getSchemes: jest.fn()
3
3
  }))
4
4
 
5
- const { UNKNOWN } = require('../../app/constants/unknown')
6
- const { getSchemes } = require('../../app/get-schemes')
7
- const { getSourceSystemFromSchemeId } = require('../../app/get-source-system-from-scheme-id')
5
+ const { UNKNOWN } = require('../../../app/constants/unknown')
6
+ const { getSchemes } = require('../../../app/scheme-properties/get-schemes')
7
+ const { getSourceSystemFromSchemeId } = require('../../../app/source-system/get-source-system-from-scheme-id')
8
8
 
9
9
  describe('getSourceSystemFromSchemeId', () => {
10
10
  beforeEach(() => {
@@ -0,0 +1,8 @@
1
+ const { getSourceSystems } = require('../../../app/source-system/get-source-systems')
2
+ const sourceSystems = require('../../../app/constants/source-systems')
3
+
4
+ describe('getSourceSystems', () => {
5
+ test('returns all source systems', () => {
6
+ expect(getSourceSystems()).toEqual(sourceSystems)
7
+ })
8
+ })