fix missing quantity calculation

deepsource-autofix-76c6eb20
Dan Gowans 2023-02-27 14:30:23 -05:00
parent 37984ed2f3
commit 5eb925c2cd
1 changed files with 168 additions and 161 deletions

View File

@ -32,42 +32,42 @@
<%- include('style.css'); %> <%- include('style.css'); %>
body { body {
margin: 0 50px; margin: 0 50px;
} }
@page { @page {
margin: 50px 0; margin: 50px 0;
} }
.termsList { .termsList {
counter-reset: list; counter-reset: list;
} }
.termsList > li { .termsList > li {
list-style: none; list-style: none;
position: relative; position: relative;
padding-bottom: 10px; padding-bottom: 10px;
} }
.termsList > li::before { .termsList > li::before {
content: "(" counter(list, lower-alpha) ")"; content: "(" counter(list, lower-alpha) ")";
counter-increment: list; counter-increment: list;
position: absolute; position: absolute;
left: -1.8em; left: -1.8em;
} }
.confirmList > li { .confirmList > li {
list-style: none; list-style: none;
position: relative; position: relative;
padding-bottom: 10px; padding-bottom: 10px;
} }
.confirmList > li::before { .confirmList > li::before {
content: "▢"; content: "▢";
position: absolute; position: absolute;
left: -1.4em; left: -1.4em;
top: -0.2em; top: -0.2em;
font-size: 15pt; font-size: 15pt;
} }
</style> </style>
</head> </head>
@ -79,7 +79,7 @@
<p class="has-text-centered"> <p class="has-text-centered">
in in
<span class="field" style="width:300px"> <span class="field" style="width:300px">
<%= lotOccupancy.mapName %> <%= lotOccupancy.mapName %>
</span> </span>
cemetery<br /> cemetery<br />
<span class="is-capitalized">operated by</span><br /> <span class="is-capitalized">operated by</span><br />
@ -103,80 +103,80 @@
</p> </p>
<table class="layout-table is-10pt" style="table-layout:fixed"> <table class="layout-table is-10pt" style="table-layout:fixed">
<tbody> <tbody>
<tr> <tr>
<td> <td>
<h2 class="is-10pt">Purchaser</h2> <h2 class="is-10pt">Purchaser</h2>
<table class="is-10pt layout-table">
<tbody>
<tr>
<th class="has-text-left">Name:</th>
<td class="has-border-bottom">
<%= purchaser ? purchaser.occupantName + ' ' + purchaser.occupantFamilyName : "" %>
</td>
</tr><tr>
<th class="has-text-left" rowspan="2" style="vertical-align:top">Address:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantAddress1 : "" %>&nbsp;</td>
</tr><tr>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantAddress2 : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">City:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantCity : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Province:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantProvince : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left has-text-nowrap">Postal Code:</th>
<td class="has-border-bottom" style="width:100%"><%= purchaser ? purchaser.occupantPostalCode : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Telephone:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantPhoneNumber : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">E-mail:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantEmailAddress : "" %>&nbsp;</td>
</tr>
</tbody>
</table>
</td>
<td>
<h2 class="is-10pt">Recipient</h2>
<table class="is-10pt layout-table"> <table class="is-10pt layout-table">
<tbody> <tbody>
<tr> <tr>
<th class="has-text-left">Name:</th> <th class="has-text-left">Name:</th>
<td class="has-border-bottom"> <td class="has-border-bottom">
<%= purchaser ? purchaser.occupantName + ' ' + purchaser.occupantFamilyName : "" %> <%= recipient ? recipient.occupantName + ' ' + recipient.occupantFamilyName : "" %>
</td> </td>
</tr><tr> </tr><tr>
<th class="has-text-left" rowspan="2" style="vertical-align:top">Address:</th> <th class="has-text-left" rowspan="2" style="vertical-align:top">Address:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantAddress1 : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantAddress1 : "" %>&nbsp;</td>
</tr><tr> </tr><tr>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantAddress2 : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantAddress2 : "" %>&nbsp;</td>
</tr><tr> </tr><tr>
<th class="has-text-left">City:</th> <th class="has-text-left">City:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantCity : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantCity : "" %>&nbsp;</td>
</tr><tr> </tr><tr>
<th class="has-text-left">Province:</th> <th class="has-text-left">Province:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantProvince : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantProvince : "" %>&nbsp;</td>
</tr><tr> </tr><tr>
<th class="has-text-left has-text-nowrap">Postal Code:</th> <th class="has-text-left">Postal Code:</th>
<td class="has-border-bottom" style="width:100%"><%= purchaser ? purchaser.occupantPostalCode : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantPostalCode : "" %>&nbsp;</td>
</tr><tr> </tr><tr>
<th class="has-text-left">Telephone:</th> <th class="has-text-left">Telephone:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantPhoneNumber : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantPhoneNumber : "" %>&nbsp;</td>
</tr><tr> </tr><tr>
<th class="has-text-left">E-mail:</th> <th class="has-text-left">E-mail:</th>
<td class="has-border-bottom"><%= purchaser ? purchaser.occupantEmailAddress : "" %>&nbsp;</td> <td class="has-border-bottom"><%= recipient ? recipient.occupantEmailAddress : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Date of birth:</th>
<td class="has-border-bottom">&nbsp;</td>
</tr><tr>
<th class="has-text-left has-text-nowrap">Place of birth:</th>
<td class="has-border-bottom" style="width:100%">&nbsp;</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</td> </td>
<td> </tr>
<h2 class="is-10pt">Recipient</h2>
<table class="is-10pt layout-table">
<tbody>
<tr>
<th class="has-text-left">Name:</th>
<td class="has-border-bottom">
<%= recipient ? recipient.occupantName + ' ' + recipient.occupantFamilyName : "" %>
</td>
</tr><tr>
<th class="has-text-left" rowspan="2" style="vertical-align:top">Address:</th>
<td class="has-border-bottom"><%= recipient ? recipient.occupantAddress1 : "" %>&nbsp;</td>
</tr><tr>
<td class="has-border-bottom"><%= recipient ? recipient.occupantAddress2 : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">City:</th>
<td class="has-border-bottom"><%= recipient ? recipient.occupantCity : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Province:</th>
<td class="has-border-bottom"><%= recipient ? recipient.occupantProvince : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Postal Code:</th>
<td class="has-border-bottom"><%= recipient ? recipient.occupantPostalCode : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Telephone:</th>
<td class="has-border-bottom"><%= recipient ? recipient.occupantPhoneNumber : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">E-mail:</th>
<td class="has-border-bottom"><%= recipient ? recipient.occupantEmailAddress : "" %>&nbsp;</td>
</tr><tr>
<th class="has-text-left">Date of birth:</th>
<td class="has-border-bottom">&nbsp;</td>
</tr><tr>
<th class="has-text-left has-text-nowrap">Place of birth:</th>
<td class="has-border-bottom" style="width:100%">&nbsp;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody> </tbody>
</table> </table>
<p> <p>
@ -206,81 +206,88 @@
<h2 class="is-10pt is-capitalized">Details</h2> <h2 class="is-10pt is-capitalized">Details</h2>
<table class="is-10pt data-table"> <table class="is-10pt data-table">
<tr> <tr>
<td><%= configFunctions.getProperty("aliases.map") %></td> <td><%= configFunctions.getProperty("aliases.map") %></td>
<td><%= lotOccupancy.mapName %></td> <td><%= lotOccupancy.mapName ?? '(No ' + configFunctions.getProperty("aliases.map") + ')' %></td>
</tr> </tr>
<tr> <tr>
<td><%= configFunctions.getProperty("aliases.lot") %></td> <td><%= configFunctions.getProperty("aliases.lot") %></td>
<td><%= lotOccupancy.lotName %></td> <td><%= lotOccupancy.lotName ?? '(No ' + configFunctions.getProperty("aliases.lot") + ')' %></td>
</tr> </tr>
<% <%
for (const field of lotOccupancy.lotOccupancyFields) { for (const field of lotOccupancy.lotOccupancyFields) {
if (field.lotOccupancyFieldValue) { if (field.lotOccupancyFieldValue) {
%> %>
<tr> <tr>
<td><%= field.occupancyTypeField %></td> <td><%= field.occupancyTypeField %></td>
<td><%= field.lotOccupancyFieldValue %></td> <td><%= field.lotOccupancyFieldValue %></td>
</tr> </tr>
<% <%
}
} }
}
%> %>
</table> </table>
</td> </td>
<td> <td>
<h2 class="is-10pt is-capitalized">Interment Rights and Services</h2> <h2 class="is-10pt is-capitalized">Interment Rights and Services</h2>
<table class="is-10pt data-table"> <table class="is-10pt data-table">
<tbody> <tbody>
<% <%
let currentFeeCategory = ""; let currentFeeCategory = "";
let feeAmountTotal = 0; let feeAmountTotal = 0;
let taxAmountTotal = 0; let taxAmountTotal = 0;
%> %>
<% for (const fee of lotOccupancy.lotOccupancyFees) { %> <% for (const fee of lotOccupancy.lotOccupancyFees) { %>
<% if (currentFeeCategory !== fee.feeCategory) { %> <% if (currentFeeCategory !== fee.feeCategory) { %>
<tr>
<td colspan="2">
<strong><%= fee.feeCategory %></strong>
</td>
</tr>
<% currentFeeCategory = fee.feeCategory; %>
<% } %>
<tr> <tr>
<td> <td colspan="3">
<%= fee.feeName %> <strong><%= fee.feeCategory %></strong>
</td> </td>
<td class="has-text-right">
$<%= fee.feeAmount.toFixed(2) %>
</td>
</tr> </tr>
<% <% currentFeeCategory = fee.feeCategory; %>
feeAmountTotal += fee.feeAmount; <% } %>
taxAmountTotal += fee.taxAmount; <tr>
%> <td <% if (fee.quantity === 1) { %>colspan="2"<% } %>>
<% } %> <%= fee.feeName %>
<tr>
<td><strong>Sub Total</strong></td>
<td class="has-text-right">
<strong>$<%= feeAmountTotal.toFixed(2) %></strong>
</td> </td>
</tr><tr> <% if (fee.quantity !== 1) { %>
<td>HST</td> <td class="has-text-right is-8pt has-text-nowrap">
$<%= fee.feeAmount.toFixed(2) %>
&times;
<%= fee.quantity %>
</td>
<% } %>
<td class="has-text-right"> <td class="has-text-right">
$<%= taxAmountTotal.toFixed(2) %> $<%= fee.feeAmount.toFixed(2) %>
</td> </td>
</tr><tr> </tr>
<td><strong>Total Sale</strong></td> <%
<td class="has-text-right"> feeAmountTotal += fee.feeAmount * fee.quantity;
<strong>$<%= (feeAmountTotal + taxAmountTotal).toFixed(2) %></strong> taxAmountTotal += fee.taxAmount * fee.quantity;
</td> %>
</tr><tr> <% } %>
<td><strong>Balance Owing</strong></td> <tr>
<td class="has-text-right"> <td colspan="2"><strong>Sub Total</strong></td>
<strong>$<%= (feeAmountTotal + taxAmountTotal - lotOccupancyFunctions.getTransactionTotal(lotOccupancy)).toFixed(2) %></strong> <td class="has-text-right">
</td> <strong>$<%= feeAmountTotal.toFixed(2) %></strong>
</tr> </td>
</tfoot> </tr><tr>
</table> <td colspan="2">HST</td>
<td class="has-text-right">
$<%= taxAmountTotal.toFixed(2) %>
</td>
</tr><tr>
<td colspan="2"><strong>Total Sale</strong></td>
<td class="has-text-right">
<strong>$<%= (feeAmountTotal + taxAmountTotal).toFixed(2) %></strong>
</td>
</tr><tr>
<td colspan="2"><strong>Balance Owing</strong></td>
<td class="has-text-right">
<strong>$<%= (feeAmountTotal + taxAmountTotal - lotOccupancyFunctions.getTransactionTotal(lotOccupancy)).toFixed(2) %></strong>
</td>
</tr>
</tbody>
</table>
</td> </td>
</tr> </tr>
</table> </table>
@ -288,36 +295,36 @@
<!-- PAGE BREAK --> <!-- PAGE BREAK -->
<h2 class="is-10pt" style="page-break-before:always"> <h2 class="is-10pt" style="page-break-before:always">
Contribution Levels to the Care and Maintenance Fund<br /> Contribution Levels to the Care and Maintenance Fund<br />
(based on the price of Interment Rights and as prescribed by the <em>Funeral, Burial and Cremation Services Act</em>) (based on the price of Interment Rights and as prescribed by the <em>Funeral, Burial and Cremation Services Act</em>)
</h2> </h2>
<table class="layout-table is-10pt"> <table class="layout-table is-10pt">
<tr> <tr>
<td>Niches</td> <td>Niches</td>
<td>the greater of 15% and $100</td> <td>the greater of 15% and $100</td>
</tr> </tr>
<tr> <tr>
<td>Crypts</td> <td>Crypts</td>
<td>the greater of 20% and $500</td> <td>the greater of 20% and $500</td>
</tr> </tr>
<tr> <tr>
<td> <td>
In-ground grave (2.23 sq.m. or 24 sq.ft. or larger) In-ground grave (2.23 sq.m. or 24 sq.ft. or larger)
</td> </td>
<td> <td>
the greater of 40% and $250 the greater of 40% and $250
</td> </td>
</tr> </tr>
<tr> <tr>
<td>In-ground grave (smaller than 2.23 sq.m. or 24 sq ft)</td> <td>In-ground grave (smaller than 2.23 sq.m. or 24 sq ft)</td>
<td>the greater of 40% and $150</td> <td>the greater of 40% and $150</td>
</tr> </tr>
</table> </table>
<h2 class="is-10pt"> <h2 class="is-10pt">
Contribution Levels to the Care and Maintenance Fund - Markers<br /> Contribution Levels to the Care and Maintenance Fund - Markers<br />
(as prescribed by the <em>Funeral, Burial and Cremation Services Act</em>) (as prescribed by the <em>Funeral, Burial and Cremation Services Act</em>)
</h2> </h2>
<table class="layout-table is-10pt"> <table class="layout-table is-10pt">