clean up awaits
parent
09b3de1086
commit
d4670603b7
|
|
@ -50,7 +50,7 @@ async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connect
|
||||||
workOrder.workOrderContracts = workOrderContractsResults.contracts;
|
workOrder.workOrderContracts = workOrderContractsResults.contracts;
|
||||||
}
|
}
|
||||||
if (options.includeComments) {
|
if (options.includeComments) {
|
||||||
workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database);
|
workOrder.workOrderComments = getWorkOrderComments(workOrder.workOrderId, database);
|
||||||
}
|
}
|
||||||
if (options.includeMilestones) {
|
if (options.includeMilestones) {
|
||||||
workOrder.workOrderMilestones = await getWorkOrderMilestones({
|
workOrder.workOrderMilestones = await getWorkOrderMilestones({
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ async function _getWorkOrder(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.includeComments) {
|
if (options.includeComments) {
|
||||||
workOrder.workOrderComments = await getWorkOrderComments(
|
workOrder.workOrderComments = getWorkOrderComments(
|
||||||
workOrder.workOrderId,
|
workOrder.workOrderId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export declare function initializeDatabase(): Promise<boolean>;
|
export declare function initializeDatabase(): boolean;
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ const initializingUser = {
|
||||||
isAdmin: true
|
isAdmin: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export async function initializeDatabase() {
|
export function initializeDatabase() {
|
||||||
const sunriseDB = sqlite(databasePath);
|
const sunriseDB = sqlite(databasePath);
|
||||||
const row = sunriseDB
|
const row = sunriseDB
|
||||||
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'")
|
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'")
|
||||||
|
|
@ -400,83 +400,83 @@ export async function initializeDatabase() {
|
||||||
sunriseDB.prepare(sql).run();
|
sunriseDB.prepare(sql).run();
|
||||||
}
|
}
|
||||||
sunriseDB.close();
|
sunriseDB.close();
|
||||||
await initializeData();
|
initializeData();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
async function initializeData() {
|
function initializeData() {
|
||||||
debug('Initializing data...');
|
debug('Initializing data...');
|
||||||
await addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser);
|
addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser);
|
||||||
await addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser);
|
addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser);
|
||||||
await addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser);
|
addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser);
|
||||||
await addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser);
|
addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser);
|
||||||
await addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser);
|
addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser);
|
||||||
await addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser);
|
addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser);
|
||||||
await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser);
|
addRecord('BurialSiteStatuses', 'Available', 1, initializingUser);
|
||||||
await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser);
|
addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser);
|
||||||
await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser);
|
addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser);
|
||||||
// Contract Types
|
// Contract Types
|
||||||
await addContractType({
|
addContractType({
|
||||||
contractType: 'Preneed',
|
contractType: 'Preneed',
|
||||||
isPreneed: '1',
|
isPreneed: '1',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addContractType({
|
addContractType({
|
||||||
contractType: 'Interment',
|
contractType: 'Interment',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addContractType({
|
addContractType({
|
||||||
contractType: 'Cremation',
|
contractType: 'Cremation',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
// Interment Container Types
|
// Interment Container Types
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'No Shell',
|
intermentContainerType: 'No Shell',
|
||||||
intermentContainerTypeKey: 'NS',
|
intermentContainerTypeKey: 'NS',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'Concrete Liner',
|
intermentContainerType: 'Concrete Liner',
|
||||||
intermentContainerTypeKey: 'CL',
|
intermentContainerTypeKey: 'CL',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'Unpainted Vault',
|
intermentContainerType: 'Unpainted Vault',
|
||||||
intermentContainerTypeKey: 'UV',
|
intermentContainerTypeKey: 'UV',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'Concrete Vault',
|
intermentContainerType: 'Concrete Vault',
|
||||||
intermentContainerTypeKey: 'CV',
|
intermentContainerTypeKey: 'CV',
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'Wooden Shell',
|
intermentContainerType: 'Wooden Shell',
|
||||||
intermentContainerTypeKey: 'WS',
|
intermentContainerTypeKey: 'WS',
|
||||||
orderNumber: 5
|
orderNumber: 5
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'Steel Vault',
|
intermentContainerType: 'Steel Vault',
|
||||||
intermentContainerTypeKey: 'SV',
|
intermentContainerTypeKey: 'SV',
|
||||||
orderNumber: 6
|
orderNumber: 6
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addIntermentContainerType({
|
addIntermentContainerType({
|
||||||
intermentContainerType: 'Urn',
|
intermentContainerType: 'Urn',
|
||||||
intermentContainerTypeKey: 'U',
|
intermentContainerTypeKey: 'U',
|
||||||
isCremationType: '1',
|
isCremationType: '1',
|
||||||
orderNumber: 7
|
orderNumber: 7
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
// Committal Types
|
// Committal Types
|
||||||
await addCommittalType({
|
addCommittalType({
|
||||||
committalType: 'Graveside',
|
committalType: 'Graveside',
|
||||||
committalTypeKey: 'GS',
|
committalTypeKey: 'GS',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addCommittalType({
|
addCommittalType({
|
||||||
committalType: 'Chapel',
|
committalType: 'Chapel',
|
||||||
committalTypeKey: 'CS',
|
committalTypeKey: 'CS',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addCommittalType({
|
addCommittalType({
|
||||||
committalType: 'Church',
|
committalType: 'Church',
|
||||||
committalTypeKey: 'CH',
|
committalTypeKey: 'CH',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
|
|
@ -484,32 +484,32 @@ async function initializeData() {
|
||||||
/*
|
/*
|
||||||
* Fee Categories
|
* Fee Categories
|
||||||
*/
|
*/
|
||||||
await addFeeCategory({
|
addFeeCategory({
|
||||||
feeCategory: 'Interment Rights',
|
feeCategory: 'Interment Rights',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addFeeCategory({
|
addFeeCategory({
|
||||||
feeCategory: 'Cremation Services',
|
feeCategory: 'Cremation Services',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addFeeCategory({
|
addFeeCategory({
|
||||||
feeCategory: 'Burial Charges',
|
feeCategory: 'Burial Charges',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addFeeCategory({
|
addFeeCategory({
|
||||||
feeCategory: 'Disinterment of Human Remains',
|
feeCategory: 'Disinterment of Human Remains',
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
await addFeeCategory({
|
addFeeCategory({
|
||||||
feeCategory: 'Additional Services',
|
feeCategory: 'Additional Services',
|
||||||
orderNumber: 5
|
orderNumber: 5
|
||||||
}, initializingUser);
|
}, initializingUser);
|
||||||
/*
|
/*
|
||||||
* Work Orders
|
* Work Orders
|
||||||
*/
|
*/
|
||||||
await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, initializingUser);
|
addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, initializingUser);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, initializingUser);
|
addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, initializingUser);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, initializingUser);
|
addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, initializingUser);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, initializingUser);
|
addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, initializingUser);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, initializingUser);
|
addRecord('WorkOrderMilestoneTypes', 'Interment', 4, initializingUser);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -445,7 +445,7 @@ const initializingUser: User = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initializeDatabase(): Promise<boolean> {
|
export function initializeDatabase(): boolean {
|
||||||
const sunriseDB = sqlite(databasePath)
|
const sunriseDB = sqlite(databasePath)
|
||||||
|
|
||||||
const row = sunriseDB
|
const row = sunriseDB
|
||||||
|
|
@ -466,28 +466,28 @@ export async function initializeDatabase(): Promise<boolean> {
|
||||||
|
|
||||||
sunriseDB.close()
|
sunriseDB.close()
|
||||||
|
|
||||||
await initializeData()
|
initializeData()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initializeData(): Promise<void> {
|
function initializeData(): void {
|
||||||
debug('Initializing data...')
|
debug('Initializing data...')
|
||||||
|
|
||||||
await addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser)
|
addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser)
|
||||||
await addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser)
|
addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser)
|
||||||
await addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser)
|
addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser)
|
||||||
await addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser)
|
addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser)
|
||||||
await addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser)
|
addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser)
|
||||||
await addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser)
|
addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser)
|
||||||
|
|
||||||
await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser)
|
addRecord('BurialSiteStatuses', 'Available', 1, initializingUser)
|
||||||
await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser)
|
addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser)
|
||||||
await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser)
|
addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser)
|
||||||
|
|
||||||
// Contract Types
|
// Contract Types
|
||||||
|
|
||||||
await addContractType(
|
addContractType(
|
||||||
{
|
{
|
||||||
contractType: 'Preneed',
|
contractType: 'Preneed',
|
||||||
isPreneed: '1',
|
isPreneed: '1',
|
||||||
|
|
@ -496,7 +496,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addContractType(
|
addContractType(
|
||||||
{
|
{
|
||||||
contractType: 'Interment',
|
contractType: 'Interment',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
|
|
@ -504,7 +504,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addContractType(
|
addContractType(
|
||||||
{
|
{
|
||||||
contractType: 'Cremation',
|
contractType: 'Cremation',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
|
|
@ -514,7 +514,7 @@ async function initializeData(): Promise<void> {
|
||||||
|
|
||||||
// Interment Container Types
|
// Interment Container Types
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'No Shell',
|
intermentContainerType: 'No Shell',
|
||||||
intermentContainerTypeKey: 'NS',
|
intermentContainerTypeKey: 'NS',
|
||||||
|
|
@ -523,7 +523,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'Concrete Liner',
|
intermentContainerType: 'Concrete Liner',
|
||||||
intermentContainerTypeKey: 'CL',
|
intermentContainerTypeKey: 'CL',
|
||||||
|
|
@ -532,7 +532,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'Unpainted Vault',
|
intermentContainerType: 'Unpainted Vault',
|
||||||
intermentContainerTypeKey: 'UV',
|
intermentContainerTypeKey: 'UV',
|
||||||
|
|
@ -541,7 +541,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'Concrete Vault',
|
intermentContainerType: 'Concrete Vault',
|
||||||
intermentContainerTypeKey: 'CV',
|
intermentContainerTypeKey: 'CV',
|
||||||
|
|
@ -550,7 +550,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'Wooden Shell',
|
intermentContainerType: 'Wooden Shell',
|
||||||
intermentContainerTypeKey: 'WS',
|
intermentContainerTypeKey: 'WS',
|
||||||
|
|
@ -559,7 +559,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'Steel Vault',
|
intermentContainerType: 'Steel Vault',
|
||||||
intermentContainerTypeKey: 'SV',
|
intermentContainerTypeKey: 'SV',
|
||||||
|
|
@ -568,7 +568,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addIntermentContainerType(
|
addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerType: 'Urn',
|
intermentContainerType: 'Urn',
|
||||||
intermentContainerTypeKey: 'U',
|
intermentContainerTypeKey: 'U',
|
||||||
|
|
@ -580,7 +580,7 @@ async function initializeData(): Promise<void> {
|
||||||
|
|
||||||
// Committal Types
|
// Committal Types
|
||||||
|
|
||||||
await addCommittalType(
|
addCommittalType(
|
||||||
{
|
{
|
||||||
committalType: 'Graveside',
|
committalType: 'Graveside',
|
||||||
committalTypeKey: 'GS',
|
committalTypeKey: 'GS',
|
||||||
|
|
@ -589,7 +589,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addCommittalType(
|
addCommittalType(
|
||||||
{
|
{
|
||||||
committalType: 'Chapel',
|
committalType: 'Chapel',
|
||||||
committalTypeKey: 'CS',
|
committalTypeKey: 'CS',
|
||||||
|
|
@ -598,7 +598,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addCommittalType(
|
addCommittalType(
|
||||||
{
|
{
|
||||||
committalType: 'Church',
|
committalType: 'Church',
|
||||||
committalTypeKey: 'CH',
|
committalTypeKey: 'CH',
|
||||||
|
|
@ -611,7 +611,7 @@ async function initializeData(): Promise<void> {
|
||||||
* Fee Categories
|
* Fee Categories
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addFeeCategory(
|
addFeeCategory(
|
||||||
{
|
{
|
||||||
feeCategory: 'Interment Rights',
|
feeCategory: 'Interment Rights',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
|
|
@ -619,7 +619,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addFeeCategory(
|
addFeeCategory(
|
||||||
{
|
{
|
||||||
feeCategory: 'Cremation Services',
|
feeCategory: 'Cremation Services',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
|
|
@ -627,7 +627,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addFeeCategory(
|
addFeeCategory(
|
||||||
{
|
{
|
||||||
feeCategory: 'Burial Charges',
|
feeCategory: 'Burial Charges',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
|
|
@ -635,7 +635,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addFeeCategory(
|
addFeeCategory(
|
||||||
{
|
{
|
||||||
feeCategory: 'Disinterment of Human Remains',
|
feeCategory: 'Disinterment of Human Remains',
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
|
|
@ -643,7 +643,7 @@ async function initializeData(): Promise<void> {
|
||||||
initializingUser
|
initializingUser
|
||||||
)
|
)
|
||||||
|
|
||||||
await addFeeCategory(
|
addFeeCategory(
|
||||||
{
|
{
|
||||||
feeCategory: 'Additional Services',
|
feeCategory: 'Additional Services',
|
||||||
orderNumber: 5
|
orderNumber: 5
|
||||||
|
|
@ -655,10 +655,10 @@ async function initializeData(): Promise<void> {
|
||||||
* Work Orders
|
* Work Orders
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, initializingUser)
|
addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, initializingUser)
|
||||||
|
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, initializingUser)
|
addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, initializingUser)
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, initializingUser)
|
addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, initializingUser)
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, initializingUser)
|
addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, initializingUser)
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, initializingUser)
|
addRecord('WorkOrderMilestoneTypes', 'Interment', 4, initializingUser)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export declare function getCemeteryIdByKey(cemeteryKeyToSearch: string | undefined, user: User): Promise<number>;
|
export declare function getCemeteryIdByKey(cemeteryKeyToSearch: string | undefined, user: User): number;
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ const cemeteryKeyToCemetery = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const cemeteryCache = new Map();
|
const cemeteryCache = new Map();
|
||||||
export async function getCemeteryIdByKey(cemeteryKeyToSearch, user) {
|
export function getCemeteryIdByKey(cemeteryKeyToSearch, user) {
|
||||||
/*
|
/*
|
||||||
if (masterRow.CM_CEMETERY === "HS" &&
|
if (masterRow.CM_CEMETERY === "HS" &&
|
||||||
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
|
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
|
||||||
|
|
@ -211,7 +211,7 @@ export async function getCemeteryIdByKey(cemeteryKeyToSearch, user) {
|
||||||
if (cemeteryCache.has(cemeteryKey)) {
|
if (cemeteryCache.has(cemeteryKey)) {
|
||||||
return cemeteryCache.get(cemeteryKey);
|
return cemeteryCache.get(cemeteryKey);
|
||||||
}
|
}
|
||||||
const cemetery = await getCemeteryByKey(cemeteryKey);
|
const cemetery = getCemeteryByKey(cemeteryKey);
|
||||||
if (cemetery === undefined) {
|
if (cemetery === undefined) {
|
||||||
console.log(`Creating cemetery: ${cemeteryKey}`);
|
console.log(`Creating cemetery: ${cemeteryKey}`);
|
||||||
let addForm = cemeteryKeyToCemetery[cemeteryKey];
|
let addForm = cemeteryKeyToCemetery[cemeteryKey];
|
||||||
|
|
@ -231,7 +231,7 @@ export async function getCemeteryIdByKey(cemeteryKeyToSearch, user) {
|
||||||
cemeteryPhoneNumber: '',
|
cemeteryPhoneNumber: '',
|
||||||
parentCemeteryId: ''
|
parentCemeteryId: ''
|
||||||
};
|
};
|
||||||
const cemeteryId = await addCemetery(addForm, user);
|
const cemeteryId = addCemetery(addForm, user);
|
||||||
cemeteryCache.set(cemeteryKey, cemeteryId);
|
cemeteryCache.set(cemeteryKey, cemeteryId);
|
||||||
}
|
}
|
||||||
return cemeteryCache.get(cemeteryKey);
|
return cemeteryCache.get(cemeteryKey);
|
||||||
|
|
|
||||||
|
|
@ -264,10 +264,10 @@ const cemeteryKeyToCemetery: Record<string, AddCemeteryForm> = {
|
||||||
|
|
||||||
const cemeteryCache = new Map<string, number>()
|
const cemeteryCache = new Map<string, number>()
|
||||||
|
|
||||||
export async function getCemeteryIdByKey(
|
export function getCemeteryIdByKey(
|
||||||
cemeteryKeyToSearch: string | undefined,
|
cemeteryKeyToSearch: string | undefined,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): number {
|
||||||
/*
|
/*
|
||||||
if (masterRow.CM_CEMETERY === "HS" &&
|
if (masterRow.CM_CEMETERY === "HS" &&
|
||||||
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
|
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
|
||||||
|
|
@ -281,7 +281,7 @@ export async function getCemeteryIdByKey(
|
||||||
return cemeteryCache.get(cemeteryKey) as number
|
return cemeteryCache.get(cemeteryKey) as number
|
||||||
}
|
}
|
||||||
|
|
||||||
const cemetery = await getCemeteryByKey(cemeteryKey)
|
const cemetery = getCemeteryByKey(cemeteryKey)
|
||||||
|
|
||||||
if (cemetery === undefined) {
|
if (cemetery === undefined) {
|
||||||
console.log(`Creating cemetery: ${cemeteryKey}`)
|
console.log(`Creating cemetery: ${cemeteryKey}`)
|
||||||
|
|
@ -309,7 +309,7 @@ export async function getCemeteryIdByKey(
|
||||||
parentCemeteryId: ''
|
parentCemeteryId: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const cemeteryId = await addCemetery(addForm, user)
|
const cemeteryId = addCemetery(addForm, user)
|
||||||
|
|
||||||
cemeteryCache.set(cemeteryKey, cemeteryId)
|
cemeteryCache.set(cemeteryKey, cemeteryId)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export declare function getCommittalTypeIdByKey(committalTypeKey: string, user: User): Promise<number>;
|
export declare function getCommittalTypeIdByKey(committalTypeKey: string, user: User): number;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
import addCommittalType from "../../database/addCommittalType.js";
|
import addCommittalType from '../../database/addCommittalType.js';
|
||||||
import getCommittalTypes from "../../database/getCommittalTypes.js";
|
import getCommittalTypes from '../../database/getCommittalTypes.js';
|
||||||
let committalTypes = await getCommittalTypes();
|
let committalTypes = getCommittalTypes();
|
||||||
export async function getCommittalTypeIdByKey(committalTypeKey, user) {
|
export function getCommittalTypeIdByKey(committalTypeKey, user) {
|
||||||
const committalType = committalTypes.find((committalType) => committalType.committalTypeKey ===
|
const committalType = committalTypes.find((committalType) => committalType.committalTypeKey === committalTypeKey);
|
||||||
committalTypeKey);
|
|
||||||
if (committalType === undefined) {
|
if (committalType === undefined) {
|
||||||
const committalTypeId = await addCommittalType({
|
const committalTypeId = addCommittalType({
|
||||||
committalTypeKey,
|
committalTypeKey,
|
||||||
committalType: committalTypeKey
|
committalType: committalTypeKey
|
||||||
}, user);
|
}, user);
|
||||||
committalTypes = await getCommittalTypes();
|
committalTypes = getCommittalTypes();
|
||||||
return committalTypeId;
|
return committalTypeId;
|
||||||
}
|
}
|
||||||
return committalType.committalTypeId;
|
return committalType.committalTypeId;
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,18 @@
|
||||||
import addCommittalType from "../../database/addCommittalType.js";
|
import addCommittalType from '../../database/addCommittalType.js'
|
||||||
import getCommittalTypes from "../../database/getCommittalTypes.js";
|
import getCommittalTypes from '../../database/getCommittalTypes.js'
|
||||||
|
|
||||||
let committalTypes = await getCommittalTypes()
|
let committalTypes = getCommittalTypes()
|
||||||
|
|
||||||
export async function getCommittalTypeIdByKey(
|
export function getCommittalTypeIdByKey(
|
||||||
committalTypeKey: string,
|
committalTypeKey: string,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): number {
|
||||||
const committalType = committalTypes.find(
|
const committalType = committalTypes.find(
|
||||||
(committalType) =>
|
(committalType) => committalType.committalTypeKey === committalTypeKey
|
||||||
committalType.committalTypeKey ===
|
|
||||||
committalTypeKey
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (committalType === undefined) {
|
if (committalType === undefined) {
|
||||||
const committalTypeId = await addCommittalType(
|
const committalTypeId = addCommittalType(
|
||||||
{
|
{
|
||||||
committalTypeKey,
|
committalTypeKey,
|
||||||
committalType: committalTypeKey
|
committalType: committalTypeKey
|
||||||
|
|
@ -22,10 +20,10 @@ export async function getCommittalTypeIdByKey(
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
committalTypes = await getCommittalTypes()
|
committalTypes = getCommittalTypes()
|
||||||
|
|
||||||
return committalTypeId
|
return committalTypeId
|
||||||
}
|
}
|
||||||
|
|
||||||
return committalType.committalTypeId
|
return committalType.committalTypeId
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export declare function getFeeIdByFeeDescription(feeDescription: string, user: User): Promise<number>;
|
export declare function getFeeIdByFeeDescription(feeDescription: string, user: User): number;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import addFee from '../../database/addFee.js';
|
||||||
import { sunriseDB as databasePath } from '../../helpers/database.helpers.js';
|
import { sunriseDB as databasePath } from '../../helpers/database.helpers.js';
|
||||||
let feeCategoryId = 0;
|
let feeCategoryId = 0;
|
||||||
const feeCache = new Map();
|
const feeCache = new Map();
|
||||||
export async function getFeeIdByFeeDescription(feeDescription, user) {
|
export function getFeeIdByFeeDescription(feeDescription, user) {
|
||||||
if (feeCache.keys.length === 0) {
|
if (feeCache.keys.length === 0) {
|
||||||
const database = sqlite(databasePath, {
|
const database = sqlite(databasePath, {
|
||||||
readonly: true
|
readonly: true
|
||||||
|
|
@ -23,7 +23,7 @@ export async function getFeeIdByFeeDescription(feeDescription, user) {
|
||||||
}
|
}
|
||||||
let feeId = feeCache.get(feeDescription);
|
let feeId = feeCache.get(feeDescription);
|
||||||
if (feeId === undefined) {
|
if (feeId === undefined) {
|
||||||
feeId = await addFee({
|
feeId = addFee({
|
||||||
feeName: feeDescription.slice(9),
|
feeName: feeDescription.slice(9),
|
||||||
feeDescription,
|
feeDescription,
|
||||||
feeCategoryId,
|
feeCategoryId,
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ let feeCategoryId = 0
|
||||||
|
|
||||||
const feeCache = new Map<string, number>()
|
const feeCache = new Map<string, number>()
|
||||||
|
|
||||||
export async function getFeeIdByFeeDescription(
|
export function getFeeIdByFeeDescription(
|
||||||
feeDescription: string,
|
feeDescription: string,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): number {
|
||||||
if (feeCache.keys.length === 0) {
|
if (feeCache.keys.length === 0) {
|
||||||
const database = sqlite(databasePath, {
|
const database = sqlite(databasePath, {
|
||||||
readonly: true
|
readonly: true
|
||||||
|
|
@ -42,7 +42,7 @@ export async function getFeeIdByFeeDescription(
|
||||||
let feeId = feeCache.get(feeDescription)
|
let feeId = feeCache.get(feeDescription)
|
||||||
|
|
||||||
if (feeId === undefined) {
|
if (feeId === undefined) {
|
||||||
feeId = await addFee(
|
feeId = addFee(
|
||||||
{
|
{
|
||||||
feeName: feeDescription.slice(9),
|
feeName: feeDescription.slice(9),
|
||||||
feeDescription,
|
feeDescription,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
export declare function getFuneralHomeIdByKey(funeralHomeKey: string, user: User): Promise<number>;
|
export declare function getFuneralHomeIdByKey(funeralHomeKey: string, user: User): number;
|
||||||
export declare function initializeFuneralHomes(user: User): Promise<void>;
|
export declare function initializeFuneralHomes(user: User): void;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '492 Wellington Street East',
|
funeralHomeAddress1: '492 Wellington Street East',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6A 2L9',
|
funeralHomePostalCode: 'P6A 2L9',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-759-2522'
|
funeralHomePhoneNumber: '705-759-2522'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -16,8 +16,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '175 Main Street',
|
funeralHomeAddress1: '175 Main Street',
|
||||||
funeralHomeAddress2: 'P.O. Box 280',
|
funeralHomeAddress2: 'P.O. Box 280',
|
||||||
funeralHomeCity: 'Thessalon',
|
funeralHomeCity: 'Thessalon',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P0R 1L0',
|
funeralHomePostalCode: 'P0R 1L0',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-842-2520'
|
funeralHomePhoneNumber: '705-842-2520'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -26,8 +26,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '',
|
funeralHomeAddress1: '',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: '',
|
funeralHomePostalCode: '',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: ''
|
funeralHomePhoneNumber: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -36,8 +36,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '215 St. James Street',
|
funeralHomeAddress1: '215 St. James Street',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6A 1P7',
|
funeralHomePostalCode: 'P6A 1P7',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-759-8456'
|
funeralHomePhoneNumber: '705-759-8456'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -46,8 +46,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '140 Churchill Avenue',
|
funeralHomeAddress1: '140 Churchill Avenue',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Wawa',
|
funeralHomeCity: 'Wawa',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P0S 1K0',
|
funeralHomePostalCode: 'P0S 1K0',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-856-7340'
|
funeralHomePhoneNumber: '705-856-7340'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -56,8 +56,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '942 Great Northern Road',
|
funeralHomeAddress1: '942 Great Northern Road',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6B 0B6',
|
funeralHomePostalCode: 'P6B 0B6',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-945-7758'
|
funeralHomePhoneNumber: '705-945-7758'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -66,8 +66,8 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '215 St. James Street',
|
funeralHomeAddress1: '215 St. James Street',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6A 1P7',
|
funeralHomePostalCode: 'P6A 1P7',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-759-8456'
|
funeralHomePhoneNumber: '705-759-8456'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -76,39 +76,39 @@ const funeralHomes = [
|
||||||
funeralHomeAddress1: '72 Lakeside Avenue',
|
funeralHomeAddress1: '72 Lakeside Avenue',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Blind River',
|
funeralHomeCity: 'Blind River',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P0R 1B0',
|
funeralHomePostalCode: 'P0R 1B0',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
funeralHomePhoneNumber: '705-356-7151'
|
funeralHomePhoneNumber: '705-356-7151'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const funeralHomeKeyToId = new Map();
|
const funeralHomeKeyToId = new Map();
|
||||||
export async function getFuneralHomeIdByKey(funeralHomeKey, user) {
|
export function getFuneralHomeIdByKey(funeralHomeKey, user) {
|
||||||
if (funeralHomeKeyToId.has(funeralHomeKey)) {
|
if (funeralHomeKeyToId.has(funeralHomeKey)) {
|
||||||
return funeralHomeKeyToId.get(funeralHomeKey);
|
return funeralHomeKeyToId.get(funeralHomeKey);
|
||||||
}
|
}
|
||||||
const funeralHomeId = await addFuneralHome({
|
const funeralHomeId = addFuneralHome({
|
||||||
funeralHomeKey,
|
funeralHomeKey,
|
||||||
funeralHomeName: funeralHomeKey,
|
funeralHomeName: funeralHomeKey,
|
||||||
funeralHomeAddress1: '',
|
funeralHomeAddress1: '',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: '',
|
funeralHomeCity: '',
|
||||||
funeralHomeProvince: '',
|
|
||||||
funeralHomePostalCode: '',
|
funeralHomePostalCode: '',
|
||||||
|
funeralHomeProvince: '',
|
||||||
funeralHomePhoneNumber: ''
|
funeralHomePhoneNumber: ''
|
||||||
}, user);
|
}, user);
|
||||||
funeralHomeKeyToId.set(funeralHomeKey, funeralHomeId);
|
funeralHomeKeyToId.set(funeralHomeKey, funeralHomeId);
|
||||||
return funeralHomeId;
|
return funeralHomeId;
|
||||||
}
|
}
|
||||||
export async function initializeFuneralHomes(user) {
|
export function initializeFuneralHomes(user) {
|
||||||
for (const funeralHome of funeralHomes) {
|
for (const funeralHome of funeralHomes) {
|
||||||
const funeralHomeId = await addFuneralHome({
|
const funeralHomeId = addFuneralHome({
|
||||||
funeralHomeKey: funeralHome.funeralHomeKey ?? '',
|
funeralHomeKey: funeralHome.funeralHomeKey ?? '',
|
||||||
funeralHomeName: funeralHome.funeralHomeName ?? '',
|
funeralHomeName: funeralHome.funeralHomeName ?? '',
|
||||||
funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '',
|
funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '',
|
||||||
funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '',
|
funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '',
|
||||||
funeralHomeCity: funeralHome.funeralHomeCity ?? '',
|
funeralHomeCity: funeralHome.funeralHomeCity ?? '',
|
||||||
funeralHomeProvince: funeralHome.funeralHomeProvince ?? '',
|
|
||||||
funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '',
|
funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '',
|
||||||
|
funeralHomeProvince: funeralHome.funeralHomeProvince ?? '',
|
||||||
funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? ''
|
funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? ''
|
||||||
}, user);
|
}, user);
|
||||||
funeralHomeKeyToId.set(funeralHome.funeralHomeKey ?? '', funeralHomeId);
|
funeralHomeKeyToId.set(funeralHome.funeralHomeKey ?? '', funeralHomeId);
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '492 Wellington Street East',
|
funeralHomeAddress1: '492 Wellington Street East',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6A 2L9',
|
funeralHomePostalCode: 'P6A 2L9',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-759-2522'
|
funeralHomePhoneNumber: '705-759-2522'
|
||||||
},
|
},
|
||||||
|
|
@ -21,8 +21,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '175 Main Street',
|
funeralHomeAddress1: '175 Main Street',
|
||||||
funeralHomeAddress2: 'P.O. Box 280',
|
funeralHomeAddress2: 'P.O. Box 280',
|
||||||
funeralHomeCity: 'Thessalon',
|
funeralHomeCity: 'Thessalon',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P0R 1L0',
|
funeralHomePostalCode: 'P0R 1L0',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-842-2520'
|
funeralHomePhoneNumber: '705-842-2520'
|
||||||
},
|
},
|
||||||
|
|
@ -33,8 +33,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '',
|
funeralHomeAddress1: '',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: '',
|
funeralHomePostalCode: '',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: ''
|
funeralHomePhoneNumber: ''
|
||||||
},
|
},
|
||||||
|
|
@ -45,8 +45,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '215 St. James Street',
|
funeralHomeAddress1: '215 St. James Street',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6A 1P7',
|
funeralHomePostalCode: 'P6A 1P7',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-759-8456'
|
funeralHomePhoneNumber: '705-759-8456'
|
||||||
},
|
},
|
||||||
|
|
@ -57,8 +57,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '140 Churchill Avenue',
|
funeralHomeAddress1: '140 Churchill Avenue',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Wawa',
|
funeralHomeCity: 'Wawa',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P0S 1K0',
|
funeralHomePostalCode: 'P0S 1K0',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-856-7340'
|
funeralHomePhoneNumber: '705-856-7340'
|
||||||
},
|
},
|
||||||
|
|
@ -69,8 +69,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '942 Great Northern Road',
|
funeralHomeAddress1: '942 Great Northern Road',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6B 0B6',
|
funeralHomePostalCode: 'P6B 0B6',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-945-7758'
|
funeralHomePhoneNumber: '705-945-7758'
|
||||||
},
|
},
|
||||||
|
|
@ -81,8 +81,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '215 St. James Street',
|
funeralHomeAddress1: '215 St. James Street',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Sault Ste. Marie',
|
funeralHomeCity: 'Sault Ste. Marie',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P6A 1P7',
|
funeralHomePostalCode: 'P6A 1P7',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-759-8456'
|
funeralHomePhoneNumber: '705-759-8456'
|
||||||
},
|
},
|
||||||
|
|
@ -93,8 +93,8 @@ const funeralHomes: FuneralHome[] = [
|
||||||
funeralHomeAddress1: '72 Lakeside Avenue',
|
funeralHomeAddress1: '72 Lakeside Avenue',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: 'Blind River',
|
funeralHomeCity: 'Blind River',
|
||||||
funeralHomeProvince: 'ON',
|
|
||||||
funeralHomePostalCode: 'P0R 1B0',
|
funeralHomePostalCode: 'P0R 1B0',
|
||||||
|
funeralHomeProvince: 'ON',
|
||||||
|
|
||||||
funeralHomePhoneNumber: '705-356-7151'
|
funeralHomePhoneNumber: '705-356-7151'
|
||||||
}
|
}
|
||||||
|
|
@ -102,15 +102,15 @@ const funeralHomes: FuneralHome[] = [
|
||||||
|
|
||||||
const funeralHomeKeyToId = new Map<string, number>()
|
const funeralHomeKeyToId = new Map<string, number>()
|
||||||
|
|
||||||
export async function getFuneralHomeIdByKey(
|
export function getFuneralHomeIdByKey(
|
||||||
funeralHomeKey: string,
|
funeralHomeKey: string,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): number {
|
||||||
if (funeralHomeKeyToId.has(funeralHomeKey)) {
|
if (funeralHomeKeyToId.has(funeralHomeKey)) {
|
||||||
return funeralHomeKeyToId.get(funeralHomeKey) as number
|
return funeralHomeKeyToId.get(funeralHomeKey) as number
|
||||||
}
|
}
|
||||||
|
|
||||||
const funeralHomeId = await addFuneralHome(
|
const funeralHomeId = addFuneralHome(
|
||||||
{
|
{
|
||||||
funeralHomeKey,
|
funeralHomeKey,
|
||||||
funeralHomeName: funeralHomeKey,
|
funeralHomeName: funeralHomeKey,
|
||||||
|
|
@ -118,8 +118,9 @@ export async function getFuneralHomeIdByKey(
|
||||||
funeralHomeAddress1: '',
|
funeralHomeAddress1: '',
|
||||||
funeralHomeAddress2: '',
|
funeralHomeAddress2: '',
|
||||||
funeralHomeCity: '',
|
funeralHomeCity: '',
|
||||||
funeralHomeProvince: '',
|
|
||||||
funeralHomePostalCode: '',
|
funeralHomePostalCode: '',
|
||||||
|
funeralHomeProvince: '',
|
||||||
|
|
||||||
funeralHomePhoneNumber: ''
|
funeralHomePhoneNumber: ''
|
||||||
},
|
},
|
||||||
user
|
user
|
||||||
|
|
@ -130,9 +131,9 @@ export async function getFuneralHomeIdByKey(
|
||||||
return funeralHomeId
|
return funeralHomeId
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initializeFuneralHomes(user: User): Promise<void> {
|
export function initializeFuneralHomes(user: User): void {
|
||||||
for (const funeralHome of funeralHomes) {
|
for (const funeralHome of funeralHomes) {
|
||||||
const funeralHomeId = await addFuneralHome(
|
const funeralHomeId = addFuneralHome(
|
||||||
{
|
{
|
||||||
funeralHomeKey: funeralHome.funeralHomeKey ?? '',
|
funeralHomeKey: funeralHome.funeralHomeKey ?? '',
|
||||||
funeralHomeName: funeralHome.funeralHomeName ?? '',
|
funeralHomeName: funeralHome.funeralHomeName ?? '',
|
||||||
|
|
@ -140,8 +141,8 @@ export async function initializeFuneralHomes(user: User): Promise<void> {
|
||||||
funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '',
|
funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '',
|
||||||
funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '',
|
funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '',
|
||||||
funeralHomeCity: funeralHome.funeralHomeCity ?? '',
|
funeralHomeCity: funeralHome.funeralHomeCity ?? '',
|
||||||
funeralHomeProvince: funeralHome.funeralHomeProvince ?? '',
|
|
||||||
funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '',
|
funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '',
|
||||||
|
funeralHomeProvince: funeralHome.funeralHomeProvince ?? '',
|
||||||
|
|
||||||
funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? ''
|
funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? ''
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export declare function getIntermentContainerTypeIdByKey(intermentContainerTypeKey: string, user: User): Promise<number>;
|
export declare function getIntermentContainerTypeIdByKey(intermentContainerTypeKey: string, user: User): number;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
import addIntermentContainerType from '../../database/addIntermentContainerType.js';
|
import addIntermentContainerType from '../../database/addIntermentContainerType.js';
|
||||||
import getIntermentContainerTypes from '../../database/getIntermentContainerTypes.js';
|
import getIntermentContainerTypes from '../../database/getIntermentContainerTypes.js';
|
||||||
let intermentContainerTypes = await getIntermentContainerTypes();
|
let intermentContainerTypes = getIntermentContainerTypes();
|
||||||
export async function getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user) {
|
export function getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user) {
|
||||||
const intermentContainerType = intermentContainerTypes.find((intermentContainerType) => intermentContainerType.intermentContainerTypeKey ===
|
const intermentContainerType = intermentContainerTypes.find((intermentContainerType) => intermentContainerType.intermentContainerTypeKey ===
|
||||||
intermentContainerTypeKey);
|
intermentContainerTypeKey);
|
||||||
if (intermentContainerType === undefined) {
|
if (intermentContainerType === undefined) {
|
||||||
const intermentContainerTypeId = await addIntermentContainerType({
|
const intermentContainerTypeId = addIntermentContainerType({
|
||||||
intermentContainerTypeKey,
|
intermentContainerTypeKey,
|
||||||
intermentContainerType: intermentContainerTypeKey
|
intermentContainerType: intermentContainerTypeKey
|
||||||
}, user);
|
}, user);
|
||||||
intermentContainerTypes = await getIntermentContainerTypes();
|
intermentContainerTypes = getIntermentContainerTypes();
|
||||||
return intermentContainerTypeId;
|
return intermentContainerTypeId;
|
||||||
}
|
}
|
||||||
return intermentContainerType.intermentContainerTypeId;
|
return intermentContainerType.intermentContainerTypeId;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import addIntermentContainerType from '../../database/addIntermentContainerType.js'
|
import addIntermentContainerType from '../../database/addIntermentContainerType.js'
|
||||||
import getIntermentContainerTypes from '../../database/getIntermentContainerTypes.js'
|
import getIntermentContainerTypes from '../../database/getIntermentContainerTypes.js'
|
||||||
|
|
||||||
let intermentContainerTypes = await getIntermentContainerTypes()
|
let intermentContainerTypes = getIntermentContainerTypes()
|
||||||
|
|
||||||
export async function getIntermentContainerTypeIdByKey(
|
export function getIntermentContainerTypeIdByKey(
|
||||||
intermentContainerTypeKey: string,
|
intermentContainerTypeKey: string,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): number {
|
||||||
const intermentContainerType = intermentContainerTypes.find(
|
const intermentContainerType = intermentContainerTypes.find(
|
||||||
(intermentContainerType) =>
|
(intermentContainerType) =>
|
||||||
intermentContainerType.intermentContainerTypeKey ===
|
intermentContainerType.intermentContainerTypeKey ===
|
||||||
|
|
@ -14,7 +14,7 @@ export async function getIntermentContainerTypeIdByKey(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (intermentContainerType === undefined) {
|
if (intermentContainerType === undefined) {
|
||||||
const intermentContainerTypeId = await addIntermentContainerType(
|
const intermentContainerTypeId = addIntermentContainerType(
|
||||||
{
|
{
|
||||||
intermentContainerTypeKey,
|
intermentContainerTypeKey,
|
||||||
intermentContainerType: intermentContainerTypeKey
|
intermentContainerType: intermentContainerTypeKey
|
||||||
|
|
@ -22,7 +22,7 @@ export async function getIntermentContainerTypeIdByKey(
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
intermentContainerTypes = await getIntermentContainerTypes()
|
intermentContainerTypes = getIntermentContainerTypes()
|
||||||
|
|
||||||
return intermentContainerTypeId
|
return intermentContainerTypeId
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ async function importFromMasterCSV() {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (masterRow of cmmaster.data) {
|
for (masterRow of cmmaster.data) {
|
||||||
const cemeteryId = await getCemeteryIdByKey(masterRow.CM_CEMETERY, user);
|
const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user);
|
||||||
const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY);
|
const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY);
|
||||||
let burialSiteId;
|
let burialSiteId;
|
||||||
if (masterRow.CM_CEMETERY !== '00') {
|
if (masterRow.CM_CEMETERY !== '00') {
|
||||||
|
|
@ -87,7 +87,7 @@ async function importFromMasterCSV() {
|
||||||
const burialSite = await getBurialSiteByBurialSiteName(burialSiteName);
|
const burialSite = await getBurialSiteByBurialSiteName(burialSiteName);
|
||||||
burialSiteId =
|
burialSiteId =
|
||||||
burialSite === undefined
|
burialSite === undefined
|
||||||
? await addBurialSite({
|
? addBurialSite({
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
burialSiteNameSegment2,
|
burialSiteNameSegment2,
|
||||||
burialSiteNameSegment3,
|
burialSiteNameSegment3,
|
||||||
|
|
@ -99,7 +99,7 @@ async function importFromMasterCSV() {
|
||||||
cemeterySvgId: '',
|
cemeterySvgId: '',
|
||||||
burialSiteLatitude: '',
|
burialSiteLatitude: '',
|
||||||
burialSiteLongitude: ''
|
burialSiteLongitude: ''
|
||||||
}, user)
|
}, user).burialSiteId
|
||||||
: burialSite.burialSiteId;
|
: burialSite.burialSiteId;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -135,7 +135,7 @@ async function importFromMasterCSV() {
|
||||||
preneedContractStartDateString = '0001-01-01';
|
preneedContractStartDateString = '0001-01-01';
|
||||||
}
|
}
|
||||||
const purchaserPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim();
|
const purchaserPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim();
|
||||||
preneedContractId = await addContract({
|
preneedContractId = addContract({
|
||||||
contractTypeId: importIds.preneedContractType.contractTypeId,
|
contractTypeId: importIds.preneedContractType.contractTypeId,
|
||||||
burialSiteId: burialSiteId ?? '',
|
burialSiteId: burialSiteId ?? '',
|
||||||
contractStartDateString: preneedContractStartDateString,
|
contractStartDateString: preneedContractStartDateString,
|
||||||
|
|
@ -159,7 +159,7 @@ async function importFromMasterCSV() {
|
||||||
deceasedProvince: masterRow.CM_PROV
|
deceasedProvince: masterRow.CM_PROV
|
||||||
}, user);
|
}, user);
|
||||||
if (masterRow.CM_REMARK1 !== '') {
|
if (masterRow.CM_REMARK1 !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId: preneedContractId,
|
contractId: preneedContractId,
|
||||||
commentDateString: preneedContractStartDateString,
|
commentDateString: preneedContractStartDateString,
|
||||||
commentTimeString: '00:00',
|
commentTimeString: '00:00',
|
||||||
|
|
@ -167,7 +167,7 @@ async function importFromMasterCSV() {
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
if (masterRow.CM_REMARK2 !== '') {
|
if (masterRow.CM_REMARK2 !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId: preneedContractId,
|
contractId: preneedContractId,
|
||||||
comment: masterRow.CM_REMARK2,
|
comment: masterRow.CM_REMARK2,
|
||||||
commentDateString: preneedContractStartDateString,
|
commentDateString: preneedContractStartDateString,
|
||||||
|
|
@ -175,7 +175,7 @@ async function importFromMasterCSV() {
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId: preneedContractId,
|
contractId: preneedContractId,
|
||||||
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`,
|
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`,
|
||||||
commentDateString: preneedContractStartDateString,
|
commentDateString: preneedContractStartDateString,
|
||||||
|
|
@ -183,7 +183,7 @@ async function importFromMasterCSV() {
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
if (contractEndDateString === '') {
|
if (contractEndDateString === '') {
|
||||||
await updateBurialSiteStatus(burialSiteId ?? '', importIds.reservedBurialSiteStatusId, user);
|
updateBurialSiteStatus(burialSiteId ?? '', importIds.reservedBurialSiteStatusId, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -212,14 +212,14 @@ async function importFromMasterCSV() {
|
||||||
const deceasedPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim();
|
const deceasedPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim();
|
||||||
const funeralHomeId = masterRow.CM_FUNERAL_HOME === ''
|
const funeralHomeId = masterRow.CM_FUNERAL_HOME === ''
|
||||||
? ''
|
? ''
|
||||||
: await getFuneralHomeIdByKey(masterRow.CM_FUNERAL_HOME, user);
|
: getFuneralHomeIdByKey(masterRow.CM_FUNERAL_HOME, user);
|
||||||
const funeralDateString = masterRow.CM_FUNERAL_YR === ''
|
const funeralDateString = masterRow.CM_FUNERAL_YR === ''
|
||||||
? ''
|
? ''
|
||||||
: formatDateString(masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, masterRow.CM_FUNERAL_DAY);
|
: formatDateString(masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, masterRow.CM_FUNERAL_DAY);
|
||||||
const committalTypeId = contractType.contractType === 'Cremation' ||
|
const committalTypeId = contractType.contractType === 'Cremation' ||
|
||||||
masterRow.CM_COMMITTAL_TYPE === ''
|
masterRow.CM_COMMITTAL_TYPE === ''
|
||||||
? ''
|
? ''
|
||||||
: await getCommittalTypeIdByKey(masterRow.CM_COMMITTAL_TYPE, user);
|
: getCommittalTypeIdByKey(masterRow.CM_COMMITTAL_TYPE, user);
|
||||||
const deathDateString = masterRow.CM_DEATH_YR === ''
|
const deathDateString = masterRow.CM_DEATH_YR === ''
|
||||||
? ''
|
? ''
|
||||||
: formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY);
|
: formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY);
|
||||||
|
|
@ -229,8 +229,8 @@ async function importFromMasterCSV() {
|
||||||
: masterRow.CM_CONTAINER_TYPE;
|
: masterRow.CM_CONTAINER_TYPE;
|
||||||
const intermentContainerTypeId = intermentContainerTypeKey === ''
|
const intermentContainerTypeId = intermentContainerTypeKey === ''
|
||||||
? ''
|
? ''
|
||||||
: await getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user);
|
: getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user);
|
||||||
deceasedContractId = await addContract({
|
deceasedContractId = addContract({
|
||||||
contractTypeId: contractType.contractTypeId,
|
contractTypeId: contractType.contractTypeId,
|
||||||
burialSiteId: burialSiteId ?? '',
|
burialSiteId: burialSiteId ?? '',
|
||||||
contractStartDateString: deceasedContractStartDateString,
|
contractStartDateString: deceasedContractStartDateString,
|
||||||
|
|
@ -265,7 +265,7 @@ async function importFromMasterCSV() {
|
||||||
intermentContainerTypeId
|
intermentContainerTypeId
|
||||||
}, user);
|
}, user);
|
||||||
if (masterRow.CM_REMARK1 !== '') {
|
if (masterRow.CM_REMARK1 !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId: deceasedContractId,
|
contractId: deceasedContractId,
|
||||||
commentDateString: deceasedContractStartDateString,
|
commentDateString: deceasedContractStartDateString,
|
||||||
commentTimeString: '00:00',
|
commentTimeString: '00:00',
|
||||||
|
|
@ -273,7 +273,7 @@ async function importFromMasterCSV() {
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
if (masterRow.CM_REMARK2 !== '') {
|
if (masterRow.CM_REMARK2 !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId: deceasedContractId,
|
contractId: deceasedContractId,
|
||||||
commentDateString: deceasedContractStartDateString,
|
commentDateString: deceasedContractStartDateString,
|
||||||
commentTimeString: '00:00',
|
commentTimeString: '00:00',
|
||||||
|
|
@ -281,14 +281,14 @@ async function importFromMasterCSV() {
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId: deceasedContractId,
|
contractId: deceasedContractId,
|
||||||
commentDateString: deceasedContractStartDateString,
|
commentDateString: deceasedContractStartDateString,
|
||||||
commentTimeString: '00:00',
|
commentTimeString: '00:00',
|
||||||
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`
|
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
await updateBurialSiteStatus(burialSiteId ?? '', importIds.takenBurialSiteStatusId, user);
|
updateBurialSiteStatus(burialSiteId ?? '', importIds.takenBurialSiteStatusId, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -322,7 +322,7 @@ async function importFromPrepaidCSV() {
|
||||||
}
|
}
|
||||||
let burialSite;
|
let burialSite;
|
||||||
if (cemeteryKey !== '') {
|
if (cemeteryKey !== '') {
|
||||||
const cemeteryId = await getCemeteryIdByKey(cemeteryKey, user);
|
const cemeteryId = getCemeteryIdByKey(cemeteryKey, user);
|
||||||
const burialSiteNameSegment1 = prepaidRow.CMPP_BLOCK === '0' ? '' : prepaidRow.CMPP_BLOCK;
|
const burialSiteNameSegment1 = prepaidRow.CMPP_BLOCK === '0' ? '' : prepaidRow.CMPP_BLOCK;
|
||||||
const burialSiteNameSegment2 = (prepaidRow.CMPP_RANGE1 === '0' ? '' : prepaidRow.CMPP_RANGE1) +
|
const burialSiteNameSegment2 = (prepaidRow.CMPP_RANGE1 === '0' ? '' : prepaidRow.CMPP_RANGE1) +
|
||||||
(prepaidRow.CMPP_RANGE2 === '0' ? '' : prepaidRow.CMPP_RANGE2);
|
(prepaidRow.CMPP_RANGE2 === '0' ? '' : prepaidRow.CMPP_RANGE2);
|
||||||
|
|
@ -342,7 +342,7 @@ async function importFromPrepaidCSV() {
|
||||||
burialSite = await getBurialSiteByBurialSiteName(burialSiteName);
|
burialSite = await getBurialSiteByBurialSiteName(burialSiteName);
|
||||||
if (!burialSite) {
|
if (!burialSite) {
|
||||||
const burialSiteTypeId = getBurialSiteTypeId(cemeteryKey);
|
const burialSiteTypeId = getBurialSiteTypeId(cemeteryKey);
|
||||||
const burialSiteId = await addBurialSite({
|
const burialSiteKeys = addBurialSite({
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
burialSiteNameSegment2,
|
burialSiteNameSegment2,
|
||||||
burialSiteNameSegment3,
|
burialSiteNameSegment3,
|
||||||
|
|
@ -357,12 +357,12 @@ async function importFromPrepaidCSV() {
|
||||||
burialSiteLongitude: '',
|
burialSiteLongitude: '',
|
||||||
burialSiteImage: ''
|
burialSiteImage: ''
|
||||||
}, user);
|
}, user);
|
||||||
burialSite = await getBurialSite(burialSiteId);
|
burialSite = await getBurialSite(burialSiteKeys.burialSiteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (burialSite &&
|
if (burialSite &&
|
||||||
burialSite.burialSiteStatusId === importIds.availableBurialSiteStatusId) {
|
burialSite.burialSiteStatusId === importIds.availableBurialSiteStatusId) {
|
||||||
await updateBurialSiteStatus(burialSite.burialSiteId, importIds.reservedBurialSiteStatusId, user);
|
updateBurialSiteStatus(burialSite.burialSiteId, importIds.reservedBurialSiteStatusId, user);
|
||||||
}
|
}
|
||||||
const contractStartDateString = formatDateString(prepaidRow.CMPP_PURCH_YR, prepaidRow.CMPP_PURCH_MON, prepaidRow.CMPP_PURCH_DAY);
|
const contractStartDateString = formatDateString(prepaidRow.CMPP_PURCH_YR, prepaidRow.CMPP_PURCH_MON, prepaidRow.CMPP_PURCH_DAY);
|
||||||
let contractId;
|
let contractId;
|
||||||
|
|
@ -383,7 +383,7 @@ async function importFromPrepaidCSV() {
|
||||||
contractId = possibleContracts.contracts[0].contractId;
|
contractId = possibleContracts.contracts[0].contractId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contractId ||= await addContract({
|
contractId ||= addContract({
|
||||||
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
||||||
contractTypeId: importIds.preneedContractType.contractTypeId,
|
contractTypeId: importIds.preneedContractType.contractTypeId,
|
||||||
contractStartDateString,
|
contractStartDateString,
|
||||||
|
|
@ -399,7 +399,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_GRAV_SD !== '0.0') {
|
if (prepaidRow.CMPP_FEE_GRAV_SD !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_GRAV_SD,
|
feeAmount: prepaidRow.CMPP_FEE_GRAV_SD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_GRAV_SD
|
taxAmount: prepaidRow.CMPP_GST_GRAV_SD
|
||||||
|
|
@ -408,7 +408,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_GRAV_DD !== '0.0') {
|
if (prepaidRow.CMPP_FEE_GRAV_DD !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_GRAV_DD,
|
feeAmount: prepaidRow.CMPP_FEE_GRAV_DD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_GRAV_DD
|
taxAmount: prepaidRow.CMPP_GST_GRAV_DD
|
||||||
|
|
@ -417,7 +417,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_CHAP_SD !== '0.0') {
|
if (prepaidRow.CMPP_FEE_CHAP_SD !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_CHAP_SD,
|
feeAmount: prepaidRow.CMPP_FEE_CHAP_SD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_CHAP_SD
|
taxAmount: prepaidRow.CMPP_GST_CHAP_SD
|
||||||
|
|
@ -426,7 +426,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_CHAP_DD !== '0.0') {
|
if (prepaidRow.CMPP_FEE_CHAP_DD !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_CHAP_DD,
|
feeAmount: prepaidRow.CMPP_FEE_CHAP_DD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_CHAP_DD
|
taxAmount: prepaidRow.CMPP_GST_CHAP_DD
|
||||||
|
|
@ -435,7 +435,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_ENTOMBMENT !== '0.0') {
|
if (prepaidRow.CMPP_FEE_ENTOMBMENT !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT,
|
feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT,
|
||||||
taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT
|
taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT
|
||||||
|
|
@ -444,7 +444,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_CREM !== '0.0') {
|
if (prepaidRow.CMPP_FEE_CREM !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_CREM', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_CREM', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_CREM,
|
feeAmount: prepaidRow.CMPP_FEE_CREM,
|
||||||
taxAmount: prepaidRow.CMPP_GST_CREM
|
taxAmount: prepaidRow.CMPP_GST_CREM
|
||||||
|
|
@ -453,7 +453,7 @@ async function importFromPrepaidCSV() {
|
||||||
if (prepaidRow.CMPP_FEE_NICHE !== '0.0') {
|
if (prepaidRow.CMPP_FEE_NICHE !== '0.0') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_NICHE', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_NICHE', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_NICHE,
|
feeAmount: prepaidRow.CMPP_FEE_NICHE,
|
||||||
taxAmount: prepaidRow.CMPP_GST_NICHE
|
taxAmount: prepaidRow.CMPP_GST_NICHE
|
||||||
|
|
@ -463,7 +463,7 @@ async function importFromPrepaidCSV() {
|
||||||
prepaidRow.CMPP_FEE_DISINTERMENT !== '20202.02') {
|
prepaidRow.CMPP_FEE_DISINTERMENT !== '20202.02') {
|
||||||
await addContractFee({
|
await addContractFee({
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT,
|
feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT,
|
||||||
taxAmount: prepaidRow.CMPP_GST_DISINTERMENT
|
taxAmount: prepaidRow.CMPP_GST_DISINTERMENT
|
||||||
|
|
@ -489,7 +489,7 @@ async function importFromPrepaidCSV() {
|
||||||
Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === '20202.02'
|
Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === '20202.02'
|
||||||
? '0'
|
? '0'
|
||||||
: prepaidRow.CMPP_GST_DISINTERMENT);
|
: prepaidRow.CMPP_GST_DISINTERMENT);
|
||||||
await addContractTransaction({
|
addContractTransaction({
|
||||||
contractId,
|
contractId,
|
||||||
externalReceiptNumber: '',
|
externalReceiptNumber: '',
|
||||||
transactionAmount,
|
transactionAmount,
|
||||||
|
|
@ -497,14 +497,14 @@ async function importFromPrepaidCSV() {
|
||||||
transactionNote: `Order Number: ${prepaidRow.CMPP_ORDER_NO}`
|
transactionNote: `Order Number: ${prepaidRow.CMPP_ORDER_NO}`
|
||||||
}, user);
|
}, user);
|
||||||
if (prepaidRow.CMPP_REMARK1 !== '') {
|
if (prepaidRow.CMPP_REMARK1 !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId,
|
contractId,
|
||||||
commentDateString: contractStartDateString,
|
commentDateString: contractStartDateString,
|
||||||
comment: prepaidRow.CMPP_REMARK1
|
comment: prepaidRow.CMPP_REMARK1
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
if (prepaidRow.CMPP_REMARK2 !== '') {
|
if (prepaidRow.CMPP_REMARK2 !== '') {
|
||||||
await addContractComment({
|
addContractComment({
|
||||||
contractId,
|
contractId,
|
||||||
commentDateString: contractStartDateString,
|
commentDateString: contractStartDateString,
|
||||||
comment: prepaidRow.CMPP_REMARK2
|
comment: prepaidRow.CMPP_REMARK2
|
||||||
|
|
@ -539,13 +539,13 @@ async function importFromWorkOrderCSV() {
|
||||||
const workOrderOpenDateString = dateIntegerToString(Number.parseInt(workOrderRow.WO_INITIATION_DATE, 10));
|
const workOrderOpenDateString = dateIntegerToString(Number.parseInt(workOrderRow.WO_INITIATION_DATE, 10));
|
||||||
if (workOrder) {
|
if (workOrder) {
|
||||||
if (workOrder.workOrderCloseDate) {
|
if (workOrder.workOrderCloseDate) {
|
||||||
await reopenWorkOrder(workOrder.workOrderId, user);
|
reopenWorkOrder(workOrder.workOrderId, user);
|
||||||
delete workOrder.workOrderCloseDate;
|
delete workOrder.workOrderCloseDate;
|
||||||
delete workOrder.workOrderCloseDateString;
|
delete workOrder.workOrderCloseDateString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const workOrderId = await addWorkOrder({
|
const workOrderId = addWorkOrder({
|
||||||
workOrderNumber,
|
workOrderNumber,
|
||||||
workOrderTypeId: importIds.workOrderTypeId,
|
workOrderTypeId: importIds.workOrderTypeId,
|
||||||
workOrderDescription: `${workOrderRow.WO_REMARK1} ${workOrderRow.WO_REMARK2} ${workOrderRow.WO_REMARK3}`.trim(),
|
workOrderDescription: `${workOrderRow.WO_REMARK1} ${workOrderRow.WO_REMARK2} ${workOrderRow.WO_REMARK3}`.trim(),
|
||||||
|
|
@ -577,12 +577,12 @@ async function importFromWorkOrderCSV() {
|
||||||
});
|
});
|
||||||
burialSite = await getBurialSiteByBurialSiteName(burialSiteName);
|
burialSite = await getBurialSiteByBurialSiteName(burialSiteName);
|
||||||
if (burialSite) {
|
if (burialSite) {
|
||||||
await updateBurialSiteStatus(burialSite.burialSiteId, importIds.takenBurialSiteStatusId, user);
|
updateBurialSiteStatus(burialSite.burialSiteId, importIds.takenBurialSiteStatusId, user);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const cemeteryId = await getCemeteryIdByKey(workOrderRow.WO_CEMETERY, user);
|
const cemeteryId = getCemeteryIdByKey(workOrderRow.WO_CEMETERY, user);
|
||||||
const burialSiteTypeId = getBurialSiteTypeId(workOrderRow.WO_CEMETERY);
|
const burialSiteTypeId = getBurialSiteTypeId(workOrderRow.WO_CEMETERY);
|
||||||
const burialSiteId = await addBurialSite({
|
const burialSiteKeys = addBurialSite({
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
burialSiteNameSegment2,
|
burialSiteNameSegment2,
|
||||||
burialSiteNameSegment3,
|
burialSiteNameSegment3,
|
||||||
|
|
@ -597,11 +597,11 @@ async function importFromWorkOrderCSV() {
|
||||||
burialSiteLatitude: '',
|
burialSiteLatitude: '',
|
||||||
burialSiteLongitude: ''
|
burialSiteLongitude: ''
|
||||||
}, user);
|
}, user);
|
||||||
burialSite = await getBurialSite(burialSiteId);
|
burialSite = await getBurialSite(burialSiteKeys.burialSiteId);
|
||||||
}
|
}
|
||||||
const workOrderContainsBurialSite = workOrder?.workOrderBurialSites?.find((possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId);
|
const workOrderContainsBurialSite = workOrder?.workOrderBurialSites?.find((possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId);
|
||||||
if (!workOrderContainsBurialSite) {
|
if (!workOrderContainsBurialSite) {
|
||||||
await addWorkOrderBurialSite({
|
addWorkOrderBurialSite({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
burialSiteId: burialSite.burialSiteId
|
burialSiteId: burialSite.burialSiteId
|
||||||
}, user);
|
}, user);
|
||||||
|
|
@ -617,19 +617,19 @@ async function importFromWorkOrderCSV() {
|
||||||
: importIds.cremationContractType;
|
: importIds.cremationContractType;
|
||||||
const funeralHomeId = workOrderRow.WO_FUNERAL_HOME === ''
|
const funeralHomeId = workOrderRow.WO_FUNERAL_HOME === ''
|
||||||
? ''
|
? ''
|
||||||
: await getFuneralHomeIdByKey(workOrderRow.WO_FUNERAL_HOME, user);
|
: getFuneralHomeIdByKey(workOrderRow.WO_FUNERAL_HOME, user);
|
||||||
const committalTypeId = contractType.contractType === 'Cremation' ||
|
const committalTypeId = contractType.contractType === 'Cremation' ||
|
||||||
workOrderRow.WO_COMMITTAL_TYPE === ''
|
workOrderRow.WO_COMMITTAL_TYPE === ''
|
||||||
? ''
|
? ''
|
||||||
: await getCommittalTypeIdByKey(workOrderRow.WO_COMMITTAL_TYPE, user);
|
: getCommittalTypeIdByKey(workOrderRow.WO_COMMITTAL_TYPE, user);
|
||||||
const intermentContainerTypeKey = contractType.contractType === 'Cremation' &&
|
const intermentContainerTypeKey = contractType.contractType === 'Cremation' &&
|
||||||
workOrderRow.WO_CONTAINER_TYPE !== ''
|
workOrderRow.WO_CONTAINER_TYPE !== ''
|
||||||
? 'U'
|
? 'U'
|
||||||
: workOrderRow.WO_CONTAINER_TYPE;
|
: workOrderRow.WO_CONTAINER_TYPE;
|
||||||
const intermentContainerTypeId = intermentContainerTypeKey === ''
|
const intermentContainerTypeId = intermentContainerTypeKey === ''
|
||||||
? ''
|
? ''
|
||||||
: await getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user);
|
: getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user);
|
||||||
const contractId = await addContract({
|
const contractId = addContract({
|
||||||
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
||||||
contractTypeId: contractType.contractTypeId,
|
contractTypeId: contractType.contractTypeId,
|
||||||
contractStartDateString,
|
contractStartDateString,
|
||||||
|
|
@ -654,7 +654,7 @@ async function importFromWorkOrderCSV() {
|
||||||
deathAgePeriod: getDeathAgePeriod(workOrderRow.WO_PERIOD),
|
deathAgePeriod: getDeathAgePeriod(workOrderRow.WO_PERIOD),
|
||||||
intermentContainerTypeId
|
intermentContainerTypeId
|
||||||
}, user);
|
}, user);
|
||||||
await addWorkOrderContract({
|
addWorkOrderContract({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
contractId
|
contractId
|
||||||
}, user);
|
}, user);
|
||||||
|
|
@ -662,7 +662,7 @@ async function importFromWorkOrderCSV() {
|
||||||
let hasIncompleteMilestones = !workOrderRow.WO_CONFIRMATION_IN;
|
let hasIncompleteMilestones = !workOrderRow.WO_CONFIRMATION_IN;
|
||||||
let maxMilestoneCompletionDateString = workOrderOpenDateString;
|
let maxMilestoneCompletionDateString = workOrderOpenDateString;
|
||||||
if (importIds.acknowledgedWorkOrderMilestoneTypeId) {
|
if (importIds.acknowledgedWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone({
|
addWorkOrderMilestone({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
workOrderMilestoneTypeId: importIds.acknowledgedWorkOrderMilestoneTypeId,
|
workOrderMilestoneTypeId: importIds.acknowledgedWorkOrderMilestoneTypeId,
|
||||||
workOrderMilestoneDateString: workOrderOpenDateString,
|
workOrderMilestoneDateString: workOrderOpenDateString,
|
||||||
|
|
@ -676,7 +676,7 @@ async function importFromWorkOrderCSV() {
|
||||||
if (workOrderRow.WO_DEATH_YR) {
|
if (workOrderRow.WO_DEATH_YR) {
|
||||||
const workOrderMilestoneDateString = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY);
|
const workOrderMilestoneDateString = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY);
|
||||||
if (importIds.deathWorkOrderMilestoneTypeId) {
|
if (importIds.deathWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone({
|
addWorkOrderMilestone({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
workOrderMilestoneTypeId: importIds.deathWorkOrderMilestoneTypeId,
|
workOrderMilestoneTypeId: importIds.deathWorkOrderMilestoneTypeId,
|
||||||
workOrderMilestoneDateString,
|
workOrderMilestoneDateString,
|
||||||
|
|
@ -704,7 +704,7 @@ async function importFromWorkOrderCSV() {
|
||||||
}
|
}
|
||||||
const workOrderMilestoneTimeString = formatTimeString(funeralHour.toString(), workOrderRow.WO_FUNERAL_MIN === '' ? '0' : workOrderRow.WO_FUNERAL_MIN);
|
const workOrderMilestoneTimeString = formatTimeString(funeralHour.toString(), workOrderRow.WO_FUNERAL_MIN === '' ? '0' : workOrderRow.WO_FUNERAL_MIN);
|
||||||
if (importIds.funeralWorkOrderMilestoneTypeId) {
|
if (importIds.funeralWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone({
|
addWorkOrderMilestone({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
workOrderMilestoneTypeId: importIds.funeralWorkOrderMilestoneTypeId,
|
workOrderMilestoneTypeId: importIds.funeralWorkOrderMilestoneTypeId,
|
||||||
workOrderMilestoneDateString,
|
workOrderMilestoneDateString,
|
||||||
|
|
@ -727,7 +727,7 @@ async function importFromWorkOrderCSV() {
|
||||||
}
|
}
|
||||||
if (workOrderRow.WO_CREMATION === 'Y' &&
|
if (workOrderRow.WO_CREMATION === 'Y' &&
|
||||||
importIds.cremationWorkOrderMilestoneTypeId) {
|
importIds.cremationWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone({
|
addWorkOrderMilestone({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
workOrderMilestoneTypeId: importIds.cremationWorkOrderMilestoneTypeId,
|
workOrderMilestoneTypeId: importIds.cremationWorkOrderMilestoneTypeId,
|
||||||
workOrderMilestoneDateString: maxMilestoneCompletionDateString,
|
workOrderMilestoneDateString: maxMilestoneCompletionDateString,
|
||||||
|
|
@ -743,7 +743,7 @@ async function importFromWorkOrderCSV() {
|
||||||
if (workOrderRow.WO_INTERMENT_YR) {
|
if (workOrderRow.WO_INTERMENT_YR) {
|
||||||
const workOrderMilestoneDateString = formatDateString(workOrderRow.WO_INTERMENT_YR, workOrderRow.WO_INTERMENT_MON, workOrderRow.WO_INTERMENT_DAY);
|
const workOrderMilestoneDateString = formatDateString(workOrderRow.WO_INTERMENT_YR, workOrderRow.WO_INTERMENT_MON, workOrderRow.WO_INTERMENT_DAY);
|
||||||
if (importIds.intermentWorkOrderMilestoneTypeId) {
|
if (importIds.intermentWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone({
|
addWorkOrderMilestone({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
workOrderMilestoneTypeId: importIds.intermentWorkOrderMilestoneTypeId,
|
workOrderMilestoneTypeId: importIds.intermentWorkOrderMilestoneTypeId,
|
||||||
workOrderMilestoneDateString,
|
workOrderMilestoneDateString,
|
||||||
|
|
@ -764,7 +764,7 @@ async function importFromWorkOrderCSV() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasIncompleteMilestones) {
|
if (!hasIncompleteMilestones) {
|
||||||
await closeWorkOrder({
|
closeWorkOrder({
|
||||||
workOrderId: workOrder.workOrderId,
|
workOrderId: workOrder.workOrderId,
|
||||||
workOrderCloseDateString: maxMilestoneCompletionDateString
|
workOrderCloseDateString: maxMilestoneCompletionDateString
|
||||||
}, user);
|
}, user);
|
||||||
|
|
@ -822,7 +822,7 @@ console.time('importFromCsv');
|
||||||
purgeTables();
|
purgeTables();
|
||||||
// purgeConfigTables()
|
// purgeConfigTables()
|
||||||
// Initialize SSM Data
|
// Initialize SSM Data
|
||||||
await initializeFuneralHomes(user);
|
initializeFuneralHomes(user);
|
||||||
// Do Imports
|
// Do Imports
|
||||||
await importFromMasterCSV();
|
await importFromMasterCSV();
|
||||||
await importFromPrepaidCSV();
|
await importFromPrepaidCSV();
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (masterRow of cmmaster.data) {
|
for (masterRow of cmmaster.data) {
|
||||||
const cemeteryId = await getCemeteryIdByKey(masterRow.CM_CEMETERY, user)
|
const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user)
|
||||||
|
|
||||||
const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY)
|
const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY)
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
|
|
||||||
burialSiteId =
|
burialSiteId =
|
||||||
burialSite === undefined
|
burialSite === undefined
|
||||||
? await addBurialSite(
|
? addBurialSite(
|
||||||
{
|
{
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
burialSiteNameSegment2,
|
burialSiteNameSegment2,
|
||||||
|
|
@ -155,7 +155,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
burialSiteLongitude: ''
|
burialSiteLongitude: ''
|
||||||
},
|
},
|
||||||
user
|
user
|
||||||
)
|
).burialSiteId
|
||||||
: burialSite.burialSiteId
|
: burialSite.burialSiteId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
const purchaserPostalCode =
|
const purchaserPostalCode =
|
||||||
`${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim()
|
`${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim()
|
||||||
|
|
||||||
preneedContractId = await addContract(
|
preneedContractId = addContract(
|
||||||
{
|
{
|
||||||
contractTypeId: importIds.preneedContractType.contractTypeId,
|
contractTypeId: importIds.preneedContractType.contractTypeId,
|
||||||
burialSiteId: burialSiteId ?? '',
|
burialSiteId: burialSiteId ?? '',
|
||||||
|
|
@ -259,7 +259,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (masterRow.CM_REMARK1 !== '') {
|
if (masterRow.CM_REMARK1 !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId: preneedContractId,
|
contractId: preneedContractId,
|
||||||
commentDateString: preneedContractStartDateString,
|
commentDateString: preneedContractStartDateString,
|
||||||
|
|
@ -271,7 +271,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masterRow.CM_REMARK2 !== '') {
|
if (masterRow.CM_REMARK2 !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId: preneedContractId,
|
contractId: preneedContractId,
|
||||||
|
|
||||||
|
|
@ -284,7 +284,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId: preneedContractId,
|
contractId: preneedContractId,
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contractEndDateString === '') {
|
if (contractEndDateString === '') {
|
||||||
await updateBurialSiteStatus(
|
updateBurialSiteStatus(
|
||||||
burialSiteId ?? '',
|
burialSiteId ?? '',
|
||||||
importIds.reservedBurialSiteStatusId,
|
importIds.reservedBurialSiteStatusId,
|
||||||
user
|
user
|
||||||
|
|
@ -353,7 +353,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
const funeralHomeId =
|
const funeralHomeId =
|
||||||
masterRow.CM_FUNERAL_HOME === ''
|
masterRow.CM_FUNERAL_HOME === ''
|
||||||
? ''
|
? ''
|
||||||
: await getFuneralHomeIdByKey(masterRow.CM_FUNERAL_HOME, user)
|
: getFuneralHomeIdByKey(masterRow.CM_FUNERAL_HOME, user)
|
||||||
|
|
||||||
const funeralDateString =
|
const funeralDateString =
|
||||||
masterRow.CM_FUNERAL_YR === ''
|
masterRow.CM_FUNERAL_YR === ''
|
||||||
|
|
@ -368,7 +368,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
contractType.contractType === 'Cremation' ||
|
contractType.contractType === 'Cremation' ||
|
||||||
masterRow.CM_COMMITTAL_TYPE === ''
|
masterRow.CM_COMMITTAL_TYPE === ''
|
||||||
? ''
|
? ''
|
||||||
: await getCommittalTypeIdByKey(masterRow.CM_COMMITTAL_TYPE, user)
|
: getCommittalTypeIdByKey(masterRow.CM_COMMITTAL_TYPE, user)
|
||||||
|
|
||||||
const deathDateString =
|
const deathDateString =
|
||||||
masterRow.CM_DEATH_YR === ''
|
masterRow.CM_DEATH_YR === ''
|
||||||
|
|
@ -388,12 +388,12 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
const intermentContainerTypeId =
|
const intermentContainerTypeId =
|
||||||
intermentContainerTypeKey === ''
|
intermentContainerTypeKey === ''
|
||||||
? ''
|
? ''
|
||||||
: await getIntermentContainerTypeIdByKey(
|
: getIntermentContainerTypeIdByKey(
|
||||||
intermentContainerTypeKey,
|
intermentContainerTypeKey,
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
deceasedContractId = await addContract(
|
deceasedContractId = addContract(
|
||||||
{
|
{
|
||||||
contractTypeId: contractType.contractTypeId,
|
contractTypeId: contractType.contractTypeId,
|
||||||
burialSiteId: burialSiteId ?? '',
|
burialSiteId: burialSiteId ?? '',
|
||||||
|
|
@ -440,7 +440,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (masterRow.CM_REMARK1 !== '') {
|
if (masterRow.CM_REMARK1 !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId: deceasedContractId,
|
contractId: deceasedContractId,
|
||||||
commentDateString: deceasedContractStartDateString,
|
commentDateString: deceasedContractStartDateString,
|
||||||
|
|
@ -452,7 +452,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masterRow.CM_REMARK2 !== '') {
|
if (masterRow.CM_REMARK2 !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId: deceasedContractId,
|
contractId: deceasedContractId,
|
||||||
commentDateString: deceasedContractStartDateString,
|
commentDateString: deceasedContractStartDateString,
|
||||||
|
|
@ -464,7 +464,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
if (masterRow.CM_WORK_ORDER.trim() !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId: deceasedContractId,
|
contractId: deceasedContractId,
|
||||||
commentDateString: deceasedContractStartDateString,
|
commentDateString: deceasedContractStartDateString,
|
||||||
|
|
@ -475,7 +475,7 @@ async function importFromMasterCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateBurialSiteStatus(
|
updateBurialSiteStatus(
|
||||||
burialSiteId ?? '',
|
burialSiteId ?? '',
|
||||||
importIds.takenBurialSiteStatusId,
|
importIds.takenBurialSiteStatusId,
|
||||||
user
|
user
|
||||||
|
|
@ -523,7 +523,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
let burialSite: recordTypes.BurialSite | undefined
|
let burialSite: recordTypes.BurialSite | undefined
|
||||||
|
|
||||||
if (cemeteryKey !== '') {
|
if (cemeteryKey !== '') {
|
||||||
const cemeteryId = await getCemeteryIdByKey(cemeteryKey, user)
|
const cemeteryId = getCemeteryIdByKey(cemeteryKey, user)
|
||||||
|
|
||||||
const burialSiteNameSegment1 =
|
const burialSiteNameSegment1 =
|
||||||
prepaidRow.CMPP_BLOCK === '0' ? '' : prepaidRow.CMPP_BLOCK
|
prepaidRow.CMPP_BLOCK === '0' ? '' : prepaidRow.CMPP_BLOCK
|
||||||
|
|
@ -556,7 +556,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
if (!burialSite) {
|
if (!burialSite) {
|
||||||
const burialSiteTypeId = getBurialSiteTypeId(cemeteryKey)
|
const burialSiteTypeId = getBurialSiteTypeId(cemeteryKey)
|
||||||
|
|
||||||
const burialSiteId = await addBurialSite(
|
const burialSiteKeys = addBurialSite(
|
||||||
{
|
{
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
burialSiteNameSegment2,
|
burialSiteNameSegment2,
|
||||||
|
|
@ -579,7 +579,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
burialSite = await getBurialSite(burialSiteId)
|
burialSite = await getBurialSite(burialSiteKeys.burialSiteId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -587,7 +587,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
burialSite &&
|
burialSite &&
|
||||||
burialSite.burialSiteStatusId === importIds.availableBurialSiteStatusId
|
burialSite.burialSiteStatusId === importIds.availableBurialSiteStatusId
|
||||||
) {
|
) {
|
||||||
await updateBurialSiteStatus(
|
updateBurialSiteStatus(
|
||||||
burialSite.burialSiteId,
|
burialSite.burialSiteId,
|
||||||
importIds.reservedBurialSiteStatusId,
|
importIds.reservedBurialSiteStatusId,
|
||||||
user
|
user
|
||||||
|
|
@ -624,7 +624,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contractId ||= await addContract(
|
contractId ||= addContract(
|
||||||
{
|
{
|
||||||
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
||||||
contractTypeId: importIds.preneedContractType.contractTypeId,
|
contractTypeId: importIds.preneedContractType.contractTypeId,
|
||||||
|
|
@ -647,7 +647,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_GRAV_SD,
|
feeAmount: prepaidRow.CMPP_FEE_GRAV_SD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_GRAV_SD
|
taxAmount: prepaidRow.CMPP_GST_GRAV_SD
|
||||||
|
|
@ -660,7 +660,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_GRAV_DD,
|
feeAmount: prepaidRow.CMPP_FEE_GRAV_DD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_GRAV_DD
|
taxAmount: prepaidRow.CMPP_GST_GRAV_DD
|
||||||
|
|
@ -673,7 +673,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_CHAP_SD,
|
feeAmount: prepaidRow.CMPP_FEE_CHAP_SD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_CHAP_SD
|
taxAmount: prepaidRow.CMPP_GST_CHAP_SD
|
||||||
|
|
@ -686,7 +686,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_CHAP_DD,
|
feeAmount: prepaidRow.CMPP_FEE_CHAP_DD,
|
||||||
taxAmount: prepaidRow.CMPP_GST_CHAP_DD
|
taxAmount: prepaidRow.CMPP_GST_CHAP_DD
|
||||||
|
|
@ -699,7 +699,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT,
|
feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT,
|
||||||
taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT
|
taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT
|
||||||
|
|
@ -712,7 +712,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_CREM', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_CREM', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_CREM,
|
feeAmount: prepaidRow.CMPP_FEE_CREM,
|
||||||
taxAmount: prepaidRow.CMPP_GST_CREM
|
taxAmount: prepaidRow.CMPP_GST_CREM
|
||||||
|
|
@ -725,7 +725,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription('CMPP_FEE_NICHE', user),
|
feeId: getFeeIdByFeeDescription('CMPP_FEE_NICHE', user),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
feeAmount: prepaidRow.CMPP_FEE_NICHE,
|
feeAmount: prepaidRow.CMPP_FEE_NICHE,
|
||||||
taxAmount: prepaidRow.CMPP_GST_NICHE
|
taxAmount: prepaidRow.CMPP_GST_NICHE
|
||||||
|
|
@ -741,7 +741,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
await addContractFee(
|
await addContractFee(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
feeId: await getFeeIdByFeeDescription(
|
feeId: getFeeIdByFeeDescription(
|
||||||
'CMPP_FEE_DISINTERMENT',
|
'CMPP_FEE_DISINTERMENT',
|
||||||
user
|
user
|
||||||
),
|
),
|
||||||
|
|
@ -779,7 +779,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
: prepaidRow.CMPP_GST_DISINTERMENT
|
: prepaidRow.CMPP_GST_DISINTERMENT
|
||||||
)
|
)
|
||||||
|
|
||||||
await addContractTransaction(
|
addContractTransaction(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
externalReceiptNumber: '',
|
externalReceiptNumber: '',
|
||||||
|
|
@ -791,7 +791,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (prepaidRow.CMPP_REMARK1 !== '') {
|
if (prepaidRow.CMPP_REMARK1 !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
commentDateString: contractStartDateString,
|
commentDateString: contractStartDateString,
|
||||||
|
|
@ -802,7 +802,7 @@ async function importFromPrepaidCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prepaidRow.CMPP_REMARK2 !== '') {
|
if (prepaidRow.CMPP_REMARK2 !== '') {
|
||||||
await addContractComment(
|
addContractComment(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
commentDateString: contractStartDateString,
|
commentDateString: contractStartDateString,
|
||||||
|
|
@ -852,12 +852,12 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
|
|
||||||
if (workOrder) {
|
if (workOrder) {
|
||||||
if (workOrder.workOrderCloseDate) {
|
if (workOrder.workOrderCloseDate) {
|
||||||
await reopenWorkOrder(workOrder.workOrderId!, user)
|
reopenWorkOrder(workOrder.workOrderId!, user)
|
||||||
delete workOrder.workOrderCloseDate
|
delete workOrder.workOrderCloseDate
|
||||||
delete workOrder.workOrderCloseDateString
|
delete workOrder.workOrderCloseDateString
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const workOrderId = await addWorkOrder(
|
const workOrderId = addWorkOrder(
|
||||||
{
|
{
|
||||||
workOrderNumber,
|
workOrderNumber,
|
||||||
workOrderTypeId: importIds.workOrderTypeId,
|
workOrderTypeId: importIds.workOrderTypeId,
|
||||||
|
|
@ -904,20 +904,17 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
burialSite = await getBurialSiteByBurialSiteName(burialSiteName)
|
burialSite = await getBurialSiteByBurialSiteName(burialSiteName)
|
||||||
|
|
||||||
if (burialSite) {
|
if (burialSite) {
|
||||||
await updateBurialSiteStatus(
|
updateBurialSiteStatus(
|
||||||
burialSite.burialSiteId,
|
burialSite.burialSiteId,
|
||||||
importIds.takenBurialSiteStatusId,
|
importIds.takenBurialSiteStatusId,
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
const cemeteryId = await getCemeteryIdByKey(
|
const cemeteryId = getCemeteryIdByKey(workOrderRow.WO_CEMETERY, user)
|
||||||
workOrderRow.WO_CEMETERY,
|
|
||||||
user
|
|
||||||
)
|
|
||||||
|
|
||||||
const burialSiteTypeId = getBurialSiteTypeId(workOrderRow.WO_CEMETERY)
|
const burialSiteTypeId = getBurialSiteTypeId(workOrderRow.WO_CEMETERY)
|
||||||
|
|
||||||
const burialSiteId = await addBurialSite(
|
const burialSiteKeys = addBurialSite(
|
||||||
{
|
{
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
burialSiteNameSegment2,
|
burialSiteNameSegment2,
|
||||||
|
|
@ -939,15 +936,17 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
burialSite = await getBurialSite(burialSiteId)
|
burialSite = await getBurialSite(burialSiteKeys.burialSiteId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const workOrderContainsBurialSite = workOrder?.workOrderBurialSites?.find(
|
const workOrderContainsBurialSite =
|
||||||
(possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId
|
workOrder?.workOrderBurialSites?.find(
|
||||||
)
|
(possibleLot) =>
|
||||||
|
possibleLot.burialSiteId === burialSite?.burialSiteId
|
||||||
|
)
|
||||||
|
|
||||||
if (!workOrderContainsBurialSite) {
|
if (!workOrderContainsBurialSite) {
|
||||||
await addWorkOrderBurialSite(
|
addWorkOrderBurialSite(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
burialSiteId: burialSite.burialSiteId
|
burialSiteId: burialSite.burialSiteId
|
||||||
|
|
@ -976,13 +975,13 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
const funeralHomeId =
|
const funeralHomeId =
|
||||||
workOrderRow.WO_FUNERAL_HOME === ''
|
workOrderRow.WO_FUNERAL_HOME === ''
|
||||||
? ''
|
? ''
|
||||||
: await getFuneralHomeIdByKey(workOrderRow.WO_FUNERAL_HOME, user)
|
: getFuneralHomeIdByKey(workOrderRow.WO_FUNERAL_HOME, user)
|
||||||
|
|
||||||
const committalTypeId =
|
const committalTypeId =
|
||||||
contractType.contractType === 'Cremation' ||
|
contractType.contractType === 'Cremation' ||
|
||||||
workOrderRow.WO_COMMITTAL_TYPE === ''
|
workOrderRow.WO_COMMITTAL_TYPE === ''
|
||||||
? ''
|
? ''
|
||||||
: await getCommittalTypeIdByKey(workOrderRow.WO_COMMITTAL_TYPE, user)
|
: getCommittalTypeIdByKey(workOrderRow.WO_COMMITTAL_TYPE, user)
|
||||||
|
|
||||||
const intermentContainerTypeKey =
|
const intermentContainerTypeKey =
|
||||||
contractType.contractType === 'Cremation' &&
|
contractType.contractType === 'Cremation' &&
|
||||||
|
|
@ -993,12 +992,12 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
const intermentContainerTypeId =
|
const intermentContainerTypeId =
|
||||||
intermentContainerTypeKey === ''
|
intermentContainerTypeKey === ''
|
||||||
? ''
|
? ''
|
||||||
: await getIntermentContainerTypeIdByKey(
|
: getIntermentContainerTypeIdByKey(
|
||||||
intermentContainerTypeKey,
|
intermentContainerTypeKey,
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
const contractId = await addContract(
|
const contractId = addContract(
|
||||||
{
|
{
|
||||||
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
||||||
contractTypeId: contractType.contractTypeId,
|
contractTypeId: contractType.contractTypeId,
|
||||||
|
|
@ -1041,7 +1040,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
await addWorkOrderContract(
|
addWorkOrderContract(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
contractId
|
contractId
|
||||||
|
|
@ -1055,7 +1054,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
let maxMilestoneCompletionDateString = workOrderOpenDateString
|
let maxMilestoneCompletionDateString = workOrderOpenDateString
|
||||||
|
|
||||||
if (importIds.acknowledgedWorkOrderMilestoneTypeId) {
|
if (importIds.acknowledgedWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone(
|
addWorkOrderMilestone(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
workOrderMilestoneTypeId:
|
workOrderMilestoneTypeId:
|
||||||
|
|
@ -1081,7 +1080,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (importIds.deathWorkOrderMilestoneTypeId) {
|
if (importIds.deathWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone(
|
addWorkOrderMilestone(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
workOrderMilestoneTypeId: importIds.deathWorkOrderMilestoneTypeId,
|
workOrderMilestoneTypeId: importIds.deathWorkOrderMilestoneTypeId,
|
||||||
|
|
@ -1130,7 +1129,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (importIds.funeralWorkOrderMilestoneTypeId) {
|
if (importIds.funeralWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone(
|
addWorkOrderMilestone(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
workOrderMilestoneTypeId:
|
workOrderMilestoneTypeId:
|
||||||
|
|
@ -1164,7 +1163,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
workOrderRow.WO_CREMATION === 'Y' &&
|
workOrderRow.WO_CREMATION === 'Y' &&
|
||||||
importIds.cremationWorkOrderMilestoneTypeId
|
importIds.cremationWorkOrderMilestoneTypeId
|
||||||
) {
|
) {
|
||||||
await addWorkOrderMilestone(
|
addWorkOrderMilestone(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
workOrderMilestoneTypeId:
|
workOrderMilestoneTypeId:
|
||||||
|
|
@ -1192,7 +1191,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (importIds.intermentWorkOrderMilestoneTypeId) {
|
if (importIds.intermentWorkOrderMilestoneTypeId) {
|
||||||
await addWorkOrderMilestone(
|
addWorkOrderMilestone(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
workOrderMilestoneTypeId:
|
workOrderMilestoneTypeId:
|
||||||
|
|
@ -1222,7 +1221,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasIncompleteMilestones) {
|
if (!hasIncompleteMilestones) {
|
||||||
await closeWorkOrder(
|
closeWorkOrder(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId!,
|
workOrderId: workOrder.workOrderId!,
|
||||||
workOrderCloseDateString: maxMilestoneCompletionDateString
|
workOrderCloseDateString: maxMilestoneCompletionDateString
|
||||||
|
|
@ -1295,7 +1294,7 @@ purgeTables()
|
||||||
// purgeConfigTables()
|
// purgeConfigTables()
|
||||||
|
|
||||||
// Initialize SSM Data
|
// Initialize SSM Data
|
||||||
await initializeFuneralHomes(user)
|
initializeFuneralHomes(user)
|
||||||
|
|
||||||
// Do Imports
|
// Do Imports
|
||||||
await importFromMasterCSV()
|
await importFromMasterCSV()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue