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