Skip to content

Commit

Permalink
Update documentation on BAP submission Record_Type_Name__c field, and…
Browse files Browse the repository at this point in the history
… simplify sorting of form types by using common string each record type starts with (e.g. 'CSB Funding Request' which matches 2022 submissions of that name and 2023 submissions, which are named 'CSB Funding Request 2023')
  • Loading branch information
courtneymyers committed Dec 7, 2023
1 parent fdc30cb commit 89c87c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
58 changes: 25 additions & 33 deletions app/client/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ type BapFormSubmission = {
CSB_Modified_Full_String__c: string; // ISO 8601 date time string
CSB_Review_Item_ID__c: string; // CSB Rebate ID with form/version ID (9 digits)
Parent_Rebate_ID__c: string; // CSB Rebate ID (6 digits)
Record_Type_Name__c:
| "CSB Funding Request" // TODO: remove once BAP's update has been deployed
| "CSB Payment Request" // TODO: remove once BAP's update has been deployed
| "CSB Close Out Request" // TODO: remove once BAP's update has been deployed
| "CSB Funding Request 2022"
| "CSB Payment Request 2022"
| "CSB Close Out Request 2022"
Record_Type_Name__c: /*
* NOTE: 2022 submissions don't have a year in their record type name, but
* we'll account for it here in case the BAP switches to using it in the future.
*/
| "CSB Funding Request" // NOTE: 2022 submissions
| "CSB Payment Request" // NOTE: 2022 submissions
| "CSB Close Out Request" // NOTE: 2022 submissions
| "CSB Funding Request 2022" // NOTE: not currently used
| "CSB Payment Request 2022" // NOTE: not currently used
| "CSB Close Out Request 2022" // NOTE: not currently used
| "CSB Funding Request 2023"
| "CSB Payment Request 2023"
| "CSB Close Out Request 2023";
Expand Down Expand Up @@ -393,40 +396,29 @@ export function useSubmissionsQueries(rebateYear: RebateYear) {
queryFn: () => {
const url = `${serverUrl}/api/bap/submissions`;
return getData<BapFormSubmission[]>(url).then((res) => {
const frfRecordTypeNames = [
"CSB Funding Request", // TODO: remove once BAP's update has been deployed
"CSB Funding Request 2022",
"CSB Funding Request 2023",
];

const prfRecordTypeNames = [
"CSB Payment Request", // TODO: remove once BAP's update has been deployed
"CSB Payment Request 2022",
"CSB Payment Request 2023",
];

const crfRecordTypeNames = [
"CSB Close Out Request", // TODO: remove once BAP's update has been deployed
"CSB Close Out Request 2022",
"CSB Close Out Request 2023",
];
if (!Array.isArray(res)) {
return Promise.reject(res);
}

const submissions = res.reduce(
(object, submission) => {
const { Record_Type_Name__c, Rebate_Program_Year__c } = submission;

const formType = frfRecordTypeNames.includes(Record_Type_Name__c)
? "frfs"
: prfRecordTypeNames.includes(Record_Type_Name__c)
? "prfs"
: crfRecordTypeNames.includes(Record_Type_Name__c)
? "crfs"
: null;

const rebateYear =
Rebate_Program_Year__c === null ? "2022" : Rebate_Program_Year__c;

if (formType) object[rebateYear][formType].push(submission);
const formType =
Record_Type_Name__c.startsWith("CSB Funding Request") // prettier-ignore
? "frfs"
: Record_Type_Name__c.startsWith("CSB Payment Request")
? "prfs"
: Record_Type_Name__c.startsWith("CSB Close Out Request")
? "crfs"
: null;

if (rebateYear && formType) {
object[rebateYear][formType].push(submission);
}

return object;
},
Expand Down
2 changes: 1 addition & 1 deletion app/server/app/utilities/bap.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ async function queryForBapFormSubmissionsStatuses(req, comboKeys) {
CSB_Modified_Full_String__c: 1, // ISO 8601 date time string
CSB_Review_Item_ID__c: 1, // CSB Rebate ID with form/version ID (9 digits)
Parent_Rebate_ID__c: 1, // CSB Rebate ID (6 digits)
Record_Type_Name__c: 1, // 'CSB Funding Request' | 'CSB Payment Request' | 'CSB Close Out Request' // TODO: update with new names
Record_Type_Name__c: 1, // 'CSB Funding Request' | 'CSB Payment Request' | 'CSB Close Out Request' | 'CSB Funding Request 2023' | 'CSB Payment Request 2023' | 'CSB Close Out Request 2023'
Rebate_Program_Year__c: 1, // '2022' | '2023'
"Parent_CSB_Rebate__r.CSB_Funding_Request_Status__c": 1,
"Parent_CSB_Rebate__r.CSB_Payment_Request_Status__c": 1,
Expand Down

0 comments on commit 89c87c6

Please sign in to comment.