@defra-fish/pocl-job 1.22.0-rc.7 → 1.22.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/pocl-job",
|
|
3
|
-
"version": "1.22.0
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Post Office Counter Licence sales processor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@defra-fish/business-rules-lib": "1.22.0
|
|
39
|
-
"@defra-fish/connectors-lib": "1.22.0
|
|
38
|
+
"@defra-fish/business-rules-lib": "1.22.0",
|
|
39
|
+
"@defra-fish/connectors-lib": "1.22.0",
|
|
40
40
|
"commander": "^7.2.0",
|
|
41
41
|
"debug": "^4.3.1",
|
|
42
42
|
"filesize": "^6.3.0",
|
|
@@ -45,6 +45,5 @@
|
|
|
45
45
|
"moment-timezone": "^0.5.33",
|
|
46
46
|
"sax-stream": "^1.3.0",
|
|
47
47
|
"ssh2-sftp-client": "^6.0.1"
|
|
48
|
-
}
|
|
49
|
-
"gitHead": "4840a94a046213c95478ea8ce84c086a81d5b2fb"
|
|
48
|
+
}
|
|
50
49
|
}
|
|
@@ -130,6 +130,28 @@ describe('transaction transforms', () => {
|
|
|
130
130
|
})
|
|
131
131
|
)
|
|
132
132
|
})
|
|
133
|
+
|
|
134
|
+
it('ignores journal id if it\'s not provided', async () => {
|
|
135
|
+
const { createTransactionPayload } = await Transaction.transform(generateInputJSON())
|
|
136
|
+
|
|
137
|
+
expect(Object.keys(createTransactionPayload).includes('journalId')).toBeFalsy()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it.each([
|
|
141
|
+
['123456'],
|
|
142
|
+
['654321'],
|
|
143
|
+
['A6B7C9']
|
|
144
|
+
])('transforms a DDE record - includes DD_ID %s', async DD_ID => {
|
|
145
|
+
const { createTransactionPayload: { journalId } } = await Transaction.transform(
|
|
146
|
+
generateInputJSON({
|
|
147
|
+
DATA_SOURCE: { value: DIRECT_DEBIT_DATASOURCE },
|
|
148
|
+
MOPEX: { value: '6' },
|
|
149
|
+
DD_ID: { value: DD_ID }
|
|
150
|
+
})
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
expect(journalId).toBe(DD_ID)
|
|
154
|
+
})
|
|
133
155
|
})
|
|
134
156
|
|
|
135
157
|
const generateInputJSON = (overrides = {}) => ({
|
|
@@ -55,10 +55,11 @@ export const MethodOfPayment = new Binding({
|
|
|
55
55
|
transform: context => paymentMethods[Binding.TransformTextOnly(context)] || 'Other'
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
-
export const
|
|
58
|
+
export const DataSourceBinding = new Binding({ element: 'DATA_SOURCE', transform: Binding.TransformTextOnly })
|
|
59
|
+
export const DDIDBinding = new Binding({ element: 'DD_ID', transform: Binding.TransformTextOnly })
|
|
59
60
|
|
|
60
61
|
const getDataSource = children => {
|
|
61
|
-
if (children[
|
|
62
|
+
if (children[DataSourceBinding.element] && children[DataSourceBinding.element] === DIRECT_DEBIT_DATASOURCE) {
|
|
62
63
|
return DIRECT_DEBIT_DATASOURCE
|
|
63
64
|
}
|
|
64
65
|
return POST_OFFICE_DATASOURCE
|
|
@@ -78,7 +79,9 @@ export const Transaction = new Binding({
|
|
|
78
79
|
MethodOfPayment,
|
|
79
80
|
AmountPaid,
|
|
80
81
|
TransactionDate,
|
|
81
|
-
TransactionTime
|
|
82
|
+
TransactionTime,
|
|
83
|
+
DataSourceBinding,
|
|
84
|
+
DDIDBinding
|
|
82
85
|
],
|
|
83
86
|
element: 'REC',
|
|
84
87
|
transform: ({ children }) => {
|
|
@@ -104,11 +107,13 @@ export const Transaction = new Binding({
|
|
|
104
107
|
const paymentSource = dataSource === DIRECT_DEBIT_DATASOURCE ? DIRECT_DEBIT_PAYMENTSOURCE : POST_OFFICE_DATASOURCE
|
|
105
108
|
const serialNumber = children[SerialNumber.element]
|
|
106
109
|
const permit = children[licenceBindings.Permit.element]
|
|
110
|
+
const journalId = children[DDIDBinding.element]
|
|
107
111
|
|
|
108
112
|
return {
|
|
109
113
|
id: serialNumber,
|
|
110
114
|
createTransactionPayload: {
|
|
111
115
|
dataSource,
|
|
116
|
+
...(journalId && { journalId }),
|
|
112
117
|
serialNumber,
|
|
113
118
|
permissions: [
|
|
114
119
|
{
|