ssm burial permit

deepsource-autofix-76c6eb20
Dan Gowans 2022-10-13 10:13:45 -04:00
parent ff0dd39868
commit 6990fd0a10
13 changed files with 189 additions and 13 deletions

View File

@ -2,9 +2,11 @@ import path from "path";
import * as ejs from "ejs";
import * as configFunctions from "../../helpers/functions.config.js";
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
import * as lotOccupancyFunctions from "../../helpers/functions.lotOccupancy.js";
import { getReportData, getPdfPrintConfig } from "../../helpers/functions.print.js";
import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";
import camelcase from "camelcase";
const attachmentOrInline = "attachment";
export const handler = async (request, response, next) => {
const printName = request.params.printName;
const printConfig = getPdfPrintConfig(printName);
@ -15,7 +17,7 @@ export const handler = async (request, response, next) => {
const reportData = getReportData(printConfig, request.query);
const reportPath = path.join("views", "print", "pdf", printName + ".ejs");
const pdfCallbackFunction = (pdf) => {
response.setHeader("Content-Disposition", "attachment;" + " filename=" + camelcase(printConfig.title) + ".pdf");
response.setHeader("Content-Disposition", attachmentOrInline + ";" + " filename=" + camelcase(printConfig.title) + ".pdf");
response.setHeader("Content-Type", "application/pdf");
response.send(pdf);
};
@ -35,6 +37,7 @@ export const handler = async (request, response, next) => {
};
reportData.configFunctions = configFunctions;
reportData.dateTimeFunctions = dateTimeFunctions;
reportData.lotOccupancyFunctions = lotOccupancyFunctions;
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
};
export default handler;

View File

@ -5,12 +5,15 @@ import * as ejs from "ejs";
import * as configFunctions from "../../helpers/functions.config.js";
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
import * as lotOccupancyFunctions from "../../helpers/functions.lotOccupancy.js";
import { getReportData, getPdfPrintConfig } from "../../helpers/functions.print.js";
import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";
import camelcase from "camelcase";
const attachmentOrInline: "attachment" | "inline" = "attachment";
export const handler: RequestHandler = async (request, response, next) => {
const printName = request.params.printName;
@ -30,7 +33,7 @@ export const handler: RequestHandler = async (request, response, next) => {
const pdfCallbackFunction = (pdf: Buffer) => {
response.setHeader(
"Content-Disposition",
"attachment;" + " filename=" + camelcase(printConfig.title) + ".pdf"
attachmentOrInline + ";" + " filename=" + camelcase(printConfig.title) + ".pdf"
);
response.setHeader("Content-Type", "application/pdf");
@ -63,6 +66,7 @@ export const handler: RequestHandler = async (request, response, next) => {
reportData.configFunctions = configFunctions;
reportData.dateTimeFunctions = dateTimeFunctions;
reportData.lotOccupancyFunctions = lotOccupancyFunctions;
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
};

View File

@ -0,0 +1,3 @@
import type * as recordTypes from "../types/recordTypes";
export declare const filterOccupantsByLotOccupantType: (lotOccupancy: recordTypes.LotOccupancy, lotOccupantType: string) => recordTypes.LotOccupancyOccupant[];
export declare const getFieldValueByOccupancyTypeField: (lotOccupancy: recordTypes.LotOccupancy, occupancyTypeField: string) => string;

View File

@ -0,0 +1,17 @@
export const filterOccupantsByLotOccupantType = (lotOccupancy, lotOccupantType) => {
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
const occupants = lotOccupancy.lotOccupancyOccupants.filter((possibleOccupant) => {
return possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
});
return occupants;
};
export const getFieldValueByOccupancyTypeField = (lotOccupancy, occupancyTypeField) => {
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
const field = lotOccupancy.lotOccupancyFields.find((possibleField) => {
return possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase;
});
if (field) {
return field.lotOccupancyFieldValue;
}
return undefined;
};

View File

@ -0,0 +1,31 @@
import type * as recordTypes from "../types/recordTypes";
export const filterOccupantsByLotOccupantType = (
lotOccupancy: recordTypes.LotOccupancy,
lotOccupantType: string
): recordTypes.LotOccupancyOccupant[] => {
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
const occupants = lotOccupancy.lotOccupancyOccupants.filter((possibleOccupant) => {
return possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
});
return occupants;
};
export const getFieldValueByOccupancyTypeField = (
lotOccupancy: recordTypes.LotOccupancy,
occupancyTypeField: string
): string => {
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
const field = lotOccupancy.lotOccupancyFields.find((possibleField) => {
return possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase;
});
if (field) {
return field.lotOccupancyFieldValue;
}
return undefined;
};

View File

@ -68,13 +68,17 @@ const initializeCemeteryDatabase = () => {
orderNumber: 1
}, session);
addLotOccupantType({
lotOccupantType: "Preneed Owner",
lotOccupantType: "Funeral Director",
orderNumber: 2
}, session);
addLotOccupantType({
lotOccupantType: "Purchaser",
lotOccupantType: "Preneed Owner",
orderNumber: 3
}, session);
addLotOccupantType({
lotOccupantType: "Purchaser",
orderNumber: 4
}, session);
addOccupancyType({
occupancyType: "Preneed",
orderNumber: 1

View File

@ -143,7 +143,7 @@ const initializeCemeteryDatabase = () => {
addLotOccupantType(
{
lotOccupantType: "Preneed Owner",
lotOccupantType: "Funeral Director",
orderNumber: 2
},
session
@ -151,12 +151,20 @@ const initializeCemeteryDatabase = () => {
addLotOccupantType(
{
lotOccupantType: "Purchaser",
lotOccupantType: "Preneed Owner",
orderNumber: 3
},
session
);
addLotOccupantType(
{
lotOccupantType: "Purchaser",
orderNumber: 4
},
session
);
/*
* Occupancy Types
*/

View File

@ -17,7 +17,8 @@ export const getLotOccupancy = (lotOccupancyId) => {
" o.lotId, l.lotName, l.lotTypeId," +
" l.mapId, m.mapName," +
" o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString," +
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString" +
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString," +
" o.recordUpdate_timeMillis" +
" from LotOccupancies o" +
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
" left join Lots l on o.lotId = l.lotId" +

View File

@ -32,7 +32,8 @@ export const getLotOccupancy = (
" o.lotId, l.lotName, l.lotTypeId," +
" l.mapId, m.mapName," +
" o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString," +
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString" +
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString," +
" o.recordUpdate_timeMillis" +
" from LotOccupancies o" +
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
" left join Lots l on o.lotId = l.lotId" +

View File

@ -1,10 +1,79 @@
<%
const funeralDirectorLotOccupantType = "Funeral Director";
const funeralDirectorOccupants = lotOccupancyFunctions.filterOccupantsByLotOccupantType(lotOccupancy, funeralDirectorLotOccupantType);
const deceasedLotOccupantType = "Deceased";
const deceasedOccupants = lotOccupancyFunctions.filterOccupantsByLotOccupantType(lotOccupancy, deceasedLotOccupantType);
const deathDateOccupantTypeField = "Death Date";
%>
<html>
<head>
<style>
<%- include('style.css'); %>
</style>
</head>
<body>
<h1>Burial Permit</h1>
<body style="margin:100px 80px">
<p class="mb-2 has-text-centered is-capitalized">Province of Ontario</p>
<p class="has-text-centered is-italic">Vital Statistics Act</p>
<h1 class="has-text-centered is-capitalized mt-4 mb-4">Burial Permit</h1>
<p>
Under the <span class="is-italic">Vital Statistics Act</span>
and the regulations,
subject to the limitations thereof,
this permit is granted to:<br />
</p>
<p class="has-text-centered">
<% if (funeralDirectorOccupants.length > 0) { %>
<% const funeralDirector = funeralDirectorOccupants[0]; %>
<strong><%= funeralDirector.occupantName %></strong><br />
<%= funeralDirector.occupantAddress1 %><br />
<% if (funeralDirector.occupantAddress2) { %><%= funeralDirector.occupantAddress2 %><br /><% } %>
<%= funeralDirector.occupantCity %>, <%= funeralDirector.occupantProvince %><br />
<%= funeralDirector.occupantPostalCode %>
<% } %>
</p>
<p class="mt-4">
for the purpose of the burial or other disposition of the body of:
</p>
<p class="has-text-centered">
<% if (deceasedOccupants.length > 0) { %>
<% const deceased = deceasedOccupants[0]; %>
<strong><%= deceased.occupantName %></strong>
<% } %>
</p>
<p>
who died at
<span class="field has-text-centered" style="width:300px">&nbsp;</span>
in Ontario on
<span class="field has-text-centered" style="width:150px">
<%= lotOccupancyFunctions.getFieldValueByOccupancyTypeField(lotOccupancy, deathDateOccupantTypeField); %>
</span>
.
</p>
<p class="has-text-right mt-6">
<span class="field mb-1" style="width:300px">&nbsp;</span><br />
<span class="is-8pt">(Signature of Division Registrar)</span>
</p>
<p class="has-text-right">
Sault Ste. Marie
&nbsp;
&nbsp;
&nbsp;
5724
</p>
<p class="has-text-right">
<span class="field" style="width:150px">
<%= dateTimeFunctions.dateToString(new Date(lotOccupancy.recordUpdate_timeMillis)) %>
</span>
</p>
</body>
</html>

View File

@ -29,6 +29,13 @@ body {
content: '\2714';
}
.field {
border-bottom: 1px solid black;
display: inline-block;
width: 100%;
padding: 10px 0;
}
/* Data Table */
.data-table {
@ -78,10 +85,30 @@ td.is-width-1 {
margin-top: 10px;
}
.mt-4 {
margin-top: 40px;
}
.mt-6 {
margin-top: 60px;
}
.mb-0 {
margin-bottom: 0;
}
.mb-1 {
margin-bottom: 10px;
}
.mb-2 {
margin-bottom: 20px;
}
.mb-4 {
margin-bottom: 40px;
}
.pl-1 {
padding-left: 10px;
}
@ -96,7 +123,15 @@ td.is-width-1 {
text-align: right;
}
.has-text-italicized {
.has-text-centered {
text-align: center;
}
.is-capitalized {
text-transform: uppercase;
}
.is-italic {
font-style: italic;
}

View File

@ -72,7 +72,7 @@
<% } %>
<p class="has-text-right has-text-italicized is-8pt" style="position:absolute;bottom:10px;right:10px">
<p class="has-text-right is-italic is-8pt" style="position:absolute;bottom:10px;right:10px">
<%
const recordCreateDate = new Date(workOrder.recordCreate_timeMillis);
const currentDate = new Date();

View File

@ -143,7 +143,7 @@
<h2 class="mb-0">Notes</h2>
<p class="has-text-right has-text-italicized is-8pt" style="position:absolute;bottom:10px;right:10px">
<p class="has-text-right is-italic is-8pt" style="position:absolute;bottom:10px;right:10px">
<%
const recordCreateDate = new Date(workOrder.recordCreate_timeMillis);
const currentDate = new Date();