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() }