Skip to content

Commit

Permalink
Merge pull request #10378 from flexion/5512-rebased
Browse files Browse the repository at this point in the history
5512 PDFs
  • Loading branch information
TomElliottFlexion authored May 9, 2024
2 parents 37c2cc7 + 52e9465 commit 6db1c64
Show file tree
Hide file tree
Showing 19 changed files with 529 additions and 7 deletions.
66 changes: 66 additions & 0 deletions shared/src/business/useCases/generatePetitionPdfInteractor.ts
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 shared/src/business/utilities/documentGenerators/petition.ts
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;
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#docket-header {
#docket-header, #petition-header {
.case-information #caption,
#case-caption {
width: 49%;
Expand Down Expand Up @@ -42,10 +42,28 @@
}
}

.case-information #temp-docket-number, .case-information #electronically-filed {
width: 48%;
float: right;
font-size: 14px;
text-indent: 5px;
}

.case-information #temp-docket-number {
margin-top: 4px;
}

.case-information #electronically-filed {
margin-top: 40px;
}

.document-title {
margin-top: 30px;
font-size: 16px;
text-align: center;
text-decoration: underline;

.underline {
text-decoration: underline;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.order-court-header {
.order-court-header, .petition-court-header {
margin-bottom: 30px;
line-height: 160%;
text-align: center;
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
@import './documents/standing-pretrial-order';
@import './documents/printable-working-copy-list';
@import './documents/entry-of-appearance';
@import './documents/petition';
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const DocketHeader = ({
</div>
<div id="docket-number">Docket No. {docketNumberWithSuffix}</div>
<div className="clear"></div>
{documentTitle && <h3 className="document-title">{documentTitle}</h3>}
{documentTitle && (
<h3 className="document-title underline">{documentTitle}</h3>
)}
</div>
</div>
);
Expand Down
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>
);
};
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>
);
};
Loading

0 comments on commit 6db1c64

Please sign in to comment.