ffc-pay-schemes 1.0.12 → 1.0.14
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 +13 -7
- package/app/constants/file-masks.js +14 -0
- package/app/constants/manual-sources.js +79 -0
- package/app/constants/pillars.js +21 -0
- package/app/constants/schemes.js +26 -13
- package/app/constants/sequence-positions.js +13 -0
- package/app/helpers/get-batch-sequence-from-file-name.js +34 -0
- package/app/helpers/get-journal-source-from-pillar.js +15 -0
- package/app/scheme-properties/get-scheme-from-batch-file-name.js +11 -0
- package/index.js +6 -0
- package/package.json +1 -1
- package/test/unit/helpers/get-batch-sequence-from-file-name.test.js +55 -0
- package/test/unit/helpers/get-journal-source-from-pillar.test.js +25 -0
- package/test/unit/scheme-properties/get-scheme-from-batch-file-name.test.js +51 -0
- package/test-output/cobertura-coverage.xml +128 -5
- package/test-output/junit.xml +346 -284
- 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/file-masks.js.html +127 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/frps-schemes.js.html +1 -1
- 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 +67 -7
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/manual-sources.js.html +322 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +65 -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 +57 -18
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/sequence-positions.js.html +124 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/siti-agri-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/helpers/get-batch-sequence-from-file-name.js.html +187 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-journal-source-from-pillar.js.html +130 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/get-reporting-data-filter.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/index.html +50 -5
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-frps.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-siti-agri.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/is-valid-scheme-id.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-does-not-require-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/helpers/scheme-provides-accounting-values.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-pillar.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-id-from-source-system.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/get-scheme-ids.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-id/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-name-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/get-scheme-names.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-name/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-from-batch-file-name.js.html +118 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-scheme-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/get-schemes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-properties/index.html +19 -4
- package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-system-from-scheme-id.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/source-system/get-source-systems.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/source-system/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/index.html +5 -5
- package/test-output/lcov-report/ffc-pay-schemes/index.js.html +28 -4
- package/test-output/lcov-report/index.html +22 -22
- package/test-output/lcov.info +145 -6
package/README.md
CHANGED
|
@@ -17,8 +17,11 @@ const {
|
|
|
17
17
|
createInvoiceNumber,
|
|
18
18
|
createSplitInvoiceNumber,
|
|
19
19
|
getAccountCodeMap,
|
|
20
|
+
getBatchSequenceFromFileName,
|
|
21
|
+
getJournalSourceFromPillar,
|
|
20
22
|
getReportingDataFilter,
|
|
21
23
|
getSchemeBatchProperties,
|
|
24
|
+
getSchemeFromBatchFileName,
|
|
22
25
|
getSchemeIdFromPillar,
|
|
23
26
|
getSchemeIdFromSourceSystem,
|
|
24
27
|
getSchemeIds,
|
|
@@ -39,8 +42,11 @@ const {
|
|
|
39
42
|
- `createInvoiceNumber(paymentRequest)` creates an invoice number for a given `paymentRequest`.
|
|
40
43
|
- `createSplitInvoiceNumber(paymentRequest)` creates a split invoice number for a given `paymentRequest`.
|
|
41
44
|
- `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
|
|
45
|
+
- `getBatchSequenceFromFileName(schemeId, fileName)` returns the sequence as identified in the supplied `fileName`, checking the correct position using the `schemeId`.
|
|
46
|
+
- `getJournalSourceFromPillar(schemeId, source, pillar)` returns the appropriate manual source used in Payment journals for manual schemes, based on the supplied `pillar`. If `schemeId` is not the MANUAL scheme, or a match is not found, the supplied `source` will be returned.
|
|
42
47
|
- `getReportingDataFilter(schemeId)` returns the fields which should be added to any data filters applied in reporting checks, for a given `schemeId`.
|
|
43
48
|
- `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
|
|
49
|
+
- `getSchemeFromBatchFileName(fileName)` returns the supported scheme details based on the expected file mask matching the supplied `fileName`.
|
|
44
50
|
- `getSchemeIdFromPillar(pillar)` returns the scheme ID for a given `pillar`.
|
|
45
51
|
- `getSchemeIdFromSourceSystem(sourceSystem)` returns the scheme ID for a given `sourceSystem`.
|
|
46
52
|
- `getSchemeIds()` returns all supported scheme IDs.
|
|
@@ -61,18 +67,20 @@ const {
|
|
|
61
67
|
```js
|
|
62
68
|
const {
|
|
63
69
|
getSchemes,
|
|
70
|
+
getSchemeIds,
|
|
64
71
|
getSchemeProperties,
|
|
65
72
|
schemeDoesNotRequirePPAs,
|
|
66
|
-
schemeProvidesAccountingValues
|
|
67
|
-
schemeIds
|
|
73
|
+
schemeProvidesAccountingValues
|
|
68
74
|
} = require('ffc-pay-schemes')
|
|
69
75
|
|
|
70
76
|
const schemes = getSchemes()
|
|
71
77
|
|
|
72
|
-
const
|
|
78
|
+
const { BPS } = getSchemeIds()
|
|
79
|
+
|
|
80
|
+
const scheme = getSchemeProperties(BPS)
|
|
73
81
|
|
|
74
|
-
const doesNotRequirePPAs = schemeDoesNotRequirePPAs(
|
|
75
|
-
const providesAccountingValues = schemeProvidesAccountingValues(
|
|
82
|
+
const doesNotRequirePPAs = schemeDoesNotRequirePPAs(BPS)
|
|
83
|
+
const providesAccountingValues = schemeProvidesAccountingValues(BPS)
|
|
76
84
|
```
|
|
77
85
|
|
|
78
86
|
## Payment Hub usage
|
|
@@ -81,7 +89,6 @@ The following services are intended to be used with the ffc-pay-schemes package:
|
|
|
81
89
|
|
|
82
90
|
- ffc-pay-alerting
|
|
83
91
|
- ffc-pay-batch-processor
|
|
84
|
-
- ffc-pay-dps
|
|
85
92
|
- ffc-pay-enrichment
|
|
86
93
|
- ffc-pay-event-hub
|
|
87
94
|
- ffc-pay-gateway
|
|
@@ -91,7 +98,6 @@ The following services are intended to be used with the ffc-pay-schemes package:
|
|
|
91
98
|
- ffc-pay-submission
|
|
92
99
|
- ffc-pay-tracking
|
|
93
100
|
- ffc-pay-web
|
|
94
|
-
- ffc-pay-xb
|
|
95
101
|
|
|
96
102
|
In the event a new payment scheme is added to the package, all of the above services must be bumped to the latest package version to ensure that Payment Hub can process associated payments.
|
|
97
103
|
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const {
|
|
2
|
+
DA,
|
|
3
|
+
IP,
|
|
4
|
+
SPS,
|
|
5
|
+
DF,
|
|
6
|
+
FCCS,
|
|
7
|
+
XG,
|
|
8
|
+
TR,
|
|
9
|
+
RDPECS,
|
|
10
|
+
RDPELS,
|
|
11
|
+
BK,
|
|
12
|
+
INT,
|
|
13
|
+
OPA,
|
|
14
|
+
NELS,
|
|
15
|
+
FCLS,
|
|
16
|
+
RDTLS,
|
|
17
|
+
NECS,
|
|
18
|
+
RDTCP,
|
|
19
|
+
P1,
|
|
20
|
+
EA,
|
|
21
|
+
RDTEXQ,
|
|
22
|
+
EXNRDPE,
|
|
23
|
+
SFI,
|
|
24
|
+
SFI_PILOT,
|
|
25
|
+
LUMP_SUMS,
|
|
26
|
+
VET_VISITS,
|
|
27
|
+
CS,
|
|
28
|
+
BPS,
|
|
29
|
+
ES,
|
|
30
|
+
FC,
|
|
31
|
+
IMPS,
|
|
32
|
+
SFI23,
|
|
33
|
+
DELINKED,
|
|
34
|
+
SFI_EXPANDED,
|
|
35
|
+
COHT_CAPITAL,
|
|
36
|
+
COHT_REVENUE,
|
|
37
|
+
FPTT,
|
|
38
|
+
WMP
|
|
39
|
+
} = require('./pillars')
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
[DA]: 'NMAN_DA',
|
|
43
|
+
[IP]: 'NMAN_IP',
|
|
44
|
+
[SPS]: 'NMAN_SPS',
|
|
45
|
+
[DF]: 'NMAN_DF',
|
|
46
|
+
[FCCS]: 'NMAN_FC',
|
|
47
|
+
[XG]: 'NMAN_XG',
|
|
48
|
+
[TR]: 'NMAN_TR',
|
|
49
|
+
[RDPECS]: 'NMAN_RDPE',
|
|
50
|
+
[RDPELS]: 'NMAN_RDPE',
|
|
51
|
+
[BK]: 'NMAN_BK',
|
|
52
|
+
[INT]: 'NMAN_INT',
|
|
53
|
+
[OPA]: 'NMAN_OPA',
|
|
54
|
+
[NELS]: 'NMAN_NELS',
|
|
55
|
+
[FCLS]: 'NMAN_FCLS',
|
|
56
|
+
[RDTLS]: 'NMAN_RDT',
|
|
57
|
+
[NECS]: 'NMAN_NE',
|
|
58
|
+
[RDTCP]: 'NMAN_RDT',
|
|
59
|
+
[P1]: 'NMAN_NE',
|
|
60
|
+
[EA]: 'NMAN_EA',
|
|
61
|
+
[RDTEXQ]: 'NMAN_RDT',
|
|
62
|
+
[EXNRDPE]: 'NMAN_RDT',
|
|
63
|
+
[SFI]: 'PMAN_SFI',
|
|
64
|
+
[SFI_PILOT]: 'PMAN_SFIP',
|
|
65
|
+
[LUMP_SUMS]: 'NMAN_DA',
|
|
66
|
+
[VET_VISITS]: 'NMAN_DA',
|
|
67
|
+
[CS]: 'PMAN_CS',
|
|
68
|
+
[BPS]: 'NMAN_DA',
|
|
69
|
+
[ES]: 'NMAN_DA',
|
|
70
|
+
[FC]: 'NMAN_DA',
|
|
71
|
+
[IMPS]: 'NMAN_DA',
|
|
72
|
+
[SFI23]: 'PMAN_SFIA',
|
|
73
|
+
[DELINKED]: 'PMAN_DP',
|
|
74
|
+
[SFI_EXPANDED]: 'PMAN_ESFIO',
|
|
75
|
+
[COHT_CAPITAL]: 'PMAN_COHTC',
|
|
76
|
+
[COHT_REVENUE]: 'PMAN_COHTR',
|
|
77
|
+
[FPTT]: 'PMAN_FPTT',
|
|
78
|
+
[WMP]: 'PMAN_WMP'
|
|
79
|
+
}
|
package/app/constants/pillars.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
DA: 'DA',
|
|
3
|
+
IP: 'IP',
|
|
4
|
+
SPS: 'SPS',
|
|
5
|
+
DF: 'DF',
|
|
6
|
+
FCCS: 'FCCS',
|
|
7
|
+
XG: 'XG',
|
|
8
|
+
TR: 'TR',
|
|
9
|
+
RDPECS: 'RDPECS',
|
|
10
|
+
RDPELS: 'RDPELS',
|
|
11
|
+
BK: 'BK',
|
|
12
|
+
INT: 'INT',
|
|
13
|
+
OPA: 'OPA',
|
|
14
|
+
NELS: 'NELS',
|
|
15
|
+
FCLS: 'FCLS',
|
|
16
|
+
RDTLS: 'RDTLS',
|
|
17
|
+
NECS: 'NECS',
|
|
18
|
+
RDTCP: 'RDTCP',
|
|
19
|
+
P1: 'P1',
|
|
20
|
+
EA: 'EA',
|
|
21
|
+
RDTEXQ: 'RDTEXQ',
|
|
22
|
+
EXNRDPE: 'ExNRDPE',
|
|
2
23
|
SFI: 'SFI',
|
|
3
24
|
SFI_PILOT: 'SFIP',
|
|
4
25
|
LUMP_SUMS: 'LSES',
|
package/app/constants/schemes.js
CHANGED
|
@@ -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,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,15 @@
|
|
|
1
|
+
const { MANUAL } = require('../constants/scheme-ids')
|
|
2
|
+
const manualSources = require('../constants/manual-sources')
|
|
3
|
+
|
|
4
|
+
const getJournalSourceFromPillar = (schemeId, source, pillar) => {
|
|
5
|
+
if (schemeId !== MANUAL) {
|
|
6
|
+
return source
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const manualSource = manualSources[pillar]
|
|
10
|
+
return manualSource ?? source
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
getJournalSourceFromPillar
|
|
15
|
+
}
|
package/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
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')
|
|
5
|
+
const { getJournalSourceFromPillar } = require('./app/helpers/get-journal-source-from-pillar')
|
|
4
6
|
const { getReportingDataFilter } = require('./app/helpers/get-reporting-data-filter')
|
|
5
7
|
const { getSchemeBatchProperties } = require('./app/scheme-properties/get-scheme-batch-properties')
|
|
8
|
+
const { getSchemeFromBatchFileName } = require('./app/scheme-properties/get-scheme-from-batch-file-name')
|
|
6
9
|
const { getSchemeIdFromPillar } = require('./app/scheme-id/get-scheme-id-from-pillar')
|
|
7
10
|
const { getSchemeIdFromSourceSystem } = require('./app/scheme-id/get-scheme-id-from-source-system')
|
|
8
11
|
const { getSchemeIds } = require('./app/scheme-id/get-scheme-ids')
|
|
@@ -22,8 +25,11 @@ module.exports = {
|
|
|
22
25
|
createInvoiceNumber,
|
|
23
26
|
createSplitInvoiceNumber,
|
|
24
27
|
getAccountCodeMap,
|
|
28
|
+
getBatchSequenceFromFileName,
|
|
29
|
+
getJournalSourceFromPillar,
|
|
25
30
|
getReportingDataFilter,
|
|
26
31
|
getSchemeBatchProperties,
|
|
32
|
+
getSchemeFromBatchFileName,
|
|
27
33
|
getSchemeIdFromPillar,
|
|
28
34
|
getSchemeIdFromSourceSystem,
|
|
29
35
|
getSchemeIds,
|
package/package.json
CHANGED
|
@@ -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,25 @@
|
|
|
1
|
+
const { MANUAL, SFI } = require('../../../app/constants/scheme-ids')
|
|
2
|
+
const { DA, SFI: SFI_PILLAR } = require('../../../app/constants/pillars')
|
|
3
|
+
const manualSources = require('../../../app/constants/manual-sources')
|
|
4
|
+
const { getJournalSourceFromPillar } = require('../../../app/helpers/get-journal-source-from-pillar')
|
|
5
|
+
|
|
6
|
+
describe('getJournalSourceFromPillar', () => {
|
|
7
|
+
test('returns the source for non-manual schemes', () => {
|
|
8
|
+
expect(getJournalSourceFromPillar(SFI, 'SOURCE', DA)).toBe('SOURCE')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('returns the manual source for a matching pillar', () => {
|
|
12
|
+
expect(getJournalSourceFromPillar(MANUAL, 'SOURCE', DA))
|
|
13
|
+
.toBe(manualSources[DA])
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('returns the manual source for the SFI pillar', () => {
|
|
17
|
+
expect(getJournalSourceFromPillar(MANUAL, 'SOURCE', SFI_PILLAR))
|
|
18
|
+
.toBe(manualSources[SFI_PILLAR])
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('returns the original source when the pillar has no manual source', () => {
|
|
22
|
+
expect(getJournalSourceFromPillar(MANUAL, 'SOURCE', 'UNKNOWN'))
|
|
23
|
+
.toBe('SOURCE')
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -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
|
+
})
|