@defra-fish/recurring-payments-job 1.63.0-rc.8 → 1.63.0-rc.9

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.63.0-rc.8",
3
+ "version": "1.63.0-rc.9",
4
4
  "description": "Rod Licensing Recurring Payments Job",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,11 +36,11 @@
36
36
  "test": "echo \"Error: run tests from root\" && exit 1"
37
37
  },
38
38
  "dependencies": {
39
- "@defra-fish/business-rules-lib": "1.63.0-rc.8",
40
- "@defra-fish/connectors-lib": "1.63.0-rc.8",
39
+ "@defra-fish/business-rules-lib": "1.63.0-rc.9",
40
+ "@defra-fish/connectors-lib": "1.63.0-rc.9",
41
41
  "commander": "^7.2.0",
42
42
  "debug": "^4.3.3",
43
43
  "moment-timezone": "^0.5.34"
44
44
  },
45
- "gitHead": "4376fb63f6e1867708241521e43c4bce5791e08a"
45
+ "gitHead": "fc11192e1947a9a254138b543c8718ad892f0a15"
46
46
  }
@@ -20,17 +20,18 @@ jest.mock('@defra-fish/business-rules-lib', () => ({
20
20
  }))
21
21
  jest.mock('@defra-fish/connectors-lib', () => ({
22
22
  salesApi: {
23
- getDueRecurringPayments: jest.fn(() => []),
24
- preparePermissionDataForRenewal: jest.fn(() => ({
25
- licensee: { countryCode: 'GB-ENG' }
26
- })),
23
+ createPaymentJournal: jest.fn(),
27
24
  createTransaction: jest.fn(() => ({
28
25
  id: 'test-transaction-id',
29
26
  cost: 30
30
27
  })),
28
+ getDueRecurringPayments: jest.fn(() => []),
29
+ getPaymentJournal: jest.fn(),
30
+ preparePermissionDataForRenewal: jest.fn(() => ({
31
+ licensee: { countryCode: 'GB-ENG' }
32
+ })),
31
33
  processRPResult: jest.fn(),
32
- updatePaymentJournal: jest.fn(),
33
- getPaymentJournal: jest.fn()
34
+ updatePaymentJournal: jest.fn()
34
35
  }
35
36
  }))
36
37
 
@@ -308,6 +309,31 @@ describe('recurring-payments-processor', () => {
308
309
  expect(salesApi.createTransaction).toHaveBeenCalledWith(expectedData)
309
310
  })
310
311
 
312
+ it('creates a payment journal entry', async () => {
313
+ salesApi.getDueRecurringPayments.mockReturnValueOnce([getMockDueRecurringPayment()])
314
+ const samplePayment = {
315
+ payment_id: Symbol('payment-id'),
316
+ created_date: Symbol('created-date')
317
+ }
318
+ const sampleTransaction = {
319
+ id: Symbol('transaction-id'),
320
+ cost: 99
321
+ }
322
+ sendPayment.mockResolvedValueOnce(samplePayment)
323
+ salesApi.createTransaction.mockResolvedValueOnce(sampleTransaction)
324
+
325
+ await processRecurringPayments()
326
+
327
+ expect(salesApi.createPaymentJournal).toHaveBeenCalledWith(
328
+ sampleTransaction.id,
329
+ expect.objectContaining({
330
+ paymentReference: samplePayment.payment_id,
331
+ paymentTimestamp: samplePayment.created_date,
332
+ paymentStatus: PAYMENT_JOURNAL_STATUS_CODES.InProgress
333
+ })
334
+ )
335
+ })
336
+
311
337
  it('strips the concession name returned by preparePermissionDataForRenewal before passing to createTransaction', async () => {
312
338
  salesApi.getDueRecurringPayments.mockReturnValueOnce([getMockDueRecurringPayment()])
313
339
 
@@ -77,6 +77,12 @@ const createNewTransaction = async (referenceNumber, recurringPayment) => {
77
77
  const takeRecurringPayment = async (agreementId, transaction) => {
78
78
  const preparedPayment = preparePayment(agreementId, transaction)
79
79
  const payment = await sendPayment(preparedPayment)
80
+ await salesApi.createPaymentJournal(transaction.id, {
81
+ paymentReference: payment.payment_id,
82
+ paymentTimestamp: payment.created_date,
83
+ paymentStatus: PAYMENT_JOURNAL_STATUS_CODES.InProgress
84
+ })
85
+
80
86
  return {
81
87
  agreementId,
82
88
  paymentId: payment.payment_id,