Add full project files
This commit is contained in:
@@ -0,0 +1,316 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "UserRole" AS ENUM ('ADMIN', 'PRODUCER', 'SUPERVISOR', 'ARTIST');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "JobStatus" AS ENUM ('DRAFT', 'SENT', 'APPROVED', 'REJECTED', 'ARCHIVED');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "users" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT,
|
||||
"email" TEXT NOT NULL,
|
||||
"emailVerified" TIMESTAMP(3),
|
||||
"image" TEXT,
|
||||
"password" TEXT,
|
||||
"role" "UserRole" NOT NULL DEFAULT 'ARTIST',
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "accounts" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"provider" TEXT NOT NULL,
|
||||
"providerAccountId" TEXT NOT NULL,
|
||||
"refresh_token" TEXT,
|
||||
"access_token" TEXT,
|
||||
"expires_at" INTEGER,
|
||||
"token_type" TEXT,
|
||||
"scope" TEXT,
|
||||
"id_token" TEXT,
|
||||
"session_state" TEXT,
|
||||
|
||||
CONSTRAINT "accounts_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "sessions" (
|
||||
"id" TEXT NOT NULL,
|
||||
"sessionToken" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "sessions_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "verification_tokens" (
|
||||
"identifier" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "clients" (
|
||||
"id" TEXT NOT NULL,
|
||||
"companyName" TEXT NOT NULL,
|
||||
"contactPerson" TEXT,
|
||||
"email" TEXT,
|
||||
"phone" TEXT,
|
||||
"vatNumber" TEXT,
|
||||
"companyRegNumber" TEXT,
|
||||
"billingAddress" TEXT,
|
||||
"notes" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "clients_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "jobs" (
|
||||
"id" TEXT NOT NULL,
|
||||
"projectTitle" TEXT NOT NULL,
|
||||
"projectCode" TEXT NOT NULL,
|
||||
"clientId" TEXT NOT NULL,
|
||||
"createdById" TEXT,
|
||||
"issueDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"expiryDate" TIMESTAMP(3),
|
||||
"currency" TEXT NOT NULL DEFAULT 'USD',
|
||||
"status" "JobStatus" NOT NULL DEFAULT 'DRAFT',
|
||||
"description" TEXT,
|
||||
"internalNotes" TEXT,
|
||||
"markupPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"taxPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"discountPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"customHeaderHtml" TEXT,
|
||||
"customFooterHtml" TEXT,
|
||||
"termsAndConditions" TEXT,
|
||||
"version" INTEGER NOT NULL DEFAULT 1,
|
||||
"parentJobId" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "jobs_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "job_history" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"field" TEXT NOT NULL,
|
||||
"oldValue" TEXT,
|
||||
"newValue" TEXT,
|
||||
"changedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"changedBy" TEXT,
|
||||
|
||||
CONSTRAINT "job_history_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "comments" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"userId" TEXT,
|
||||
"body" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "comments_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "rate_cards" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"department" TEXT,
|
||||
"defaultDailyRate" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"hoursPerDay" DECIMAL(5,2) NOT NULL DEFAULT 8,
|
||||
"currency" TEXT NOT NULL DEFAULT 'USD',
|
||||
"notes" TEXT,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "rate_cards_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "shot_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "shot_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "shot_line_item_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"templateId" TEXT NOT NULL,
|
||||
"taskName" TEXT NOT NULL,
|
||||
"artistRole" TEXT,
|
||||
"defaultHours" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"rateCardId" TEXT,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
CONSTRAINT "shot_line_item_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "asset_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "asset_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "asset_line_item_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"templateId" TEXT NOT NULL,
|
||||
"taskName" TEXT NOT NULL,
|
||||
"artistRole" TEXT,
|
||||
"defaultHours" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"rateCardId" TEXT,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
CONSTRAINT "asset_line_item_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "shots" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"shotCode" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"durationSeconds" INTEGER,
|
||||
"complexityMultiplier" DECIMAL(5,4) NOT NULL DEFAULT 1,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "shots_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "assets" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"assetName" TEXT NOT NULL,
|
||||
"assetType" TEXT,
|
||||
"description" TEXT,
|
||||
"complexityMultiplier" DECIMAL(5,4) NOT NULL DEFAULT 1,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "assets_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "line_items" (
|
||||
"id" TEXT NOT NULL,
|
||||
"shotId" TEXT,
|
||||
"assetId" TEXT,
|
||||
"rateCardId" TEXT,
|
||||
"taskName" TEXT NOT NULL,
|
||||
"artistRole" TEXT,
|
||||
"quantityHours" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"dailyRate" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"hoursPerDay" DECIMAL(5,2) NOT NULL DEFAULT 8,
|
||||
"numArtists" DECIMAL(5,2) NOT NULL DEFAULT 1,
|
||||
"numDays" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"manualHourlyRate" DECIMAL(10,4),
|
||||
"manualSubtotal" DECIMAL(14,4),
|
||||
"markupPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"discountPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"taxPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"hourlyRate" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"subtotal" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"markupAmount" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"discountAmount" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"taxAmount" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"total" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "line_items_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "accounts_provider_providerAccountId_key" ON "accounts"("provider", "providerAccountId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "sessions_sessionToken_key" ON "sessions"("sessionToken");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "verification_tokens_token_key" ON "verification_tokens"("token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "verification_tokens_identifier_token_key" ON "verification_tokens"("identifier", "token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "jobs_projectCode_key" ON "jobs"("projectCode");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "jobs" ADD CONSTRAINT "jobs_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "clients"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "jobs" ADD CONSTRAINT "jobs_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "jobs" ADD CONSTRAINT "jobs_parentJobId_fkey" FOREIGN KEY ("parentJobId") REFERENCES "jobs"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "job_history" ADD CONSTRAINT "job_history_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "comments" ADD CONSTRAINT "comments_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "comments" ADD CONSTRAINT "comments_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "shot_line_item_templates" ADD CONSTRAINT "shot_line_item_templates_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "shot_templates"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "asset_line_item_templates" ADD CONSTRAINT "asset_line_item_templates_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "asset_templates"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "shots" ADD CONSTRAINT "shots_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "assets" ADD CONSTRAINT "assets_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "line_items" ADD CONSTRAINT "line_items_shotId_fkey" FOREIGN KEY ("shotId") REFERENCES "shots"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "line_items" ADD CONSTRAINT "line_items_assetId_fkey" FOREIGN KEY ("assetId") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "line_items" ADD CONSTRAINT "line_items_rateCardId_fkey" FOREIGN KEY ("rateCardId") REFERENCES "rate_cards"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,27 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "jobs" ALTER COLUMN "currency" SET DEFAULT 'ZAR';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "rate_cards" ALTER COLUMN "currency" SET DEFAULT 'ZAR';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "studio_settings" (
|
||||
"id" TEXT NOT NULL DEFAULT 'default',
|
||||
"studioName" TEXT NOT NULL DEFAULT 'My VFX Studio',
|
||||
"studioEmail" TEXT,
|
||||
"studioPhone" TEXT,
|
||||
"studioAddress" TEXT,
|
||||
"logoUrl" TEXT,
|
||||
"vatNumber" TEXT,
|
||||
"companyRegNumber" TEXT,
|
||||
"invoiceHeader" TEXT,
|
||||
"invoiceFooter" TEXT,
|
||||
"defaultTermsAndConditions" TEXT,
|
||||
"defaultCurrency" TEXT NOT NULL DEFAULT 'ZAR',
|
||||
"defaultMarkupPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"defaultDiscountPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"defaultTaxPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "studio_settings_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -0,0 +1,114 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ScheduleTemplate" AS ENUM ('STANDARD_FILM', 'SMALL_COMMERCIAL', 'EPISODIC', 'CUSTOM');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "MilestoneStatus" AS ENUM ('DRAFT', 'PENDING', 'INVOICED', 'PARTIALLY_PAID', 'PAID', 'OVERDUE', 'CANCELLED');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "InvoiceStatus" AS ENUM ('DRAFT', 'SENT', 'VIEWED', 'PARTIALLY_PAID', 'PAID', 'OVERDUE', 'CANCELLED');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PaymentMethod" AS ENUM ('EFT', 'CASH', 'CREDIT_CARD', 'BANK_TRANSFER', 'CRYPTO', 'OTHER');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "jobs" ADD COLUMN "estimatedCompletionDate" TIMESTAMP(3),
|
||||
ADD COLUMN "startDate" TIMESTAMP(3);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "payment_schedules" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"template" "ScheduleTemplate" NOT NULL DEFAULT 'CUSTOM',
|
||||
"notes" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "payment_schedules_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "payment_milestones" (
|
||||
"id" TEXT NOT NULL,
|
||||
"scheduleId" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"dueDate" TIMESTAMP(3),
|
||||
"percentOfTotal" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"fixedAmount" DECIMAL(14,4),
|
||||
"status" "MilestoneStatus" NOT NULL DEFAULT 'PENDING',
|
||||
"paymentReceivedDate" TIMESTAMP(3),
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "payment_milestones_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "invoices" (
|
||||
"id" TEXT NOT NULL,
|
||||
"invoiceNumber" TEXT NOT NULL,
|
||||
"clientId" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"milestoneId" TEXT,
|
||||
"status" "InvoiceStatus" NOT NULL DEFAULT 'DRAFT',
|
||||
"issueDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"dueDate" TIMESTAMP(3),
|
||||
"paymentTerms" TEXT,
|
||||
"currency" TEXT NOT NULL DEFAULT 'ZAR',
|
||||
"subtotal" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"taxPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"taxAmount" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"totalAmount" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"amountPaid" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"amountDue" DECIMAL(14,4) NOT NULL DEFAULT 0,
|
||||
"notes" TEXT,
|
||||
"internalNotes" TEXT,
|
||||
"bankingDetails" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "invoices_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "invoice_payments" (
|
||||
"id" TEXT NOT NULL,
|
||||
"invoiceId" TEXT NOT NULL,
|
||||
"amount" DECIMAL(14,4) NOT NULL,
|
||||
"paymentDate" TIMESTAMP(3) NOT NULL,
|
||||
"paymentMethod" "PaymentMethod" NOT NULL DEFAULT 'EFT',
|
||||
"reference" TEXT,
|
||||
"notes" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "invoice_payments_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "payment_schedules_jobId_key" ON "payment_schedules"("jobId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "invoices_invoiceNumber_key" ON "invoices"("invoiceNumber");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "invoices_milestoneId_key" ON "invoices"("milestoneId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "payment_schedules" ADD CONSTRAINT "payment_schedules_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "payment_milestones" ADD CONSTRAINT "payment_milestones_scheduleId_fkey" FOREIGN KEY ("scheduleId") REFERENCES "payment_schedules"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "clients"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_milestoneId_fkey" FOREIGN KEY ("milestoneId") REFERENCES "payment_milestones"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "invoice_payments" ADD CONSTRAINT "invoice_payments_invoiceId_fkey" FOREIGN KEY ("invoiceId") REFERENCES "invoices"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,11 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "JobType" AS ENUM ('STANDARD', 'EPISODIC');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "jobs" ADD COLUMN "jobType" "JobType" NOT NULL DEFAULT 'STANDARD',
|
||||
ADD COLUMN "showId" TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "shots" ADD COLUMN "episode" TEXT,
|
||||
ADD COLUMN "scene" TEXT NOT NULL DEFAULT '',
|
||||
ADD COLUMN "shotNumber" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "shots" ADD COLUMN "shotGroup" TEXT;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "invoices" DROP CONSTRAINT "invoices_jobId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,58 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "line_items" ADD COLUMN "supervisionId" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "supervisions" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"supervisionTitle" TEXT NOT NULL,
|
||||
"shootName" TEXT,
|
||||
"location" TEXT,
|
||||
"shootDates" TEXT,
|
||||
"numShootDays" INTEGER NOT NULL DEFAULT 0,
|
||||
"travelDays" INTEGER NOT NULL DEFAULT 0,
|
||||
"prepDays" INTEGER NOT NULL DEFAULT 0,
|
||||
"wrapDays" INTEGER NOT NULL DEFAULT 0,
|
||||
"description" TEXT,
|
||||
"complexityMultiplier" DECIMAL(5,4) NOT NULL DEFAULT 1,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "supervisions_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "supervision_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "supervision_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "supervision_line_item_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"templateId" TEXT NOT NULL,
|
||||
"taskName" TEXT NOT NULL,
|
||||
"artistRole" TEXT,
|
||||
"defaultHours" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"rateCardId" TEXT,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
CONSTRAINT "supervision_line_item_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "supervisions" ADD CONSTRAINT "supervisions_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "supervision_line_item_templates" ADD CONSTRAINT "supervision_line_item_templates_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "supervision_templates"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "line_items" ADD CONSTRAINT "line_items_supervisionId_fkey" FOREIGN KEY ("supervisionId") REFERENCES "supervisions"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,57 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "line_items" ADD COLUMN "previsId" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "previses" (
|
||||
"id" TEXT NOT NULL,
|
||||
"jobId" TEXT NOT NULL,
|
||||
"sequenceName" TEXT NOT NULL,
|
||||
"previsCode" TEXT,
|
||||
"sequenceType" TEXT NOT NULL DEFAULT 'Previs',
|
||||
"description" TEXT,
|
||||
"duration" TEXT,
|
||||
"frameRange" TEXT,
|
||||
"revisionCount" INTEGER NOT NULL DEFAULT 0,
|
||||
"deliveryStage" TEXT NOT NULL DEFAULT 'Blocking',
|
||||
"complexityMultiplier" DECIMAL(5,4) NOT NULL DEFAULT 1,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "previses_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "previs_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "previs_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "previs_line_item_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"templateId" TEXT NOT NULL,
|
||||
"taskName" TEXT NOT NULL,
|
||||
"artistRole" TEXT,
|
||||
"defaultHours" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"rateCardId" TEXT,
|
||||
"notes" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
CONSTRAINT "previs_line_item_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "previses" ADD CONSTRAINT "previses_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "previs_line_item_templates" ADD CONSTRAINT "previs_line_item_templates_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "previs_templates"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "line_items" ADD CONSTRAINT "line_items_previsId_fkey" FOREIGN KEY ("previsId") REFERENCES "previses"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,23 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "task_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"taskName" TEXT NOT NULL,
|
||||
"artistRole" TEXT,
|
||||
"rateCardId" TEXT,
|
||||
"quantityHours" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"dailyRate" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"hoursPerDay" DECIMAL(5,2) NOT NULL DEFAULT 8,
|
||||
"numArtists" DECIMAL(5,2) NOT NULL DEFAULT 1,
|
||||
"numDays" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"manualHourlyRate" DECIMAL(10,4),
|
||||
"manualSubtotal" DECIMAL(14,4),
|
||||
"markupPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"discountPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"taxPercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
"notes" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "task_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "jobs" ADD COLUMN "productionFeePercent" DECIMAL(10,4) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN "pullManagementFeePercent" DECIMAL(10,4) NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "postgresql"
|
||||
@@ -0,0 +1,626 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
// ─── Auth / Users ────────────────────────────────────────────────────────────
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
password String?
|
||||
role UserRole @default(ARTIST)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
jobs Job[] @relation("JobCreator")
|
||||
comments Comment[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String?
|
||||
access_token String?
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String?
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
@@map("verification_tokens")
|
||||
}
|
||||
|
||||
enum UserRole {
|
||||
ADMIN
|
||||
PRODUCER
|
||||
SUPERVISOR
|
||||
ARTIST
|
||||
}
|
||||
|
||||
// ─── Clients ─────────────────────────────────────────────────────────────────
|
||||
|
||||
model Client {
|
||||
id String @id @default(cuid())
|
||||
companyName String
|
||||
contactPerson String?
|
||||
email String?
|
||||
phone String?
|
||||
vatNumber String?
|
||||
companyRegNumber String?
|
||||
billingAddress String?
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
jobs Job[]
|
||||
invoices Invoice[]
|
||||
|
||||
@@map("clients")
|
||||
}
|
||||
|
||||
// ─── Jobs / Quotes ────────────────────────────────────────────────────────────
|
||||
|
||||
model Job {
|
||||
id String @id @default(cuid())
|
||||
projectTitle String
|
||||
projectCode String @unique
|
||||
showId String @default("")
|
||||
jobType JobType @default(STANDARD)
|
||||
clientId String
|
||||
createdById String?
|
||||
issueDate DateTime @default(now())
|
||||
expiryDate DateTime?
|
||||
currency String @default("ZAR")
|
||||
status JobStatus @default(DRAFT)
|
||||
description String?
|
||||
internalNotes String?
|
||||
markupPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
taxPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
discountPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
productionFeePercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
pullManagementFeePercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
customHeaderHtml String?
|
||||
customFooterHtml String?
|
||||
termsAndConditions String?
|
||||
startDate DateTime?
|
||||
estimatedCompletionDate DateTime?
|
||||
version Int @default(1)
|
||||
parentJobId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
createdBy User? @relation("JobCreator", fields: [createdById], references: [id])
|
||||
parentJob Job? @relation("JobVersions", fields: [parentJobId], references: [id], onDelete: SetNull)
|
||||
versions Job[] @relation("JobVersions")
|
||||
shots Shot[]
|
||||
assets Asset[]
|
||||
supervisions Supervision[]
|
||||
previses Previs[]
|
||||
comments Comment[]
|
||||
history JobHistory[]
|
||||
paymentSchedule PaymentSchedule?
|
||||
invoices Invoice[]
|
||||
|
||||
@@map("jobs")
|
||||
}
|
||||
|
||||
enum JobStatus {
|
||||
DRAFT
|
||||
SENT
|
||||
APPROVED
|
||||
REJECTED
|
||||
ARCHIVED
|
||||
}
|
||||
|
||||
enum JobType {
|
||||
STANDARD
|
||||
EPISODIC
|
||||
}
|
||||
|
||||
model JobHistory {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
field String
|
||||
oldValue String?
|
||||
newValue String?
|
||||
changedAt DateTime @default(now())
|
||||
changedBy String?
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("job_history")
|
||||
}
|
||||
|
||||
model Comment {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
userId String?
|
||||
body String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
|
||||
@@map("comments")
|
||||
}
|
||||
|
||||
// ─── Rate Cards ───────────────────────────────────────────────────────────────
|
||||
|
||||
model RateCard {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
department String?
|
||||
defaultDailyRate Decimal @default(0) @db.Decimal(10, 4)
|
||||
hoursPerDay Decimal @default(8) @db.Decimal(5, 2)
|
||||
currency String @default("ZAR")
|
||||
notes String?
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
lineItems LineItem[]
|
||||
|
||||
@@map("rate_cards")
|
||||
}
|
||||
|
||||
// ─── Shot Templates ───────────────────────────────────────────────────────────
|
||||
|
||||
model ShotTemplate {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
lineItemTemplates ShotLineItemTemplate[]
|
||||
|
||||
@@map("shot_templates")
|
||||
}
|
||||
|
||||
model ShotLineItemTemplate {
|
||||
id String @id @default(cuid())
|
||||
templateId String
|
||||
taskName String
|
||||
artistRole String?
|
||||
defaultHours Decimal @default(0) @db.Decimal(10, 4)
|
||||
rateCardId String?
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
|
||||
template ShotTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("shot_line_item_templates")
|
||||
}
|
||||
|
||||
// ─── Asset Templates ──────────────────────────────────────────────────────────
|
||||
|
||||
model AssetTemplate {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
lineItemTemplates AssetLineItemTemplate[]
|
||||
|
||||
@@map("asset_templates")
|
||||
}
|
||||
|
||||
model AssetLineItemTemplate {
|
||||
id String @id @default(cuid())
|
||||
templateId String
|
||||
taskName String
|
||||
artistRole String?
|
||||
defaultHours Decimal @default(0) @db.Decimal(10, 4)
|
||||
rateCardId String?
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
|
||||
template AssetTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("asset_line_item_templates")
|
||||
}
|
||||
|
||||
// ─── Shots ────────────────────────────────────────────────────────────────────
|
||||
|
||||
model Shot {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
shotCode String
|
||||
shotNumber Int @default(0)
|
||||
scene String @default("")
|
||||
episode String?
|
||||
shotGroup String?
|
||||
description String?
|
||||
durationSeconds Int?
|
||||
complexityMultiplier Decimal @default(1) @db.Decimal(5, 4)
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
lineItems LineItem[]
|
||||
|
||||
@@map("shots")
|
||||
}
|
||||
|
||||
// ─── Assets ───────────────────────────────────────────────────────────────────
|
||||
|
||||
model Asset {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
assetName String
|
||||
assetType String?
|
||||
description String?
|
||||
complexityMultiplier Decimal @default(1) @db.Decimal(5, 4)
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
lineItems LineItem[]
|
||||
|
||||
@@map("assets")
|
||||
}
|
||||
|
||||
// ─── Supervision ─────────────────────────────────────────────────────────────
|
||||
|
||||
model Supervision {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
supervisionTitle String
|
||||
shootName String?
|
||||
location String?
|
||||
shootDates String?
|
||||
numShootDays Int @default(0)
|
||||
travelDays Int @default(0)
|
||||
prepDays Int @default(0)
|
||||
wrapDays Int @default(0)
|
||||
description String?
|
||||
complexityMultiplier Decimal @default(1) @db.Decimal(5, 4)
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
lineItems LineItem[]
|
||||
|
||||
@@map("supervisions")
|
||||
}
|
||||
|
||||
model SupervisionTemplate {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
lineItemTemplates SupervisionLineItemTemplate[]
|
||||
|
||||
@@map("supervision_templates")
|
||||
}
|
||||
|
||||
model SupervisionLineItemTemplate {
|
||||
id String @id @default(cuid())
|
||||
templateId String
|
||||
taskName String
|
||||
artistRole String?
|
||||
defaultHours Decimal @default(0) @db.Decimal(10, 4)
|
||||
rateCardId String?
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
|
||||
template SupervisionTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("supervision_line_item_templates")
|
||||
}
|
||||
|
||||
// ─── Previs ───────────────────────────────────────────────────────────────────
|
||||
|
||||
model Previs {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
sequenceName String
|
||||
previsCode String?
|
||||
sequenceType String @default("Previs")
|
||||
description String?
|
||||
duration String?
|
||||
frameRange String?
|
||||
revisionCount Int @default(0)
|
||||
deliveryStage String @default("Blocking")
|
||||
complexityMultiplier Decimal @default(1) @db.Decimal(5, 4)
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
lineItems LineItem[]
|
||||
|
||||
@@map("previses")
|
||||
}
|
||||
|
||||
model PrevisTemplate {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
lineItemTemplates PrevisLineItemTemplate[]
|
||||
|
||||
@@map("previs_templates")
|
||||
}
|
||||
|
||||
model PrevisLineItemTemplate {
|
||||
id String @id @default(cuid())
|
||||
templateId String
|
||||
taskName String
|
||||
artistRole String?
|
||||
defaultHours Decimal @default(0) @db.Decimal(10, 4)
|
||||
rateCardId String?
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
|
||||
template PrevisTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("previs_line_item_templates")
|
||||
}
|
||||
|
||||
// ─── Line Items ───────────────────────────────────────────────────────────────
|
||||
|
||||
model LineItem {
|
||||
id String @id @default(cuid())
|
||||
shotId String?
|
||||
assetId String?
|
||||
supervisionId String?
|
||||
previsId String?
|
||||
rateCardId String?
|
||||
taskName String
|
||||
artistRole String?
|
||||
// Inputs
|
||||
quantityHours Decimal @default(0) @db.Decimal(10, 4)
|
||||
dailyRate Decimal @default(0) @db.Decimal(10, 4)
|
||||
hoursPerDay Decimal @default(8) @db.Decimal(5, 2)
|
||||
numArtists Decimal @default(1) @db.Decimal(5, 2)
|
||||
numDays Decimal @default(0) @db.Decimal(10, 4)
|
||||
// Overrides
|
||||
manualHourlyRate Decimal? @db.Decimal(10, 4)
|
||||
manualSubtotal Decimal? @db.Decimal(14, 4)
|
||||
// Adjustments
|
||||
markupPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
discountPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
taxPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
// Stored computed totals (recalculated server-side before PDF)
|
||||
hourlyRate Decimal @default(0) @db.Decimal(10, 4)
|
||||
subtotal Decimal @default(0) @db.Decimal(14, 4)
|
||||
markupAmount Decimal @default(0) @db.Decimal(14, 4)
|
||||
discountAmount Decimal @default(0) @db.Decimal(14, 4)
|
||||
taxAmount Decimal @default(0) @db.Decimal(14, 4)
|
||||
total Decimal @default(0) @db.Decimal(14, 4)
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shot Shot? @relation(fields: [shotId], references: [id], onDelete: Cascade)
|
||||
asset Asset? @relation(fields: [assetId], references: [id], onDelete: Cascade)
|
||||
supervision Supervision? @relation(fields: [supervisionId], references: [id], onDelete: Cascade)
|
||||
previs Previs? @relation(fields: [previsId], references: [id], onDelete: Cascade)
|
||||
rateCard RateCard? @relation(fields: [rateCardId], references: [id])
|
||||
|
||||
@@map("line_items")
|
||||
}
|
||||
|
||||
// ─── Task Templates ───────────────────────────────────────────────────────────
|
||||
|
||||
model TaskTemplate {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
taskName String
|
||||
artistRole String?
|
||||
rateCardId String?
|
||||
quantityHours Decimal @default(0) @db.Decimal(10, 4)
|
||||
dailyRate Decimal @default(0) @db.Decimal(10, 4)
|
||||
hoursPerDay Decimal @default(8) @db.Decimal(5, 2)
|
||||
numArtists Decimal @default(1) @db.Decimal(5, 2)
|
||||
numDays Decimal @default(0) @db.Decimal(10, 4)
|
||||
manualHourlyRate Decimal? @db.Decimal(10, 4)
|
||||
manualSubtotal Decimal? @db.Decimal(14, 4)
|
||||
markupPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
discountPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
taxPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("task_templates")
|
||||
}
|
||||
|
||||
// ─── Studio Settings ──────────────────────────────────────────────────────────
|
||||
|
||||
model StudioSettings {
|
||||
id String @id @default("default")
|
||||
studioName String @default("My VFX Studio")
|
||||
studioEmail String?
|
||||
studioPhone String?
|
||||
studioAddress String?
|
||||
logoUrl String?
|
||||
vatNumber String?
|
||||
companyRegNumber String?
|
||||
invoiceHeader String?
|
||||
invoiceFooter String?
|
||||
defaultTermsAndConditions String?
|
||||
defaultCurrency String @default("ZAR")
|
||||
defaultMarkupPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
defaultDiscountPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
defaultTaxPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("studio_settings")
|
||||
}
|
||||
|
||||
// ─── Payment Schedule ─────────────────────────────────────────────────────────
|
||||
|
||||
enum ScheduleTemplate {
|
||||
STANDARD_FILM
|
||||
SMALL_COMMERCIAL
|
||||
EPISODIC
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
enum MilestoneStatus {
|
||||
DRAFT
|
||||
PENDING
|
||||
INVOICED
|
||||
PARTIALLY_PAID
|
||||
PAID
|
||||
OVERDUE
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
model PaymentSchedule {
|
||||
id String @id @default(cuid())
|
||||
jobId String @unique
|
||||
template ScheduleTemplate @default(CUSTOM)
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
milestones PaymentMilestone[]
|
||||
|
||||
@@map("payment_schedules")
|
||||
}
|
||||
|
||||
model PaymentMilestone {
|
||||
id String @id @default(cuid())
|
||||
scheduleId String
|
||||
title String
|
||||
description String?
|
||||
dueDate DateTime?
|
||||
percentOfTotal Decimal @default(0) @db.Decimal(10, 4)
|
||||
fixedAmount Decimal? @db.Decimal(14, 4)
|
||||
status MilestoneStatus @default(PENDING)
|
||||
paymentReceivedDate DateTime?
|
||||
notes String?
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
schedule PaymentSchedule @relation(fields: [scheduleId], references: [id], onDelete: Cascade)
|
||||
invoice Invoice?
|
||||
|
||||
@@map("payment_milestones")
|
||||
}
|
||||
|
||||
// ─── Invoices ─────────────────────────────────────────────────────────────────
|
||||
|
||||
enum InvoiceStatus {
|
||||
DRAFT
|
||||
SENT
|
||||
VIEWED
|
||||
PARTIALLY_PAID
|
||||
PAID
|
||||
OVERDUE
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
enum PaymentMethod {
|
||||
EFT
|
||||
CASH
|
||||
CREDIT_CARD
|
||||
BANK_TRANSFER
|
||||
CRYPTO
|
||||
OTHER
|
||||
}
|
||||
|
||||
model Invoice {
|
||||
id String @id @default(cuid())
|
||||
invoiceNumber String @unique
|
||||
clientId String
|
||||
jobId String
|
||||
milestoneId String? @unique
|
||||
status InvoiceStatus @default(DRAFT)
|
||||
issueDate DateTime @default(now())
|
||||
dueDate DateTime?
|
||||
paymentTerms String?
|
||||
currency String @default("ZAR")
|
||||
subtotal Decimal @default(0) @db.Decimal(14, 4)
|
||||
taxPercent Decimal @default(0) @db.Decimal(10, 4)
|
||||
taxAmount Decimal @default(0) @db.Decimal(14, 4)
|
||||
totalAmount Decimal @default(0) @db.Decimal(14, 4)
|
||||
amountPaid Decimal @default(0) @db.Decimal(14, 4)
|
||||
amountDue Decimal @default(0) @db.Decimal(14, 4)
|
||||
notes String?
|
||||
internalNotes String?
|
||||
bankingDetails String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
milestone PaymentMilestone? @relation(fields: [milestoneId], references: [id])
|
||||
payments InvoicePayment[]
|
||||
|
||||
@@map("invoices")
|
||||
}
|
||||
|
||||
model InvoicePayment {
|
||||
id String @id @default(cuid())
|
||||
invoiceId String
|
||||
amount Decimal @db.Decimal(14, 4)
|
||||
paymentDate DateTime
|
||||
paymentMethod PaymentMethod @default(EFT)
|
||||
reference String?
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("invoice_payments")
|
||||
}
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
import { config } from "dotenv";
|
||||
config();
|
||||
import { PrismaClient, JobStatus } from "@prisma/client";
|
||||
import { PrismaPg } from "@prisma/adapter-pg";
|
||||
import Decimal from "decimal.js";
|
||||
|
||||
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! });
|
||||
const prisma = new PrismaClient({ adapter } as any);
|
||||
|
||||
async function main() {
|
||||
console.log("🌱 Seeding database...");
|
||||
|
||||
// --- Rate Cards ---
|
||||
const rateCardsData = [
|
||||
{ name: "VFX Supervisor", department: "Leadership", defaultDailyRate: 1200, hoursPerDay: 8 },
|
||||
{ name: "CG Supervisor", department: "Leadership", defaultDailyRate: 1100, hoursPerDay: 8 },
|
||||
{ name: "Senior Compositor", department: "Compositing", defaultDailyRate: 950, hoursPerDay: 8 },
|
||||
{ name: "Mid Compositor", department: "Compositing", defaultDailyRate: 750, hoursPerDay: 8 },
|
||||
{ name: "Junior Compositor", department: "Compositing", defaultDailyRate: 500, hoursPerDay: 8 },
|
||||
{ name: "Senior Animator", department: "Animation", defaultDailyRate: 900, hoursPerDay: 8 },
|
||||
{ name: "Mid Animator", department: "Animation", defaultDailyRate: 700, hoursPerDay: 8 },
|
||||
{ name: "Senior Modeller", department: "3D Art", defaultDailyRate: 850, hoursPerDay: 8 },
|
||||
{ name: "Texture Artist", department: "3D Art", defaultDailyRate: 750, hoursPerDay: 8 },
|
||||
{ name: "Lighting TD", department: "Lighting", defaultDailyRate: 900, hoursPerDay: 8 },
|
||||
{ name: "FX Artist", department: "FX", defaultDailyRate: 900, hoursPerDay: 8 },
|
||||
{ name: "Matchmove Artist", department: "Tracking", defaultDailyRate: 650, hoursPerDay: 8 },
|
||||
{ name: "Roto Artist", department: "Prep", defaultDailyRate: 450, hoursPerDay: 8 },
|
||||
{ name: "Paint Artist", department: "Prep", defaultDailyRate: 500, hoursPerDay: 8 },
|
||||
{ name: "Pipeline TD", department: "Pipeline", defaultDailyRate: 1000, hoursPerDay: 8 },
|
||||
];
|
||||
|
||||
const rateCards = await Promise.all(
|
||||
rateCardsData.map((rc) =>
|
||||
prisma.rateCard.upsert({
|
||||
where: { id: `seed-rc-${rc.name.toLowerCase().replace(/\s+/g, "-")}` },
|
||||
create: {
|
||||
id: `seed-rc-${rc.name.toLowerCase().replace(/\s+/g, "-")}`,
|
||||
name: rc.name,
|
||||
department: rc.department,
|
||||
defaultDailyRate: new Decimal(rc.defaultDailyRate),
|
||||
hoursPerDay: new Decimal(rc.hoursPerDay),
|
||||
currency: "ZAR",
|
||||
isActive: true,
|
||||
},
|
||||
update: {},
|
||||
})
|
||||
)
|
||||
);
|
||||
console.log(` ✓ ${rateCards.length} rate cards`);
|
||||
|
||||
// --- Clients ---
|
||||
const client1 = await prisma.client.upsert({
|
||||
where: { id: "seed-client-01" },
|
||||
create: {
|
||||
id: "seed-client-01",
|
||||
companyName: "Acme Studios",
|
||||
contactPerson: "Jane Reynolds",
|
||||
email: "jane@acmestudios.com",
|
||||
phone: "+1 310 555 0100",
|
||||
billingAddress: "1234 Sunset Blvd\nLos Angeles, CA 90028",
|
||||
vatNumber: "US-123456789",
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
const client2 = await prisma.client.upsert({
|
||||
where: { id: "seed-client-02" },
|
||||
create: {
|
||||
id: "seed-client-02",
|
||||
companyName: "Nebula Films",
|
||||
contactPerson: "Tom Kavanagh",
|
||||
email: "tom@nebulafilms.co.uk",
|
||||
phone: "+44 20 7946 0100",
|
||||
billingAddress: "22 Soho Square\nLondon, W1D 4QE",
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
console.log(" ✓ 2 clients");
|
||||
|
||||
// --- Jobs ---
|
||||
const job1 = await prisma.job.upsert({
|
||||
where: { id: "seed-job-01" },
|
||||
create: {
|
||||
id: "seed-job-01",
|
||||
projectTitle: "Feature Film VFX Package",
|
||||
projectCode: "ACME-2024-001",
|
||||
clientId: client1.id,
|
||||
status: "DRAFT" as JobStatus,
|
||||
currency: "ZAR",
|
||||
markupPercent: new Decimal(10),
|
||||
taxPercent: new Decimal(15),
|
||||
discountPercent: new Decimal(0),
|
||||
description:
|
||||
"Full VFX package for Acme Studios' upcoming feature film including creature work, environments, and practical enhancement.",
|
||||
termsAndConditions:
|
||||
"Payment terms: 50% on approval, 50% on delivery. Prices valid for 30 days. Rates exclude VAT where applicable.",
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
const shot1 = await prisma.shot.upsert({
|
||||
where: { id: "seed-shot-01" },
|
||||
create: {
|
||||
id: "seed-shot-01",
|
||||
jobId: job1.id,
|
||||
shotCode: "SH0010",
|
||||
durationSeconds: 4,
|
||||
complexityMultiplier: new Decimal(1.5),
|
||||
description: "Hero creature reveal — CG creature integration in live action environment",
|
||||
sortOrder: 0,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
const shot2 = await prisma.shot.upsert({
|
||||
where: { id: "seed-shot-02" },
|
||||
create: {
|
||||
id: "seed-shot-02",
|
||||
jobId: job1.id,
|
||||
shotCode: "SH0020",
|
||||
durationSeconds: 2,
|
||||
complexityMultiplier: new Decimal(1.0),
|
||||
description: "Establishing environment — CG extension of practical set",
|
||||
sortOrder: 1,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
const seniorComp = rateCards.find((r) => r.name === "Senior Compositor")!;
|
||||
const lightingTD = rateCards.find((r) => r.name === "Lighting TD")!;
|
||||
const fxArtist = rateCards.find((r) => r.name === "FX Artist")!;
|
||||
const rotoArtist = rateCards.find((r) => r.name === "Roto Artist")!;
|
||||
|
||||
// Line items for shot 1
|
||||
const lineItemsShot1 = [
|
||||
{ taskName: "Roto / Paint", rateCardId: rotoArtist.id, artistRole: rotoArtist.name, dailyRate: 450, hoursPerDay: 8, numArtists: 1, numDays: 3, sortOrder: 0 },
|
||||
{ taskName: "Lighting & Rendering", rateCardId: lightingTD.id, artistRole: lightingTD.name, dailyRate: 900, hoursPerDay: 8, numArtists: 1, numDays: 5, sortOrder: 1 },
|
||||
{ taskName: "FX Simulation", rateCardId: fxArtist.id, artistRole: fxArtist.name, dailyRate: 900, hoursPerDay: 8, numArtists: 1, numDays: 4, sortOrder: 2 },
|
||||
{ taskName: "Compositing", rateCardId: seniorComp.id, artistRole: seniorComp.name, dailyRate: 950, hoursPerDay: 8, numArtists: 1, numDays: 7, sortOrder: 3 },
|
||||
];
|
||||
|
||||
for (const li of lineItemsShot1) {
|
||||
await prisma.lineItem.upsert({
|
||||
where: { id: `seed-li-s1-${li.sortOrder}` },
|
||||
create: {
|
||||
id: `seed-li-s1-${li.sortOrder}`,
|
||||
shotId: shot1.id,
|
||||
taskName: li.taskName,
|
||||
rateCardId: li.rateCardId,
|
||||
artistRole: li.artistRole,
|
||||
dailyRate: new Decimal(li.dailyRate),
|
||||
hoursPerDay: new Decimal(li.hoursPerDay),
|
||||
numArtists: new Decimal(li.numArtists),
|
||||
numDays: new Decimal(li.numDays),
|
||||
quantityHours: new Decimal(0),
|
||||
markupPercent: new Decimal(0),
|
||||
discountPercent: new Decimal(0),
|
||||
taxPercent: new Decimal(0),
|
||||
hourlyRate: new Decimal(li.dailyRate / li.hoursPerDay),
|
||||
subtotal: new Decimal(li.dailyRate * li.numDays * li.numArtists * 1.5),
|
||||
markupAmount: new Decimal(0),
|
||||
discountAmount: new Decimal(0),
|
||||
taxAmount: new Decimal(0),
|
||||
total: new Decimal(li.dailyRate * li.numDays * li.numArtists * 1.5),
|
||||
sortOrder: li.sortOrder,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
}
|
||||
|
||||
// Line items for shot 2
|
||||
const midComp = rateCards.find((r) => r.name === "Mid Compositor")!;
|
||||
const lineItemsShot2 = [
|
||||
{ taskName: "Roto / Paint", rateCardId: rotoArtist.id, artistRole: rotoArtist.name, dailyRate: 450, hoursPerDay: 8, numArtists: 2, numDays: 2, sortOrder: 0 },
|
||||
{ taskName: "Compositing", rateCardId: midComp.id, artistRole: midComp.name, dailyRate: 750, hoursPerDay: 8, numArtists: 1, numDays: 4, sortOrder: 1 },
|
||||
];
|
||||
|
||||
for (const li of lineItemsShot2) {
|
||||
await prisma.lineItem.upsert({
|
||||
where: { id: `seed-li-s2-${li.sortOrder}` },
|
||||
create: {
|
||||
id: `seed-li-s2-${li.sortOrder}`,
|
||||
shotId: shot2.id,
|
||||
taskName: li.taskName,
|
||||
rateCardId: li.rateCardId,
|
||||
artistRole: li.artistRole,
|
||||
dailyRate: new Decimal(li.dailyRate),
|
||||
hoursPerDay: new Decimal(li.hoursPerDay),
|
||||
numArtists: new Decimal(li.numArtists),
|
||||
numDays: new Decimal(li.numDays),
|
||||
quantityHours: new Decimal(0),
|
||||
markupPercent: new Decimal(0),
|
||||
discountPercent: new Decimal(0),
|
||||
taxPercent: new Decimal(0),
|
||||
hourlyRate: new Decimal(li.dailyRate / li.hoursPerDay),
|
||||
subtotal: new Decimal(li.dailyRate * li.numDays * li.numArtists),
|
||||
markupAmount: new Decimal(0),
|
||||
discountAmount: new Decimal(0),
|
||||
taxAmount: new Decimal(0),
|
||||
total: new Decimal(li.dailyRate * li.numDays * li.numArtists),
|
||||
sortOrder: li.sortOrder,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
}
|
||||
|
||||
console.log(" ✓ 1 job with 2 shots and line items");
|
||||
|
||||
// --- Asset example on job 1 ---
|
||||
const asset1 = await prisma.asset.upsert({
|
||||
where: { id: "seed-asset-01" },
|
||||
create: {
|
||||
id: "seed-asset-01",
|
||||
jobId: job1.id,
|
||||
assetName: "Hero Creature",
|
||||
assetType: "Character",
|
||||
complexityMultiplier: new Decimal(2.0),
|
||||
description: "Full CG creature, hero quality, 4K textures",
|
||||
sortOrder: 0,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
const seniorModeller = rateCards.find((r) => r.name === "Senior Modeller")!;
|
||||
const textureArtist = rateCards.find((r) => r.name === "Texture Artist")!;
|
||||
|
||||
const assetLineItems = [
|
||||
{ taskName: "High Res Modelling", rateCardId: seniorModeller.id, artistRole: seniorModeller.name, dailyRate: 850, numDays: 8, numArtists: 1, sortOrder: 0 },
|
||||
{ taskName: "Texturing & Look Dev", rateCardId: textureArtist.id, artistRole: textureArtist.name, dailyRate: 750, numDays: 5, numArtists: 1, sortOrder: 1 },
|
||||
{ taskName: "Rigging", rateCardId: seniorModeller.id, artistRole: "Rigging Artist", dailyRate: 850, numDays: 6, numArtists: 1, sortOrder: 2 },
|
||||
];
|
||||
|
||||
for (const li of assetLineItems) {
|
||||
await prisma.lineItem.upsert({
|
||||
where: { id: `seed-li-a1-${li.sortOrder}` },
|
||||
create: {
|
||||
id: `seed-li-a1-${li.sortOrder}`,
|
||||
assetId: asset1.id,
|
||||
taskName: li.taskName,
|
||||
rateCardId: li.rateCardId,
|
||||
artistRole: li.artistRole,
|
||||
dailyRate: new Decimal(li.dailyRate),
|
||||
hoursPerDay: new Decimal(8),
|
||||
numArtists: new Decimal(li.numArtists),
|
||||
numDays: new Decimal(li.numDays),
|
||||
quantityHours: new Decimal(0),
|
||||
markupPercent: new Decimal(0),
|
||||
discountPercent: new Decimal(0),
|
||||
taxPercent: new Decimal(0),
|
||||
hourlyRate: new Decimal(li.dailyRate / 8),
|
||||
subtotal: new Decimal(li.dailyRate * li.numDays * li.numArtists * 2.0),
|
||||
markupAmount: new Decimal(0),
|
||||
discountAmount: new Decimal(0),
|
||||
taxAmount: new Decimal(0),
|
||||
total: new Decimal(li.dailyRate * li.numDays * li.numArtists * 2.0),
|
||||
sortOrder: li.sortOrder,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
}
|
||||
|
||||
console.log(" ✓ 1 asset with line items");
|
||||
|
||||
// Second job for client 2 (sent)
|
||||
await prisma.job.upsert({
|
||||
where: { id: "seed-job-02" },
|
||||
create: {
|
||||
id: "seed-job-02",
|
||||
projectTitle: "TV Commercial Package",
|
||||
projectCode: "NEBULA-2024-001",
|
||||
clientId: client2.id,
|
||||
status: "SENT" as JobStatus,
|
||||
currency: "ZAR",
|
||||
markupPercent: new Decimal(15),
|
||||
taxPercent: new Decimal(15),
|
||||
discountPercent: new Decimal(0),
|
||||
description: "30-second commercial with full CG product visualization and environment.",
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
|
||||
console.log(" ✓ 1 additional job (sent)");
|
||||
console.log("✅ Seeding complete!");
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => { console.error(e); process.exit(1); })
|
||||
.finally(async () => { await prisma.$disconnect(); });
|
||||
Reference in New Issue
Block a user