Opportunity fields (#744)

* Add opportunity probability and point of contact

* Have requests sent properly

* Add probaility field
This commit is contained in:
Emilien Chauvet
2023-07-18 17:32:15 -07:00
committed by GitHub
parent 87a116d369
commit f98e49c26e
7 changed files with 139 additions and 21 deletions

View File

@ -68,6 +68,20 @@ export class PipelineProgressResolver {
@PrismaSelector({ modelName: 'PipelineProgress' })
prismaSelect: PrismaSelect<'PipelineProgress'>,
): Promise<Partial<PipelineProgress> | null> {
// TODO: Do a proper check with recursion testing on args in a more generic place
for (const key in args.data) {
if (args.data[key]) {
for (const subKey in args.data[key]) {
if (JSON.stringify(args.data[key][subKey]) === '{}') {
delete args.data[key][subKey];
}
}
}
if (JSON.stringify(args.data[key]) === '{}') {
delete args.data[key];
}
}
return this.pipelineProgressService.update({
where: args.where,
data: args.data,

View File

@ -0,0 +1,15 @@
/*
Warnings:
- Made the column `settingsId` on table `users` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" ADD COLUMN "pointOfContactId" TEXT,
ADD COLUMN "probability" INTEGER;
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "settingsId" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_pointOfContactId_fkey" FOREIGN KEY ("pointOfContactId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -251,8 +251,9 @@ model Person {
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
PipelineProgress PipelineProgress[]
@@map("people")
}
@ -436,14 +437,17 @@ enum PipelineProgressableType {
model PipelineProgress {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
amount Int?
closeDate DateTime?
id String @id @default(uuid())
amount Int?
closeDate DateTime?
probability Int?
pipeline Pipeline @relation(fields: [pipelineId], references: [id])
pipelineId String
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id])
pipelineStageId String
pointOfContact Person? @relation(fields: [pointOfContactId], references: [id])
pointOfContactId String?
progressableType PipelineProgressableType
progressableId String
/// @TypeGraphQL.omit(input: true, output: true)