feat(profile): add counterparty profile and enforce it for order creation

This commit is contained in:
Ruslan Bakiev
2026-04-02 16:46:36 +07:00
parent 3a9b922a07
commit 3ee14d508c
4 changed files with 176 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
-- CreateTable
CREATE TABLE "CounterpartyProfile" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"companyName" TEXT NOT NULL,
"companyFullName" TEXT NOT NULL,
"inn" TEXT NOT NULL,
"kpp" TEXT,
"ogrn" TEXT,
"legalAddress" TEXT NOT NULL,
"bankName" TEXT NOT NULL,
"bik" TEXT NOT NULL,
"correspondentAccount" TEXT NOT NULL,
"checkingAccount" TEXT NOT NULL,
"signerFullName" TEXT NOT NULL,
"signerPosition" TEXT NOT NULL,
"signerBasis" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "CounterpartyProfile_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "CounterpartyProfile_userId_key" ON "CounterpartyProfile"("userId");
-- AddForeignKey
ALTER TABLE "CounterpartyProfile" ADD CONSTRAINT "CounterpartyProfile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -61,6 +61,7 @@ model User {
role UserRole
companyId String?
company Company? @relation(fields: [companyId], references: [id])
counterpartyProfile CounterpartyProfile?
registrationRequests RegistrationRequest[] @relation("RegistrationRequester")
reviewedRequests RegistrationRequest[] @relation("RegistrationReviewer")
sentInvitations Invitation[] @relation("InvitationManager")
@@ -78,6 +79,27 @@ model User {
updatedAt DateTime @updatedAt
}
model CounterpartyProfile {
id String @id @default(cuid())
userId String @unique
user User @relation(fields: [userId], references: [id])
companyName String
companyFullName String
inn String
kpp String?
ogrn String?
legalAddress String
bankName String
bik String
correspondentAccount String
checkingAccount String
signerFullName String
signerPosition String
signerBasis String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model RegistrationRequest {
id String @id @default(cuid())
companyName String