Skip to content

Commit

Permalink
Merge pull request #358 from bcgov/ofmcc-5817-update-default-filter
Browse files Browse the repository at this point in the history
OFMCC-5817 - Update default filter
  • Loading branch information
vietle-cgi authored Sep 13, 2024
2 parents 1303bd3 + ffc2cdd commit cbe22f2
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion backend/src/components/fundingAgreements.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function getFundingAgreements(req, res) {
operation += '&$expand=ofm_application($select=_ofm_expense_authority_value;$expand=ofm_expense_authority($select=ofm_first_name,ofm_last_name))'
}
const filter = `${buildDateFilterQuery(req?.query, 'ofm_start_date')}${buildFilterQuery(req?.query, FundingAgreementMappings)}`
operation += `&$filter=(${filter})&$orderby=ofm_version_number desc`
operation += `&$filter=(${filter})&pageSize=500&$orderby=ofm_version_number desc`
const response = await getOperation(operation)
response?.value?.forEach((funding) => {
const fa = new MappableObjectForFront(funding, FundingAgreementMappings).toJSON()
Expand Down
2 changes: 1 addition & 1 deletion backend/src/components/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function getPayments(req, res) {
const payments = []
let operation = 'ofm_payments?$select=ofm_paymentid,ofm_name,_ofm_facility_value,_ofm_funding_value,ofm_payment_type,ofm_amount,ofm_invoice_date,statuscode,statecode'
const filter = `${buildDateFilterQuery(req?.query, 'ofm_invoice_date')}${buildFilterQuery(req?.query, PaymentMappings)}`
operation += `&$filter=(${filter})`
operation += `&$filter=(${filter})&pageSize=500`
const response = await getOperation(operation)
response?.value?.forEach((item) => payments.push(new MappableObjectForFront(item, PaymentMappings).toJSON()))
return res.status(HttpStatus.OK).json(payments)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/components/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function getSurveyResponses(req, res) {
if (req.query?.isSubmitted != null) {
filter += req.query?.isSubmitted === 'true' ? ' and _ofm_contact_value ne null' : ' and _ofm_contact_value eq null'
}
const operation = `ofm_survey_responses?$filter=(${filter})`
const operation = `ofm_survey_responses?$filter=(${filter})&pageSize=500`
const response = await getOperation(operation)
response?.value?.forEach((surveyResponse) => surveyResponses.push(new MappableObjectForFront(surveyResponse, SurveyResponseMappings).toJSON()))
if (isEmpty(surveyResponses)) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/funding/FundingAgreementsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default {
this.fundingAgreements = []
await Promise.all(
searchQueries?.facilities?.map(async (facility) => {
const facilityFas = await FundingAgreementService.getFAsByFacilityIdAndStartDate(facility.facilityId, searchQueries?.dateFrom, searchQueries?.dateTo)
const facilityFas = await FundingAgreementService.getFAsByFacilityId(facility.facilityId, searchQueries?.dateFrom, searchQueries?.dateTo)
if (facilityFas) {
facilityFas.forEach((fa) => {
fa.fundingAgreementType = APPLICATION_TYPES.OFM
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/funding/FundingSearchCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
},
defaultDateFilter: {
type: String,
default: DATE_FILTER_TYPES.THREE_MONTHS,
default: null,
},
},
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/components/funding/PaymentRecordsTab.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-container fluid class="pa-0">
<div class="mt-2 ml-2">View upcoming and past payments for all funding types.</div>
<FundingSearchCard :loading="loading" :show-payment-types-filter="true" :default-date-filter="DATE_FILTER_TYPES.YTD" class="my-6" @search="loadPayments" />
<FundingSearchCard :loading="loading" :show-payment-types-filter="true" class="my-6" @search="loadPayments" />
<h2 class="mb-2">Payment History</h2>
<v-skeleton-loader :loading="loading" type="table-tbody">
<v-data-table
Expand Down Expand Up @@ -122,7 +122,7 @@ export default {
let paymentHistory = []
await Promise.all(
this.searchQueries?.facilities?.map(async (facility) => {
const paidPaymentsForFacility = await PaymentService.getPaymentsByFacilityIdAndStatusAndDate(
const paidPaymentsForFacility = await PaymentService.getPaymentsByFacilityIdAndStatus(
facility.facilityId,
PAYMENT_STATUS_CODES.PAID,
this.searchQueries?.dateFrom,
Expand Down Expand Up @@ -152,10 +152,7 @@ export default {
}
await Promise.all(
this.searchQueries?.facilities?.map(async (facility) => {
const scheduledPaymentsForFacility =
this.searchQueries?.dateFilterType === DATE_FILTER_TYPES.YTD
? await PaymentService.getActivePaymentsByFacilityId(facility.facilityId)
: await PaymentService.getActivePaymentsByFacilityIdAndDate(facility.facilityId, dateFrom, dateTo)
const scheduledPaymentsForFacility = await PaymentService.getActivePaymentsByFacilityId(facility.facilityId, dateFrom, dateTo)
scheduledPayments = scheduledPayments?.concat(scheduledPaymentsForFacility)
}),
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/reports/ReportingHistoryTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default {
this.searchQueries = searchQueries
await Promise.all(
this.userInfo?.facilities?.map(async (facility) => {
const response = await ReportsService.getSubmittedSurveyResponsesByFacilityAndSubmittedDate(facility.facilityId, searchQueries?.dateFrom, searchQueries?.dateTo)
const response = await ReportsService.getSubmittedSurveyResponsesByFacility(facility.facilityId, searchQueries?.dateFrom, searchQueries?.dateTo)
if (!isEmpty(response)) {
this.submittedReports = this.submittedReports?.concat(response)
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/reports/ReportingSearchCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default {
resetFilter() {
// this.selectedReportTypes = this.reportTemplates
this.selectedStatuses = this.STATUS_FILTER_OPTIONS
this.selectedDateFilterType = DATE_FILTER_TYPES.THREE_MONTHS
this.selectedDateFilterType = null
this.selectedDateFrom = null
this.selectedDateTo = null
},
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/services/fundingAgreementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ export default {
}
},

async getFAsByFacilityIdAndStartDate(facilityId, startDateFrom, startDateTo) {
async getFAsByFacilityId(facilityId, startDateFrom = null, startDateTo = null) {
try {
if (!facilityId && !startDateFrom) return
let url = `${ApiRoutes.FUNDING_AGREEMENTS}?facilityId=${facilityId}&includeEA=true&dateFrom=${startDateFrom}`
if (!facilityId) return
let url = `${ApiRoutes.FUNDING_AGREEMENTS}?facilityId=${facilityId}&includeEA=true`
if (startDateFrom) {
url += `&dateFrom=${startDateFrom}`
}
if (startDateTo) {
url += `&dateTo=${startDateTo}`
}
Expand Down
27 changes: 11 additions & 16 deletions frontend/src/services/paymentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ import ApiService from '@/common/apiService'
import { ApiRoutes, CRM_STATE_CODES } from '@/utils/constants'

export default {
async getActivePaymentsByFacilityId(facilityId) {
async getActivePaymentsByFacilityId(facilityId, dateFrom = null, dateTo = null) {
try {
if (!facilityId) return
const response = await ApiService.apiAxios.get(`${ApiRoutes.PAYMENTS}?facilityId=${facilityId}&stateCode=${CRM_STATE_CODES.ACTIVE}`)
return response?.data
} catch (error) {
console.log(`Failed to get the list of active payments by facility id - ${error}`)
throw error
}
},

async getActivePaymentsByFacilityIdAndDate(facilityId, dateFrom, dateTo) {
try {
if (!facilityId || !dateFrom) return
let url = `${ApiRoutes.PAYMENTS}?facilityId=${facilityId}&stateCode=${CRM_STATE_CODES.ACTIVE}&dateFrom=${dateFrom}`
let url = `${ApiRoutes.PAYMENTS}?facilityId=${facilityId}&stateCode=${CRM_STATE_CODES.ACTIVE}`
if (dateFrom) {
url += `&dateFrom=${dateFrom}`
}
if (dateTo) {
url += `&dateTo=${dateTo}`
}
Expand All @@ -28,10 +20,13 @@ export default {
}
},

async getPaymentsByFacilityIdAndStatusAndDate(facilityId, statusCode, dateFrom, dateTo) {
async getPaymentsByFacilityIdAndStatus(facilityId, statusCode, dateFrom = null, dateTo = null) {
try {
if (!facilityId || !statusCode || !dateFrom) return
let url = `${ApiRoutes.PAYMENTS}?facilityId=${facilityId}&statusCode=${statusCode}&dateFrom=${dateFrom}`
if (!facilityId || !statusCode) return
let url = `${ApiRoutes.PAYMENTS}?facilityId=${facilityId}&statusCode=${statusCode}`
if (dateFrom) {
url += `&dateFrom=${dateFrom}`
}
if (dateTo) {
url += `&dateTo=${dateTo}`
}
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/services/reportsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ export default {
}
},

async getSubmittedSurveyResponsesByFacilityAndSubmittedDate(facilityId, dateFrom, dateTo) {
async getSubmittedSurveyResponsesByFacility(facilityId, dateFrom = null, dateTo = null) {
try {
if (!facilityId) return
let url = `${ApiRoutes.REPORTS}/survey-responses?facilityId=${facilityId}&isSubmitted=true&dateFrom=${dateFrom}`
let url = `${ApiRoutes.REPORTS}/survey-responses?facilityId=${facilityId}&isSubmitted=true`
if (dateFrom) {
url += `&dateFrom=${dateFrom}`
}
if (dateTo) {
url += `&dateTo=${dateTo}`
}
Expand Down

0 comments on commit cbe22f2

Please sign in to comment.