Initial admin edits
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "AppBanner" ADD COLUMN "bannerLink" TEXT;
|
||||
@@ -0,0 +1,23 @@
|
||||
-- Preserve customer ↔ company links where only CustomerBrand existed (match by brand/company name or slug)
|
||||
UPDATE "Customer" c
|
||||
SET "companyId" = comp.id
|
||||
FROM "CustomerBrand" cb
|
||||
JOIN "Brand" b ON b.id = cb."brandId"
|
||||
JOIN "Company" comp ON LOWER(TRIM(comp.name)) = LOWER(TRIM(b.name))
|
||||
WHERE cb."customerId" = c.id
|
||||
AND c."companyId" IS NULL;
|
||||
|
||||
UPDATE "Customer" c
|
||||
SET "companyId" = comp.id
|
||||
FROM "CustomerBrand" cb
|
||||
JOIN "Brand" b ON b.id = cb."brandId"
|
||||
JOIN "Company" comp ON b.slug IS NOT NULL AND comp.slug = b.slug
|
||||
WHERE cb."customerId" = c.id
|
||||
AND c."companyId" IS NULL;
|
||||
|
||||
ALTER TABLE "Product" DROP CONSTRAINT IF EXISTS "Product_brandId_fkey";
|
||||
DROP INDEX IF EXISTS "Product_brandId_idx";
|
||||
ALTER TABLE "Product" DROP COLUMN IF EXISTS "brandId";
|
||||
|
||||
DROP TABLE IF EXISTS "CustomerBrand";
|
||||
DROP TABLE IF EXISTS "Brand";
|
||||
@@ -0,0 +1,30 @@
|
||||
-- نادمی تکس: شرکت اصلی (دریافت پرداخت + پیشفرض محصولات بدون شرکت مشخص)
|
||||
INSERT INTO "Company" (
|
||||
"id",
|
||||
"name",
|
||||
"slug",
|
||||
"description",
|
||||
"isActive",
|
||||
"displayOrder",
|
||||
"cashInvoiceValidityHours",
|
||||
"updatedAt"
|
||||
)
|
||||
VALUES (
|
||||
'company-nademitex',
|
||||
'نادمی تکس',
|
||||
'nademitex',
|
||||
'شرکت اصلی — تمام پرداختهای اپ به حسابهای این شرکت واریز میشود',
|
||||
true,
|
||||
0,
|
||||
8,
|
||||
CURRENT_TIMESTAMP
|
||||
)
|
||||
ON CONFLICT ("slug") DO UPDATE SET
|
||||
"name" = EXCLUDED."name",
|
||||
"description" = EXCLUDED."description",
|
||||
"isActive" = true;
|
||||
|
||||
-- حسابهای بانکی فقط برای دریافت پرداخت نادمی تکس
|
||||
UPDATE "BankAccount"
|
||||
SET "companyId" = (SELECT "id" FROM "Company" WHERE "slug" = 'nademitex' LIMIT 1)
|
||||
WHERE "companyId" IS NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Product" ADD COLUMN "specs" TEXT;
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE "SystemSettings" ADD COLUMN "supportWhatsapp" TEXT;
|
||||
ALTER TABLE "SystemSettings" ADD COLUMN "supportTelegram" TEXT;
|
||||
ALTER TABLE "SystemSettings" ADD COLUMN "supportInstagram" TEXT;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "SettlementType" ADD VALUE 'cash_check';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "SystemSettings" ADD COLUMN "defaultSettlementCashCheck" BOOLEAN NOT NULL DEFAULT false;
|
||||
+11
-32
@@ -11,6 +11,7 @@ datasource db {
|
||||
enum SettlementType {
|
||||
cash
|
||||
check
|
||||
cash_check
|
||||
}
|
||||
|
||||
enum CheckRegistrationMode {
|
||||
@@ -175,6 +176,8 @@ model Product {
|
||||
code String
|
||||
color String
|
||||
description String?
|
||||
/// مشخصات آزاد محصول (نمایش در specs-extra اپ)
|
||||
specs String? @db.Text
|
||||
minMeterage Float @default(30)
|
||||
orderMultiplier Float @default(10)
|
||||
/// قیمت هر متر (تومان) برای نمایش کاتالوگ / پیشفاکتور
|
||||
@@ -194,12 +197,10 @@ model Product {
|
||||
subtitle String?
|
||||
rollMeters Float @default(50)
|
||||
isNew Boolean @default(false)
|
||||
brandId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
brand Brand? @relation(fields: [brandId], references: [id], onDelete: SetNull)
|
||||
cartItems CartItem[]
|
||||
orderItems OrderItem[]
|
||||
favorites ProductFavorite[]
|
||||
@@ -208,7 +209,6 @@ model Product {
|
||||
|
||||
@@unique([companyId, code])
|
||||
@@index([companyId])
|
||||
@@index([brandId])
|
||||
@@index([usageCategory])
|
||||
@@index([season])
|
||||
}
|
||||
@@ -254,7 +254,6 @@ model Customer {
|
||||
favorites ProductFavorite[]
|
||||
catalogRequests CatalogRequest[]
|
||||
productSuggestions ProductSuggestion[]
|
||||
customerBrands CustomerBrand[]
|
||||
addresses CustomerAddress[]
|
||||
|
||||
@@index([companyId])
|
||||
@@ -485,8 +484,9 @@ model SystemSettings {
|
||||
id String @id @default("default")
|
||||
maxMeteragePerInvoice Int @default(5000)
|
||||
cashInvoiceValidityHours Int @default(8)
|
||||
defaultSettlementCheck Boolean @default(true)
|
||||
defaultSettlementCash Boolean @default(true)
|
||||
defaultSettlementCheck Boolean @default(true)
|
||||
defaultSettlementCash Boolean @default(true)
|
||||
defaultSettlementCashCheck Boolean @default(false)
|
||||
/// حداقل سفارش: تعداد طاقه از هر محصول (§۱۹)
|
||||
minOrderRollsPerProduct Int @default(1)
|
||||
/// نمایش قیمت عمومی در کاتالوگ (پیشفرض خاموش)
|
||||
@@ -502,6 +502,9 @@ model SystemSettings {
|
||||
smsShippingUpdate Boolean @default(true)
|
||||
supportPhone String?
|
||||
supportEmail String?
|
||||
supportWhatsapp String?
|
||||
supportTelegram String?
|
||||
supportInstagram String?
|
||||
/// تصاویر دستههای کاربرد/فصل اپ کاربر: { trousers: dataUrl, summer: dataUrl, ... }
|
||||
categoryImagesJson Json?
|
||||
/// تعاریف دستهها (کاربرد/فصل). اگر خالی باشد از مقادیر پیشفرض کد استفاده میشود.
|
||||
@@ -517,6 +520,8 @@ model AppBanner {
|
||||
subtitle String?
|
||||
ctaLabel String?
|
||||
ctaLink String?
|
||||
/// لینک کلیک روی تصویر بنر (مستقل از لینک دکمه)
|
||||
bannerLink String?
|
||||
imageUrl String?
|
||||
displayOrder Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
@@ -627,32 +632,6 @@ model ProductFavorite {
|
||||
@@index([customerId])
|
||||
}
|
||||
|
||||
model Brand {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
slug String? @unique
|
||||
description String?
|
||||
isActive Boolean @default(true)
|
||||
displayOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
customers CustomerBrand[]
|
||||
products Product[]
|
||||
}
|
||||
|
||||
model CustomerBrand {
|
||||
customerId String
|
||||
brandId String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
||||
brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([customerId, brandId])
|
||||
@@index([brandId])
|
||||
}
|
||||
|
||||
model CustomerLevelDef {
|
||||
id String @id @default(cuid())
|
||||
code String @unique
|
||||
|
||||
+17
-6
@@ -66,6 +66,17 @@ async function main() {
|
||||
|
||||
await prisma.company.createMany({
|
||||
data: [
|
||||
{
|
||||
id: 'company-nademitex',
|
||||
name: 'نادمی تکس',
|
||||
slug: 'nademitex',
|
||||
description: 'شرکت اصلی — دریافت تمام پرداختهای اپ',
|
||||
isActive: true,
|
||||
displayOrder: 0,
|
||||
maxMeteragePerInvoice: null,
|
||||
cashInvoiceValidityHours: 8,
|
||||
cashInvoiceValidUntilHour: 17,
|
||||
},
|
||||
{
|
||||
id: 'company-par',
|
||||
name: 'شرکت پَر',
|
||||
@@ -95,9 +106,9 @@ async function main() {
|
||||
data: [
|
||||
{
|
||||
id: 'ba-par-1',
|
||||
companyId: 'company-par',
|
||||
companyId: 'company-nademitex',
|
||||
bankName: 'بانک ملی',
|
||||
accountHolder: 'شرکت پَر',
|
||||
accountHolder: 'نادمی تکس',
|
||||
accountNumber: '0123456789',
|
||||
cardNumber: '6037-9912-3456-7890',
|
||||
iban: 'IR120170000000012345678901',
|
||||
@@ -106,9 +117,9 @@ async function main() {
|
||||
},
|
||||
{
|
||||
id: 'ba-par-2',
|
||||
companyId: 'company-par',
|
||||
companyId: 'company-nademitex',
|
||||
bankName: 'بانک صادرات',
|
||||
accountHolder: 'شرکت پَر',
|
||||
accountHolder: 'نادمی تکس',
|
||||
accountNumber: '9876543210',
|
||||
cardNumber: '6037-6912-3456-7891',
|
||||
iban: 'IR620190000000098765432101',
|
||||
@@ -117,9 +128,9 @@ async function main() {
|
||||
},
|
||||
{
|
||||
id: 'ba-fam-1',
|
||||
companyId: 'company-fam-baft',
|
||||
companyId: 'company-nademitex',
|
||||
bankName: 'بانک ملت',
|
||||
accountHolder: 'فامبافت',
|
||||
accountHolder: 'نادمی تکس',
|
||||
accountNumber: '1122334455',
|
||||
cardNumber: '6104-3378-9012-3456',
|
||||
iban: 'IR450120000000011223344556',
|
||||
|
||||
Reference in New Issue
Block a user