@danielcok17/prisma-db 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/prisma/app.prisma
CHANGED
|
@@ -130,6 +130,7 @@ model User {
|
|
|
130
130
|
// Ingestion pipeline
|
|
131
131
|
ingestedDocuments IngestedDocument[]
|
|
132
132
|
adminGrants AdminGrant[]
|
|
133
|
+
invoiceGrants InvoiceGrant[]
|
|
133
134
|
emailSends EmailSend[]
|
|
134
135
|
emailConsent EmailConsent?
|
|
135
136
|
userScore UserScore?
|
|
@@ -213,6 +214,7 @@ model Organization {
|
|
|
213
214
|
stripeCustomer StripeCustomer?
|
|
214
215
|
folderShares FolderShare[]
|
|
215
216
|
adminGrants AdminGrant[]
|
|
217
|
+
invoiceGrants InvoiceGrant[]
|
|
216
218
|
|
|
217
219
|
createdAt DateTime @default(now())
|
|
218
220
|
updatedAt DateTime @updatedAt
|
|
@@ -725,7 +727,8 @@ model StripeSubscription {
|
|
|
725
727
|
trialEnd DateTime?
|
|
726
728
|
|
|
727
729
|
// Additional fields
|
|
728
|
-
quantity Int
|
|
730
|
+
quantity Int @default(1) // Počet seats (pre LAW_FIRM/ENTERPRISE tier)
|
|
731
|
+
collectionMethod CollectionMethod @default(CHARGE_AUTOMATICALLY) // Karta vs faktúra
|
|
729
732
|
defaultPaymentMethodId String? // Stripe payment method ID
|
|
730
733
|
|
|
731
734
|
metadata Json? // Dodatočné Stripe metadata
|
|
@@ -1150,6 +1153,17 @@ enum ReferralStatus {
|
|
|
1150
1153
|
REWARDED
|
|
1151
1154
|
}
|
|
1152
1155
|
|
|
1156
|
+
enum InvoiceGrantStatus {
|
|
1157
|
+
PENDING // Faktúra odoslaná, čaká na platbu
|
|
1158
|
+
PAID // Zaplatené, grant aktívny
|
|
1159
|
+
VOID // Stornovaná (admin alebo Stripe)
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
enum CollectionMethod {
|
|
1163
|
+
CHARGE_AUTOMATICALLY // Automatické strhnutie kartou
|
|
1164
|
+
SEND_INVOICE // Faktúra na email (bank transfer)
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1153
1167
|
// ============================================
|
|
1154
1168
|
// CANVAS DOCUMENT MODELS
|
|
1155
1169
|
// ============================================
|
|
@@ -1372,6 +1386,33 @@ model AdminGrant {
|
|
|
1372
1386
|
@@index([isActive])
|
|
1373
1387
|
}
|
|
1374
1388
|
|
|
1389
|
+
// One-off admin invoice — standalone faktúra pre špeciálne prípady (demo, trial, custom deal)
|
|
1390
|
+
// Pre recurring fakturáciu použiť StripeSubscription s collectionMethod=SEND_INVOICE
|
|
1391
|
+
model InvoiceGrant {
|
|
1392
|
+
id String @id @default(cuid())
|
|
1393
|
+
userId String?
|
|
1394
|
+
organizationId String?
|
|
1395
|
+
stripeInvoiceId String @unique
|
|
1396
|
+
tier SubscriptionTier
|
|
1397
|
+
durationDays Int // Na koľko dní sa aktivuje grant po platbe
|
|
1398
|
+
amount Int // Suma v centoch (EUR)
|
|
1399
|
+
status InvoiceGrantStatus @default(PENDING)
|
|
1400
|
+
grantId String? // ID AdminGrantu vytvoreného po platbe
|
|
1401
|
+
createdBy String // Admin email
|
|
1402
|
+
notes String?
|
|
1403
|
+
paidAt DateTime?
|
|
1404
|
+
createdAt DateTime @default(now())
|
|
1405
|
+
updatedAt DateTime @updatedAt
|
|
1406
|
+
|
|
1407
|
+
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1408
|
+
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
1409
|
+
|
|
1410
|
+
@@index([userId])
|
|
1411
|
+
@@index([organizationId])
|
|
1412
|
+
@@index([status])
|
|
1413
|
+
@@index([stripeInvoiceId])
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1375
1416
|
model AppInvite {
|
|
1376
1417
|
id String @id @default(cuid())
|
|
1377
1418
|
email String
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "InvoiceGrantStatus" AS ENUM ('PENDING', 'PAID', 'VOID');
|
|
3
|
+
|
|
4
|
+
-- CreateEnum
|
|
5
|
+
CREATE TYPE "CollectionMethod" AS ENUM ('CHARGE_AUTOMATICALLY', 'SEND_INVOICE');
|
|
6
|
+
|
|
7
|
+
-- AlterTable
|
|
8
|
+
ALTER TABLE "StripeSubscription" ADD COLUMN "collectionMethod" "CollectionMethod" NOT NULL DEFAULT 'CHARGE_AUTOMATICALLY';
|
|
9
|
+
|
|
10
|
+
-- CreateTable
|
|
11
|
+
CREATE TABLE "InvoiceGrant" (
|
|
12
|
+
"id" TEXT NOT NULL,
|
|
13
|
+
"userId" TEXT,
|
|
14
|
+
"organizationId" TEXT,
|
|
15
|
+
"stripeInvoiceId" TEXT NOT NULL,
|
|
16
|
+
"tier" "SubscriptionTier" NOT NULL,
|
|
17
|
+
"durationDays" INTEGER NOT NULL,
|
|
18
|
+
"amount" INTEGER NOT NULL,
|
|
19
|
+
"status" "InvoiceGrantStatus" NOT NULL DEFAULT 'PENDING',
|
|
20
|
+
"grantId" TEXT,
|
|
21
|
+
"createdBy" TEXT NOT NULL,
|
|
22
|
+
"notes" TEXT,
|
|
23
|
+
"paidAt" TIMESTAMP(3),
|
|
24
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
25
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
26
|
+
|
|
27
|
+
CONSTRAINT "InvoiceGrant_pkey" PRIMARY KEY ("id")
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
-- CreateIndex
|
|
31
|
+
CREATE UNIQUE INDEX "InvoiceGrant_stripeInvoiceId_key" ON "InvoiceGrant"("stripeInvoiceId");
|
|
32
|
+
|
|
33
|
+
-- CreateIndex
|
|
34
|
+
CREATE INDEX "InvoiceGrant_userId_idx" ON "InvoiceGrant"("userId");
|
|
35
|
+
|
|
36
|
+
-- CreateIndex
|
|
37
|
+
CREATE INDEX "InvoiceGrant_organizationId_idx" ON "InvoiceGrant"("organizationId");
|
|
38
|
+
|
|
39
|
+
-- CreateIndex
|
|
40
|
+
CREATE INDEX "InvoiceGrant_status_idx" ON "InvoiceGrant"("status");
|
|
41
|
+
|
|
42
|
+
-- CreateIndex
|
|
43
|
+
CREATE INDEX "InvoiceGrant_stripeInvoiceId_idx" ON "InvoiceGrant"("stripeInvoiceId");
|
|
44
|
+
|
|
45
|
+
-- AddForeignKey
|
|
46
|
+
ALTER TABLE "InvoiceGrant" ADD CONSTRAINT "InvoiceGrant_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
47
|
+
|
|
48
|
+
-- AddForeignKey
|
|
49
|
+
ALTER TABLE "InvoiceGrant" ADD CONSTRAINT "InvoiceGrant_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|