@defra-fish/sales-api-service 1.62.0-rc.2 → 1.62.0-rc.4

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/sales-api-service",
3
- "version": "1.62.0-rc.2",
3
+ "version": "1.62.0-rc.4",
4
4
  "description": "Rod Licensing Sales API",
5
5
  "type": "module",
6
6
  "engines": {
@@ -35,9 +35,9 @@
35
35
  "test": "echo \"Error: run tests from root\" && exit 1"
36
36
  },
37
37
  "dependencies": {
38
- "@defra-fish/business-rules-lib": "1.62.0-rc.2",
39
- "@defra-fish/connectors-lib": "1.62.0-rc.2",
40
- "@defra-fish/dynamics-lib": "1.62.0-rc.2",
38
+ "@defra-fish/business-rules-lib": "1.62.0-rc.4",
39
+ "@defra-fish/connectors-lib": "1.62.0-rc.4",
40
+ "@defra-fish/dynamics-lib": "1.62.0-rc.4",
41
41
  "@hapi/boom": "^9.1.2",
42
42
  "@hapi/hapi": "^20.1.3",
43
43
  "@hapi/inert": "^6.0.3",
@@ -52,5 +52,5 @@
52
52
  "moment-timezone": "^0.5.34",
53
53
  "uuid": "^8.3.2"
54
54
  },
55
- "gitHead": "6a3a2c6a81067424144382557214c49c27559cdf"
55
+ "gitHead": "ffb61b6f55dc319cc1afbe57f8787deeb27f1dee"
56
56
  }
@@ -5,9 +5,9 @@ Object {
5
5
  "agreementId": "435678",
6
6
  "cancelledDate": null,
7
7
  "cancelledReason": null,
8
- "endDate": 2023-11-12T00:00:00.000Z,
9
- "name": "Test Name",
10
- "nextDueDate": 2023-11-02T00:00:00.000Z,
8
+ "endDate": "2023-11-12T00:00:00.000Z",
9
+ "name": "Fester Tester 2023",
10
+ "nextDueDate": "2023-11-02T00:00:00.000Z",
11
11
  "publicId": "abcdef99987",
12
12
  "status": 0,
13
13
  }
@@ -227,7 +227,14 @@ const getMockResponse = () => ({
227
227
  })
228
228
 
229
229
  describe('recurring payments service', () => {
230
- const createSimpleSampleTransactionRecord = () => ({ payment: { recurring: true }, permissions: [{}] })
230
+ const createSimpleSampleTransactionRecord = () => ({
231
+ payment: {
232
+ recurring: {
233
+ nextDueDate: '2025-01-01T00:00:00.000Z'
234
+ }
235
+ },
236
+ permissions: [{}]
237
+ })
231
238
  const createSamplePermission = overrides => {
232
239
  const p = new Permission()
233
240
  p.referenceNumber = 'ABC123'
@@ -284,11 +291,10 @@ describe('recurring payments service', () => {
284
291
  const transactionRecord = {
285
292
  payment: {
286
293
  recurring: {
287
- name: 'Test Name',
288
- nextDueDate: new Date('2023-11-02'),
294
+ nextDueDate: '2023-11-02T00:00:00.000Z',
289
295
  cancelledDate: null,
290
296
  cancelledReason: null,
291
- endDate: new Date('2023-11-12'),
297
+ endDate: '2023-11-12T00:00:00.000Z',
292
298
  agreementId: '435678',
293
299
  status: 0
294
300
  }
@@ -300,6 +306,19 @@ describe('recurring payments service', () => {
300
306
  expect(result.recurringPayment).toMatchSnapshot()
301
307
  })
302
308
 
309
+ it('should set a valid name on the recurringPayment', async () => {
310
+ const transactionRecord = {
311
+ payment: {
312
+ recurring: {
313
+ nextDueDate: '2023-07-07T00:00:00.000Z'
314
+ }
315
+ },
316
+ permissions: [getMockPermission()]
317
+ }
318
+ const result = await processRecurringPayment(transactionRecord, getMockContact())
319
+ expect(result.recurringPayment.name).toBe('Fester Tester 2023')
320
+ })
321
+
303
322
  it.each(['abc-123', 'def-987'])('generates a publicId %s for the recurring payment', async samplePublicId => {
304
323
  createHash.mockReturnValue({
305
324
  update: () => {},
@@ -65,7 +65,7 @@ export const processRecurringPayment = async (transactionRecord, contact) => {
65
65
  if (transactionRecord.payment?.recurring) {
66
66
  const recurringPayment = new RecurringPayment()
67
67
  hash.update(recurringPayment.uniqueContentId)
68
- recurringPayment.name = transactionRecord.payment.recurring.name
68
+ recurringPayment.name = determineRecurringPaymentName(transactionRecord, contact)
69
69
  recurringPayment.nextDueDate = transactionRecord.payment.recurring.nextDueDate
70
70
  recurringPayment.cancelledDate = transactionRecord.payment.recurring.cancelledDate
71
71
  recurringPayment.cancelledReason = transactionRecord.payment.recurring.cancelledReason
@@ -148,3 +148,8 @@ export const cancelRecurringPayment = async id => {
148
148
  console.log('No matches found for cancellation')
149
149
  }
150
150
  }
151
+
152
+ const determineRecurringPaymentName = (transactionRecord, contact) => {
153
+ const [dueYear] = transactionRecord.payment.recurring.nextDueDate.split('-')
154
+ return [contact.firstName, contact.lastName, dueYear].join(' ')
155
+ }