ffc-pay-schemes 1.1.2 → 1.1.4
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 +1 -1
- package/app/scheme-id/get-scheme-id-from-pillar.js +3 -1
- package/app/scheme-properties/get-siti-agri-schemes.js +20 -6
- package/package.json +1 -1
- package/test/unit/scheme-id/get-scheme-id-from-pillar.test.js +28 -0
- package/test/unit/scheme-properties/get-siti-agri-schemes.test.js +30 -6
- package/test-output/cobertura-coverage.xml +32 -26
- package/test-output/junit.xml +384 -378
- package/test-output/lcov-report/constants/account-codes/ap.js.html +1 -1
- package/test-output/lcov-report/constants/account-codes/ar-admin.js.html +1 -1
- package/test-output/lcov-report/constants/account-codes/ar-irregular.js.html +1 -1
- package/test-output/lcov-report/constants/account-codes/index.html +1 -1
- package/test-output/lcov-report/constants/delivery-bodies.js.html +1 -1
- package/test-output/lcov-report/constants/description-codes.js.html +1 -1
- package/test-output/lcov-report/constants/file-masks.js.html +1 -1
- package/test-output/lcov-report/constants/frps-schemes.js.html +1 -1
- package/test-output/lcov-report/constants/fund-codes.js.html +1 -1
- package/test-output/lcov-report/constants/index.html +5 -20
- package/test-output/lcov-report/constants/manual-sources.js.html +1 -1
- package/test-output/lcov-report/constants/pillars.js.html +1 -1
- package/test-output/lcov-report/constants/scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/constants/scheme-ids.js.html +1 -1
- package/test-output/lcov-report/constants/scheme-names.js.html +1 -1
- package/test-output/lcov-report/constants/schemes-not-requiring-ppas.js.html +1 -1
- package/test-output/lcov-report/constants/schemes-providing-account-values.js.html +1 -1
- package/test-output/lcov-report/constants/schemes.js.html +1 -1
- package/test-output/lcov-report/constants/sequence-positions.js.html +1 -1
- package/test-output/lcov-report/constants/siti-agri-schemes.js.html +1 -1
- package/test-output/lcov-report/constants/source-systems.js.html +1 -1
- package/test-output/lcov-report/constants/unknown.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/create-es-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/create-imps-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/index.html +1 -1
- package/test-output/lcov-report/create-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
- package/test-output/lcov-report/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/create-split-invoice-number/index.html +1 -1
- package/test-output/lcov-report/create-split-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/bps-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/cohtc-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/cs-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/default-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/delinked-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/index.html +1 -1
- package/test-output/lcov-report/get-account-code-map/index.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/lump-sums-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/sfi-frps-map.js.html +1 -1
- package/test-output/lcov-report/get-account-code-map/vet-visits-map.js.html +1 -1
- package/test-output/lcov-report/helpers/get-batch-sequence-from-file-name.js.html +1 -1
- package/test-output/lcov-report/helpers/get-delivery-body-from-scheme-id.js.html +115 -0
- package/test-output/lcov-report/helpers/get-fund-code-from-scheme-id.js.html +115 -0
- package/test-output/lcov-report/helpers/get-journal-source-from-pillar.js.html +1 -1
- package/test-output/lcov-report/helpers/get-reporting-data-filter.js.html +1 -1
- package/test-output/lcov-report/helpers/index.html +1 -1
- package/test-output/lcov-report/helpers/is-frps.js.html +1 -1
- package/test-output/lcov-report/helpers/is-siti-agri.js.html +1 -1
- package/test-output/lcov-report/helpers/scheme-does-not-require-ppas.js.html +1 -1
- package/test-output/lcov-report/helpers/scheme-provides-accounting-values.js.html +1 -1
- package/test-output/lcov-report/index.html +26 -26
- package/test-output/lcov-report/pillar/get-pillar-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/pillar/get-pillars.js.html +1 -1
- package/test-output/lcov-report/pillar/index.html +1 -1
- package/test-output/lcov-report/scheme-id/get-scheme-id-from-pillar.js.html +13 -7
- package/test-output/lcov-report/scheme-id/get-scheme-id-from-source-system.js.html +1 -1
- package/test-output/lcov-report/scheme-id/get-scheme-ids.js.html +1 -1
- package/test-output/lcov-report/scheme-id/get-siti-agri-scheme-ids.js.html +1 -1
- package/test-output/lcov-report/scheme-id/index.html +5 -5
- package/test-output/lcov-report/scheme-id/is-valid-scheme-id.js.html +1 -1
- package/test-output/lcov-report/scheme-name/get-scheme-name-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/scheme-name/get-scheme-names.js.html +1 -1
- package/test-output/lcov-report/scheme-name/index.html +1 -1
- package/test-output/lcov-report/scheme-properties/get-scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/scheme-properties/get-scheme-from-batch-file-name.js.html +1 -1
- package/test-output/lcov-report/scheme-properties/get-scheme-properties.js.html +1 -1
- package/test-output/lcov-report/scheme-properties/get-schemes.js.html +1 -1
- package/test-output/lcov-report/scheme-properties/get-siti-agri-schemes.js.html +58 -16
- package/test-output/lcov-report/scheme-properties/index.html +18 -18
- package/test-output/lcov-report/source-system/get-source-system-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/source-system/get-source-systems.js.html +1 -1
- package/test-output/lcov-report/source-system/index.html +1 -1
- package/test-output/lcov.info +39 -33
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ const {
|
|
|
53
53
|
- `getReportingDataFilter(schemeId)` returns the fields which should be added to any data filters applied in reporting checks, for a given `schemeId`.
|
|
54
54
|
- `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
|
|
55
55
|
- `getSchemeFromBatchFileName(fileName)` returns the supported scheme details based on the expected file mask matching the supplied `fileName`.
|
|
56
|
-
- `getSchemeIdFromPillar(pillar)` returns the scheme ID for a given `pillar`.
|
|
56
|
+
- `getSchemeIdFromPillar(pillar)` returns the scheme ID for a given `pillar`. Note the pillar match is case insensitive, i.e. `sfi26` and `Sfi26` will both match with `SFI26`.
|
|
57
57
|
- `getSchemeIdFromSourceSystem(sourceSystem)` returns the scheme ID for a given `sourceSystem`.
|
|
58
58
|
- `getSchemeIds()` returns all supported scheme IDs.
|
|
59
59
|
- `getSchemeNameFromSchemeId(schemeId)` returns the scheme name for a given `schemeId`.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const { getSchemes } = require('../scheme-properties/get-schemes')
|
|
2
2
|
|
|
3
3
|
const getSchemeIdFromPillar = (pillar) => {
|
|
4
|
-
const matchingScheme = getSchemes().find((scheme) =>
|
|
4
|
+
const matchingScheme = getSchemes().find((scheme) =>
|
|
5
|
+
String(scheme.pillar ?? '').toLowerCase() === String(pillar ?? '').toLowerCase()
|
|
6
|
+
)
|
|
5
7
|
return matchingScheme?.schemeId
|
|
6
8
|
}
|
|
7
9
|
|
|
@@ -2,14 +2,28 @@ const pillars = require('../constants/pillars')
|
|
|
2
2
|
const sitiAgriSchemeIds = require('../constants/siti-agri-schemes')
|
|
3
3
|
const schemeNames = require('../constants/scheme-names')
|
|
4
4
|
const sourceSystems = require('../constants/source-systems')
|
|
5
|
+
const schemeIds = require('../constants/scheme-ids')
|
|
6
|
+
|
|
7
|
+
const schemeKeyById = Object.entries(schemeIds).reduce((acc, [key, value]) => {
|
|
8
|
+
acc[value] = key
|
|
9
|
+
return acc
|
|
10
|
+
}, {})
|
|
5
11
|
|
|
6
12
|
const getSitiAgriSchemes = () =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
sitiAgriSchemeIds.map((schemeId) => {
|
|
14
|
+
const schemeKey = schemeKeyById[schemeId]
|
|
15
|
+
|
|
16
|
+
if (!schemeKey) {
|
|
17
|
+
throw new Error(`No scheme metadata found for schemeId: ${schemeId}`)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
schemeId,
|
|
22
|
+
schemeName: schemeNames[schemeKey],
|
|
23
|
+
sourceSystem: sourceSystems[schemeKey],
|
|
24
|
+
pillar: pillars[schemeKey]
|
|
25
|
+
}
|
|
26
|
+
})
|
|
13
27
|
|
|
14
28
|
module.exports = {
|
|
15
29
|
getSitiAgriSchemes
|
package/package.json
CHANGED
|
@@ -23,6 +23,34 @@ describe('getSchemeIdFromPillar', () => {
|
|
|
23
23
|
expect(getSchemeIdFromPillar('Example Pillar')).toBe(1)
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
+
test('matches the pillar regardless of case', () => {
|
|
27
|
+
getSchemes.mockReturnValue([
|
|
28
|
+
{
|
|
29
|
+
schemeId: 2,
|
|
30
|
+
schemeName: 'Example Scheme',
|
|
31
|
+
sourceSystem: 'Example Source',
|
|
32
|
+
pillar: 'Example Pillar'
|
|
33
|
+
}
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
expect(getSchemeIdFromPillar('example pillar')).toBe(2)
|
|
37
|
+
expect(getSchemeIdFromPillar('EXAMPLE PILLAR')).toBe(2)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('treats nullish pillar values as empty strings when comparing', () => {
|
|
41
|
+
getSchemes.mockReturnValue([
|
|
42
|
+
{
|
|
43
|
+
schemeId: 3,
|
|
44
|
+
schemeName: 'Example Scheme',
|
|
45
|
+
sourceSystem: 'Example Source',
|
|
46
|
+
pillar: undefined
|
|
47
|
+
}
|
|
48
|
+
])
|
|
49
|
+
|
|
50
|
+
expect(getSchemeIdFromPillar(undefined)).toBe(3)
|
|
51
|
+
expect(getSchemeIdFromPillar('')).toBe(3)
|
|
52
|
+
})
|
|
53
|
+
|
|
26
54
|
test('returns undefined when the pillar is not found', () => {
|
|
27
55
|
getSchemes.mockReturnValue([
|
|
28
56
|
{
|
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
const sitiAgriSchemeIds = require('../../../app/constants/siti-agri-schemes')
|
|
2
|
+
const schemeIds = require('../../../app/constants/scheme-ids')
|
|
2
3
|
const schemeNames = require('../../../app/constants/scheme-names')
|
|
3
4
|
const sourceSystems = require('../../../app/constants/source-systems')
|
|
4
5
|
const pillars = require('../../../app/constants/pillars')
|
|
5
6
|
const { getSitiAgriSchemes } = require('../../../app/scheme-properties/get-siti-agri-schemes')
|
|
6
7
|
|
|
8
|
+
const schemeKeyById = Object.entries(schemeIds).reduce((acc, [key, value]) => {
|
|
9
|
+
acc[value] = key
|
|
10
|
+
return acc
|
|
11
|
+
}, {})
|
|
12
|
+
|
|
7
13
|
describe('getSitiAgriSchemes', () => {
|
|
8
14
|
test('returns one scheme object for each SITI Agri scheme id', () => {
|
|
9
|
-
const expected =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const expected = sitiAgriSchemeIds.map((schemeId) => {
|
|
16
|
+
const schemeKey = schemeKeyById[schemeId]
|
|
17
|
+
|
|
18
|
+
expect(schemeKey).toBeDefined()
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
schemeId,
|
|
22
|
+
schemeName: schemeNames[schemeKey],
|
|
23
|
+
sourceSystem: sourceSystems[schemeKey],
|
|
24
|
+
pillar: pillars[schemeKey]
|
|
25
|
+
}
|
|
26
|
+
})
|
|
15
27
|
|
|
16
28
|
expect(getSitiAgriSchemes()).toEqual(expected)
|
|
17
29
|
})
|
|
30
|
+
|
|
31
|
+
test('returns the correct metadata for specific scheme (SFI23)', () => {
|
|
32
|
+
const schemes = getSitiAgriSchemes()
|
|
33
|
+
const sfi23 = schemes.find((scheme) => scheme.schemeId === schemeIds.SFI23)
|
|
34
|
+
|
|
35
|
+
expect(sfi23).toEqual({
|
|
36
|
+
schemeId: schemeIds.SFI23,
|
|
37
|
+
schemeName: schemeNames.SFI23,
|
|
38
|
+
sourceSystem: sourceSystems.SFI23,
|
|
39
|
+
pillar: pillars.SFI23
|
|
40
|
+
})
|
|
41
|
+
})
|
|
18
42
|
})
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
<?xml version="1.0" ?>
|
|
2
2
|
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
|
|
3
|
-
<coverage lines-valid="
|
|
3
|
+
<coverage lines-valid="321" lines-covered="320" line-rate="0.9968" branches-valid="73" branches-covered="72" branch-rate="0.9863" timestamp="1793200016011" complexity="0" version="0.1">
|
|
4
4
|
<sources>
|
|
5
5
|
<source>/home/samplackett/ffc-pay-schemes</source>
|
|
6
6
|
</sources>
|
|
7
7
|
<packages>
|
|
8
|
-
<package name="constants" line-rate="
|
|
8
|
+
<package name="constants" line-rate="1" branch-rate="1">
|
|
9
9
|
<classes>
|
|
10
|
-
<class name="batch-schemes.js" filename="app/constants/batch-schemes.js" line-rate="0" branch-rate="1">
|
|
11
|
-
<methods>
|
|
12
|
-
</methods>
|
|
13
|
-
<lines>
|
|
14
|
-
<line number="1" hits="0" branch="false"/>
|
|
15
|
-
<line number="3" hits="0" branch="false"/>
|
|
16
|
-
</lines>
|
|
17
|
-
</class>
|
|
18
10
|
<class name="delivery-bodies.js" filename="app/constants/delivery-bodies.js" line-rate="1" branch-rate="1">
|
|
19
11
|
<methods>
|
|
20
12
|
</methods>
|
|
@@ -675,23 +667,24 @@
|
|
|
675
667
|
<classes>
|
|
676
668
|
<class name="get-scheme-id-from-pillar.js" filename="app/scheme-id/get-scheme-id-from-pillar.js" line-rate="1" branch-rate="1">
|
|
677
669
|
<methods>
|
|
678
|
-
<method name="(anonymous_0)" hits="
|
|
670
|
+
<method name="(anonymous_0)" hits="8" signature="()V">
|
|
679
671
|
<lines>
|
|
680
|
-
<line number="3" hits="
|
|
672
|
+
<line number="3" hits="8"/>
|
|
681
673
|
</lines>
|
|
682
674
|
</method>
|
|
683
|
-
<method name="(anonymous_1)" hits="
|
|
675
|
+
<method name="(anonymous_1)" hits="6" signature="()V">
|
|
684
676
|
<lines>
|
|
685
|
-
<line number="4" hits="
|
|
677
|
+
<line number="4" hits="6"/>
|
|
686
678
|
</lines>
|
|
687
679
|
</method>
|
|
688
680
|
</methods>
|
|
689
681
|
<lines>
|
|
690
682
|
<line number="1" hits="1" branch="false"/>
|
|
691
683
|
<line number="3" hits="1" branch="false"/>
|
|
692
|
-
<line number="4" hits="
|
|
693
|
-
<line number="5" hits="
|
|
694
|
-
<line number="
|
|
684
|
+
<line number="4" hits="8" branch="false"/>
|
|
685
|
+
<line number="5" hits="6" branch="true" condition-coverage="100% (4/4)"/>
|
|
686
|
+
<line number="7" hits="8" branch="false"/>
|
|
687
|
+
<line number="10" hits="1" branch="false"/>
|
|
695
688
|
</lines>
|
|
696
689
|
</class>
|
|
697
690
|
<class name="get-scheme-id-from-source-system.js" filename="app/scheme-id/get-scheme-id-from-source-system.js" line-rate="1" branch-rate="1">
|
|
@@ -804,7 +797,7 @@
|
|
|
804
797
|
</class>
|
|
805
798
|
</classes>
|
|
806
799
|
</package>
|
|
807
|
-
<package name="scheme-properties" line-rate="
|
|
800
|
+
<package name="scheme-properties" line-rate="0.9777" branch-rate="0.9166">
|
|
808
801
|
<classes>
|
|
809
802
|
<class name="get-scheme-batch-properties.js" filename="app/scheme-properties/get-scheme-batch-properties.js" line-rate="1" branch-rate="1">
|
|
810
803
|
<methods>
|
|
@@ -910,16 +903,21 @@
|
|
|
910
903
|
<line number="14" hits="1" branch="false"/>
|
|
911
904
|
</lines>
|
|
912
905
|
</class>
|
|
913
|
-
<class name="get-siti-agri-schemes.js" filename="app/scheme-properties/get-siti-agri-schemes.js" line-rate="
|
|
906
|
+
<class name="get-siti-agri-schemes.js" filename="app/scheme-properties/get-siti-agri-schemes.js" line-rate="0.9333" branch-rate="0.5">
|
|
914
907
|
<methods>
|
|
915
|
-
<method name="(anonymous_0)" hits="
|
|
908
|
+
<method name="(anonymous_0)" hits="18" signature="()V">
|
|
909
|
+
<lines>
|
|
910
|
+
<line number="7" hits="18"/>
|
|
911
|
+
</lines>
|
|
912
|
+
</method>
|
|
913
|
+
<method name="(anonymous_1)" hits="2" signature="()V">
|
|
916
914
|
<lines>
|
|
917
|
-
<line number="
|
|
915
|
+
<line number="12" hits="2"/>
|
|
918
916
|
</lines>
|
|
919
917
|
</method>
|
|
920
|
-
<method name="(
|
|
918
|
+
<method name="(anonymous_2)" hits="22" signature="()V">
|
|
921
919
|
<lines>
|
|
922
|
-
<line number="
|
|
920
|
+
<line number="13" hits="22"/>
|
|
923
921
|
</lines>
|
|
924
922
|
</method>
|
|
925
923
|
</methods>
|
|
@@ -928,9 +926,17 @@
|
|
|
928
926
|
<line number="2" hits="1" branch="false"/>
|
|
929
927
|
<line number="3" hits="1" branch="false"/>
|
|
930
928
|
<line number="4" hits="1" branch="false"/>
|
|
931
|
-
<line number="
|
|
932
|
-
<line number="7" hits="
|
|
933
|
-
<line number="
|
|
929
|
+
<line number="5" hits="1" branch="false"/>
|
|
930
|
+
<line number="7" hits="1" branch="false"/>
|
|
931
|
+
<line number="8" hits="18" branch="false"/>
|
|
932
|
+
<line number="9" hits="18" branch="false"/>
|
|
933
|
+
<line number="12" hits="1" branch="false"/>
|
|
934
|
+
<line number="13" hits="2" branch="false"/>
|
|
935
|
+
<line number="14" hits="22" branch="false"/>
|
|
936
|
+
<line number="16" hits="22" branch="true" condition-coverage="50% (1/2)"/>
|
|
937
|
+
<line number="17" hits="0" branch="false"/>
|
|
938
|
+
<line number="20" hits="22" branch="false"/>
|
|
939
|
+
<line number="28" hits="1" branch="false"/>
|
|
934
940
|
</lines>
|
|
935
941
|
</class>
|
|
936
942
|
</classes>
|