@defra-fish/recurring-payments-job 1.59.0-rc.4 → 1.59.0-rc.6
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/recurring-payments-job",
|
|
3
|
-
"version": "1.59.0-rc.
|
|
3
|
+
"version": "1.59.0-rc.6",
|
|
4
4
|
"description": "Rod Licensing Recurring Payments Job",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@defra-fish/business-rules-lib": "1.59.0-rc.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.59.0-rc.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.59.0-rc.6",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.59.0-rc.6",
|
|
41
41
|
"commander": "^7.2.0",
|
|
42
42
|
"moment-timezone": "^0.5.34"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "a827fb21247f70f131ec056c740afeb2c533a06c"
|
|
45
45
|
}
|
|
@@ -100,6 +100,7 @@ describe('recurring-payments-processor', () => {
|
|
|
100
100
|
|
|
101
101
|
const expectedData = {
|
|
102
102
|
dataSource: 'Recurring Payment',
|
|
103
|
+
agreementId: 'test-agreement-id',
|
|
103
104
|
permissions: [
|
|
104
105
|
{
|
|
105
106
|
isLicenceForYou,
|
|
@@ -269,7 +270,7 @@ describe('recurring-payments-processor', () => {
|
|
|
269
270
|
sendPayment.mockResolvedValueOnce(mockPaymentResponse)
|
|
270
271
|
|
|
271
272
|
await processRecurringPayments()
|
|
272
|
-
jest.
|
|
273
|
+
jest.useFakeTimers(60000)
|
|
273
274
|
|
|
274
275
|
expect(getPaymentStatus).toHaveBeenCalledWith('test-payment-id')
|
|
275
276
|
})
|
|
@@ -380,6 +381,7 @@ describe('recurring-payments-processor', () => {
|
|
|
380
381
|
expectedData.push([
|
|
381
382
|
{
|
|
382
383
|
dataSource: 'Recurring Payment',
|
|
384
|
+
agreementId: 'test-agreement-id',
|
|
383
385
|
permissions: [expect.objectContaining({ permitId: permit })]
|
|
384
386
|
}
|
|
385
387
|
])
|
|
@@ -25,13 +25,13 @@ export const processRecurringPayments = async () => {
|
|
|
25
25
|
const processRecurringPayment = async record => {
|
|
26
26
|
const referenceNumber = record.expanded.activePermission.entity.referenceNumber
|
|
27
27
|
const agreementId = record.entity.agreementId
|
|
28
|
-
const transaction = await createNewTransaction(referenceNumber)
|
|
28
|
+
const transaction = await createNewTransaction(referenceNumber, agreementId)
|
|
29
29
|
await takeRecurringPayment(agreementId, transaction)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const createNewTransaction = async referenceNumber => {
|
|
33
|
-
const transactionData = await processPermissionData(referenceNumber)
|
|
34
|
-
console.log('Creating new transaction based on', referenceNumber)
|
|
32
|
+
const createNewTransaction = async (referenceNumber, agreementId) => {
|
|
33
|
+
const transactionData = await processPermissionData(referenceNumber, agreementId)
|
|
34
|
+
console.log('Creating new transaction based on', referenceNumber, 'with agreementId', agreementId)
|
|
35
35
|
try {
|
|
36
36
|
const response = await salesApi.createTransaction(transactionData)
|
|
37
37
|
console.log('New transaction created:', response)
|
|
@@ -52,12 +52,13 @@ const takeRecurringPayment = async (agreementId, transaction) => {
|
|
|
52
52
|
})
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const processPermissionData = async referenceNumber => {
|
|
56
|
-
console.log('Preparing data based on', referenceNumber)
|
|
55
|
+
const processPermissionData = async (referenceNumber, agreementId) => {
|
|
56
|
+
console.log('Preparing data based on', referenceNumber, 'with agreementId', agreementId)
|
|
57
57
|
const data = await salesApi.preparePermissionDataForRenewal(referenceNumber)
|
|
58
58
|
const licenseeWithoutCountryCode = Object.assign((({ countryCode: _countryCode, ...l }) => l)(data.licensee))
|
|
59
59
|
return {
|
|
60
60
|
dataSource: 'Recurring Payment',
|
|
61
|
+
agreementId,
|
|
61
62
|
permissions: [
|
|
62
63
|
{
|
|
63
64
|
isLicenceForYou: data.isLicenceForYou,
|