From 448c45c87db420a89aef39a04a2d2dc74f574dad Mon Sep 17 00:00:00 2001 From: Phil Benson Date: Fri, 6 Dec 2024 16:44:23 +0000 Subject: [PATCH] Remove magic number --- .../src/services/recurring-payments.service.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sales-api-service/src/services/recurring-payments.service.js b/packages/sales-api-service/src/services/recurring-payments.service.js index d24c5b53a..3f5fce7ed 100644 --- a/packages/sales-api-service/src/services/recurring-payments.service.js +++ b/packages/sales-api-service/src/services/recurring-payments.service.js @@ -1,12 +1,13 @@ import { executeQuery, findDueRecurringPayments, RecurringPayment } from '@defra-fish/dynamics-lib' import { createHash } from 'node:crypto' +import { ADVANCED_PURCHASE_MAX_DAYS } from '@defra-fish/business-rules-lib' import moment from 'moment' export const getRecurringPayments = date => executeQuery(findDueRecurringPayments(date)) const getNextDueDate = (startDate, issueDate, endDate) => { const mStart = moment(startDate) - if (mStart.isAfter(moment(issueDate)) && mStart.isSameOrBefore(moment(issueDate).add(30, 'days'), 'day')) { + if (mStart.isAfter(moment(issueDate)) && mStart.isSameOrBefore(moment(issueDate).add(ADVANCED_PURCHASE_MAX_DAYS, 'days'), 'day')) { if (mStart.isSame(moment(issueDate), 'day')) { return moment(startDate).add(1, 'year').subtract(10, 'days').startOf('day').toISOString() }