From d5bf18f61c215683654dbde7b79507e3f7325ad1 Mon Sep 17 00:00:00 2001 From: JieunSon96 Date: Fri, 28 Jun 2024 12:15:54 -0700 Subject: [PATCH 1/4] add fee estimate --- .gitignore | 2 + .../ContactApplicant/PreviewModal.tsx | 6 ++- .../ContactApplicant/index.tsx | 11 +++- .../ContactApplicant/util.tsx | 54 ++++++++++++++++++- .../oipc_subsequent_time_extension.html | 2 +- 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 296498fdd..9155565f5 100644 --- a/.gitignore +++ b/.gitignore @@ -119,3 +119,5 @@ datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR/bi datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR.Tests/obj/* datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR.Tests/bin/* /datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.Utils.UnitTests/appsettings.dev.json + +env/ diff --git a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/PreviewModal.tsx b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/PreviewModal.tsx index 6f441f8f6..7c388fcfc 100644 --- a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/PreviewModal.tsx +++ b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/PreviewModal.tsx @@ -31,7 +31,9 @@ export const PreviewModal = React.memo(({ //gets the request detail from the store const requestDetails: any = useSelector((state: any) => state.foiRequests.foiRequestDetail); const requestExtensions: any = useSelector((state: any) => state.foiRequests.foiRequestExtesions); - + const responsePackagePdfStitchStatus = useSelector((state: any) => state.foiRequests.foiPDFStitchStatusForResponsePackage); + const cfrFeeData = useSelector((state: any) => state.foiRequests.foiRequestCFRFormHistory); + //get template const rootpath = OSS_S3_BUCKET_FULL_PATH const templatePath = "/TEMPLATES/EMAILS/header_footer_template.html"; @@ -53,7 +55,7 @@ export const PreviewModal = React.memo(({ }); }, []); requestDetails["ffaurl"] = FOI_FFA_URL; - const templateVariables = getTemplateVariables(requestDetails, requestExtensions, templateInfo); + const templateVariables = getTemplateVariables(requestDetails, requestExtensions, responsePackagePdfStitchStatus, cfrFeeData, templateInfo); const handleSend = () => { handleSave( applyVariables(innerhtml, templateVariables) ); }; diff --git a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx index a81b53bee..657ae8318 100644 --- a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx +++ b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx @@ -55,6 +55,13 @@ export const ContactApplicant = ({ const dispatch = useDispatch(); const currentCFRForm: any = useSelector((state: any) => state.foiRequests.foiRequestCFRForm); const isLoading: boolean = useSelector((state: any) => state.foiRequests.isCorrespondenceLoading); + const responsePackagePdfStitchStatus = useSelector((state: any) => state.foiRequests.foiPDFStitchStatusForResponsePackage); + const check: any = useSelector((state: any) => state.foiRequests); + const cfrFeeData = useSelector((state: any) => state.foiRequests.foiRequestCFRFormHistory); + console.log("cfrFeeData : ",cfrFeeData) + console.log("state.foiRequests : ",check) + console.log("responsePackagePdfStitchStatus : ",responsePackagePdfStitchStatus) + console.log("currentCFRForm : ",currentCFRForm) const fullNameList = getFullnameList() const getFullname = (userid: string) => { @@ -248,7 +255,7 @@ export const ContactApplicant = ({ const handleTemplateChange = (e: React.ChangeEvent) => { setCurrentTemplate(+e.target.value) - const templateVariables = getTemplateVariables(requestDetails, requestExtensions, templates[+e.target.value]); + const templateVariables = getTemplateVariables(requestDetails, requestExtensions, responsePackagePdfStitchStatus, cfrFeeData, templates[+e.target.value]); const finalTemplate = applyVariables(templates[+e.target.value].text || "", templateVariables); setEditorValue(finalTemplate) } @@ -256,7 +263,7 @@ export const ContactApplicant = ({ //When templates are selected from list const handleTemplateSelection = (index: number) => { setCurrentTemplate(index); - const templateVariables = getTemplateVariables(requestDetails,requestExtensions, templates[index]); + const templateVariables = getTemplateVariables(requestDetails,requestExtensions, responsePackagePdfStitchStatus, cfrFeeData, templates[index]); const finalTemplate = applyVariables(templates[index].text || "", templateVariables); setEditorValue(finalTemplate); changeCorrespondenceFilter("log"); diff --git a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx index 1d997bd19..52a7d09d6 100644 --- a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx +++ b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx @@ -27,13 +27,22 @@ export const getExtensiondetails = (requestExtensions:any, type: string) => { return ["","","","","",""] } -export const getTemplateVariables = (requestDetails: any, requestExtensions:any, templateInfo: any) => { +export const getTemplateVariables = (requestDetails: any, requestExtensions:any, responsePackagePdfStitchStatus:any, cfrFeeData:any, templateInfo: any) => { let oipcExtension = getExtensiondetails(requestExtensions, "OIPC"); let pbExtension = getExtensiondetails(requestExtensions, "Public Body"); // Find the record that matches the criteria for already taken a time extension under section 10(1), excluding the most recent record const filteredOutLatestExtensions = findLatestMatchingTimeExtension(requestExtensions, reasonsToCheck); + const checkFinalPackage = checkRecordReleased(responsePackagePdfStitchStatus) + + const [feeEstimateStatus, feeEstimateDate] = getFeeEstimateInfo(cfrFeeData); + console.log(feeEstimateDate); + console.log("checkFeeEstimate : ",feeEstimateStatus, " feeEstimateDate : ",feeEstimateDate) + const fullFeePaidDate = getFullFeePaidDate(cfrFeeData); + console.log("fullFeePaidDate L ",fullFeePaidDate) + const feeWaiverDecisionDate = getFeeWaiverDecisionDate(cfrFeeData); + console.log("feeWaiverDecisionDate L ",feeWaiverDecisionDate) return [ {name: "{{axisRequestId}}", value: requestDetails.axisRequestId}, {name: "{{title}}", value: templateInfo?.label || ""}, @@ -61,6 +70,11 @@ export const getTemplateVariables = (requestDetails: any, requestExtensions:any, {name: "{{filteredExtensionDate}}", value: filteredOutLatestExtensions ? filteredOutLatestExtensions.extendedduedate : ""}, {name: "{{filteredExtensionDueDays}}", value: filteredOutLatestExtensions ? filteredOutLatestExtensions.extendedduedays : ""}, {name: "{{oipcComplaintStatus}}", value: oipcComplaintCheck(requestDetails.oipcdetails)}, + {name: "{{finalPackageStatus}}", value: checkFinalPackage}, + {name: "{{feeEstimateStatus}}", value: feeEstimateStatus}, + {name: "{{feeEstimateDate}}", value: feeEstimateDate}, + {name: "{{fullFeePaidDate}}", value: getFullFeePaidDate(cfrFeeData)}, + {name: "{{feeWaiverDecisionDate}}", value: getFeeWaiverDecisionDate(cfrFeeData)}, ]; @@ -115,3 +129,41 @@ const isAlreadyTakenTimeExtension = (result: any | null): string => { // Check if there are any OIPC details. const oipcComplaintCheck = (oipcdetails: any): string => oipcdetails && oipcdetails.length > 0 ? "Yes" : "No"; + +// Function to check record release status +const checkRecordReleased = (status: string): string => { return status === "completed" ? "Yes" : "No"; }; + +// Function to check fee estimate and get the created_at date for a specific condition +const getFeeEstimateInfo = (data: any[]): [string, string] => { + const result = data.find( + item => item["cfrfeestatus.description"] === "Approved" && item.feedata.estimatedtotaldue > 0 + ); + + const status = result ? "Yes" : "No"; + const date = result ? result.created_at : ""; + + return [status, date]; +}; + +// Function to get the created_at date when the full fee is paid +const getFullFeePaidDate = (data: any[]): string => { + const result = data.find( + item => + item["cfrfeestatus.description"] === "Approved" && + item.feedata.balanceremaining <= 0 && + item.feedata.actualtotaldue <= 0 + ); + + return result ? result.created_at : ""; +}; + +// Function to get the created_at date when feewaiveramount is greater than 0 and status is Approved +const getFeeWaiverDecisionDate = (data: any[]): string => { + const result = data.find( + item => + item["cfrfeestatus.description"] === "Approved" && + item.feedata.feewaiveramount > 0 + ); + + return result ? result.created_at : ""; +}; \ No newline at end of file diff --git a/request-management-api/request_api/email_templates/oipc_subsequent_time_extension.html b/request-management-api/request_api/email_templates/oipc_subsequent_time_extension.html index f8da88a26..dd13c765a 100644 --- a/request-management-api/request_api/email_templates/oipc_subsequent_time_extension.html +++ b/request-management-api/request_api/email_templates/oipc_subsequent_time_extension.html @@ -217,7 +217,7 @@

 

-

Have any records been released to the applicant?  No    

+

Have any records been released to the applicant?  {{finalPackageStatus}}    

 

From d6dea38e6e8eddde15def82564e4776a2a04cc7e Mon Sep 17 00:00:00 2001 From: JieunSon96 Date: Fri, 28 Jun 2024 13:10:41 -0700 Subject: [PATCH 2/4] remove /env under gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9155565f5..6e58aad67 100644 --- a/.gitignore +++ b/.gitignore @@ -120,4 +120,3 @@ datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR.Te datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR.Tests/bin/* /datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.Utils.UnitTests/appsettings.dev.json -env/ From a0e3022051e51d6e4d7b0d0e2ba422d2544d9f45 Mon Sep 17 00:00:00 2001 From: JieunSon96 Date: Thu, 11 Jul 2024 16:52:57 -0700 Subject: [PATCH 3/4] change the code to show the template based on extensiontype --- .../FOI/customComponents/ContactApplicant/util.tsx | 10 +++++++--- .../oipc_applicant_consent_time_extension.html | 8 ++++---- .../email_templates/oipc_first_time_extension.html | 8 ++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx index 0ebf4aead..9f549a9cc 100644 --- a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx +++ b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx @@ -30,9 +30,13 @@ export const getExtensiondetails = (requestExtensions:any, type: string) => { } export const getExtensionType = (requestExtensions: any) => { - let oipcExtension = getExtensiondetails(requestExtensions, "OIPC"); - let pbExtension = getExtensiondetails(requestExtensions, "Public Body"); - return pbExtension[0] ? "PB" : oipcExtension[0] ? "OIPC" : "NA"; + if (!requestExtensions || requestExtensions.length === 0) { + return "NA"; + } + + // Get the type of the latest extension + let latestExtension = requestExtensions[0]; + return latestExtension["extensiontype"] === "Public Body" ? "PB" : "OIPC"; } export const getTemplateVariables = (requestDetails: any, requestExtensions:any, responsePackagePdfStitchStatus:any, cfrFeeData:any, templateInfo: any) => { diff --git a/request-management-api/request_api/email_templates/oipc_applicant_consent_time_extension.html b/request-management-api/request_api/email_templates/oipc_applicant_consent_time_extension.html index 0130b0f73..9edf9bc8e 100644 --- a/request-management-api/request_api/email_templates/oipc_applicant_consent_time_extension.html +++ b/request-management-api/request_api/email_templates/oipc_applicant_consent_time_extension.html @@ -88,16 +88,16 @@

 

-

Was a fee estimate sent?    Yes        No 

+

Was a fee estimate sent?    {{feeEstimateStatus}}         

-

Date fee estimate sent:  Date 

+

Date fee estimate sent:  {{feeEstimateDate}} 

-

Date deposit or full fee paid:   

+

Date deposit or full fee paid:   {{fullFeePaidDate}}

-

Date of fee waiver decision:  Date 

+

Date of fee waiver decision:  {{feeWaiverDecisionDate}} 

 

diff --git a/request-management-api/request_api/email_templates/oipc_first_time_extension.html b/request-management-api/request_api/email_templates/oipc_first_time_extension.html index cfb42f329..640c467a5 100644 --- a/request-management-api/request_api/email_templates/oipc_first_time_extension.html +++ b/request-management-api/request_api/email_templates/oipc_first_time_extension.html @@ -109,16 +109,16 @@

 

-

Was a fee estimate sent?    Yes        No 

+

Was a fee estimate sent?    {{feeEstimateStatus}}         

-

Date fee estimate sent:  Date 

+

Date fee estimate sent:  {{feeEstimateDate}} 

-

Date deposit or full fee paid:   

+

Date deposit or full fee paid:   {{fullFeePaidDate}}

-

Date of fee waiver decision:  Date 

+

Date of fee waiver decision:  {{feeWaiverDecisionDate}} 

 

From 9db19843d63d485b351e42354def322d78b492c7 Mon Sep 17 00:00:00 2001 From: JieunSon96 Date: Fri, 12 Jul 2024 08:47:23 -0700 Subject: [PATCH 4/4] removed console log --- .../FOI/customComponents/ContactApplicant/index.tsx | 4 ---- .../FOI/customComponents/ContactApplicant/util.tsx | 6 ++---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx index 5f64d1c99..814246fdb 100644 --- a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx +++ b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/index.tsx @@ -58,10 +58,6 @@ export const ContactApplicant = ({ const responsePackagePdfStitchStatus = useSelector((state: any) => state.foiRequests.foiPDFStitchStatusForResponsePackage); const check: any = useSelector((state: any) => state.foiRequests); const cfrFeeData = useSelector((state: any) => state.foiRequests.foiRequestCFRFormHistory); - console.log("cfrFeeData : ",cfrFeeData) - console.log("state.foiRequests : ",check) - console.log("responsePackagePdfStitchStatus : ",responsePackagePdfStitchStatus) - console.log("currentCFRForm : ",currentCFRForm) const fullNameList = getFullnameList() const getFullname = (userid: string) => { diff --git a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx index 9f549a9cc..0b336547d 100644 --- a/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx +++ b/forms-flow-web/src/components/FOI/customComponents/ContactApplicant/util.tsx @@ -49,12 +49,10 @@ export const getTemplateVariables = (requestDetails: any, requestExtensions:any, const checkFinalPackage = checkRecordReleased(responsePackagePdfStitchStatus) const [feeEstimateStatus, feeEstimateDate] = getFeeEstimateInfo(cfrFeeData); - console.log(feeEstimateDate); - console.log("checkFeeEstimate : ",feeEstimateStatus, " feeEstimateDate : ",feeEstimateDate) const fullFeePaidDate = getFullFeePaidDate(cfrFeeData); - console.log("fullFeePaidDate L ",fullFeePaidDate) + const feeWaiverDecisionDate = getFeeWaiverDecisionDate(cfrFeeData); - console.log("feeWaiverDecisionDate L ",feeWaiverDecisionDate) + return [ {name: "{{axisRequestId}}", value: requestDetails.axisRequestId}, {name: "{{title}}", value: templateInfo?.label || ""},