Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Nov 7, 2023
1 parent 3ba1fe5 commit 389af59
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 140 deletions.
18 changes: 8 additions & 10 deletions database/parkingDB-reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,14 @@ export const getReportData = (reportName, requestQuery) => {
let sqlParameters = [];
switch (reportName) {
case 'lookupAudit': {
sql =
'select b.batchID,' +
' sentDate as batchSentDate,' +
' e.licencePlateCountry, e.licencePlateProvince, e.licencePlateNumber,' +
' e.ticketID as ticketID,' +
' t.ticketNumber as ticketNumber' +
' from LicencePlateLookupBatches b' +
' left join LicencePlateLookupBatchEntries e on b.batchID = e.batchID' +
' left join ParkingTickets t on e.ticketID = t.ticketID' +
' where b.sentDate is not null';
sql = `select b.batchID,
sentDate as batchSentDate,
e.licencePlateCountry, e.licencePlateProvince, e.licencePlateNumber,
e.ticketID as ticketID, t.ticketNumber as ticketNumber
from LicencePlateLookupBatches b
left join LicencePlateLookupBatchEntries e on b.batchID = e.batchID
left join ParkingTickets t on e.ticketID = t.ticketID
where b.sentDate is not null`;
if (requestQuery.batchID && requestQuery.batchID !== '') {
sql += ' and b.batchID = ?';
sqlParameters.push(requestQuery.batchID);
Expand Down
18 changes: 8 additions & 10 deletions database/parkingDB-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,14 @@ export const getReportData = (
// eslint-disable-next-line sonarjs/no-small-switch
switch (reportName) {
case 'lookupAudit': {
sql =
'select b.batchID,' +
' sentDate as batchSentDate,' +
' e.licencePlateCountry, e.licencePlateProvince, e.licencePlateNumber,' +
' e.ticketID as ticketID,' +
' t.ticketNumber as ticketNumber' +
' from LicencePlateLookupBatches b' +
' left join LicencePlateLookupBatchEntries e on b.batchID = e.batchID' +
' left join ParkingTickets t on e.ticketID = t.ticketID' +
' where b.sentDate is not null'
sql = `select b.batchID,
sentDate as batchSentDate,
e.licencePlateCountry, e.licencePlateProvince, e.licencePlateNumber,
e.ticketID as ticketID, t.ticketNumber as ticketNumber
from LicencePlateLookupBatches b
left join LicencePlateLookupBatchEntries e on b.batchID = e.batchID
left join ParkingTickets t on e.ticketID = t.ticketID
where b.sentDate is not null`

if (requestQuery.batchID && requestQuery.batchID !== '') {
sql += ' and b.batchID = ?'
Expand Down
19 changes: 6 additions & 13 deletions helpers/functions.owner.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
export const getFormattedOwnerAddress = (owner) => {
const fieldPrefix = 'ownerName1' in owner ? '' : 'owner_';
return (owner[fieldPrefix + 'ownerName1'] +
'\n' +
(owner[fieldPrefix + 'ownerName2'] &&
owner[fieldPrefix + 'ownerName2'] !== ''
? owner[fieldPrefix + 'ownerName2'] + '\n'
: '') +
owner[fieldPrefix + 'ownerAddress'] +
'\n' +
owner[fieldPrefix + 'ownerCity'] +
', ' +
owner[fieldPrefix + 'ownerProvince'] +
' ' +
owner[fieldPrefix + 'ownerPostalCode']);
return `${owner[fieldPrefix + 'ownerName1']}\n
${owner[fieldPrefix + 'ownerName2'] &&
owner[fieldPrefix + 'ownerName2'] !== ''
? owner[fieldPrefix + 'ownerName2'] + '\n'
: ''}${owner[fieldPrefix + 'ownerAddress']}\n
${owner[fieldPrefix + 'ownerCity']}, ${owner[fieldPrefix + 'ownerProvince']} ${owner[fieldPrefix + 'ownerPostalCode']}`;
};
25 changes: 10 additions & 15 deletions helpers/functions.owner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ export const getFormattedOwnerAddress = (
): string => {
const fieldPrefix = 'ownerName1' in owner ? '' : 'owner_'

return (
(owner[fieldPrefix + 'ownerName1'] as string) +
'\n' +
(owner[fieldPrefix + 'ownerName2'] &&
owner[fieldPrefix + 'ownerName2'] !== ''
? (owner[fieldPrefix + 'ownerName2'] as string) + '\n'
: '') +
(owner[fieldPrefix + 'ownerAddress'] as string) +
'\n' +
(owner[fieldPrefix + 'ownerCity'] as string) +
', ' +
(owner[fieldPrefix + 'ownerProvince'] as string) +
' ' +
(owner[fieldPrefix + 'ownerPostalCode'] as string)
)
return `${owner[fieldPrefix + 'ownerName1'] as string}\n
${
owner[fieldPrefix + 'ownerName2'] &&
owner[fieldPrefix + 'ownerName2'] !== ''
? (owner[fieldPrefix + 'ownerName2'] as string) + '\n'
: ''
}${owner[fieldPrefix + 'ownerAddress'] as string}\n
${owner[fieldPrefix + 'ownerCity'] as string}, ${
owner[fieldPrefix + 'ownerProvince'] as string
} ${owner[fieldPrefix + 'ownerPostalCode'] as string}`
}
144 changes: 72 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 389af59

Please sign in to comment.