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.
- package/README.md +5 -1
- package/app/constants/frps-schemes.js +3 -0
- package/app/helpers/get-reporting-data-filter.js +23 -0
- package/app/helpers/is-frps.js +9 -0
- package/app/{is-valid-scheme-id.js → helpers/is-valid-scheme-id.js} +1 -1
- package/app/{scheme-does-not-require-ppas.js → helpers/scheme-does-not-require-ppas.js} +1 -1
- package/app/{scheme-provides-accounting-values.js → helpers/scheme-provides-accounting-values.js} +1 -1
- package/app/{get-scheme-id-from-pillar.js → scheme-id/get-scheme-id-from-pillar.js} +1 -1
- package/app/{get-scheme-id-from-source-system.js → scheme-id/get-scheme-id-from-source-system.js} +1 -1
- package/app/{get-scheme-ids.js → scheme-id/get-scheme-ids.js} +1 -1
- package/app/{get-scheme-name-from-scheme-id.js → scheme-name/get-scheme-name-from-scheme-id.js} +2 -2
- package/app/{get-scheme-names.js → scheme-name/get-scheme-names.js} +1 -1
- package/app/{get-scheme-batch-properties.js → scheme-properties/get-scheme-batch-properties.js} +1 -1
- package/app/{get-scheme-properties.js → scheme-properties/get-scheme-properties.js} +2 -2
- package/app/scheme-properties/get-schemes.js +16 -0
- package/app/{get-source-system-from-scheme-id.js → source-system/get-source-system-from-scheme-id.js} +2 -2
- package/app/{get-source-systems.js → source-system/get-source-systems.js} +1 -1
- package/index.js +17 -13
- package/package.json +1 -1
- package/test/unit/helpers/get-reporting-data-filter.test.js +44 -0
- package/test/unit/helpers/is-frps.test.js +17 -0
- package/test/unit/{is-valid-scheme-id.test.js → helpers/is-valid-scheme-id.test.js} +2 -2
- package/test/unit/{scheme-does-not-require-ppas.test.js → helpers/scheme-does-not-require-ppas.test.js} +3 -3
- package/test/unit/{scheme-provides-accounting-values.test.js → helpers/scheme-provides-accounting-values.test.js} +3 -3
- package/test/unit/{get-scheme-id-from-pillar.test.js → scheme-id/get-scheme-id-from-pillar.test.js} +3 -3
- package/test/unit/{get-scheme-id-from-source-system.test.js → scheme-id/get-scheme-id-from-source-system.test.js} +3 -3
- package/test/unit/scheme-id/get-scheme-ids.test.js +8 -0
- package/test/unit/{get-scheme-name-from-scheme-id.test.js → scheme-name/get-scheme-name-from-scheme-id.test.js} +4 -4
- package/test/unit/scheme-name/get-scheme-names.test.js +8 -0
- package/test/unit/{get-scheme-batch-properties.test.js → scheme-properties/get-scheme-batch-properties.test.js} +2 -2
- package/test/unit/{get-scheme-properties.test.js → scheme-properties/get-scheme-properties.test.js} +3 -3
- package/test/unit/{get-schemes.test.js → scheme-properties/get-schemes.test.js} +9 -6
- package/test/unit/{get-source-system-from-scheme-id.test.js → source-system/get-source-system-from-scheme-id.test.js} +4 -4
- package/test/unit/source-system/get-source-systems.test.js +8 -0
- package/test-output/cobertura-coverage.xml +328 -263
- package/test-output/junit.xml +338 -312
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/frps-schemes.js.html +94 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +18 -3
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +2 -2
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +2 -2
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-pillar.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-id-from-source-system.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-ids.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-name-from-scheme-id.js.html +22 -22
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-names.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +12 -6
- package/test-output/lcov-report/ffc-pay-schemes/app/get-source-system-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-source-systems.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-reporting-data-filter.js.html +154 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/index.html +176 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-frps.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-valid-scheme-id.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-does-not-require-ppas.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-provides-accounting-values.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/index.html +21 -186
- package/test-output/lcov-report/ffc-pay-schemes/app/is-valid-scheme-id.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-pillar.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-source-system.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-ids.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/index.html +146 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/is-valid-scheme-id.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-name-from-scheme-id.js.html +118 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-names.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/index.html +131 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-batch-properties.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-properties.js.html +178 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-schemes.js.html +133 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/index.html +146 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/scheme-does-not-require-ppas.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/scheme-provides-accounting-values.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-system-from-scheme-id.js.html +118 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-systems.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/source-system/index.html +131 -0
- package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
- package/test-output/lcov-report/ffc-pay-schemes/index.js.html +34 -16
- package/test-output/lcov-report/index.html +86 -26
- package/test-output/lcov.info +307 -249
- package/app/get-schemes.js +0 -14
- package/test/unit/get-scheme-ids.test.js +0 -8
- package/test/unit/get-scheme-names.test.js +0 -8
- 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 `
|
|
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,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
|
+
}
|
package/app/{scheme-provides-accounting-values.js → helpers/scheme-provides-accounting-values.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const schemesProvidingAccountingValues = require('
|
|
1
|
+
const schemesProvidingAccountingValues = require('../constants/schemes-providing-account-values')
|
|
2
2
|
|
|
3
3
|
const schemeProvidesAccountingValues = (schemeId) => {
|
|
4
4
|
return schemesProvidingAccountingValues.includes(schemeId)
|
package/app/{get-scheme-name-from-scheme-id.js → scheme-name/get-scheme-name-from-scheme-id.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { UNKNOWN } = require('
|
|
2
|
-
const { getSchemes } = require('
|
|
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)
|
package/app/{get-scheme-batch-properties.js → scheme-properties/get-scheme-batch-properties.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const schemeBatchProperties = require('
|
|
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('
|
|
2
|
-
const { MANUAL } = require('
|
|
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('
|
|
2
|
-
const { getSchemes } = require('
|
|
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)
|
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 {
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
7
|
-
const {
|
|
8
|
-
const {
|
|
9
|
-
const {
|
|
10
|
-
const {
|
|
11
|
-
const {
|
|
12
|
-
const {
|
|
13
|
-
const {
|
|
14
|
-
const {
|
|
15
|
-
const {
|
|
16
|
-
const {
|
|
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
|
@@ -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('
|
|
2
|
-
const { isValidSchemeId } = require('
|
|
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('
|
|
2
|
-
const schemeIds = require('
|
|
3
|
-
const schemesNotRequiringPPAs = require('
|
|
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('
|
|
2
|
-
const schemeIds = require('
|
|
3
|
-
const schemesProvidingAccountingValues = require('
|
|
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))(
|
package/test/unit/{get-scheme-id-from-pillar.test.js → scheme-id/get-scheme-id-from-pillar.test.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
jest.mock('
|
|
1
|
+
jest.mock('../../../app/scheme-properties/get-schemes', () => ({
|
|
2
2
|
getSchemes: jest.fn()
|
|
3
3
|
}))
|
|
4
4
|
|
|
5
|
-
const { getSchemes } = require('
|
|
6
|
-
const { getSchemeIdFromPillar } = require('
|
|
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('
|
|
1
|
+
jest.mock('../../../app/scheme-properties/get-schemes', () => ({
|
|
2
2
|
getSchemes: jest.fn()
|
|
3
3
|
}))
|
|
4
4
|
|
|
5
|
-
const { getSchemes } = require('
|
|
6
|
-
const { getSchemeIdFromSourceSystem } = require('
|
|
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('
|
|
1
|
+
jest.mock('../../../app/scheme-properties/get-schemes', () => ({
|
|
2
2
|
getSchemes: jest.fn()
|
|
3
3
|
}))
|
|
4
4
|
|
|
5
|
-
const { getSchemes } = require('
|
|
6
|
-
const { getSchemeNameFromSchemeId } = require('
|
|
7
|
-
const { UNKNOWN } = require('
|
|
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('
|
|
2
|
-
const schemeBatchProperties = require('
|
|
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)(
|
package/test/unit/{get-scheme-properties.test.js → scheme-properties/get-scheme-properties.test.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { getSchemeProperties } = require('
|
|
2
|
-
const schemes = require('
|
|
3
|
-
const { MANUAL } = require('
|
|
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('
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
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('
|
|
1
|
+
jest.mock('../../../app/scheme-properties/get-schemes', () => ({
|
|
2
2
|
getSchemes: jest.fn()
|
|
3
3
|
}))
|
|
4
4
|
|
|
5
|
-
const { UNKNOWN } = require('
|
|
6
|
-
const { getSchemes } = require('
|
|
7
|
-
const { getSourceSystemFromSchemeId } = require('
|
|
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
|
+
})
|