pull/11/head
Dan Gowans 2025-04-30 15:14:56 -04:00
parent a7ce5a99cb
commit c460d073e7
37 changed files with 250 additions and 222 deletions

View File

@ -14,7 +14,9 @@ export default function addBurialSiteTypeField(addForm, user) {
recordCreate_userName, recordCreate_timeMillis, recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis) recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
.run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); .run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
database.close(); database.close();
clearCacheByTableName('BurialSiteTypeFields'); clearCacheByTableName('BurialSiteTypeFields');
return result.lastInsertRowid; return result.lastInsertRowid;

View File

@ -47,6 +47,7 @@ export default function addBurialSiteTypeField(
addForm.isRequired === '' ? 0 : 1, addForm.isRequired === '' ? 0 : 1,
addForm.pattern ?? '', addForm.pattern ?? '',
addForm.minLength ?? 0, addForm.minLength ?? 0,
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
addForm.maxLength ?? 100, addForm.maxLength ?? 100,
addForm.orderNumber ?? -1, addForm.orderNumber ?? -1,
user.userName, user.userName,

View File

@ -1,7 +1,8 @@
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
export interface AddTransactionForm { export interface AddTransactionForm {
contractId: number | string; contractId: number | string;
transactionDateString?: string; transactionDateString?: '' | DateString;
transactionTimeString?: string; transactionTimeString?: '' | TimeString;
externalReceiptNumber: string; externalReceiptNumber: string;
transactionAmount: number | string; transactionAmount: number | string;
transactionNote: string; transactionNote: string;

View File

@ -15,12 +15,12 @@ export default function addContractTransaction(contractTransactionForm, user) {
transactionIndex = maxIndexResult.transactionIndex + 1; transactionIndex = maxIndexResult.transactionIndex + 1;
} }
const rightNow = new Date(); const rightNow = new Date();
const transactionDate = contractTransactionForm.transactionDateString const transactionDate = contractTransactionForm.transactionDateString === ''
? dateStringToInteger(contractTransactionForm.transactionDateString) ? dateToInteger(rightNow)
: dateToInteger(rightNow); : dateStringToInteger(contractTransactionForm.transactionDateString);
const transactionTime = contractTransactionForm.transactionTimeString const transactionTime = contractTransactionForm.transactionTimeString === ''
? timeStringToInteger(contractTransactionForm.transactionTimeString) ? dateToTimeInteger(rightNow)
: dateToTimeInteger(rightNow); : timeStringToInteger(contractTransactionForm.transactionTimeString);
database database
.prepare(`insert into ContractTransactions ( .prepare(`insert into ContractTransactions (
contractId, transactionIndex, contractId, transactionIndex,

View File

@ -1,4 +1,6 @@
import { import {
type DateString,
type TimeString,
dateStringToInteger, dateStringToInteger,
dateToInteger, dateToInteger,
dateToTimeInteger, dateToTimeInteger,
@ -11,8 +13,8 @@ import { sunriseDB } from '../helpers/database.helpers.js'
export interface AddTransactionForm { export interface AddTransactionForm {
contractId: number | string contractId: number | string
transactionDateString?: string transactionDateString?: '' | DateString
transactionTimeString?: string transactionTimeString?: '' | TimeString
externalReceiptNumber: string externalReceiptNumber: string
transactionAmount: number | string transactionAmount: number | string
@ -45,13 +47,19 @@ export default function addContractTransaction(
const rightNow = new Date() const rightNow = new Date()
const transactionDate = contractTransactionForm.transactionDateString const transactionDate =
? dateStringToInteger(contractTransactionForm.transactionDateString) contractTransactionForm.transactionDateString === ''
: dateToInteger(rightNow) ? dateToInteger(rightNow)
: dateStringToInteger(
contractTransactionForm.transactionDateString as DateString
)
const transactionTime = contractTransactionForm.transactionTimeString const transactionTime =
? timeStringToInteger(contractTransactionForm.transactionTimeString) contractTransactionForm.transactionTimeString === ''
: dateToTimeInteger(rightNow) ? dateToTimeInteger(rightNow)
: timeStringToInteger(
contractTransactionForm.transactionTimeString as TimeString
)
database database
.prepare( .prepare(

View File

@ -1,8 +1,8 @@
export interface AddContractTypeFieldForm { export interface AddContractTypeFieldForm {
contractTypeId?: number | string; contractTypeId?: number | string;
contractTypeField: string; contractTypeField: string;
fieldValues?: string;
fieldType?: string; fieldType?: string;
fieldValues?: string;
isRequired?: string; isRequired?: string;
maxLength?: number | string; maxLength?: number | string;
minLength?: number | string; minLength?: number | string;

View File

@ -13,7 +13,9 @@ export default function addContractTypeField(addForm, user) {
recordCreate_userName, recordCreate_timeMillis, recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis) recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
.run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); .run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
database.close(); database.close();
clearCacheByTableName('ContractTypeFields'); clearCacheByTableName('ContractTypeFields');
return result.lastInsertRowid; return result.lastInsertRowid;

View File

@ -5,9 +5,11 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
export interface AddContractTypeFieldForm { export interface AddContractTypeFieldForm {
contractTypeId?: number | string contractTypeId?: number | string
contractTypeField: string contractTypeField: string
fieldValues?: string
fieldType?: string fieldType?: string
fieldValues?: string
isRequired?: string isRequired?: string
maxLength?: number | string maxLength?: number | string
minLength?: number | string minLength?: number | string
@ -43,6 +45,7 @@ export default function addContractTypeField(
addForm.isRequired === '' ? 0 : 1, addForm.isRequired === '' ? 0 : 1,
addForm.pattern ?? '', addForm.pattern ?? '',
addForm.minLength ?? 0, addForm.minLength ?? 0,
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
addForm.maxLength ?? 100, addForm.maxLength ?? 100,
addForm.orderNumber ?? -1, addForm.orderNumber ?? -1,
user.userName, user.userName,

View File

@ -6,6 +6,7 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
export interface AddContractTypePrintForm { export interface AddContractTypePrintForm {
contractTypeId: number | string contractTypeId: number | string
printEJS: string printEJS: string
orderNumber?: number orderNumber?: number
} }

View File

@ -1,6 +1,6 @@
export interface AddForm { export interface AddForm {
funeralHomeName: string;
funeralHomeKey: string; funeralHomeKey: string;
funeralHomeName: string;
funeralHomeAddress1: string; funeralHomeAddress1: string;
funeralHomeAddress2: string; funeralHomeAddress2: string;
funeralHomeCity: string; funeralHomeCity: string;

View File

@ -3,8 +3,8 @@ import sqlite from 'better-sqlite3'
import { sunriseDB } from '../helpers/database.helpers.js' import { sunriseDB } from '../helpers/database.helpers.js'
export interface AddForm { export interface AddForm {
funeralHomeName: string
funeralHomeKey: string funeralHomeKey: string
funeralHomeName: string
funeralHomeAddress1: string funeralHomeAddress1: string
funeralHomeAddress2: string funeralHomeAddress2: string

View File

@ -1,9 +1,9 @@
export interface AddWorkOrderForm { export interface AddWorkOrderForm {
workOrderTypeId: number | string;
workOrderNumber?: string;
workOrderDescription: string; workOrderDescription: string;
workOrderOpenDateString?: string; workOrderNumber?: string;
workOrderTypeId: number | string;
workOrderCloseDateString?: string; workOrderCloseDateString?: string;
workOrderOpenDateString?: string;
contractId?: string; contractId?: string;
} }
export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): number; export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): number;

View File

@ -25,8 +25,8 @@ export default function addWorkOrder(workOrderForm, user) {
const workOrderId = result.lastInsertRowid; const workOrderId = result.lastInsertRowid;
if ((workOrderForm.contractId ?? '') !== '') { if ((workOrderForm.contractId ?? '') !== '') {
addWorkOrderContract({ addWorkOrderContract({
contractId: workOrderForm.contractId,
workOrderId, workOrderId,
contractId: workOrderForm.contractId
}, user, database); }, user, database);
} }
database.close(); database.close();

View File

@ -11,11 +11,14 @@ import addWorkOrderContract from './addWorkOrderContract.js'
import getNextWorkOrderNumber from './getNextWorkOrderNumber.js' import getNextWorkOrderNumber from './getNextWorkOrderNumber.js'
export interface AddWorkOrderForm { export interface AddWorkOrderForm {
workOrderTypeId: number | string
workOrderNumber?: string
workOrderDescription: string workOrderDescription: string
workOrderOpenDateString?: string workOrderNumber?: string
workOrderTypeId: number | string
workOrderCloseDateString?: string workOrderCloseDateString?: string
workOrderOpenDateString?: string
contractId?: string contractId?: string
} }
@ -67,8 +70,8 @@ export default function addWorkOrder(
if ((workOrderForm.contractId ?? '') !== '') { if ((workOrderForm.contractId ?? '') !== '') {
addWorkOrderContract( addWorkOrderContract(
{ {
contractId: workOrderForm.contractId as string,
workOrderId, workOrderId,
contractId: workOrderForm.contractId as string
}, },
user, user,
database database

View File

@ -1,5 +1,5 @@
export interface AddForm { export interface AddForm {
workOrderId: number | string;
burialSiteId: number | string; burialSiteId: number | string;
workOrderId: number | string;
} }
export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): boolean; export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): boolean;

View File

@ -3,8 +3,8 @@ import sqlite from 'better-sqlite3'
import { sunriseDB } from '../helpers/database.helpers.js' import { sunriseDB } from '../helpers/database.helpers.js'
export interface AddForm { export interface AddForm {
workOrderId: number | string
burialSiteId: number | string burialSiteId: number | string
workOrderId: number | string
} }
export default function addWorkOrderBurialSite( export default function addWorkOrderBurialSite(

View File

@ -1,5 +1,5 @@
export interface AddWorkOrderCommentForm { export interface AddWorkOrderCommentForm {
workOrderId: string;
comment: string; comment: string;
workOrderId: string;
} }
export default function addWorkOrderComment(workOrderCommentForm: AddWorkOrderCommentForm, user: User): number; export default function addWorkOrderComment(workOrderCommentForm: AddWorkOrderCommentForm, user: User): number;

View File

@ -4,8 +4,8 @@ import sqlite from 'better-sqlite3'
import { sunriseDB } from '../helpers/database.helpers.js' import { sunriseDB } from '../helpers/database.helpers.js'
export interface AddWorkOrderCommentForm { export interface AddWorkOrderCommentForm {
workOrderId: string
comment: string comment: string
workOrderId: string
} }
export default function addWorkOrderComment( export default function addWorkOrderComment(

View File

@ -122,7 +122,7 @@ export default function cleanupDatabase(user) {
.run(recordDeleteTimeMillisMin).changes; .run(recordDeleteTimeMillisMin).changes;
/* /*
* Burial Site Contract Fees/Transactions * Burial Site Contract Fees/Transactions
* - Maintain financials, do not delete related. * - Maintain financial data, do not delete related.
*/ */
purgedRecordCount += database purgedRecordCount += database
.prepare('delete from ContractFees where recordDelete_timeMillis <= ?') .prepare('delete from ContractFees where recordDelete_timeMillis <= ?')

View File

@ -179,7 +179,7 @@ export default function cleanupDatabase(user: User): {
/* /*
* Burial Site Contract Fees/Transactions * Burial Site Contract Fees/Transactions
* - Maintain financials, do not delete related. * - Maintain financial data, do not delete related.
*/ */
purgedRecordCount += database purgedRecordCount += database

View File

@ -1,5 +1,6 @@
import { type DateString } from '@cityssm/utils-datetime';
export interface CloseWorkOrderForm { export interface CloseWorkOrderForm {
workOrderId: number | string; workOrderId: number | string;
workOrderCloseDateString?: string; workOrderCloseDateString?: '' | DateString;
} }
export default function closeWorkOrder(workOrderForm: CloseWorkOrderForm, user: User): boolean; export default function closeWorkOrder(workOrderForm: CloseWorkOrderForm, user: User): boolean;

View File

@ -1,4 +1,8 @@
import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime' import {
type DateString,
dateStringToInteger,
dateToInteger
} from '@cityssm/utils-datetime'
import sqlite from 'better-sqlite3' import sqlite from 'better-sqlite3'
import { sunriseDB } from '../helpers/database.helpers.js' import { sunriseDB } from '../helpers/database.helpers.js'
@ -6,7 +10,7 @@ import { sunriseDB } from '../helpers/database.helpers.js'
export interface CloseWorkOrderForm { export interface CloseWorkOrderForm {
workOrderId: number | string workOrderId: number | string
workOrderCloseDateString?: string workOrderCloseDateString?: '' | DateString
} }
export default function closeWorkOrder( export default function closeWorkOrder(

View File

@ -29,6 +29,7 @@ export default async function copyContract(
funeralDirectorName: oldContract.funeralDirectorName, funeralDirectorName: oldContract.funeralDirectorName,
funeralHomeId: oldContract.funeralHomeId ?? '', funeralHomeId: oldContract.funeralHomeId ?? '',
funeralTimeString: oldContract.funeralTimeString ?? '', funeralTimeString: oldContract.funeralTimeString ?? '',
purchaserAddress1: oldContract.purchaserAddress1, purchaserAddress1: oldContract.purchaserAddress1,
purchaserAddress2: oldContract.purchaserAddress2, purchaserAddress2: oldContract.purchaserAddress2,
purchaserCity: oldContract.purchaserCity, purchaserCity: oldContract.purchaserCity,

View File

@ -16,6 +16,6 @@ export interface GetBurialSitesOptions {
includeContractCount?: boolean; includeContractCount?: boolean;
} }
export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: sqlite.Database): { export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: sqlite.Database): {
count: number;
burialSites: BurialSite[]; burialSites: BurialSite[];
count: number;
}; };

View File

@ -4,7 +4,7 @@ import { sunriseDB } from '../helpers/database.helpers.js';
import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js'; import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js';
export default function getBurialSites(filters, options, connectedDatabase) { export default function getBurialSites(filters, options, connectedDatabase) {
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true }); const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters); const { sqlParameters, sqlWhereClause } = buildWhereClause(filters);
const currentDate = dateToInteger(new Date()); const currentDate = dateToInteger(new Date());
let count = 0; let count = 0;
if (options.limit !== -1) { if (options.limit !== -1) {
@ -71,8 +71,8 @@ export default function getBurialSites(filters, options, connectedDatabase) {
database.close(); database.close();
} }
return { return {
count, burialSites,
burialSites count
}; };
} }
function buildWhereClause(filters) { function buildWhereClause(filters) {

View File

@ -28,10 +28,10 @@ export default function getBurialSites(
filters: GetBurialSitesFilters, filters: GetBurialSitesFilters,
options: GetBurialSitesOptions, options: GetBurialSitesOptions,
connectedDatabase?: sqlite.Database connectedDatabase?: sqlite.Database
): { count: number; burialSites: BurialSite[] } { ): { burialSites: BurialSite[]; count: number } {
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true }) const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true })
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters) const { sqlParameters, sqlWhereClause } = buildWhereClause(filters)
const currentDate = dateToInteger(new Date()) const currentDate = dateToInteger(new Date())
@ -120,8 +120,8 @@ export default function getBurialSites(
} }
return { return {
count, burialSites,
burialSites count
} }
} }

View File

@ -603,8 +603,8 @@ async function importFromWorkOrderCSV() {
const workOrderContainsBurialSite = workOrder?.workOrderBurialSites?.find((possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId); const workOrderContainsBurialSite = workOrder?.workOrderBurialSites?.find((possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId);
if (!workOrderContainsBurialSite) { if (!workOrderContainsBurialSite) {
addWorkOrderBurialSite({ addWorkOrderBurialSite({
workOrderId: workOrder?.workOrderId, burialSiteId: burialSite?.burialSiteId,
burialSiteId: burialSite?.burialSiteId workOrderId: workOrder?.workOrderId
}, user); }, user);
workOrder?.workOrderBurialSites?.push(burialSite); workOrder?.workOrderBurialSites?.push(burialSite);
} }
@ -633,8 +633,8 @@ async function importFromWorkOrderCSV() {
const contractId = addContract({ const contractId = addContract({
burialSiteId: burialSite ? burialSite.burialSiteId : '', burialSiteId: burialSite ? burialSite.burialSiteId : '',
contractTypeId: contractType.contractTypeId, contractTypeId: contractType.contractTypeId,
contractStartDateString,
contractEndDateString: '', contractEndDateString: '',
contractStartDateString,
funeralHomeId, funeralHomeId,
funeralDirectorName: workOrderRow.WO_FUNERAL_HOME, funeralDirectorName: workOrderRow.WO_FUNERAL_HOME,
funeralDateString: workOrderRow.WO_FUNERAL_YR === '' funeralDateString: workOrderRow.WO_FUNERAL_YR === ''
@ -656,8 +656,8 @@ async function importFromWorkOrderCSV() {
intermentContainerTypeId intermentContainerTypeId
}, user); }, user);
addWorkOrderContract({ addWorkOrderContract({
workOrderId: workOrder?.workOrderId, contractId,
contractId workOrderId: workOrder?.workOrderId
}, user); }, user);
// Milestones // Milestones
let hasIncompleteMilestones = !workOrderRow.WO_CONFIRMATION_IN; let hasIncompleteMilestones = !workOrderRow.WO_CONFIRMATION_IN;

View File

@ -959,8 +959,8 @@ async function importFromWorkOrderCSV(): Promise<void> {
if (!workOrderContainsBurialSite) { if (!workOrderContainsBurialSite) {
addWorkOrderBurialSite( addWorkOrderBurialSite(
{ {
workOrderId: workOrder?.workOrderId as number, burialSiteId: burialSite?.burialSiteId as number,
burialSiteId: burialSite?.burialSiteId as number workOrderId: workOrder?.workOrderId as number
}, },
user user
) )
@ -1011,8 +1011,9 @@ async function importFromWorkOrderCSV(): Promise<void> {
{ {
burialSiteId: burialSite ? burialSite.burialSiteId : '', burialSiteId: burialSite ? burialSite.burialSiteId : '',
contractTypeId: contractType.contractTypeId, contractTypeId: contractType.contractTypeId,
contractStartDateString,
contractEndDateString: '', contractEndDateString: '',
contractStartDateString,
funeralHomeId, funeralHomeId,
funeralDirectorName: workOrderRow.WO_FUNERAL_HOME, funeralDirectorName: workOrderRow.WO_FUNERAL_HOME,
@ -1052,8 +1053,8 @@ async function importFromWorkOrderCSV(): Promise<void> {
addWorkOrderContract( addWorkOrderContract(
{ {
workOrderId: workOrder?.workOrderId as number, contractId,
contractId workOrderId: workOrder?.workOrderId as number
}, },
user user
) )