ffc-pay-schemes 1.0.12 → 1.0.13

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 (82) hide show
  1. package/README.md +4 -0
  2. package/app/constants/file-masks.js +14 -0
  3. package/app/constants/schemes.js +26 -13
  4. package/app/constants/sequence-positions.js +13 -0
  5. package/app/helpers/get-batch-sequence-from-file-name.js +34 -0
  6. package/app/scheme-properties/get-scheme-from-batch-file-name.js +11 -0
  7. package/index.js +4 -0
  8. package/package.json +1 -1
  9. package/test/unit/helpers/get-batch-sequence-from-file-name.test.js +55 -0
  10. package/test/unit/scheme-properties/get-scheme-from-batch-file-name.test.js +51 -0
  11. package/test-output/cobertura-coverage.xml +99 -4
  12. package/test-output/junit.xml +358 -306
  13. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +1 -1
  14. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +1 -1
  15. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +1 -1
  16. package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +1 -1
  17. package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +1 -1
  18. package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +1 -1
  19. package/test-output/lcov-report/ffc-pay-schemes/app/constants/file-masks.js.html +127 -0
  20. package/test-output/lcov-report/ffc-pay-schemes/app/constants/frps-schemes.js.html +1 -1
  21. package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +1 -1
  22. package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +52 -7
  23. package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +1 -1
  24. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +1 -1
  25. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +2 -2
  26. package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
  27. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
  28. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
  29. package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +57 -18
  30. package/test-output/lcov-report/ffc-pay-schemes/app/constants/sequence-positions.js.html +124 -0
  31. package/test-output/lcov-report/ffc-pay-schemes/app/constants/siti-agri-schemes.js.html +1 -1
  32. package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
  33. package/test-output/lcov-report/ffc-pay-schemes/app/constants/unknown.js.html +1 -1
  34. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
  35. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
  36. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
  37. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  38. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
  39. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
  40. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
  41. package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
  42. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
  43. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
  44. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
  45. package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
  46. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
  47. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
  48. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
  49. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
  50. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
  51. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
  52. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
  53. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
  54. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
  55. package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
  56. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-batch-sequence-from-file-name.js.html +187 -0
  57. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-reporting-data-filter.js.html +1 -1
  58. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/index.html +35 -5
  59. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-frps.js.html +1 -1
  60. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-siti-agri.js.html +1 -1
  61. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-valid-scheme-id.js.html +1 -1
  62. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-does-not-require-ppas.js.html +1 -1
  63. package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-provides-accounting-values.js.html +1 -1
  64. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-pillar.js.html +1 -1
  65. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-source-system.js.html +1 -1
  66. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-ids.js.html +1 -1
  67. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/index.html +1 -1
  68. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-name-from-scheme-id.js.html +1 -1
  69. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-names.js.html +1 -1
  70. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/index.html +1 -1
  71. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-batch-properties.js.html +1 -1
  72. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-from-batch-file-name.js.html +118 -0
  73. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-properties.js.html +1 -1
  74. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-schemes.js.html +1 -1
  75. package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/index.html +19 -4
  76. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-system-from-scheme-id.js.html +1 -1
  77. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-systems.js.html +1 -1
  78. package/test-output/lcov-report/ffc-pay-schemes/app/source-system/index.html +1 -1
  79. package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
  80. package/test-output/lcov-report/ffc-pay-schemes/index.js.html +22 -4
  81. package/test-output/lcov-report/index.html +22 -22
  82. package/test-output/lcov.info +109 -5
package/README.md CHANGED
@@ -17,8 +17,10 @@ const {
17
17
  createInvoiceNumber,
18
18
  createSplitInvoiceNumber,
19
19
  getAccountCodeMap,
20
+ getBatchSequenceFromFileName,
20
21
  getReportingDataFilter,
21
22
  getSchemeBatchProperties,
23
+ getSchemeFromBatchFileName,
22
24
  getSchemeIdFromPillar,
23
25
  getSchemeIdFromSourceSystem,
24
26
  getSchemeIds,
@@ -39,8 +41,10 @@ const {
39
41
  - `createInvoiceNumber(paymentRequest)` creates an invoice number for a given `paymentRequest`.
40
42
  - `createSplitInvoiceNumber(paymentRequest)` creates a split invoice number for a given `paymentRequest`.
41
43
  - `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
44
+ - `getBatchSequenceFromFileName(schemeId, fileName)` returns the sequence as identified in the supplied `fileName`, checking the correct position using the `schemeId`.
42
45
  - `getReportingDataFilter(schemeId)` returns the fields which should be added to any data filters applied in reporting checks, for a given `schemeId`.
43
46
  - `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
47
+ - `getSchemeFromBatchFileName(fileName)` returns the supported scheme details based on the expected file mask matching the supplied `fileName`.
44
48
  - `getSchemeIdFromPillar(pillar)` returns the scheme ID for a given `pillar`.
45
49
  - `getSchemeIdFromSourceSystem(sourceSystem)` returns the scheme ID for a given `sourceSystem`.
46
50
  - `getSchemeIds()` returns all supported scheme IDs.
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ SFI: /^SITISFI\d{4}_AP_\d*.dat$/,
3
+ SFI_PILOT: /^SITIELM\d{4}_AP_\d*.dat$/,
4
+ LUMP_SUMS: /^SITILSES\d{4}_AP_\d*.dat$/,
5
+ CS: /^SITICS\d{4}_AP_\d*.dat$/,
6
+ BPS: /^SITI_\d{4}_AP_\d*.dat$/,
7
+ ES: /^GENESISPayReq_\d{8}_\d{4}.gne$/,
8
+ FC: /^FCAP_\d{4}_\d*\.dat$/,
9
+ IMPS: /^FIN_IMPS_A[P|R]_\d*.INT$/,
10
+ SFI23: /^SITISFIA\d{4}_AP_\d*.dat$/,
11
+ DELINKED: /^SITIDP\d{4}_AP_\d*.dat$/,
12
+ SFI_EXPANDED: /^ESFIO\d{4}_AP_\d*.dat$/,
13
+ COHT_CAPITAL: /^SITICOHTC\d{4}_AP_\d*.dat$/
14
+ }
@@ -1,6 +1,7 @@
1
+ const fileMasks = require('./file-masks')
2
+ const pillars = require('./pillars')
1
3
  const schemeIds = require('./scheme-ids')
2
4
  const sourceSystems = require('./source-systems')
3
- const pillars = require('./pillars')
4
5
  const { RP00, NE00, FC00, RP10 } = require('./delivery-bodies')
5
6
  const { DRD10, DOM10, ERD14, EGF00, EXQ00, DOM00 } = require('./fund-codes')
6
7
 
@@ -10,21 +11,24 @@ module.exports = Object.freeze([
10
11
  sourceSystem: sourceSystems.SFI,
11
12
  pillar: pillars.SFI,
12
13
  deliveryBody: RP00,
13
- fundCode: DRD10
14
+ fundCode: DRD10,
15
+ fileMask: fileMasks.SFI
14
16
  },
15
17
  {
16
18
  schemeId: schemeIds.SFI_PILOT,
17
19
  sourceSystem: sourceSystems.SFI_PILOT,
18
20
  pillar: pillars.SFI_PILOT,
19
21
  deliveryBody: RP00,
20
- fundCode: DRD10
22
+ fundCode: DRD10,
23
+ fileMask: fileMasks.SFI_PILOT
21
24
  },
22
25
  {
23
26
  schemeId: schemeIds.LUMP_SUMS,
24
27
  sourceSystem: sourceSystems.LUMP_SUMS,
25
28
  pillar: pillars.LUMP_SUMS,
26
29
  deliveryBody: RP00,
27
- fundCode: DOM10
30
+ fundCode: DOM10,
31
+ fileMask: fileMasks.LUMP_SUMS
28
32
  },
29
33
  {
30
34
  schemeId: schemeIds.VET_VISITS,
@@ -38,14 +42,16 @@ module.exports = Object.freeze([
38
42
  sourceSystem: sourceSystems.CS,
39
43
  pillar: pillars.CS,
40
44
  deliveryBody: NE00,
41
- fundCode: ERD14
45
+ fundCode: ERD14,
46
+ fileMask: fileMasks.CS
42
47
  },
43
48
  {
44
49
  schemeId: schemeIds.BPS,
45
50
  sourceSystem: sourceSystems.BPS,
46
51
  pillar: pillars.BPS,
47
52
  deliveryBody: RP00,
48
- fundCode: EGF00
53
+ fundCode: EGF00,
54
+ fileMask: fileMasks.BPS
49
55
  },
50
56
  {
51
57
  schemeId: schemeIds.MANUAL,
@@ -59,42 +65,48 @@ module.exports = Object.freeze([
59
65
  sourceSystem: sourceSystems.ES,
60
66
  pillar: pillars.ES,
61
67
  deliveryBody: NE00,
62
- fundCode: EXQ00
68
+ fundCode: EXQ00,
69
+ fileMask: fileMasks.ES
63
70
  },
64
71
  {
65
72
  schemeId: schemeIds.FC,
66
73
  sourceSystem: sourceSystems.FC,
67
74
  pillar: pillars.FC,
68
75
  deliveryBody: FC00,
69
- fundCode: DOM00
76
+ fundCode: DOM00,
77
+ fileMask: fileMasks.FC
70
78
  },
71
79
  {
72
80
  schemeId: schemeIds.IMPS,
73
81
  sourceSystem: sourceSystems.IMPS,
74
82
  pillar: pillars.IMPS,
75
83
  deliveryBody: RP00,
76
- fundCode: DOM00
84
+ fundCode: DOM00,
85
+ fileMask: fileMasks.IMPS
77
86
  },
78
87
  {
79
88
  schemeId: schemeIds.SFI23,
80
89
  sourceSystem: sourceSystems.SFI23,
81
90
  pillar: pillars.SFI23,
82
91
  deliveryBody: RP00,
83
- fundCode: DRD10
92
+ fundCode: DRD10,
93
+ fileMask: fileMasks.SFI23
84
94
  },
85
95
  {
86
96
  schemeId: schemeIds.DELINKED,
87
97
  sourceSystem: sourceSystems.DELINKED,
88
98
  pillar: pillars.DELINKED,
89
99
  deliveryBody: RP00,
90
- fundCode: DOM10
100
+ fundCode: DOM10,
101
+ fileMask: fileMasks.DELINKED
91
102
  },
92
103
  {
93
104
  schemeId: schemeIds.SFI_EXPANDED,
94
105
  sourceSystem: sourceSystems.SFI_EXPANDED,
95
106
  pillar: pillars.SFI_EXPANDED,
96
107
  deliveryBody: RP00,
97
- fundCode: DRD10
108
+ fundCode: DRD10,
109
+ fileMask: fileMasks.SFI_EXPANDED
98
110
  },
99
111
  {
100
112
  schemeId: schemeIds.COHT_REVENUE,
@@ -108,7 +120,8 @@ module.exports = Object.freeze([
108
120
  sourceSystem: sourceSystems.COHT_CAPITAL,
109
121
  pillar: pillars.COHT_CAPITAL,
110
122
  deliveryBody: RP00,
111
- fundCode: DRD10
123
+ fundCode: DRD10,
124
+ fileMask: fileMasks.COHT_CAPITAL
112
125
  },
113
126
  {
114
127
  schemeId: schemeIds.FPTT,
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ SFI: 7,
3
+ SFI_PILOT: 7,
4
+ LUMP_SUMS: 8,
5
+ CS: 6,
6
+ BPS: 5,
7
+ ES: 23,
8
+ FC: 5,
9
+ SFI23: 8,
10
+ DELINKED: 6,
11
+ SFI_EXPANDED: 5,
12
+ COHT_CAPITAL: 9
13
+ }
@@ -0,0 +1,34 @@
1
+ const schemeIds = require('../constants/scheme-ids')
2
+ const sequencePositions = require('../constants/sequence-positions')
3
+
4
+ const SEQUENCE_LENGTH = 4
5
+ const IMPS_OFFSET = 1
6
+
7
+ const getBatchSequenceFromFileName = (schemeId, fileName) => {
8
+ if (schemeId === schemeIds.IMPS) {
9
+ return Number(fileName.substring(
10
+ fileName.lastIndexOf('_') + IMPS_OFFSET,
11
+ fileName.lastIndexOf('.')
12
+ ))
13
+ }
14
+
15
+ const schemeEntry = Object.entries(schemeIds)
16
+ .find(([, id]) => id === schemeId)
17
+
18
+ if (!schemeEntry) {
19
+ throw new Error(`Unknown schemeId: ${schemeId}`)
20
+ }
21
+
22
+ const [schemeName] = schemeEntry
23
+ const sequenceStart = sequencePositions[schemeName]
24
+
25
+ if (sequenceStart === undefined) {
26
+ throw new Error(`No sequence position found for schemeId: ${schemeId}`)
27
+ }
28
+
29
+ return Number(fileName.substr(sequenceStart, SEQUENCE_LENGTH))
30
+ }
31
+
32
+ module.exports = {
33
+ getBatchSequenceFromFileName
34
+ }
@@ -0,0 +1,11 @@
1
+ const schemes = require('../constants/schemes')
2
+
3
+ const getSchemeFromBatchFileName = (fileName) => {
4
+ return schemes.find(scheme =>
5
+ scheme.fileMask?.test(fileName)
6
+ )
7
+ }
8
+
9
+ module.exports = {
10
+ getSchemeFromBatchFileName
11
+ }
package/index.js CHANGED
@@ -1,8 +1,10 @@
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 { getBatchSequenceFromFileName } = require('./app/helpers/get-batch-sequence-from-file-name')
4
5
  const { getReportingDataFilter } = require('./app/helpers/get-reporting-data-filter')
5
6
  const { getSchemeBatchProperties } = require('./app/scheme-properties/get-scheme-batch-properties')
7
+ const { getSchemeFromBatchFileName } = require('./app/scheme-properties/get-scheme-from-batch-file-name')
6
8
  const { getSchemeIdFromPillar } = require('./app/scheme-id/get-scheme-id-from-pillar')
7
9
  const { getSchemeIdFromSourceSystem } = require('./app/scheme-id/get-scheme-id-from-source-system')
8
10
  const { getSchemeIds } = require('./app/scheme-id/get-scheme-ids')
@@ -22,8 +24,10 @@ module.exports = {
22
24
  createInvoiceNumber,
23
25
  createSplitInvoiceNumber,
24
26
  getAccountCodeMap,
27
+ getBatchSequenceFromFileName,
25
28
  getReportingDataFilter,
26
29
  getSchemeBatchProperties,
30
+ getSchemeFromBatchFileName,
27
31
  getSchemeIdFromPillar,
28
32
  getSchemeIdFromSourceSystem,
29
33
  getSchemeIds,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-schemes",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
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,55 @@
1
+ jest.mock('../../../app/constants/scheme-ids', () => ({
2
+ SFI: 1,
3
+ IMPS: 11,
4
+ FPTT: 18
5
+ }))
6
+
7
+ jest.mock('../../../app/constants/sequence-positions', () => ({
8
+ SFI: 6
9
+ }))
10
+
11
+ const {
12
+ getBatchSequenceFromFileName
13
+ } = require('../../../app/helpers/get-batch-sequence-from-file-name')
14
+
15
+ const schemeIds = require('../../../app/constants/scheme-ids')
16
+
17
+ describe('getBatchSequenceFromFileName', () => {
18
+ test('returns the sequence using the scheme sequence position', () => {
19
+ const fileName = 'prefix12345678.csv'
20
+
21
+ expect(
22
+ getBatchSequenceFromFileName(schemeIds.SFI, fileName)
23
+ ).toBe(1234)
24
+ })
25
+
26
+ test('returns the IMPS sequence between the final underscore and dot', () => {
27
+ expect(
28
+ getBatchSequenceFromFileName(schemeIds.IMPS, 'IMPS_batch_5678.csv')
29
+ ).toBe(5678)
30
+ })
31
+
32
+ test('uses the final underscore for IMPS filenames', () => {
33
+ expect(
34
+ getBatchSequenceFromFileName(
35
+ schemeIds.IMPS,
36
+ 'IMPS_batch_previous_4321.csv'
37
+ )
38
+ ).toBe(4321)
39
+ })
40
+
41
+ test('throws when the scheme ID is unknown', () => {
42
+ expect(() =>
43
+ getBatchSequenceFromFileName(1000, 'filename.csv')
44
+ ).toThrow('Unknown schemeId: 1000')
45
+ })
46
+
47
+ test('throws when the scheme has no sequence position', () => {
48
+ expect(() =>
49
+ getBatchSequenceFromFileName(
50
+ schemeIds.FPTT,
51
+ 'filename.csv'
52
+ )
53
+ ).toThrow(`No sequence position found for schemeId: ${schemeIds.FPTT}`)
54
+ })
55
+ })
@@ -0,0 +1,51 @@
1
+ jest.mock('../../../app/constants/schemes', () => [
2
+ {
3
+ schemeId: 1,
4
+ fileMask: {
5
+ test: jest.fn((fileName) => fileName === 'sfi-batch.csv')
6
+ }
7
+ },
8
+ {
9
+ schemeId: 2,
10
+ fileMask: {
11
+ test: jest.fn((fileName) => fileName === 'pilot-batch.csv')
12
+ }
13
+ },
14
+ {
15
+ schemeId: 3
16
+ }
17
+ ])
18
+
19
+ const schemes = require('../../../app/constants/schemes')
20
+ const {
21
+ getSchemeFromBatchFileName
22
+ } = require('../../../app/scheme-properties/get-scheme-from-batch-file-name')
23
+
24
+ describe('getSchemeFromBatchFileName', () => {
25
+ test('returns the first matching scheme', () => {
26
+ expect(
27
+ getSchemeFromBatchFileName('pilot-batch.csv')
28
+ ).toBe(schemes[1])
29
+ })
30
+
31
+ test('skips schemes without a file mask', () => {
32
+ expect(
33
+ getSchemeFromBatchFileName('unknown-batch.csv')
34
+ ).toBeUndefined()
35
+
36
+ expect(schemes[0].fileMask.test).toHaveBeenCalledWith('unknown-batch.csv')
37
+ expect(schemes[1].fileMask.test).toHaveBeenCalledWith('unknown-batch.csv')
38
+ })
39
+
40
+ test('returns undefined when no file mask matches', () => {
41
+ expect(
42
+ getSchemeFromBatchFileName('unknown-batch.csv')
43
+ ).toBeUndefined()
44
+ })
45
+
46
+ test('stops checking after finding a match', () => {
47
+ getSchemeFromBatchFileName('sfi-batch.csv')
48
+
49
+ expect(schemes[1].fileMask.test).not.toHaveBeenCalledWith('sfi-batch.csv')
50
+ })
51
+ })
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" ?>
2
2
  <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3
- <coverage lines-valid="269" lines-covered="250" line-rate="0.9293" branches-valid="55" branches-covered="55" branch-rate="1" timestamp="1788777087732" complexity="0" version="0.1">
3
+ <coverage lines-valid="303" lines-covered="280" line-rate="0.924" branches-valid="61" branches-covered="61" branch-rate="1" timestamp="1788866911565" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/home/samplackett/ffc-pay-schemes</source>
6
6
  </sources>
@@ -29,12 +29,15 @@
29
29
  <line number="16" hits="0" branch="false"/>
30
30
  <line number="17" hits="0" branch="false"/>
31
31
  <line number="18" hits="0" branch="false"/>
32
+ <line number="19" hits="0" branch="false"/>
32
33
  <line number="20" hits="0" branch="false"/>
34
+ <line number="21" hits="0" branch="false"/>
35
+ <line number="23" hits="0" branch="false"/>
33
36
  </lines>
34
37
  </class>
35
38
  </classes>
36
39
  </package>
37
- <package name="ffc-pay-schemes.app.constants" line-rate="1" branch-rate="1">
40
+ <package name="ffc-pay-schemes.app.constants" line-rate="0.9629000000000001" branch-rate="1">
38
41
  <classes>
39
42
  <class name="delivery-bodies.js" filename="app/constants/delivery-bodies.js" line-rate="1" branch-rate="1">
40
43
  <methods>
@@ -50,6 +53,13 @@
50
53
  <line number="1" hits="9" branch="false"/>
51
54
  </lines>
52
55
  </class>
56
+ <class name="file-masks.js" filename="app/constants/file-masks.js" line-rate="1" branch-rate="1">
57
+ <methods>
58
+ </methods>
59
+ <lines>
60
+ <line number="1" hits="1" branch="false"/>
61
+ </lines>
62
+ </class>
53
63
  <class name="frps-schemes.js" filename="app/constants/frps-schemes.js" line-rate="1" branch-rate="1">
54
64
  <methods>
55
65
  </methods>
@@ -84,7 +94,7 @@
84
94
  <methods>
85
95
  </methods>
86
96
  <lines>
87
- <line number="1" hits="11" branch="false"/>
97
+ <line number="1" hits="12" branch="false"/>
88
98
  </lines>
89
99
  </class>
90
100
  <class name="scheme-names.js" filename="app/constants/scheme-names.js" line-rate="1" branch-rate="1">
@@ -119,7 +129,23 @@
119
129
  <line number="3" hits="1" branch="false"/>
120
130
  <line number="4" hits="1" branch="false"/>
121
131
  <line number="5" hits="1" branch="false"/>
122
- <line number="7" hits="1" branch="false"/>
132
+ <line number="6" hits="1" branch="false"/>
133
+ <line number="8" hits="1" branch="false"/>
134
+ </lines>
135
+ </class>
136
+ <class name="sequence-positions.js" filename="app/constants/sequence-positions.js" line-rate="0" branch-rate="1">
137
+ <methods>
138
+ </methods>
139
+ <lines>
140
+ <line number="1" hits="0" branch="false"/>
141
+ </lines>
142
+ </class>
143
+ <class name="siti-agri-schemes.js" filename="app/constants/siti-agri-schemes.js" line-rate="1" branch-rate="1">
144
+ <methods>
145
+ </methods>
146
+ <lines>
147
+ <line number="1" hits="1" branch="false"/>
148
+ <line number="3" hits="1" branch="false"/>
123
149
  </lines>
124
150
  </class>
125
151
  <class name="source-systems.js" filename="app/constants/source-systems.js" line-rate="1" branch-rate="1">
@@ -484,6 +510,39 @@
484
510
  </package>
485
511
  <package name="ffc-pay-schemes.app.helpers" line-rate="1" branch-rate="1">
486
512
  <classes>
513
+ <class name="get-batch-sequence-from-file-name.js" filename="app/helpers/get-batch-sequence-from-file-name.js" line-rate="1" branch-rate="1">
514
+ <methods>
515
+ <method name="(anonymous_0)" hits="5" signature="()V">
516
+ <lines>
517
+ <line number="7" hits="5"/>
518
+ </lines>
519
+ </method>
520
+ <method name="(anonymous_1)" hits="7" signature="()V">
521
+ <lines>
522
+ <line number="16" hits="7"/>
523
+ </lines>
524
+ </method>
525
+ </methods>
526
+ <lines>
527
+ <line number="1" hits="1" branch="false"/>
528
+ <line number="2" hits="1" branch="false"/>
529
+ <line number="4" hits="1" branch="false"/>
530
+ <line number="5" hits="1" branch="false"/>
531
+ <line number="7" hits="1" branch="false"/>
532
+ <line number="8" hits="5" branch="true" condition-coverage="100% (2/2)"/>
533
+ <line number="9" hits="2" branch="false"/>
534
+ <line number="15" hits="3" branch="false"/>
535
+ <line number="16" hits="7" branch="false"/>
536
+ <line number="18" hits="3" branch="true" condition-coverage="100% (2/2)"/>
537
+ <line number="19" hits="1" branch="false"/>
538
+ <line number="22" hits="2" branch="false"/>
539
+ <line number="23" hits="2" branch="false"/>
540
+ <line number="25" hits="2" branch="true" condition-coverage="100% (2/2)"/>
541
+ <line number="26" hits="1" branch="false"/>
542
+ <line number="29" hits="1" branch="false"/>
543
+ <line number="32" hits="1" branch="false"/>
544
+ </lines>
545
+ </class>
487
546
  <class name="get-reporting-data-filter.js" filename="app/helpers/get-reporting-data-filter.js" line-rate="1" branch-rate="1">
488
547
  <methods>
489
548
  <method name="(anonymous_0)" hits="5" signature="()V">
@@ -521,6 +580,21 @@
521
580
  <line number="7" hits="1" branch="false"/>
522
581
  </lines>
523
582
  </class>
583
+ <class name="is-siti-agri.js" filename="app/helpers/is-siti-agri.js" line-rate="1" branch-rate="1">
584
+ <methods>
585
+ <method name="(anonymous_0)" hits="14" signature="()V">
586
+ <lines>
587
+ <line number="3" hits="14"/>
588
+ </lines>
589
+ </method>
590
+ </methods>
591
+ <lines>
592
+ <line number="1" hits="1" branch="false"/>
593
+ <line number="3" hits="1" branch="false"/>
594
+ <line number="4" hits="14" branch="false"/>
595
+ <line number="7" hits="1" branch="false"/>
596
+ </lines>
597
+ </class>
524
598
  <class name="is-valid-scheme-id.js" filename="app/helpers/is-valid-scheme-id.js" line-rate="1" branch-rate="1">
525
599
  <methods>
526
600
  <method name="(anonymous_0)" hits="19" signature="()V">
@@ -693,6 +767,27 @@
693
767
  <line number="7" hits="1" branch="false"/>
694
768
  </lines>
695
769
  </class>
770
+ <class name="get-scheme-from-batch-file-name.js" filename="app/scheme-properties/get-scheme-from-batch-file-name.js" line-rate="1" branch-rate="1">
771
+ <methods>
772
+ <method name="(anonymous_0)" hits="4" signature="()V">
773
+ <lines>
774
+ <line number="3" hits="4"/>
775
+ </lines>
776
+ </method>
777
+ <method name="(anonymous_1)" hits="9" signature="()V">
778
+ <lines>
779
+ <line number="4" hits="9"/>
780
+ </lines>
781
+ </method>
782
+ </methods>
783
+ <lines>
784
+ <line number="1" hits="1" branch="false"/>
785
+ <line number="3" hits="1" branch="false"/>
786
+ <line number="4" hits="4" branch="false"/>
787
+ <line number="5" hits="9" branch="false"/>
788
+ <line number="9" hits="1" branch="false"/>
789
+ </lines>
790
+ </class>
696
791
  <class name="get-scheme-properties.js" filename="app/scheme-properties/get-scheme-properties.js" line-rate="1" branch-rate="1">
697
792
  <methods>
698
793
  <method name="(anonymous_0)" hits="54" signature="()V">