Skip to content

Commit

Permalink
Add FDMR filter (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatson484 authored Nov 10, 2023
1 parent fe44a5c commit ddb956b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/processing/get-completed-payment-requests-filter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const db = require('../data')
const { BPS, CS } = require('../constants/schemes')
const { BPS, CS, FDMR } = require('../constants/schemes')

const getCompletedPaymentRequestsFilter = (paymentRequest) => {
const defaultFilter = {
Expand All @@ -16,6 +16,13 @@ const getCompletedPaymentRequestsFilter = (paymentRequest) => {
frn: paymentRequest.frn,
marketingYear: paymentRequest.marketingYear
}
case FDMR:
return {
...defaultFilter,
schemeId: paymentRequest.schemeId,
frn: paymentRequest.frn,
agreementNumber: paymentRequest.agreementNumber
}
case CS:
return {
...defaultFilter,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-pay-processing",
"version": "2.52.47",
"version": "2.52.48",
"description": "Payment Hub processing service",
"homepage": "https://github.com/DEFRA/ffc-pay-processing",
"main": "app/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jest.mock('../../../app/data')
const db = require('../../../app/data')

const { SFI, BPS, CS } = require('../../../app/constants/schemes')
const { SFI, BPS, CS, FDMR } = require('../../../app/constants/schemes')

const { getCompletedPaymentRequestsFilter } = require('../../../app/processing/get-completed-payment-requests-filter')

Expand Down Expand Up @@ -69,6 +69,31 @@ describe('get completed payment requests filter', () => {
})
})

test('should return FDMR filter if FDMR', () => {
paymentRequest.schemeId = FDMR
const filter = getCompletedPaymentRequestsFilter(paymentRequest)
expect(filter).toMatchObject({
paymentRequestNumber: { [db.Sequelize.Op.lt]: paymentRequest.paymentRequestNumber },
invalid: false,
schemeId: paymentRequest.schemeId,
frn: paymentRequest.frn,
agreementNumber: paymentRequest.agreementNumber
})
})

test('should return FDMR filter with all existing payment requests if manually injected payment and FDMR', () => {
paymentRequest.schemeId = FDMR
paymentRequest.paymentRequestNumber = 0
const filter = getCompletedPaymentRequestsFilter(paymentRequest)
expect(filter).toMatchObject({
paymentRequestNumber: { [db.Sequelize.Op.not]: null },
invalid: false,
schemeId: paymentRequest.schemeId,
frn: paymentRequest.frn,
agreementNumber: paymentRequest.agreementNumber
})
})

test('should return CS filter if CS', () => {
paymentRequest.schemeId = CS
const filter = getCompletedPaymentRequestsFilter(paymentRequest)
Expand Down

0 comments on commit ddb956b

Please sign in to comment.