Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ collection: 'crm_configurations', timestamps: true }) export class CrmConfiguration extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true, unique: true, }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ default: true }) crmEnabled!: boolean; @Prop({ default: 'new' }) defaultLeadStatus!: string; @Prop({ default: 'round-robin' }) defaultLeadOwnerRule!: string; @Prop() defaultPipelineId?: string; @Prop({ default: 'INR' }) defaultCurrency!: string; @Prop({ default: 'IN' }) defaultCountry!: string; @Prop({ default: true }) leadScoringEnabled!: boolean; @Prop({ default: true }) duplicateDetectionEnabled!: boolean; @Prop({ default: true }) assignmentAutomationEnabled!: boolean; @Prop({ default: true }) roundRobinEnabled!: boolean; @Prop({ default: false }) territoryRoutingEnabled!: boolean; @Prop({ default: true }) webToLeadEnabled!: boolean; @Prop({ default: true }) emailTrackingEnabled!: boolean; @Prop({ default: true }) WhatsAppTrackingEnabled!: boolean; @Prop({ default: true }) automaticActivityLogging!: boolean; @Prop({ default: true }) quotationApprovalRequired!: boolean; @Prop({ default: true }) proposalApprovalRequired!: boolean; @Prop({ default: true }) contractApprovalRequired!: boolean; @Prop({ default: false }) customerOnboardingRequired!: boolean; @Prop({ default: true }) lostReasonRequired!: boolean; @Prop({ default: 30 }) staleLeadDays!: number; @Prop({ default: 60 }) staleOpportunityDays!: number; @Prop({ default: true }) followUpReminderEnabled!: boolean; @Prop({ default: true }) salesForecastEnabled!: boolean; @Prop({ default: true }) aiLeadScoringEnabled!: boolean; @Prop({ default: true }) aiNextBestActionEnabled!: boolean; @Prop({ default: true }) customerPortalEnabled!: boolean; @Prop({ default: false }) externalContactAccessEnabled!: boolean; } export const CrmConfigurationSchema = SchemaFactory.createForClass(CrmConfiguration); @Schema({ collection: 'crm_configuration_versions', timestamps: true }) export class CrmConfigurationVersion extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ required: true }) versionNumber!: number; @Prop({ type: MongooseSchema.Types.Mixed, required: true }) configurationData!: any; @Prop({ type: MongooseSchema.Types.ObjectId }) publishedBy!: MongooseSchema.Types.ObjectId; @Prop() description?: string; } export const CrmConfigurationVersionSchema = SchemaFactory.createForClass( CrmConfigurationVersion, ); CrmConfigurationVersionSchema.index( { tenantId: 1, versionNumber: 1 }, { unique: true }, ); @Schema({ collection: 'crm_numbering_rules', timestamps: true }) export class CrmNumberingRule extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ required: true, enum: [ 'lead', 'account', 'contact', 'opportunity', 'quotation', 'contract', ], }) entityType!: string; @Prop({ required: true }) prefix!: string; // e.g. "LEAD-" @Prop({ default: 6 }) paddingLength!: number; // e.g. 6 -> "000001" @Prop({ default: 1 }) startNumber!: number; } export const CrmNumberingRuleSchema = SchemaFactory.createForClass(CrmNumberingRule); CrmNumberingRuleSchema.index({ tenantId: 1, entityType: 1 }, { unique: true }); @Schema({ collection: 'crm_number_sequences', timestamps: true }) export class CrmNumberSequence extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ required: true }) entityType!: string; @Prop({ required: true, default: 0 }) currentNumber!: number; } export const CrmNumberSequenceSchema = SchemaFactory.createForClass(CrmNumberSequence); CrmNumberSequenceSchema.index({ tenantId: 1, entityType: 1 }, { unique: true }); |