138 lines
3.0 KiB
TypeScript
138 lines
3.0 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: {
|
|
id: mongoose.Types.ObjectId,
|
|
pid: String,
|
|
name: String,
|
|
avatar: String,
|
|
},
|
|
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,
|
|
permitType: 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: [
|
|
{
|
|
last_modified_date: Date,
|
|
description: String,
|
|
status: String,
|
|
assigned_user_text: String,
|
|
due_date: Date,
|
|
is_completed: String,
|
|
comment: String,
|
|
},
|
|
],
|
|
newPayment: [
|
|
{
|
|
apply_date: String,
|
|
invoice_id: Number,
|
|
amount: Number,
|
|
balance_due: Number,
|
|
code_text: String,
|
|
status: String,
|
|
},
|
|
],
|
|
newConditions: [
|
|
{
|
|
status_date: Date,
|
|
status_value: String,
|
|
short_comments: String,
|
|
name: String,
|
|
},
|
|
],
|
|
professionals: Object,
|
|
recordId: String,
|
|
relatedRecords: Object,
|
|
accelaStatus: String,
|
|
openDate: Date,
|
|
lastUpdateDate: Date,
|
|
statusUpdated: Date,
|
|
issuedDate: Date,
|
|
communityName: String,
|
|
lot: String,
|
|
block: String,
|
|
jobNumber: String,
|
|
startDate: Date,
|
|
history: Array,
|
|
taggedUsers: Array,
|
|
}).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.string().nullable().optional(),
|
|
utility: z.string().nullable().optional(),
|
|
communityName: z.string().nullable().optional(),
|
|
lot: z.string().nullable().optional(),
|
|
block: z.string().nullable().optional(),
|
|
jobNumber: z.string().nullable().optional(),
|
|
startDate: z.date().nullable().optional(),
|
|
assignedTo: z.string().nullable().optional(),
|
|
});
|
|
|
|
export type UpdateProcessedInput = z.infer<typeof updateProcessedInput>;
|
|
|
|
export const { schemas: processedSchemas, $ref: $processed } = buildJsonSchemas(
|
|
{
|
|
pageQueryParams,
|
|
updateProcessedInput,
|
|
},
|
|
{ $id: "processed" }
|
|
);
|