forked from ustaxcourt/ef-cms
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10378 from flexion/5512-rebased
5512 PDFs
- Loading branch information
Showing
19 changed files
with
529 additions
and
7 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
shared/src/business/useCases/generatePetitionPdfInteractor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
CASE_TYPE_DESCRIPTIONS_WITHOUT_IRS_NOTICE, | ||
CASE_TYPE_DESCRIPTIONS_WITH_IRS_NOTICE, | ||
} from '@shared/business/entities/EntityConstants'; | ||
// import { | ||
// ROLE_PERMISSIONS, | ||
// isAuthorized, | ||
// } from '../../../authorization/authorizationClientService'; | ||
// import { UnauthorizedError } from '@web-api/errors/errors'; | ||
|
||
// TODO type for props | ||
|
||
export const generatePetitionPdfInteractor = async ( | ||
applicationContext: IApplicationContext, | ||
{ | ||
caseCaptionExtension, | ||
caseTitle, | ||
caseType, | ||
contactPrimary, | ||
contactSecondary, | ||
docketNumberWithSuffix, | ||
noticeIssuedDate, | ||
petitionFacts, | ||
petitionReasons, | ||
preferredTrialCity, | ||
procedureType, | ||
taxYear, | ||
}: any, | ||
) => { | ||
// const user = applicationContext.getCurrentUser(); | ||
|
||
// if (!isAuthorized(user, ROLE_PERMISSIONS.???)) { | ||
// throw new UnauthorizedError('Unauthorized'); | ||
// } | ||
const caseDescription = | ||
CASE_TYPE_DESCRIPTIONS_WITH_IRS_NOTICE[caseType] || | ||
CASE_TYPE_DESCRIPTIONS_WITHOUT_IRS_NOTICE[caseType]; | ||
|
||
const file = await applicationContext.getDocumentGenerators().petition({ | ||
applicationContext, | ||
data: { | ||
caseCaptionExtension, | ||
caseDescription, | ||
caseTitle, | ||
contactPrimary, | ||
contactSecondary, | ||
docketNumberWithSuffix, | ||
noticeIssuedDate, | ||
petitionFacts, | ||
petitionReasons, | ||
preferredTrialCity, | ||
procedureType, | ||
taxYear, | ||
}, | ||
}); | ||
|
||
// 24 hrs | ||
const urlTtl = 60 * 60 * 24; | ||
|
||
return await applicationContext.getUseCaseHelpers().saveFileAndGenerateUrl({ | ||
applicationContext, | ||
file, | ||
urlTtl, | ||
useTempBucket: true, | ||
}); | ||
}; |
57 changes: 57 additions & 0 deletions
57
shared/src/business/utilities/documentGenerators/petition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { FORMATS } from '@shared/business/utilities/DateHandler'; | ||
import { Petition } from '@shared/business/utilities/pdfGenerator/documentTemplates/Petition'; | ||
import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/server'; | ||
|
||
export const petition = async ({ applicationContext, data }) => { | ||
const { | ||
caseCaptionExtension, | ||
caseDescription, | ||
caseTitle, | ||
contactPrimary, | ||
contactSecondary, | ||
docketNumberWithSuffix, | ||
noticeIssuedDate, | ||
petitionFacts, | ||
petitionReasons, | ||
preferredTrialCity, | ||
procedureType, | ||
taxYear, | ||
} = data; | ||
|
||
const date = applicationContext.getUtilities().formatNow(FORMATS.MMDDYY); | ||
|
||
const PetitionTemplate = ReactDOM.renderToString( | ||
React.createElement(Petition, { | ||
caseCaptionExtension, | ||
caseDescription, | ||
caseTitle, | ||
contactPrimary, | ||
contactSecondary, | ||
date, | ||
docketNumberWithSuffix, | ||
noticeIssuedDate, | ||
petitionFacts, | ||
petitionReasons, | ||
preferredTrialCity, | ||
procedureType, | ||
taxYear, | ||
}), | ||
); | ||
|
||
const pdfContentHtml = await generateHTMLTemplateForPDF({ | ||
applicationContext, | ||
content: PetitionTemplate, | ||
}); | ||
|
||
const pdf = await applicationContext | ||
.getUseCases() | ||
.generatePdfFromHtmlInteractor(applicationContext, { | ||
contentHtml: pdfContentHtml, | ||
displayHeaderFooter: false, | ||
docketNumber: docketNumberWithSuffix, | ||
}); | ||
|
||
return pdf; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
shared/src/business/utilities/htmlGenerator/components/order-court-header.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
shared/src/business/utilities/htmlGenerator/documents/petition.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.petition-pdf { | ||
// margin-bottom: 2cm; | ||
|
||
ol { | ||
padding-left: 0; | ||
margin-left: 0; | ||
|
||
li { | ||
margin-top: 1rem; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
ol { | ||
padding-left: 0; | ||
margin-left: 1rem; | ||
list-style-type: lower-alpha; | ||
} | ||
|
||
&.list-disc { | ||
padding-left: 0; | ||
margin-left: 1rem; | ||
list-style-type: disc; | ||
} | ||
} | ||
|
||
p { | ||
padding-left: 0; | ||
margin-left: 0; | ||
} | ||
|
||
.petitioner-info { | ||
width: 50%; | ||
margin-top: 4rem; | ||
float: left; | ||
} | ||
|
||
.spouse-info { | ||
width: 50%; | ||
margin-top: 4rem; | ||
float: right; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
shared/src/business/utilities/pdfGenerator/components/PetitionDocketHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
|
||
export const PetitionDocketHeader = ({ | ||
caseCaptionExtension, | ||
caseTitle, | ||
docketNumberWithSuffix, | ||
}: { | ||
caseCaptionExtension: string; | ||
caseTitle: string; | ||
docketNumberWithSuffix: string; | ||
}) => { | ||
return ( | ||
<div id="petition-header"> | ||
<div className="case-information"> | ||
<div id="caption"> | ||
<div id="caption-title">{caseTitle}</div> | ||
<div id="caption-extension">{caseCaptionExtension}</div> | ||
<div id="caption-v">v.</div> | ||
<div id="caption-commissioner">Commissioner of Internal Revenue</div> | ||
<div id="caption-respondent">Respondent</div> | ||
</div> | ||
<div id="electronically-filed">Electronically Filed</div> | ||
<div id="temp-docket-number">Docket No. {docketNumberWithSuffix}</div> | ||
<div className="clear"></div> | ||
<h3 className="document-title">PETITION</h3> | ||
</div> | ||
</div> | ||
); | ||
}; |
11 changes: 11 additions & 0 deletions
11
shared/src/business/utilities/pdfGenerator/components/PetitionPrimaryHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
export const PetitionPrimaryHeader = () => { | ||
return ( | ||
<div className="petition-court-header"> | ||
<h1>United States Tax Court</h1> | ||
<div className="court-address">Washington, DC 20217</div> | ||
<div className="clear"></div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.