99 lines
2.1 KiB
TypeScript
99 lines
2.1 KiB
TypeScript
import z from 'zod';
|
|
import mongoose from 'mongoose';
|
|
import { pageQueryParams } from '../pagination';
|
|
import { buildJsonSchemas } from 'fastify-zod';
|
|
|
|
const processedSchema = new mongoose.Schema({
|
|
tenantId: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
pid: {
|
|
type: String,
|
|
unique: true,
|
|
},
|
|
permitNumber: String,
|
|
county: Object,
|
|
client: {
|
|
type: mongoose.Types.ObjectId,
|
|
ref: 'organization',
|
|
},
|
|
clientData: Object,
|
|
permitDate: Date,
|
|
stage: new mongoose.Schema(
|
|
{
|
|
pipeline: Array,
|
|
currentStage: Number,
|
|
},
|
|
{ _id: false }
|
|
),
|
|
status: String,
|
|
manualStatus: String,
|
|
cleanStatus: String,
|
|
utility: String,
|
|
assignedTo: {
|
|
type: mongoose.Types.ObjectId,
|
|
ref: 'user',
|
|
},
|
|
link: String,
|
|
address: Object,
|
|
recordType: String,
|
|
description: String,
|
|
applicationDetails: Object,
|
|
applicationInfo: Object,
|
|
applicationInfoTable: Object,
|
|
conditions: Array,
|
|
ownerDetails: String,
|
|
parcelInfo: Object,
|
|
paymentData: Object,
|
|
professionalsList: Array,
|
|
inspections: Object,
|
|
createdAt: Date,
|
|
createdBy: {
|
|
type: mongoose.Types.ObjectId,
|
|
ref: 'user',
|
|
},
|
|
newProcessingStatus: Array,
|
|
newPayment: Array,
|
|
newConditions: Array,
|
|
professionals: Object,
|
|
recordId: String,
|
|
relatedRecords: Object,
|
|
accelaStatus: String,
|
|
openDate: Date,
|
|
lastUpdateDate: Date,
|
|
statusUpdated: Date,
|
|
transferDate: Date,
|
|
}).index({ tenantId: 1, permitNumber: 1 }, { unique: true });
|
|
|
|
export const processedFields = Object.keys(processedSchema.paths).filter(
|
|
(path) => path !== '__v'
|
|
);
|
|
|
|
export const processedModel = mongoose.model(
|
|
'processed',
|
|
processedSchema,
|
|
'processed'
|
|
);
|
|
|
|
const updateProcessedInput = z.object({
|
|
manualStatus: z
|
|
.enum(['Ready To Issue', 'Issued', 'Invoiced', 'Paid', 'Closed'])
|
|
.nullable()
|
|
.optional(),
|
|
utility: z
|
|
.enum(['Submitted', 'Pending', 'Applied', 'Rejected', 'Paid'])
|
|
.nullable()
|
|
.optional(),
|
|
});
|
|
|
|
export type UpdateProcessedInput = z.infer<typeof updateProcessedInput>;
|
|
|
|
export const { schemas: processedSchemas, $ref: $processed } = buildJsonSchemas(
|
|
{
|
|
pageQueryParams,
|
|
updateProcessedInput,
|
|
},
|
|
{ $id: 'processed' }
|
|
);
|