Skip to content

Commit

Permalink
issued and unissued reports
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 14, 2022
1 parent 0d5dd1a commit e594e45
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helpers/licencesDB/getReportData.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export const getReportData = (reportName, reportParameters) => {
sqlParameters = report.sqlParameters;
break;
case "licences-formatted":
let issuedFilter = "";
if (reportParameters.issued) {
issuedFilter = (reportParameters.issued === "true"
? " and l.issueDate is not null"
: " and l.issueDate is null");
}
sql = "select l.licenceId as " + licenceId + "," +
" c.licenceCategory as " + licenceCategory + "," +
" l.licenceNumber as " + licenceNumber + "," +
Expand All @@ -93,6 +99,7 @@ export const getReportData = (reportName, reportParameters) => {
" from Licences l" +
" left join LicenceCategories c on l.licenceCategoryKey = c.licenceCategoryKey" +
" where l.recordDelete_timeMillis is null" +
issuedFilter +
" order by startDate desc, endDate desc, licenceId";
break;
case "licenceAdditionalFees-all":
Expand Down
12 changes: 12 additions & 0 deletions helpers/licencesDB/getReportData.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-case-declarations */

import sqlite from "better-sqlite3";
import { licencesDB as databasePath } from "../../data/databasePaths.js";

Expand Down Expand Up @@ -117,6 +119,14 @@ export const getReportData = (reportName: string, reportParameters?: ReportParam

case "licences-formatted":

let issuedFilter = "";

if (reportParameters.issued) {
issuedFilter = (reportParameters.issued === "true"
? " and l.issueDate is not null"
: " and l.issueDate is null");
}

sql = "select l.licenceId as " + licenceId + "," +
" c.licenceCategory as " + licenceCategory + "," +
" l.licenceNumber as " + licenceNumber + "," +
Expand All @@ -133,7 +143,9 @@ export const getReportData = (reportName: string, reportParameters?: ReportParam
" from Licences l" +
" left join LicenceCategories c on l.licenceCategoryKey = c.licenceCategoryKey" +
" where l.recordDelete_timeMillis is null" +
issuedFilter +
" order by startDate desc, endDate desc, licenceId";

break;

case "licenceAdditionalFees-all":
Expand Down
22 changes: 22 additions & 0 deletions views/admin-yearEnd.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@
<div class="panel-block is-block">
<div class="columns">
<div class="column">
<div class="media">
<div class="media-left" aria-hidden="true">
<i class="fas fa-fw fa-3x fa-file-csv" aria-hidden="true"></i>
</div>
<div class="media-content">
<h3 class="title is-4 is-marginless">
<a href="<%- urlPrefix %>/reports/licences-formatted?issued=false">All Unissued <%= configFunctions.getProperty("settings.licenceAliasPlural") %></a>
</h3>
<p>After the refresh process, these licences will be deleted.</p>
</div>
</div>
<div class="media">
<div class="media-left" aria-hidden="true">
<i class="fas fa-fw fa-3x fa-file-csv" aria-hidden="true"></i>
</div>
<div class="media-content">
<h3 class="title is-4 is-marginless">
<a href="<%- urlPrefix %>/reports/licences-formatted?issued=true">All Issued <%= configFunctions.getProperty("settings.licenceAliasPlural") %></a>
</h3>
<p>After the refresh process, these licences will still exists, but will no longer be issued.</p>
</div>
</div>
</div>
<div class="column">
<div class="message is-warning">
Expand Down

0 comments on commit e594e45

Please sign in to comment.