Skip to content

Commit 6f11e96

Browse files
authored
Fix View Weekly Returns to use end date for filter (#1761)
We mistakenly used the start date of a weekly return submission line to determine if they should be included in a month, instead of the end date. This PR fixes this.
1 parent b1273a1 commit 6f11e96

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/presenters/return-submissions/view-return-submission.presenter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function go(returnSubmission, yearMonth) {
2222

2323
const [requestedYear, requestedMonth] = _determineRequestedYearAndMonth(yearMonth)
2424
const requestedMonthLines = returnSubmissionLines.filter(
25-
(line) => line.startDate.getFullYear() === requestedYear && line.startDate.getMonth() === requestedMonth
25+
(line) => line.endDate.getFullYear() === requestedYear && line.endDate.getMonth() === requestedMonth
2626
)
2727

2828
const method = returnSubmission.$method()

test/presenters/return-submissions/view-return-submission.presenter.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ describe('View Return Submissions presenter', () => {
268268
expect(headers).to.include('Week ending')
269269
})
270270

271-
it('includes the expected rows that start within the month', () => {
271+
it('includes the expected rows that end within the month', () => {
272272
const result = ViewReturnSubmissionPresenter.go(testReturnSubmission, '2025-3')
273273

274274
expect(result.tableData.rows.length).to.equal(4)
275-
expect(result.tableData.rows[0]).to.include({ date: '12 April 2025' })
276-
expect(result.tableData.rows[3]).to.include({ date: '3 May 2025' })
275+
expect(result.tableData.rows[0]).to.include({ date: '5 April 2025' })
276+
expect(result.tableData.rows).to.not.include({ date: '3 May 2025' })
277277
})
278278
})
279279
})

0 commit comments

Comments
 (0)