ffc-pay-schemes 1.0.2 → 1.0.3
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 +9 -9
- package/app/get-scheme-name.js +10 -0
- package/app/get-schemes.js +3 -1
- package/app/get-source-system.js +10 -0
- package/index.js +4 -0
- package/package.json +1 -1
- package/sonar-project.properties +2 -2
- package/test/unit/get-scheme-name.test.js +50 -0
- package/test/unit/get-schemes.test.js +5 -2
- package/test/unit/get-source-system.test.js +50 -0
- package/test-output/cobertura-coverage.xml +3 -1
- package/test-output/junit.xml +257 -257
- 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/fund-codes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/pillars.js.html +1 -1
- 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 +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/scheme-names.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-not-requiring-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes-providing-account-values.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/schemes.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/constants/source-systems.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-es-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-imps-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/create-standard-scheme-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-invoice-number/use-invoice-number-as-is.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-default-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/create-siti-agri-invoice-number.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/create-split-invoice-number/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/bps-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cohtc-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/cs-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/default-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/delinked-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/index.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/lump-sums-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/sfi-frps-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-account-code-map/vet-visits-map.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-batch-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-name.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/get-scheme-properties.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/get-schemes.js.html +9 -3
- package/test-output/lcov-report/ffc-pay-schemes/app/get-source-system.js.html +115 -0
- package/test-output/lcov-report/ffc-pay-schemes/app/index.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-does-not-require-ppas.js.html +1 -1
- package/test-output/lcov-report/ffc-pay-schemes/app/scheme-provides-accounting-values.js.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 +16 -4
- package/test-output/lcov-report/index.html +7 -7
- package/test-output/lcov.info +3 -1
package/README.md
CHANGED
|
@@ -18,25 +18,29 @@ const {
|
|
|
18
18
|
createSplitInvoiceNumber,
|
|
19
19
|
getAccountCodeMap,
|
|
20
20
|
getSchemeBatchProperties,
|
|
21
|
+
getSchemeName,
|
|
21
22
|
getSchemeProperties,
|
|
22
23
|
getSchemes,
|
|
24
|
+
getSourceSystem,
|
|
23
25
|
schemeDoesNotRequirePPAs,
|
|
24
26
|
schemeProvidesAccountingValues,
|
|
25
27
|
schemeIds
|
|
26
28
|
} = require('ffc-pay-schemes')
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
- `getSchemes()` returns all supported schemes as an array of objects containing `schemeId` and `schemeName`.
|
|
30
|
-
- `getSchemeProperties(schemeId, sourceSystem, pillar)` returns the properties for a scheme. A scheme can be identified by its ID or source system. The optional `pillar` can be used for manual payments.
|
|
31
|
-
- `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
|
|
32
|
-
- `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
|
|
33
31
|
- `createInvoiceNumber(paymentRequest)` creates an invoice number for a given `paymentRequest`.
|
|
34
32
|
- `createSplitInvoiceNumber(paymentRequest)` creates a split invoice number for a given `paymentRequest`.
|
|
33
|
+
- `getAccountCodeMap(schemeId)` returns the account code mapping used for a given `schemeId`.
|
|
34
|
+
- `getSchemeBatchProperties(schemeId)` returns the batch processing properties for a given `schemeId`.
|
|
35
|
+
- `getSchemeName(schemeId)` returns the scheme name for a given `schemeId`.
|
|
36
|
+
- `getSchemeProperties(schemeId, sourceSystem, pillar)` returns the default payment properties for a scheme. A scheme can be identified by its ID or source system. The optional `pillar` can be used for manual payments.
|
|
37
|
+
- `getSchemes()` returns all supported schemes as an array of objects containing `schemeId`, `schemeName` and `sourceSystem`.
|
|
38
|
+
- `getSourceSystem(schemeId)` returns the source system name for a given `schemeId`.
|
|
35
39
|
- `schemeDoesNotRequirePPAs(schemeId)` returns `true` if Payment Hub does not support Post Payment Adjustments (PPAs) for a given `schemeId`; otherwise, it returns `false`.
|
|
36
40
|
- `schemeProvidesAccountingValues(schemeId)` returns `true` if a given `schemeId` provides accounting values within its payment requests; otherwise, it returns `false`.
|
|
37
41
|
- `schemeIds` provides the constants for all supported scheme IDs.
|
|
38
42
|
|
|
39
|
-
###
|
|
43
|
+
### Examples
|
|
40
44
|
|
|
41
45
|
```js
|
|
42
46
|
const {
|
|
@@ -48,15 +52,11 @@ const {
|
|
|
48
52
|
} = require('ffc-pay-schemes')
|
|
49
53
|
|
|
50
54
|
const schemes = getSchemes()
|
|
51
|
-
console.log(schemes)
|
|
52
55
|
|
|
53
56
|
const scheme = getSchemeProperties(schemeIds.BPS)
|
|
54
|
-
console.log(scheme)
|
|
55
57
|
|
|
56
58
|
const doesNotRequirePPAs = schemeDoesNotRequirePPAs(schemeIds.BPS)
|
|
57
59
|
const providesAccountingValues = schemeProvidesAccountingValues(schemeIds.BPS)
|
|
58
|
-
|
|
59
|
-
console.log({ doesNotRequirePPAs, providesAccountingValues })
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## Licence
|
package/app/get-schemes.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const schemeIds = require('./constants/scheme-ids')
|
|
2
2
|
const schemeNames = require('./constants/scheme-names')
|
|
3
|
+
const sourceSystems = require('./constants/source-systems')
|
|
3
4
|
|
|
4
5
|
const getSchemes = () =>
|
|
5
6
|
Object.keys(schemeIds).map((schemeKey) => ({
|
|
6
7
|
schemeId: schemeIds[schemeKey],
|
|
7
|
-
schemeName: schemeNames[schemeKey]
|
|
8
|
+
schemeName: schemeNames[schemeKey],
|
|
9
|
+
sourceSystem: sourceSystems[schemeKey]
|
|
8
10
|
}))
|
|
9
11
|
|
|
10
12
|
module.exports = {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { getSchemes } = require('./get-schemes')
|
|
2
|
+
|
|
3
|
+
const getSourceSystem = (schemeId) => {
|
|
4
|
+
const matchingScheme = getSchemes().find((scheme) => scheme.schemeId === schemeId)
|
|
5
|
+
return matchingScheme?.sourceSystem
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
getSourceSystem
|
|
10
|
+
}
|
package/index.js
CHANGED
|
@@ -2,8 +2,10 @@ 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
4
|
const { getSchemeBatchProperties } = require('./app/get-scheme-batch-properties')
|
|
5
|
+
const { getSchemeName } = require('./app/get-scheme-name')
|
|
5
6
|
const { getSchemeProperties } = require('./app/get-scheme-properties')
|
|
6
7
|
const { getSchemes } = require('./app/get-schemes')
|
|
8
|
+
const { getSourceSystem } = require('./app/get-source-system')
|
|
7
9
|
const { schemeDoesNotRequirePPAs } = require('./app/scheme-does-not-require-ppas')
|
|
8
10
|
const { schemeProvidesAccountingValues } = require('./app/scheme-provides-accounting-values')
|
|
9
11
|
const schemeIds = require('./app/constants/scheme-ids')
|
|
@@ -13,8 +15,10 @@ module.exports = {
|
|
|
13
15
|
createSplitInvoiceNumber,
|
|
14
16
|
getAccountCodeMap,
|
|
15
17
|
getSchemeBatchProperties,
|
|
18
|
+
getSchemeName,
|
|
16
19
|
getSchemeProperties,
|
|
17
20
|
getSchemes,
|
|
21
|
+
getSourceSystem,
|
|
18
22
|
schemeDoesNotRequirePPAs,
|
|
19
23
|
schemeProvidesAccountingValues,
|
|
20
24
|
schemeIds
|
package/package.json
CHANGED
package/sonar-project.properties
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
sonar.javascript.exclusions=**/jest.config.js,**/jest.setup.js,**/__mocks__/**,**/node_modules/**,**/test/**,**/test-output/**,**/eslint.config.js
|
|
1
|
+
sonar.javascript.exclusions=**/jest.config.js,**/jest.setup.js,**/__mocks__/**,**/node_modules/**,**/test/**,**/test-output/**,**/eslint.config.js,index.js
|
|
2
2
|
sonar.javascript.lcov.reportPaths=test-output/lcov.info
|
|
3
|
-
sonar.exclusions=/test/**,**/*.test.js,*snyk_report.html,*snyk_report.css
|
|
3
|
+
sonar.exclusions=/test/**,**/*.test.js,*snyk_report.html,*snyk_report.css,README.md
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
jest.mock('../../app/get-schemes', () => ({
|
|
2
|
+
getSchemes: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { getSchemes } = require('../../app/get-schemes')
|
|
6
|
+
const { getSchemeName } = require('../../app/get-scheme-name')
|
|
7
|
+
|
|
8
|
+
describe('getSchemeName', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('returns the source system for a matching scheme ID', () => {
|
|
14
|
+
getSchemes.mockReturnValue([
|
|
15
|
+
{
|
|
16
|
+
schemeId: 1,
|
|
17
|
+
schemeName: 'Example Scheme',
|
|
18
|
+
sourceSystem: 'Example Source'
|
|
19
|
+
}
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
expect(getSchemeName(1)).toBe('Example Scheme')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('returns undefined when the scheme ID is not found', () => {
|
|
26
|
+
getSchemes.mockReturnValue([
|
|
27
|
+
{
|
|
28
|
+
schemeId: 1,
|
|
29
|
+
schemeName: 'Example Scheme',
|
|
30
|
+
sourceSystem: 'Example Source'
|
|
31
|
+
}
|
|
32
|
+
])
|
|
33
|
+
|
|
34
|
+
expect(getSchemeName(2)).toBeUndefined()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('returns undefined when no schemes are available', () => {
|
|
38
|
+
getSchemes.mockReturnValue([])
|
|
39
|
+
|
|
40
|
+
expect(getSchemeName(2)).toBeUndefined()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('gets schemes before searching for the source system', () => {
|
|
44
|
+
getSchemes.mockReturnValue([])
|
|
45
|
+
|
|
46
|
+
getSchemeName(2)
|
|
47
|
+
|
|
48
|
+
expect(getSchemes).toHaveBeenCalledTimes(1)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
const { getSchemes } = require('../../app/get-schemes')
|
|
2
2
|
const schemeIds = require('../../app/constants/scheme-ids')
|
|
3
3
|
const schemeNames = require('../../app/constants/scheme-names')
|
|
4
|
+
const sourceSystems = require('../../app/constants/source-systems')
|
|
4
5
|
|
|
5
6
|
describe('getSchemes', () => {
|
|
6
7
|
test('returns all schemes with their IDs and names', () => {
|
|
7
8
|
expect(getSchemes()).toEqual(
|
|
8
9
|
Object.keys(schemeIds).map((schemeKey) => ({
|
|
9
10
|
schemeId: schemeIds[schemeKey],
|
|
10
|
-
schemeName: schemeNames[schemeKey]
|
|
11
|
+
schemeName: schemeNames[schemeKey],
|
|
12
|
+
sourceSystem: sourceSystems[schemeKey]
|
|
11
13
|
}))
|
|
12
14
|
)
|
|
13
15
|
})
|
|
@@ -17,7 +19,8 @@ describe('getSchemes', () => {
|
|
|
17
19
|
(schemeKey) => {
|
|
18
20
|
expect(getSchemes()).toContainEqual({
|
|
19
21
|
schemeId: schemeIds[schemeKey],
|
|
20
|
-
schemeName: schemeNames[schemeKey]
|
|
22
|
+
schemeName: schemeNames[schemeKey],
|
|
23
|
+
sourceSystem: sourceSystems[schemeKey]
|
|
21
24
|
})
|
|
22
25
|
}
|
|
23
26
|
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
jest.mock('../../app/get-schemes', () => ({
|
|
2
|
+
getSchemes: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { getSchemes } = require('../../app/get-schemes')
|
|
6
|
+
const { getSourceSystem } = require('../../app/get-source-system')
|
|
7
|
+
|
|
8
|
+
describe('getSourceSystem', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('returns the source system for a matching scheme ID', () => {
|
|
14
|
+
getSchemes.mockReturnValue([
|
|
15
|
+
{
|
|
16
|
+
schemeId: 1,
|
|
17
|
+
schemeName: 'Example Scheme',
|
|
18
|
+
sourceSystem: 'Example Source'
|
|
19
|
+
}
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
expect(getSourceSystem(1)).toBe('Example Source')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('returns undefined when the scheme ID is not found', () => {
|
|
26
|
+
getSchemes.mockReturnValue([
|
|
27
|
+
{
|
|
28
|
+
schemeId: 1,
|
|
29
|
+
schemeName: 'Example Scheme',
|
|
30
|
+
sourceSystem: 'Example Source'
|
|
31
|
+
}
|
|
32
|
+
])
|
|
33
|
+
|
|
34
|
+
expect(getSourceSystem(2)).toBeUndefined()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('returns undefined when no schemes are available', () => {
|
|
38
|
+
getSchemes.mockReturnValue([])
|
|
39
|
+
|
|
40
|
+
expect(getSourceSystem(2)).toBeUndefined()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('gets schemes before searching for the source system', () => {
|
|
44
|
+
getSchemes.mockReturnValue([])
|
|
45
|
+
|
|
46
|
+
getSourceSystem(2)
|
|
47
|
+
|
|
48
|
+
expect(getSchemes).toHaveBeenCalledTimes(1)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -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="
|
|
3
|
+
<coverage lines-valid="203" lines-covered="191" line-rate="0.9408" branches-valid="50" branches-covered="50" branch-rate="1" timestamp="1787761759725" complexity="0" version="0.1">
|
|
4
4
|
<sources>
|
|
5
5
|
<source>/home/samplackett/ffc-pay-schemes</source>
|
|
6
6
|
</sources>
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
<line number="7" hits="0" branch="false"/>
|
|
21
21
|
<line number="8" hits="0" branch="false"/>
|
|
22
22
|
<line number="9" hits="0" branch="false"/>
|
|
23
|
+
<line number="10" hits="0" branch="false"/>
|
|
23
24
|
<line number="11" hits="0" branch="false"/>
|
|
25
|
+
<line number="13" hits="0" branch="false"/>
|
|
24
26
|
</lines>
|
|
25
27
|
</class>
|
|
26
28
|
</classes>
|