code cleanup
parent
f6721dfc60
commit
535c2c50f1
|
|
@ -20,7 +20,7 @@ cluster.setupPrimary(clusterSettings);
|
||||||
const activeWorkers = new Map();
|
const activeWorkers = new Map();
|
||||||
for (let index = 0; index < processCount; index += 1) {
|
for (let index = 0; index < processCount; index += 1) {
|
||||||
const worker = cluster.fork();
|
const worker = cluster.fork();
|
||||||
activeWorkers.set(worker.process.pid, worker);
|
activeWorkers.set(worker.process.pid ?? 0, worker);
|
||||||
}
|
}
|
||||||
cluster.on('message', (worker, message) => {
|
cluster.on('message', (worker, message) => {
|
||||||
for (const [pid, activeWorker] of activeWorkers.entries()) {
|
for (const [pid, activeWorker] of activeWorkers.entries()) {
|
||||||
|
|
@ -31,9 +31,9 @@ cluster.on('message', (worker, message) => {
|
||||||
worker.send(message);
|
worker.send(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cluster.on('exit', (worker, code, signal) => {
|
cluster.on('exit', (worker) => {
|
||||||
debug(`Worker ${worker.process.pid.toString()} has been killed`);
|
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`);
|
||||||
activeWorkers.delete(worker.process.pid);
|
activeWorkers.delete(worker.process.pid ?? 0);
|
||||||
debug('Starting another worker');
|
debug('Starting another worker');
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ const activeWorkers = new Map<number, Worker>()
|
||||||
|
|
||||||
for (let index = 0; index < processCount; index += 1) {
|
for (let index = 0; index < processCount; index += 1) {
|
||||||
const worker = cluster.fork()
|
const worker = cluster.fork()
|
||||||
activeWorkers.set(worker.process.pid!, worker)
|
activeWorkers.set(worker.process.pid ?? 0, worker)
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster.on('message', (worker, message: WorkerMessage) => {
|
cluster.on('message', (worker, message: WorkerMessage) => {
|
||||||
|
|
@ -51,9 +51,9 @@ cluster.on('message', (worker, message: WorkerMessage) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
cluster.on('exit', (worker, code, signal) => {
|
cluster.on('exit', (worker) => {
|
||||||
debug(`Worker ${worker.process.pid!.toString()} has been killed`)
|
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`)
|
||||||
activeWorkers.delete(worker.process.pid!)
|
activeWorkers.delete(worker.process.pid ?? 0)
|
||||||
|
|
||||||
debug('Starting another worker')
|
debug('Starting another worker')
|
||||||
cluster.fork()
|
cluster.fork()
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export async function addLotOccupancyFee(lotOccupancyFeeForm, user) {
|
||||||
let taxAmount;
|
let taxAmount;
|
||||||
if ((lotOccupancyFeeForm.feeAmount ?? '') === '') {
|
if ((lotOccupancyFeeForm.feeAmount ?? '') === '') {
|
||||||
const lotOccupancy = (await getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId));
|
const lotOccupancy = (await getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId));
|
||||||
const fee = await getFee(lotOccupancyFeeForm.feeId);
|
const fee = (await getFee(lotOccupancyFeeForm.feeId));
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
import type { LotOccupancy } from '../types/recordTypes.js'
|
import {
|
||||||
import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js'
|
calculateFeeAmount,
|
||||||
|
calculateTaxAmount
|
||||||
|
} from '../helpers/functions.fee.js'
|
||||||
|
import type { Fee, LotOccupancy } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import { getFee } from './getFee.js'
|
import { getFee } from './getFee.js'
|
||||||
import { getLotOccupancy } from './getLotOccupancy.js'
|
import { getLotOccupancy } from './getLotOccupancy.js'
|
||||||
|
|
@ -30,7 +33,7 @@ export async function addLotOccupancyFee(
|
||||||
lotOccupancyFeeForm.lotOccupancyId
|
lotOccupancyFeeForm.lotOccupancyId
|
||||||
)) as LotOccupancy
|
)) as LotOccupancy
|
||||||
|
|
||||||
const fee = await getFee(lotOccupancyFeeForm.feeId)
|
const fee = (await getFee(lotOccupancyFeeForm.feeId)) as Fee
|
||||||
|
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy)
|
feeAmount = calculateFeeAmount(fee, lotOccupancy)
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount)
|
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||||
|
|
|
||||||
|
|
@ -136,14 +136,14 @@ async function addInclusions(
|
||||||
): Promise<LotOccupancy> {
|
): Promise<LotOccupancy> {
|
||||||
if (options.includeFees) {
|
if (options.includeFees) {
|
||||||
lotOccupancy.lotOccupancyFees = await getLotOccupancyFees(
|
lotOccupancy.lotOccupancyFees = await getLotOccupancyFees(
|
||||||
lotOccupancy.lotOccupancyId!,
|
lotOccupancy.lotOccupancyId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.includeTransactions) {
|
if (options.includeTransactions) {
|
||||||
lotOccupancy.lotOccupancyTransactions = await getLotOccupancyTransactions(
|
lotOccupancy.lotOccupancyTransactions = await getLotOccupancyTransactions(
|
||||||
lotOccupancy.lotOccupancyId!,
|
lotOccupancy.lotOccupancyId,
|
||||||
{ includeIntegrations: false },
|
{ includeIntegrations: false },
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
@ -151,7 +151,7 @@ async function addInclusions(
|
||||||
|
|
||||||
if (options.includeOccupants) {
|
if (options.includeOccupants) {
|
||||||
lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants(
|
lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants(
|
||||||
lotOccupancy.lotOccupancyId!,
|
lotOccupancy.lotOccupancyId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ async function addInclusions(
|
||||||
): Promise<WorkOrder> {
|
): Promise<WorkOrder> {
|
||||||
if (options.includeComments ?? false) {
|
if (options.includeComments ?? false) {
|
||||||
workOrder.workOrderComments = await getWorkOrderComments(
|
workOrder.workOrderComments = await getWorkOrderComments(
|
||||||
workOrder.workOrderId!,
|
workOrder.workOrderId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ export async function moveFeeUp(feeId) {
|
||||||
}
|
}
|
||||||
export async function moveFeeUpToTop(feeId) {
|
export async function moveFeeUpToTop(feeId) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const currentFee = await getFee(feeId, database);
|
const currentFee = (await getFee(feeId, database));
|
||||||
if (currentFee.orderNumber > 0) {
|
if (currentFee.orderNumber > 0) {
|
||||||
updateRecordOrderNumber('Fees', feeId, -1, database);
|
updateRecordOrderNumber('Fees', feeId, -1, database);
|
||||||
database
|
database
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Fee } from '../types/recordTypes.js'
|
||||||
import { getFee } from './getFee.js'
|
import { getFee } from './getFee.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||||
|
|
@ -100,7 +101,7 @@ export async function moveFeeUp(feeId: number): Promise<boolean> {
|
||||||
export async function moveFeeUpToTop(feeId: number | string): Promise<boolean> {
|
export async function moveFeeUpToTop(feeId: number | string): Promise<boolean> {
|
||||||
const database = await acquireConnection()
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const currentFee = await getFee(feeId, database)
|
const currentFee = (await getFee(feeId, database)) as Fee
|
||||||
|
|
||||||
if (currentFee.orderNumber! > 0) {
|
if (currentFee.orderNumber! > 0) {
|
||||||
updateRecordOrderNumber('Fees', feeId, -1, database)
|
updateRecordOrderNumber('Fees', feeId, -1, database)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export async function handler(
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const startDate = new Date()
|
const startDate = new Date()
|
||||||
|
|
||||||
const lotOccupancy: LotOccupancy = {
|
const lotOccupancy: Partial<LotOccupancy> = {
|
||||||
occupancyStartDate: dateToInteger(startDate),
|
occupancyStartDate: dateToInteger(startDate),
|
||||||
occupancyStartDateString: dateToString(startDate)
|
occupancyStartDateString: dateToString(startDate)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export async function handler(
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const currentDate = new Date()
|
const currentDate = new Date()
|
||||||
|
|
||||||
const workOrder: WorkOrder = {
|
const workOrder: Partial<WorkOrder> = {
|
||||||
workOrderOpenDate: dateToInteger(currentDate),
|
workOrderOpenDate: dateToInteger(currentDate),
|
||||||
workOrderOpenDateString: dateToString(currentDate)
|
workOrderOpenDateString: dateToString(currentDate)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,12 +187,12 @@ export interface LotOccupancyComment extends Record {
|
||||||
lotOccupancyComment?: string;
|
lotOccupancyComment?: string;
|
||||||
}
|
}
|
||||||
export interface LotOccupancyField extends OccupancyTypeField, Record {
|
export interface LotOccupancyField extends OccupancyTypeField, Record {
|
||||||
lotOccupancyId?: number;
|
lotOccupancyId: number;
|
||||||
occupancyTypeFieldId?: number;
|
occupancyTypeFieldId: number;
|
||||||
lotOccupancyFieldValue?: string;
|
lotOccupancyFieldValue?: string;
|
||||||
}
|
}
|
||||||
export interface LotOccupancy extends Record {
|
export interface LotOccupancy extends Record {
|
||||||
lotOccupancyId?: number;
|
lotOccupancyId: number;
|
||||||
occupancyTypeId?: number;
|
occupancyTypeId?: number;
|
||||||
occupancyType?: string;
|
occupancyType?: string;
|
||||||
printEJS?: string;
|
printEJS?: string;
|
||||||
|
|
|
||||||
|
|
@ -245,13 +245,13 @@ export interface LotOccupancyComment extends Record {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LotOccupancyField extends OccupancyTypeField, Record {
|
export interface LotOccupancyField extends OccupancyTypeField, Record {
|
||||||
lotOccupancyId?: number
|
lotOccupancyId: number
|
||||||
occupancyTypeFieldId?: number
|
occupancyTypeFieldId: number
|
||||||
lotOccupancyFieldValue?: string
|
lotOccupancyFieldValue?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LotOccupancy extends Record {
|
export interface LotOccupancy extends Record {
|
||||||
lotOccupancyId?: number
|
lotOccupancyId: number
|
||||||
|
|
||||||
occupancyTypeId?: number
|
occupancyTypeId?: number
|
||||||
occupancyType?: string
|
occupancyType?: string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue