feat: restructure sales, add PDF quote generation and WebSocket support
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "GeneratedQuotes" (
|
||||
"id" TEXT NOT NULL,
|
||||
"quoteFile" BYTEA NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "GeneratedQuotes_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `opportunityId` to the `GeneratedQuotes` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `quoteFileName` to the `GeneratedQuotes` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `quoteRegenData` to the `GeneratedQuotes` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "GeneratedQuotes" ADD COLUMN "createdById" TEXT,
|
||||
ADD COLUMN "opportunityId" TEXT NOT NULL,
|
||||
ADD COLUMN "quoteFileName" TEXT NOT NULL,
|
||||
ADD COLUMN "quoteRegenData" JSONB NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "GeneratedQuotes" ADD CONSTRAINT "GeneratedQuotes_opportunityId_fkey" FOREIGN KEY ("opportunityId") REFERENCES "Opportunity"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "GeneratedQuotes" ADD CONSTRAINT "GeneratedQuotes_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+28
-2
@@ -41,8 +41,9 @@ model User {
|
||||
|
||||
sessions Session[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
generatedQuotes GeneratedQuotes[]
|
||||
}
|
||||
|
||||
model Role {
|
||||
@@ -130,6 +131,8 @@ model Opportunity {
|
||||
name String
|
||||
notes String?
|
||||
|
||||
generatedQuotes GeneratedQuotes[]
|
||||
|
||||
// Stage / status / priority / type / rating stored as JSON references
|
||||
// so we don't need separate lookup tables for CW enums
|
||||
typeName String?
|
||||
@@ -165,6 +168,7 @@ model Opportunity {
|
||||
|
||||
// Financials
|
||||
totalSalesTax Float @default(0)
|
||||
probability Float @default(0)
|
||||
|
||||
// Location / department
|
||||
locationName String?
|
||||
@@ -244,3 +248,25 @@ model Credential {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model GeneratedQuotes {
|
||||
id String @id @default(uuid())
|
||||
|
||||
quoteRegenData Json @default("{}") // Store any additional data needed for quote regeneration, such as product details, pricing, etc.
|
||||
quoteRegenParams Json @default("{}") // Store parameters used for quote regeneration, such as template ID, formatting options, etc.
|
||||
quoteRegenHash String @unique @default("")
|
||||
|
||||
downloads Json @default("[]") // Array of download records with timestamp and user info
|
||||
|
||||
quoteFile Bytes
|
||||
quoteFileName String
|
||||
|
||||
opportunityId String
|
||||
opportunity Opportunity @relation(fields: [opportunityId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdById String?
|
||||
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user