@defra-fish/sales-api-service 1.63.0-rc.14 → 1.63.0-rc.16

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.63.0-rc.14",
3
+ "version": "1.63.0-rc.16",
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.63.0-rc.14",
39
- "@defra-fish/connectors-lib": "1.63.0-rc.14",
40
- "@defra-fish/dynamics-lib": "1.63.0-rc.14",
38
+ "@defra-fish/business-rules-lib": "1.63.0-rc.16",
39
+ "@defra-fish/connectors-lib": "1.63.0-rc.16",
40
+ "@defra-fish/dynamics-lib": "1.63.0-rc.16",
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": "7b43e86ea607a9e8c8c8aa15d24c5fe92f6b6853"
55
+ "gitHead": "919da5c05680899ab228a9a8434694b8e6aa53e6"
56
56
  }
@@ -95,7 +95,6 @@ jest.mock('../../services/paymentjournals/payment-journals.service.js', () => ({
95
95
  }))
96
96
 
97
97
  jest.mock('@defra-fish/business-rules-lib', () => ({
98
- ADVANCED_PURCHASE_MAX_DAYS: 30,
99
98
  PAYMENT_JOURNAL_STATUS_CODES: {
100
99
  InProgress: 'InProgressCode',
101
100
  Cancelled: 'CancelledCode',
@@ -455,6 +454,17 @@ describe('recurring payments service', () => {
455
454
  '2025-11-12T00:00:00.000Z',
456
455
  '3456'
457
456
  ],
457
+ [
458
+ 'starts thirty-one days after issue date - next due on issue date plus one year',
459
+ '9o8u7yhui89u8i9oiu8i8u7yhu',
460
+ {
461
+ startDate: '2024-12-14T00:00:00.000Z',
462
+ issueDate: '2024-11-12T15:00:45.922Z',
463
+ endDate: '2025-12-13T23:59:59.999Z'
464
+ },
465
+ '2025-11-12T00:00:00.000Z',
466
+ '4321'
467
+ ],
458
468
  [
459
469
  "issued on 29th Feb '24, starts on 30th March '24 - next due on 28th Feb '25",
460
470
  'hy7u8ijhyu78jhyu8iu8hjiujn',
@@ -511,11 +521,11 @@ describe('recurring payments service', () => {
511
521
 
512
522
  it.each([
513
523
  [
514
- 'start date is thirty one days after issue date',
524
+ 'start date equals issue date',
515
525
  {
516
- startDate: '2024-12-14T00:00:00.000Z',
517
- issueDate: '2024-11-12T15:00:45.922Z',
518
- endDate: '2025-12-13T23:59:59.999Z'
526
+ startDate: '2024-11-11T00:00:00.000Z',
527
+ issueDate: '2024-11-11T00:00:00.000Z',
528
+ endDate: '2025-11-10T23:59:59.999Z'
519
529
  }
520
530
  ],
521
531
  [
@@ -10,7 +10,7 @@ import {
10
10
  import { calculateEndDate, generatePermissionNumber } from './permissions.service.js'
11
11
  import { getObfuscatedDob } from './contacts.service.js'
12
12
  import { createHash } from 'node:crypto'
13
- import { ADVANCED_PURCHASE_MAX_DAYS, PAYMENT_JOURNAL_STATUS_CODES, PAYMENT_TYPE, TRANSACTION_SOURCE } from '@defra-fish/business-rules-lib'
13
+ import { PAYMENT_JOURNAL_STATUS_CODES, PAYMENT_TYPE, TRANSACTION_SOURCE } from '@defra-fish/business-rules-lib'
14
14
  import { TRANSACTION_STAGING_TABLE, TRANSACTION_QUEUE } from '../config.js'
15
15
  import { TRANSACTION_STATUS } from '../services/transactions/constants.js'
16
16
  import { retrieveStagedTransaction } from '../services/transactions/retrieve-transaction.js'
@@ -26,7 +26,7 @@ export const getRecurringPayments = date => executeQuery(findDueRecurringPayment
26
26
 
27
27
  const getNextDueDate = (startDate, issueDate, endDate) => {
28
28
  const mStart = moment(startDate)
29
- if (mStart.isAfter(moment(issueDate)) && mStart.isSameOrBefore(moment(issueDate).add(ADVANCED_PURCHASE_MAX_DAYS, 'days'), 'day')) {
29
+ if (mStart.isAfter(moment(issueDate))) {
30
30
  if (mStart.isSame(moment(issueDate), 'day')) {
31
31
  return moment(startDate).add(1, 'year').subtract(10, 'days').startOf('day').toISOString()
32
32
  }