ffc-pay-schemes 1.0.1
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/.github/workflows/secret-scanner.yml +16 -0
- package/.gitleaks-shared/.gitleaks.toml +139 -0
- package/.gitleaks.toml +15 -0
- package/.gitleaksignore +0 -0
- package/.husky/pre-commit +30 -0
- package/LICENCE +8 -0
- package/README.md +34 -0
- package/app/constants/account-codes/ap.js +48 -0
- package/app/constants/account-codes/ar-admin.js +48 -0
- package/app/constants/account-codes/ar-irregular.js +47 -0
- package/app/constants/delivery-bodies.js +6 -0
- package/app/constants/description-codes.js +34 -0
- package/app/constants/fund-codes.js +8 -0
- package/app/constants/pillars.js +18 -0
- package/app/constants/scheme-batch-properties.js +106 -0
- package/app/constants/scheme-ids.js +19 -0
- package/app/constants/scheme-names.js +19 -0
- package/app/constants/schemes-not-requiring-ppas.js +3 -0
- package/app/constants/schemes-providing-account-values.js +3 -0
- package/app/constants/schemes.js +127 -0
- package/app/constants/source-systems.js +19 -0
- package/app/create-invoice-number/create-default-invoice-number.js +11 -0
- package/app/create-invoice-number/create-es-invoice-number.js +7 -0
- package/app/create-invoice-number/create-imps-invoice-number.js +14 -0
- package/app/create-invoice-number/create-siti-agri-invoice-number.js +12 -0
- package/app/create-invoice-number/create-standard-scheme-invoice-number.js +12 -0
- package/app/create-invoice-number/index.js +38 -0
- package/app/create-invoice-number/use-invoice-number-as-is.js +7 -0
- package/app/create-split-invoice-number/create-default-invoice-number.js +12 -0
- package/app/create-split-invoice-number/create-siti-agri-invoice-number.js +12 -0
- package/app/create-split-invoice-number/index.js +21 -0
- package/app/get-account-code-map/bps-map.js +141 -0
- package/app/get-account-code-map/cohtc-map.js +21 -0
- package/app/get-account-code-map/cs-map.js +174 -0
- package/app/get-account-code-map/default-map.js +46 -0
- package/app/get-account-code-map/delinked-map.js +31 -0
- package/app/get-account-code-map/index.js +57 -0
- package/app/get-account-code-map/lump-sums-map.js +11 -0
- package/app/get-account-code-map/sfi-frps-map.js +15 -0
- package/app/get-account-code-map/vet-visits-map.js +11 -0
- package/app/get-scheme-batch-properties.js +9 -0
- package/app/get-scheme-properties.js +31 -0
- package/app/get-schemes.js +12 -0
- package/app/scheme-does-not-require-ppas.js +9 -0
- package/app/scheme-provides-accounting-values.js +9 -0
- package/azure-pipelines.yml +45 -0
- package/eslint.config.js +3 -0
- package/index.js +21 -0
- package/jest.config.js +40 -0
- package/jest.setup.js +2 -0
- package/package.json +34 -0
- package/sonar-project.properties +3 -0
- package/test/unit/create-invoice-number/create-default-invoice-number.test.js +15 -0
- package/test/unit/create-invoice-number/create-es-invoice-number.test.js +10 -0
- package/test/unit/create-invoice-number/create-imps-invoice-number.test.js +27 -0
- package/test/unit/create-invoice-number/create-siti-agri-invoice-number.test.js +26 -0
- package/test/unit/create-invoice-number/create-standard-scheme-invoice-number.test.js +31 -0
- package/test/unit/create-invoice-number/index.test.js +113 -0
- package/test/unit/create-invoice-number/use-invoice-number-as-is.test.js +9 -0
- package/test/unit/create-split-invoice-number/create-default-invoice-number.test.js +15 -0
- package/test/unit/create-split-invoice-number/create-siti-agri-invoice-number.test.js +15 -0
- package/test/unit/create-split-invoice-number/index.test.js +34 -0
- package/test/unit/get-account-code-map/bps-map.test.js +58 -0
- package/test/unit/get-account-code-map/cohtc-map.test.js +32 -0
- package/test/unit/get-account-code-map/cs-map.test.js +62 -0
- package/test/unit/get-account-code-map/default-map.test.js +60 -0
- package/test/unit/get-account-code-map/delinked-map.test.js +42 -0
- package/test/unit/get-account-code-map/index.test.js +53 -0
- package/test/unit/get-account-code-map/lump-sums-map.test.js +16 -0
- package/test/unit/get-account-code-map/sfi-frps-map.test.js +31 -0
- package/test/unit/get-account-code-map/vet-visits-map.test.js +16 -0
- package/test/unit/get-scheme-batch-properties.test.js +16 -0
- package/test/unit/get-scheme-properties.test.js +54 -0
- package/test/unit/get-schemes.test.js +24 -0
- package/test/unit/scheme-does-not-require-ppas.test.js +17 -0
- package/test/unit/scheme-provides-accounting-values.test.js +17 -0
- package/test-output/cobertura-coverage.xml +577 -0
- package/test-output/junit.xml +589 -0
- package/test-output/lcov-report/base.css +224 -0
- package/test-output/lcov-report/block-navigation.js +87 -0
- package/test-output/lcov-report/favicon.png +0 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ap.js.html +229 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-admin.js.html +229 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/ar-irregular.js.html +226 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/account-codes/index.html +146 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/delivery-bodies.js.html +103 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/description-codes.js.html +187 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/fund-codes.js.html +109 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +266 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +139 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-batch-properties.js.html +403 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-ids.js.html +142 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +142 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +94 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +94 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +466 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +142 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +118 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +106 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +127 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +121 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +121 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +206 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +199 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +106 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +121 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +121 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +146 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +148 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +508 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +148 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +607 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +223 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +178 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +236 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +256 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +118 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +130 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +118 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +178 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +121 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/index.html +176 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.html +112 -0
- package/test-output/lcov-report/ffc-pay-schemes/index.html +116 -0
- package/test-output/lcov-report/ffc-pay-schemes/index.js.html +148 -0
- package/test-output/lcov-report/index.html +206 -0
- package/test-output/lcov-report/prettify.css +1 -0
- package/test-output/lcov-report/prettify.js +2 -0
- package/test-output/lcov-report/sort-arrow-sprite.png +0 -0
- package/test-output/lcov-report/sorter.js +210 -0
- package/test-output/lcov.info +644 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { SOS210, SOS471, SOS472, SOS473, SOS474 } = require('../constants/account-codes/ap')
|
|
2
|
+
const { SOS471: SOS471Ad, SOS472: SOS472Ad, SOS473: SOS473Ad, SOS474: SOS474Ad, SOS330 } = require('../constants/account-codes/ar-admin')
|
|
3
|
+
const { SOS471: SOS471Irr, SOS472: SOS472Irr, SOS473: SOS473Irr, SOS474: SOS474Irr, SOS310 } = require('../constants/account-codes/ar-irregular')
|
|
4
|
+
const { G00, X01, X02, X03, X04 } = require('../constants/description-codes')
|
|
5
|
+
|
|
6
|
+
module.exports = [{
|
|
7
|
+
lineCode: G00,
|
|
8
|
+
ap: SOS210,
|
|
9
|
+
arAdmin: SOS330,
|
|
10
|
+
arIrregular: SOS310
|
|
11
|
+
}, {
|
|
12
|
+
lineCode: X01,
|
|
13
|
+
ap: SOS471,
|
|
14
|
+
arAdmin: SOS471Ad,
|
|
15
|
+
arIrregular: SOS471Irr
|
|
16
|
+
}, {
|
|
17
|
+
lineCode: X02,
|
|
18
|
+
ap: SOS472,
|
|
19
|
+
arAdmin: SOS472Ad,
|
|
20
|
+
arIrregular: SOS472Irr
|
|
21
|
+
}, {
|
|
22
|
+
lineCode: X03,
|
|
23
|
+
ap: SOS473,
|
|
24
|
+
arAdmin: SOS473Ad,
|
|
25
|
+
arIrregular: SOS473Irr
|
|
26
|
+
}, {
|
|
27
|
+
lineCode: X04,
|
|
28
|
+
ap: SOS474,
|
|
29
|
+
arAdmin: SOS474Ad,
|
|
30
|
+
arIrregular: SOS474Irr
|
|
31
|
+
}]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const {
|
|
2
|
+
SFI,
|
|
3
|
+
SFI_PILOT,
|
|
4
|
+
LUMP_SUMS,
|
|
5
|
+
VET_VISITS,
|
|
6
|
+
CS,
|
|
7
|
+
BPS,
|
|
8
|
+
SFI23,
|
|
9
|
+
DELINKED,
|
|
10
|
+
SFI_EXPANDED,
|
|
11
|
+
COHT_REVENUE,
|
|
12
|
+
COHT_CAPITAL,
|
|
13
|
+
FPTT,
|
|
14
|
+
WMP
|
|
15
|
+
} = require('../constants/scheme-ids')
|
|
16
|
+
|
|
17
|
+
const defaultMap = require('./default-map')
|
|
18
|
+
const sfiFrpsMap = require('./sfi-frps-map')
|
|
19
|
+
const lumpSumsMap = require('./lump-sums-map')
|
|
20
|
+
const vetVisitsMap = require('./vet-visits-map')
|
|
21
|
+
const csMap = require('./cs-map')
|
|
22
|
+
const bpsMap = require('./bps-map')
|
|
23
|
+
const delinkedMap = require('./delinked-map')
|
|
24
|
+
const cohtcMap = require('./cohtc-map')
|
|
25
|
+
|
|
26
|
+
const schemeMap = new Map([
|
|
27
|
+
[SFI, sfiFrpsMap],
|
|
28
|
+
[SFI_PILOT, sfiFrpsMap],
|
|
29
|
+
[SFI23, sfiFrpsMap],
|
|
30
|
+
[SFI_EXPANDED, sfiFrpsMap],
|
|
31
|
+
[LUMP_SUMS, lumpSumsMap],
|
|
32
|
+
[VET_VISITS, vetVisitsMap],
|
|
33
|
+
[CS, csMap],
|
|
34
|
+
[BPS, bpsMap],
|
|
35
|
+
[DELINKED, delinkedMap],
|
|
36
|
+
[COHT_REVENUE, defaultMap],
|
|
37
|
+
[COHT_CAPITAL, cohtcMap],
|
|
38
|
+
[FPTT, sfiFrpsMap],
|
|
39
|
+
[WMP, sfiFrpsMap]
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
const getAccountCodeMap = (schemeId) => {
|
|
43
|
+
if (!schemeId) {
|
|
44
|
+
throw new Error('schemeId is required')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const mapForScheme = schemeMap.get(schemeId)
|
|
48
|
+
if (mapForScheme) {
|
|
49
|
+
return mapForScheme
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
throw new Error(`No account codes found for scheme ${schemeId}`)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
getAccountCodeMap
|
|
57
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { SOS210 } = require('../constants/account-codes/ap')
|
|
2
|
+
const { SOS330 } = require('../constants/account-codes/ar-admin')
|
|
3
|
+
const { SOS310 } = require('../constants/account-codes/ar-irregular')
|
|
4
|
+
const { G00 } = require('../constants/description-codes')
|
|
5
|
+
|
|
6
|
+
module.exports = [{
|
|
7
|
+
lineCode: G00,
|
|
8
|
+
ap: SOS210,
|
|
9
|
+
arAdmin: SOS330,
|
|
10
|
+
arIrregular: SOS310
|
|
11
|
+
}]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const defaultMap = require('./default-map')
|
|
2
|
+
|
|
3
|
+
const { SOS920 } = require('../constants/account-codes/ap')
|
|
4
|
+
const { SOS940 } = require('../constants/account-codes/ar-admin')
|
|
5
|
+
const { SOS960 } = require('../constants/account-codes/ar-irregular')
|
|
6
|
+
const { P02 } = require('../constants/description-codes')
|
|
7
|
+
|
|
8
|
+
const p02Entry = {
|
|
9
|
+
lineCode: P02,
|
|
10
|
+
ap: SOS920,
|
|
11
|
+
arAdmin: SOS940,
|
|
12
|
+
arIrregular: SOS960
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = [defaultMap[0], p02Entry, ...defaultMap.slice(1)]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { SOS210 } = require('../constants/account-codes/ap')
|
|
2
|
+
const { SOS330 } = require('../constants/account-codes/ar-admin')
|
|
3
|
+
const { SOS310 } = require('../constants/account-codes/ar-irregular')
|
|
4
|
+
const { G00 } = require('../constants/description-codes')
|
|
5
|
+
|
|
6
|
+
module.exports = [{
|
|
7
|
+
lineCode: G00,
|
|
8
|
+
ap: SOS210,
|
|
9
|
+
arAdmin: SOS330,
|
|
10
|
+
arIrregular: SOS310
|
|
11
|
+
}]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const schemes = require('./constants/schemes')
|
|
2
|
+
const { MANUAL } = require('./constants/scheme-ids')
|
|
3
|
+
|
|
4
|
+
const getSchemeProperties = (schemeId, sourceSystem, pillar) => {
|
|
5
|
+
let scheme = schemeId
|
|
6
|
+
? schemes.find(item => item.schemeId === schemeId)
|
|
7
|
+
: schemes.find(item => item.sourceSystem === sourceSystem)
|
|
8
|
+
|
|
9
|
+
if (!scheme) {
|
|
10
|
+
throw new Error(`Scheme with ID ${schemeId}, sourceSystem ${sourceSystem} not found`)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (scheme?.schemeId === MANUAL && pillar) {
|
|
14
|
+
const pillarScheme = schemes.find(item => item.pillar === pillar)
|
|
15
|
+
|
|
16
|
+
if (pillarScheme) {
|
|
17
|
+
scheme = {
|
|
18
|
+
...scheme,
|
|
19
|
+
pillar,
|
|
20
|
+
deliveryBody: pillarScheme.deliveryBody,
|
|
21
|
+
fundCode: pillarScheme.fundCode
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return scheme
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
getSchemeProperties
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const schemeIds = require('./constants/scheme-ids')
|
|
2
|
+
const schemeNames = require('./constants/scheme-names')
|
|
3
|
+
|
|
4
|
+
const getSchemes = () =>
|
|
5
|
+
Object.keys(schemeIds).map((schemeKey) => ({
|
|
6
|
+
schemeId: schemeIds[schemeKey],
|
|
7
|
+
schemeName: schemeNames[schemeKey]
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
getSchemes
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const schemesProvidingAccountingValues = require('./constants/schemes-providing-account-values')
|
|
2
|
+
|
|
3
|
+
const schemeProvidesAccountingValues = (schemeId) => {
|
|
4
|
+
return schemesProvidingAccountingValues.includes(schemeId)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
schemeProvidesAccountingValues
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Pipeline name convention
|
|
2
|
+
name: '$(Build.SourceBranchName)$(System.PullRequest.SourceBranch)$(Rev:.r)'
|
|
3
|
+
|
|
4
|
+
# Trigger configuration
|
|
5
|
+
trigger:
|
|
6
|
+
- main
|
|
7
|
+
- feature/*
|
|
8
|
+
- release/*
|
|
9
|
+
|
|
10
|
+
pr:
|
|
11
|
+
- main
|
|
12
|
+
- releases/*
|
|
13
|
+
|
|
14
|
+
# Parameters
|
|
15
|
+
parameters:
|
|
16
|
+
- name: prDeployment
|
|
17
|
+
type: boolean
|
|
18
|
+
default: true
|
|
19
|
+
- name: branchDeployment
|
|
20
|
+
type: boolean
|
|
21
|
+
default: true
|
|
22
|
+
- name: sndDeployment
|
|
23
|
+
type: boolean
|
|
24
|
+
default: true
|
|
25
|
+
|
|
26
|
+
# Resources
|
|
27
|
+
resources:
|
|
28
|
+
repositories:
|
|
29
|
+
- repository: templates
|
|
30
|
+
endpoint: DEFRA
|
|
31
|
+
type: github
|
|
32
|
+
name: defra/fcp-pipeline-common
|
|
33
|
+
# ref: pl-709 # Optional: build specific pipeline branch
|
|
34
|
+
|
|
35
|
+
# Pipeline template
|
|
36
|
+
extends:
|
|
37
|
+
template: fcp-common-pipeline.yaml@templates
|
|
38
|
+
parameters:
|
|
39
|
+
appFrameworkType: nodejs # Optional: nodejs (default), dotnet, java
|
|
40
|
+
Type: npm # Optional: kubernetes (default), npm, functions, nuget
|
|
41
|
+
npmLegacyPeerDeps: false # Optional: default is false
|
|
42
|
+
failOnThreshold: moderate # Optional: moderate (default), low, high, critical
|
|
43
|
+
prDeployment: ${{ parameters.prDeployment }}
|
|
44
|
+
branchDeployment: ${{ parameters.branchDeployment }}
|
|
45
|
+
sndDeployment: ${{ parameters.sndDeployment }}
|
package/eslint.config.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { createInvoiceNumber } = require('./app/create-invoice-number')
|
|
2
|
+
const { createSplitInvoiceNumber } = require('./app/create-split-invoice-number')
|
|
3
|
+
const { getAccountCodeMap } = require('./app/get-account-code-map')
|
|
4
|
+
const { getSchemeBatchProperties } = require('./app/get-scheme-batch-properties')
|
|
5
|
+
const { getSchemeProperties } = require('./app/get-scheme-properties')
|
|
6
|
+
const { getSchemes } = require('./app/get-schemes')
|
|
7
|
+
const { schemeDoesNotRequirePPAs } = require('./app/scheme-does-not-require-ppas')
|
|
8
|
+
const { schemeProvidesAccountingValues } = require('./app/scheme-provides-accounting-values')
|
|
9
|
+
const schemeIds = require('./app/constants/scheme-ids')
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
createInvoiceNumber,
|
|
13
|
+
createSplitInvoiceNumber,
|
|
14
|
+
getAccountCodeMap,
|
|
15
|
+
getSchemeBatchProperties,
|
|
16
|
+
getSchemeProperties,
|
|
17
|
+
getSchemes,
|
|
18
|
+
schemeDoesNotRequirePPAs,
|
|
19
|
+
schemeProvidesAccountingValues,
|
|
20
|
+
schemeIds
|
|
21
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
collectCoverage: true,
|
|
3
|
+
collectCoverageFrom: [
|
|
4
|
+
'**/*.js',
|
|
5
|
+
'!**/*.test.js'
|
|
6
|
+
],
|
|
7
|
+
coverageDirectory: 'test-output',
|
|
8
|
+
coverageReporters: [
|
|
9
|
+
'text-summary',
|
|
10
|
+
'lcov',
|
|
11
|
+
'cobertura'
|
|
12
|
+
],
|
|
13
|
+
coveragePathIgnorePatterns: [
|
|
14
|
+
'<rootDir>/node_modules/',
|
|
15
|
+
'<rootDir>/test-output/',
|
|
16
|
+
'<rootDir>/test/',
|
|
17
|
+
'<rootDir>/jest.config.js',
|
|
18
|
+
'<rootDir>/app/config',
|
|
19
|
+
'<rootDir>/jest.setup.js',
|
|
20
|
+
'<rootDir>/eslint.config.js'
|
|
21
|
+
],
|
|
22
|
+
modulePathIgnorePatterns: [
|
|
23
|
+
'node_modules'
|
|
24
|
+
],
|
|
25
|
+
reporters: [
|
|
26
|
+
'default',
|
|
27
|
+
[
|
|
28
|
+
'jest-junit',
|
|
29
|
+
{
|
|
30
|
+
suiteName: 'jest tests',
|
|
31
|
+
outputDirectory: 'test-output',
|
|
32
|
+
outputName: 'junit.xml'
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
],
|
|
36
|
+
testEnvironment: 'node',
|
|
37
|
+
testPathIgnorePatterns: [],
|
|
38
|
+
setupFilesAfterEnv: ['./jest.setup.js'],
|
|
39
|
+
verbose: true
|
|
40
|
+
}
|
package/jest.setup.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ffc-pay-schemes",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Module for defining and providing details for the payment schemes supported by the Payment Hub.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest --runInBand --forceExit",
|
|
8
|
+
"test:unit": "PORT=0 node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPatterns=test/unit",
|
|
9
|
+
"test:watch": "jest --coverage=false --onlyChanged --watch --runInBand",
|
|
10
|
+
"test:lint": "eslint",
|
|
11
|
+
"test:lint:fix": "eslint --fix",
|
|
12
|
+
"prepare": "node --eval \"const fs=require('fs'),cp=require('child_process');if(fs.existsSync('.git')&&!process.env.CI&&!process.env.TF_BUILD)cp.execSync('husky',{stdio:'inherit'})\""
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/DEFRA/ffc-pay-schemes.git"
|
|
17
|
+
},
|
|
18
|
+
"author": "Defra DDTS",
|
|
19
|
+
"contributors": [
|
|
20
|
+
"Sam Plackett samuel.plackett@atos.ai"
|
|
21
|
+
],
|
|
22
|
+
"license": "OGL-UK-3.0",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/DEFRA/ffc-pay-schemes/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/DEFRA/ffc-pay-schemes#readme",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"eslint": "9.39.5",
|
|
29
|
+
"husky": "9.1.7",
|
|
30
|
+
"jest": "30.4.2",
|
|
31
|
+
"jest-junit": "17.0.0",
|
|
32
|
+
"neostandard": "0.13.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
sonar.javascript.exclusions=**/jest.config.js,**/jest.setup.js,**/__mocks__/**,**/node_modules/**,**/test/**,**/test-output/**,**/eslint.config.js
|
|
2
|
+
sonar.javascript.lcov.reportPaths=test-output/lcov.info
|
|
3
|
+
sonar.exclusions=/test/**,**/*.test.js,*snyk_report.html,*snyk_report.css
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { createDefaultInvoiceNumber } = require('../../../app/create-invoice-number/create-default-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createDefaultInvoiceNumber', () => {
|
|
4
|
+
test('creates an invoice number with a padded payment request number', () => {
|
|
5
|
+
expect(createDefaultInvoiceNumber({
|
|
6
|
+
agreementNumber: 'AGR123',
|
|
7
|
+
paymentRequestNumber: 7
|
|
8
|
+
})).toBe('AGR123V007')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('returns null when required values are missing', () => {
|
|
12
|
+
expect(createDefaultInvoiceNumber({ agreementNumber: 'AGR123' })).toBeNull()
|
|
13
|
+
expect(createDefaultInvoiceNumber({ paymentRequestNumber: 7 })).toBeNull()
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { createESInvoiceNumber } = require('../../../app/create-invoice-number/create-es-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createESInvoiceNumber', () => {
|
|
4
|
+
test('creates an ES invoice number', () => {
|
|
5
|
+
expect(createESInvoiceNumber({
|
|
6
|
+
invoiceNumber: 'INV123',
|
|
7
|
+
contractNumber: 'CON456'
|
|
8
|
+
})).toBe('I(INV123)CON456')
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { createIMPSInvoiceNumber } = require('../../../app/create-invoice-number/create-imps-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createIMPSInvoiceNumber', () => {
|
|
4
|
+
test('adds the trader to an invoice number', () => {
|
|
5
|
+
expect(createIMPSInvoiceNumber({
|
|
6
|
+
invoiceNumber: 'INV/123',
|
|
7
|
+
trader: 'TRADER'
|
|
8
|
+
})).toBe('INV/TRADER123')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('returns the invoice number when it already contains the trader', () => {
|
|
12
|
+
const paymentRequest = {
|
|
13
|
+
invoiceNumber: 'INV/TRADER123',
|
|
14
|
+
trader: 'TRADER'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
expect(createIMPSInvoiceNumber(paymentRequest))
|
|
18
|
+
.toBe(paymentRequest.invoiceNumber)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('returns null when the invoice number has no separator', () => {
|
|
22
|
+
expect(createIMPSInvoiceNumber({
|
|
23
|
+
invoiceNumber: 'INV123',
|
|
24
|
+
trader: 'TRADER'
|
|
25
|
+
})).toBeNull()
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { createSitiAgriInvoiceNumber } = require('../../../app/create-invoice-number/create-siti-agri-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createSitiAgriInvoiceNumber', () => {
|
|
4
|
+
test('creates a SITI Agri invoice number', () => {
|
|
5
|
+
expect(createSitiAgriInvoiceNumber({
|
|
6
|
+
invoiceNumber: 'A1234567',
|
|
7
|
+
contractNumber: 'CON123',
|
|
8
|
+
paymentRequestNumber: 5
|
|
9
|
+
})).toBe('S1234567CON123V005')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('returns null when the invoice number is too short', () => {
|
|
13
|
+
expect(createSitiAgriInvoiceNumber({
|
|
14
|
+
invoiceNumber: '123456',
|
|
15
|
+
contractNumber: 'CON123',
|
|
16
|
+
paymentRequestNumber: 5
|
|
17
|
+
})).toBeNull()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('returns null when required values are missing', () => {
|
|
21
|
+
expect(createSitiAgriInvoiceNumber({
|
|
22
|
+
invoiceNumber: 'A1234567',
|
|
23
|
+
paymentRequestNumber: 5
|
|
24
|
+
})).toBeNull()
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { createStandardSchemeInvoiceNumber } = require('../../../app/create-invoice-number/create-standard-scheme-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createStandardSchemeInvoiceNumber', () => {
|
|
4
|
+
test('creates a standard scheme invoice number', () => {
|
|
5
|
+
expect(createStandardSchemeInvoiceNumber({
|
|
6
|
+
invoiceNumber: 'A1234567',
|
|
7
|
+
contractNumber: 'CON123',
|
|
8
|
+
paymentRequestNumber: 5
|
|
9
|
+
})).toBe('A1234567CON123V005')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('returns null when the invoice number is too short', () => {
|
|
13
|
+
expect(createStandardSchemeInvoiceNumber({
|
|
14
|
+
invoiceNumber: '123456',
|
|
15
|
+
contractNumber: 'CON123',
|
|
16
|
+
paymentRequestNumber: 5
|
|
17
|
+
})).toBeNull()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('returns null when required values are missing', () => {
|
|
21
|
+
expect(createStandardSchemeInvoiceNumber({
|
|
22
|
+
invoiceNumber: 'A1234567',
|
|
23
|
+
paymentRequestNumber: 5
|
|
24
|
+
})).toBeNull()
|
|
25
|
+
|
|
26
|
+
expect(createStandardSchemeInvoiceNumber({
|
|
27
|
+
invoiceNumber: 'A1234567',
|
|
28
|
+
contractNumber: 'CON123'
|
|
29
|
+
})).toBeNull()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
jest.mock('../../../app/create-invoice-number/create-standard-scheme-invoice-number', () => ({
|
|
2
|
+
createStandardSchemeInvoiceNumber: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
jest.mock('../../../app/create-invoice-number/create-siti-agri-invoice-number', () => ({
|
|
5
|
+
createSitiAgriInvoiceNumber: jest.fn()
|
|
6
|
+
}))
|
|
7
|
+
jest.mock('../../../app/create-invoice-number/create-es-invoice-number', () => ({
|
|
8
|
+
createESInvoiceNumber: jest.fn()
|
|
9
|
+
}))
|
|
10
|
+
jest.mock('../../../app/create-invoice-number/create-imps-invoice-number', () => ({
|
|
11
|
+
createIMPSInvoiceNumber: jest.fn()
|
|
12
|
+
}))
|
|
13
|
+
jest.mock('../../../app/create-invoice-number/create-default-invoice-number', () => ({
|
|
14
|
+
createDefaultInvoiceNumber: jest.fn()
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
const { createInvoiceNumber } = require('../../../app/create-invoice-number')
|
|
18
|
+
const { createStandardSchemeInvoiceNumber } = require('../../../app/create-invoice-number/create-standard-scheme-invoice-number')
|
|
19
|
+
const { createSitiAgriInvoiceNumber } = require('../../../app/create-invoice-number/create-siti-agri-invoice-number')
|
|
20
|
+
const { createESInvoiceNumber } = require('../../../app/create-invoice-number/create-es-invoice-number')
|
|
21
|
+
const { createIMPSInvoiceNumber } = require('../../../app/create-invoice-number/create-imps-invoice-number')
|
|
22
|
+
const { createDefaultInvoiceNumber } = require('../../../app/create-invoice-number/create-default-invoice-number')
|
|
23
|
+
|
|
24
|
+
const schemeIds = require('../../../app/constants/scheme-ids')
|
|
25
|
+
const sourceSystems = require('../../../app/constants/source-systems')
|
|
26
|
+
|
|
27
|
+
describe('createInvoiceNumber', () => {
|
|
28
|
+
const paymentRequest = {
|
|
29
|
+
invoiceNumber: 'INV123',
|
|
30
|
+
schemeId: schemeIds.SFI,
|
|
31
|
+
sourceSystem: 'SOURCE',
|
|
32
|
+
contractNumber: 'CON123',
|
|
33
|
+
agreementNumber: 'AGR123',
|
|
34
|
+
paymentRequestNumber: 1,
|
|
35
|
+
trader: 'TRADER'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
jest.clearAllMocks()
|
|
40
|
+
|
|
41
|
+
createStandardSchemeInvoiceNumber.mockReturnValue('standard-invoice')
|
|
42
|
+
createSitiAgriInvoiceNumber.mockReturnValue('siti-agri-invoice')
|
|
43
|
+
createESInvoiceNumber.mockReturnValue('es-invoice')
|
|
44
|
+
createIMPSInvoiceNumber.mockReturnValue('imps-invoice')
|
|
45
|
+
createDefaultInvoiceNumber.mockReturnValue('default-invoice')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test.each(['MANUAL', 'FC', 'FPTT', 'WMP'])(
|
|
49
|
+
'returns the existing invoice number for %s',
|
|
50
|
+
(schemeKey) => {
|
|
51
|
+
const request = {
|
|
52
|
+
...paymentRequest,
|
|
53
|
+
schemeId: schemeIds[schemeKey]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
expect(createInvoiceNumber(request)).toBe(request.invoiceNumber)
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
test('returns the existing invoice number for a manual source system', () => {
|
|
61
|
+
const request = {
|
|
62
|
+
...paymentRequest,
|
|
63
|
+
sourceSystem: sourceSystems.MANUAL
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
expect(createInvoiceNumber(request)).toBe(request.invoiceNumber)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
test.each(['DELINKED', 'SFI_EXPANDED', 'COHT_REVENUE', 'COHT_CAPITAL'])(
|
|
70
|
+
'uses the standard scheme invoice number creator for %s',
|
|
71
|
+
(schemeKey) => {
|
|
72
|
+
const request = { ...paymentRequest, schemeId: schemeIds[schemeKey] }
|
|
73
|
+
|
|
74
|
+
expect(createInvoiceNumber(request)).toBe('standard-invoice')
|
|
75
|
+
expect(createStandardSchemeInvoiceNumber).toHaveBeenCalledWith(request)
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
test.each(['SFI', 'SFI_PILOT', 'LUMP_SUMS', 'CS', 'BPS', 'SFI23'])(
|
|
80
|
+
'uses the SITI Agri invoice number creator for %s',
|
|
81
|
+
(schemeKey) => {
|
|
82
|
+
const request = { ...paymentRequest, schemeId: schemeIds[schemeKey] }
|
|
83
|
+
|
|
84
|
+
expect(createInvoiceNumber(request)).toBe('siti-agri-invoice')
|
|
85
|
+
expect(createSitiAgriInvoiceNumber).toHaveBeenCalledWith(request)
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
test('uses the ES invoice number creator', () => {
|
|
90
|
+
const request = { ...paymentRequest, schemeId: schemeIds.ES }
|
|
91
|
+
|
|
92
|
+
expect(createInvoiceNumber(request)).toBe('es-invoice')
|
|
93
|
+
expect(createESInvoiceNumber).toHaveBeenCalledWith(request)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('uses the IMPS invoice number creator', () => {
|
|
97
|
+
const request = { ...paymentRequest, schemeId: schemeIds.IMPS }
|
|
98
|
+
|
|
99
|
+
expect(createInvoiceNumber(request)).toBe('imps-invoice')
|
|
100
|
+
expect(createIMPSInvoiceNumber).toHaveBeenCalledWith(request)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('uses the default invoice number creator for an unmapped scheme', () => {
|
|
104
|
+
const request = { ...paymentRequest, schemeId: schemeIds.MANUAL + 100 }
|
|
105
|
+
|
|
106
|
+
expect(createInvoiceNumber(request)).toBe('default-invoice')
|
|
107
|
+
expect(createDefaultInvoiceNumber).toHaveBeenCalledWith(request)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
test('returns null when the payment request is invalid', () => {
|
|
111
|
+
expect(createInvoiceNumber()).toBeNull()
|
|
112
|
+
})
|
|
113
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const { useInvoiceNumberAsIs } = require('../../../app/create-invoice-number/use-invoice-number-as-is')
|
|
2
|
+
|
|
3
|
+
describe('useInvoiceNumberAsIs', () => {
|
|
4
|
+
test('returns the invoice number unchanged', () => {
|
|
5
|
+
const invoiceNumber = 'INV-12345'
|
|
6
|
+
|
|
7
|
+
expect(useInvoiceNumberAsIs(invoiceNumber)).toBe(invoiceNumber)
|
|
8
|
+
})
|
|
9
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { createDefaultInvoiceNumber } = require('../../../app/create-split-invoice-number/create-default-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createDefaultInvoiceNumber', () => {
|
|
4
|
+
test.each([
|
|
5
|
+
['INV1234', 'A', 'INVA134'],
|
|
6
|
+
['123456789', 'B', '12345B689'],
|
|
7
|
+
['ABC-1234', '9', 'ABC-9134']
|
|
8
|
+
])(
|
|
9
|
+
'inserts splitId %s into invoice number %s',
|
|
10
|
+
(invoiceNumber, splitId, expectedInvoiceNumber) => {
|
|
11
|
+
expect(createDefaultInvoiceNumber(invoiceNumber, splitId))
|
|
12
|
+
.toBe(expectedInvoiceNumber)
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { createSitiAgriInvoiceNumber } = require('../../../app/create-split-invoice-number/create-siti-agri-invoice-number')
|
|
2
|
+
|
|
3
|
+
describe('createSitiAgriInvoiceNumber', () => {
|
|
4
|
+
test.each([
|
|
5
|
+
['1234567890123', 'A', '12345678A9023'],
|
|
6
|
+
['ABCDEFGH12345', '9', 'ABCDEFGH91245'],
|
|
7
|
+
['SITIAGRI000123', 'X', 'SITIAGRIX00023']
|
|
8
|
+
])(
|
|
9
|
+
'inserts splitId %s into invoice number %s',
|
|
10
|
+
(invoiceNumber, splitId, expectedInvoiceNumber) => {
|
|
11
|
+
expect(createSitiAgriInvoiceNumber(invoiceNumber, splitId))
|
|
12
|
+
.toBe(expectedInvoiceNumber)
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
})
|