@defra-fish/dynamics-lib 1.61.0 → 1.62.0-rc.1

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/dynamics-lib",
3
- "version": "1.61.0",
3
+ "version": "1.62.0-rc.1",
4
4
  "description": "Framework to support integration with dynamics",
5
5
  "type": "module",
6
6
  "engines": {
@@ -43,5 +43,5 @@
43
43
  "simple-oauth2": "^4.3.0",
44
44
  "uuid": "^8.3.2"
45
45
  },
46
- "gitHead": "8d1841265a40178f285288e5323a36e887483434"
46
+ "gitHead": "89028907ee2ee612a0126fb9b7857791c2e9563d"
47
47
  }
@@ -9,7 +9,8 @@ describe('Recurring Payment Queries', () => {
9
9
 
10
10
  expect(query.toRetrieveRequest()).toEqual({
11
11
  collection: 'defra_recurringpayments',
12
- filter: "defra_nextduedate eq 'Wed Nov 08 2023 00:00:00 GMT+0000 (Greenwich Mean Time)' and defra_cancelleddate eq null",
12
+ filter:
13
+ "defra_nextduedate eq 'Wed Nov 08 2023 00:00:00 GMT+0000 (Greenwich Mean Time)' and defra_cancelleddate eq null and _defra_nextrecurringpayment_value eq null and statecode eq 0",
13
14
  select: [
14
15
  'defra_recurringpaymentid',
15
16
  'defra_name',
@@ -35,7 +36,7 @@ describe('Recurring Payment Queries', () => {
35
36
 
36
37
  expect(query.toRetrieveRequest()).toEqual({
37
38
  collection: 'defra_recurringpayments',
38
- filter: `defra_agreementid eq '${agreementId}'`,
39
+ filter: `defra_agreementid eq '${agreementId}' and statecode eq 0`,
39
40
  select: [
40
41
  'defra_recurringpaymentid',
41
42
  'defra_name',
@@ -10,14 +10,21 @@ import { PredefinedQuery } from './predefined-query.js'
10
10
  export const findDueRecurringPayments = date => {
11
11
  const { contact, activePermission } = RecurringPayment.definition.relationships
12
12
 
13
- const filter = `defra_nextduedate eq '${date}' and defra_cancelleddate eq null`
13
+ const filters = []
14
+
15
+ filters.push(`defra_nextduedate eq '${date}'`)
16
+ filters.push('defra_cancelleddate eq null')
17
+ filters.push('_defra_nextrecurringpayment_value eq null')
18
+
19
+ filters.push(RecurringPayment.definition.defaultFilter)
14
20
 
15
21
  return new PredefinedQuery({
16
22
  root: RecurringPayment,
17
- filter: filter,
23
+ filter: filters.join(' and '),
18
24
  expand: [contact, activePermission]
19
25
  })
20
26
  }
27
+
21
28
  /**
22
29
  * Builds a query to retrieve recurring payments by agreementId
23
30
  *
@@ -25,10 +32,13 @@ export const findDueRecurringPayments = date => {
25
32
  * @returns {PredefinedQuery}
26
33
  */
27
34
  export const findRecurringPaymentsByAgreementId = agreementId => {
28
- const filter = `defra_agreementid eq '${agreementId}'`
35
+ const filters = []
36
+
37
+ filters.push(`defra_agreementid eq '${agreementId}'`)
38
+ filters.push(RecurringPayment.definition.defaultFilter)
29
39
 
30
40
  return new PredefinedQuery({
31
41
  root: RecurringPayment,
32
- filter: filter
42
+ filter: filters.join(' and ')
33
43
  })
34
44
  }