cityssm/parking-ticket-system

View on GitHub
database/parkingDB/canParkingTicketBeAddedToConvictionBatch.js

Summary

Maintainability
A
0 mins
Test Coverage
F
20%
import sqlite from 'better-sqlite3';
import { parkingDB as databasePath } from '../../data/databasePaths.js';
export default function canParkingTicketBeAddedToConvictionBatch(ticketId, connectedDatabase) {
    const database = connectedDatabase ?? sqlite(databasePath);
    const resolvedDate = database
        .prepare(`select resolvedDate from ParkingTickets
        where ticketId = ?
        and recordDelete_timeMillis is null`)
        .pluck()
        .get(ticketId);
    if (connectedDatabase === undefined) {
        database.close();
    }
    return (resolvedDate ?? undefined) === undefined;
}