Adding a task generated from the account balance to products
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ProductAccountingLink" (
|
||||
"id" TEXT NOT NULL,
|
||||
"productId" TEXT NOT NULL,
|
||||
"connectionId" TEXT NOT NULL,
|
||||
"externalName" TEXT NOT NULL,
|
||||
"ayar" INTEGER,
|
||||
"vaznSabet" DOUBLE PRECISION,
|
||||
"matchMethod" TEXT NOT NULL DEFAULT 'import',
|
||||
"linkedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "ProductAccountingLink_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ProductAccountingLink_productId_idx" ON "ProductAccountingLink"("productId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ProductAccountingLink_connectionId_idx" ON "ProductAccountingLink"("connectionId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ProductAccountingLink_productId_connectionId_key" ON "ProductAccountingLink"("productId", "connectionId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ProductAccountingLink_connectionId_externalName_key" ON "ProductAccountingLink"("connectionId", "externalName");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductAccountingLink" ADD CONSTRAINT "ProductAccountingLink_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductAccountingLink" ADD CONSTRAINT "ProductAccountingLink_connectionId_fkey" FOREIGN KEY ("connectionId") REFERENCES "AccountingConnection"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -647,6 +647,7 @@ model Product {
|
||||
quoteLineItems QuoteLineItem[]
|
||||
invoiceLineItems InvoiceLineItem[]
|
||||
stockMovements StockMovement[]
|
||||
accountingLinks ProductAccountingLink[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -1316,6 +1317,7 @@ model AccountingConnection {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
personLinks PersonAccountingLink[]
|
||||
productLinks ProductAccountingLink[]
|
||||
documentLogs AccountingDocumentLog[]
|
||||
balanceCaches AccountingBalanceCache[]
|
||||
|
||||
@@ -1346,6 +1348,29 @@ model PersonAccountingLink {
|
||||
@@index([connectionId])
|
||||
}
|
||||
|
||||
/// لینک محصول CRM ↔ نام کارساخته (یا معادل) در تهحساب
|
||||
model ProductAccountingLink {
|
||||
id String @id @default(cuid())
|
||||
productId String
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
connectionId String
|
||||
connection AccountingConnection @relation(fields: [connectionId], references: [id], onDelete: Cascade)
|
||||
/// نام کارساخته در تهحساب (DoListNameKarsakhte.Name)
|
||||
externalName String
|
||||
ayar Int?
|
||||
vaznSabet Float?
|
||||
/// import | manual
|
||||
matchMethod String @default("import")
|
||||
linkedAt DateTime @default(now())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([productId, connectionId])
|
||||
@@unique([connectionId, externalName])
|
||||
@@index([productId])
|
||||
@@index([connectionId])
|
||||
}
|
||||
|
||||
model AccountingDocumentLog {
|
||||
id String @id @default(cuid())
|
||||
connectionId String
|
||||
|
||||
Reference in New Issue
Block a user