first commit
This commit is contained in:
121
prisma/migrations/20260406193800_init/migration.sql
Normal file
121
prisma/migrations/20260406193800_init/migration.sql
Normal file
@@ -0,0 +1,121 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Machine" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"relayChannel" INTEGER NOT NULL,
|
||||
"defaultPriceCents" INTEGER NOT NULL,
|
||||
"defaultDurationMinutes" INTEGER NOT NULL,
|
||||
"outOfService" BOOLEAN NOT NULL DEFAULT false,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Employee" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"pin" TEXT NOT NULL,
|
||||
"isAdmin" BOOLEAN NOT NULL DEFAULT false,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Transaction" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"machineId" TEXT NOT NULL,
|
||||
"employeeId" TEXT NOT NULL,
|
||||
"amountCents" INTEGER NOT NULL,
|
||||
"paymentMethod" TEXT NOT NULL,
|
||||
"startedAt" DATETIME NOT NULL,
|
||||
"expectedEndAt" DATETIME NOT NULL,
|
||||
"status" TEXT NOT NULL DEFAULT 'pending_relay',
|
||||
"endedAt" DATETIME,
|
||||
"relayOnAttemptedAt" DATETIME,
|
||||
"relayTurnedOnAt" DATETIME,
|
||||
"relayOffAttemptedAt" DATETIME,
|
||||
"relayTurnedOffAt" DATETIME,
|
||||
"relayFailureReason" TEXT,
|
||||
"voidReason" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "Transaction_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "Machine" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Transaction_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TransactionExtension" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"transactionId" TEXT NOT NULL,
|
||||
"employeeId" TEXT NOT NULL,
|
||||
"extraMinutes" INTEGER NOT NULL,
|
||||
"extraAmountCents" INTEGER NOT NULL,
|
||||
"reason" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "TransactionExtension_transactionId_fkey" FOREIGN KEY ("transactionId") REFERENCES "Transaction" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "TransactionExtension_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Shift" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"employeeId" TEXT NOT NULL,
|
||||
"startTime" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"endTime" DATETIME,
|
||||
"startingCashCents" INTEGER NOT NULL,
|
||||
"expectedCashCents" INTEGER,
|
||||
"actualCashCents" INTEGER,
|
||||
"differenceCashCents" INTEGER,
|
||||
"notes" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "Shift_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CashMovement" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"shiftId" TEXT NOT NULL,
|
||||
"employeeId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"amountCents" INTEGER NOT NULL,
|
||||
"reason" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "CashMovement_shiftId_fkey" FOREIGN KEY ("shiftId") REFERENCES "Shift" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "CashMovement_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "AppConfig" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 1,
|
||||
"businessName" TEXT NOT NULL DEFAULT 'La Burbuja',
|
||||
"timezone" TEXT NOT NULL DEFAULT 'America/Monterrey',
|
||||
"currency" TEXT NOT NULL DEFAULT 'MXN',
|
||||
"serialPortPath" TEXT NOT NULL DEFAULT 'COM3',
|
||||
"serialBaudRate" INTEGER NOT NULL DEFAULT 9600,
|
||||
"relayMockMode" BOOLEAN NOT NULL DEFAULT true,
|
||||
"relayConnected" BOOLEAN NOT NULL DEFAULT false,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Machine_name_key" ON "Machine"("name");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Machine_relayChannel_key" ON "Machine"("relayChannel");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Transaction_expectedEndAt_idx" ON "Transaction"("expectedEndAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Transaction_status_idx" ON "Transaction"("status");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Shift_startTime_idx" ON "Shift"("startTime");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "CashMovement_createdAt_idx" ON "CashMovement"("createdAt");
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_AppConfig" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 1,
|
||||
"businessName" TEXT NOT NULL DEFAULT 'La Burbuja',
|
||||
"timezone" TEXT NOT NULL DEFAULT 'America/Monterrey',
|
||||
"currency" TEXT NOT NULL DEFAULT 'MXN',
|
||||
"serialPortPath" TEXT NOT NULL DEFAULT 'COM3',
|
||||
"serialBaudRate" INTEGER NOT NULL DEFAULT 9600,
|
||||
"relayMockMode" BOOLEAN NOT NULL DEFAULT true,
|
||||
"relayConnected" BOOLEAN NOT NULL DEFAULT false,
|
||||
"selfServiceWashPriceCents" INTEGER NOT NULL DEFAULT 4500,
|
||||
"selfServiceDryPriceCents" INTEGER NOT NULL DEFAULT 4500,
|
||||
"selfServiceCycleMinutes" INTEGER NOT NULL DEFAULT 50,
|
||||
"encargoPricePerKgCents" INTEGER NOT NULL DEFAULT 3300,
|
||||
"encargoMinimumChargeCents" INTEGER NOT NULL DEFAULT 12000,
|
||||
"xlEdredonIndividualCents" INTEGER NOT NULL DEFAULT 15000,
|
||||
"xlEdredonMatrimonialCents" INTEGER NOT NULL DEFAULT 18000,
|
||||
"xlEdredonKingCents" INTEGER NOT NULL DEFAULT 20000,
|
||||
"xlCobijaGruesaCents" INTEGER NOT NULL DEFAULT 12000,
|
||||
"xlAlmohadaParCents" INTEGER NOT NULL DEFAULT 8000,
|
||||
"dryCleaningMinimumCents" INTEGER NOT NULL DEFAULT 15000,
|
||||
"dryCleaningUrgentSurchargePct" INTEGER NOT NULL DEFAULT 50,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
INSERT INTO "new_AppConfig" ("businessName", "currency", "id", "relayConnected", "relayMockMode", "serialBaudRate", "serialPortPath", "timezone", "updatedAt") SELECT "businessName", "currency", "id", "relayConnected", "relayMockMode", "serialBaudRate", "serialPortPath", "timezone", "updatedAt" FROM "AppConfig";
|
||||
DROP TABLE "AppConfig";
|
||||
ALTER TABLE "new_AppConfig" RENAME TO "AppConfig";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `baseAmountCents` to the `Transaction` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `customerId` to the `Transaction` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `ticketNumber` to the `Transaction` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- CreateTable
|
||||
CREATE TABLE "Customer" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"firstName" TEXT NOT NULL,
|
||||
"lastName" TEXT NOT NULL,
|
||||
"phone" TEXT NOT NULL,
|
||||
"email" TEXT,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
INSERT INTO "Customer" ("id", "firstName", "lastName", "phone", "email", "isActive", "createdAt", "updatedAt")
|
||||
VALUES ('legacy-customer', 'Cliente', 'Mostrador', 'LEGACY-UNASSIGNED', NULL, true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_AppConfig" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 1,
|
||||
"businessName" TEXT NOT NULL DEFAULT 'La Burbuja',
|
||||
"timezone" TEXT NOT NULL DEFAULT 'America/Monterrey',
|
||||
"currency" TEXT NOT NULL DEFAULT 'MXN',
|
||||
"serialPortPath" TEXT NOT NULL DEFAULT 'COM3',
|
||||
"serialBaudRate" INTEGER NOT NULL DEFAULT 9600,
|
||||
"relayMockMode" BOOLEAN NOT NULL DEFAULT true,
|
||||
"relayConnected" BOOLEAN NOT NULL DEFAULT false,
|
||||
"selfServiceWashPriceCents" INTEGER NOT NULL DEFAULT 4500,
|
||||
"selfServiceDryPriceCents" INTEGER NOT NULL DEFAULT 4500,
|
||||
"selfServiceCycleMinutes" INTEGER NOT NULL DEFAULT 50,
|
||||
"encargoPricePerKgCents" INTEGER NOT NULL DEFAULT 3300,
|
||||
"encargoMinimumChargeCents" INTEGER NOT NULL DEFAULT 12000,
|
||||
"xlEdredonIndividualCents" INTEGER NOT NULL DEFAULT 15000,
|
||||
"xlEdredonMatrimonialCents" INTEGER NOT NULL DEFAULT 18000,
|
||||
"xlEdredonKingCents" INTEGER NOT NULL DEFAULT 20000,
|
||||
"xlCobijaGruesaCents" INTEGER NOT NULL DEFAULT 12000,
|
||||
"xlAlmohadaParCents" INTEGER NOT NULL DEFAULT 8000,
|
||||
"dryCleaningMinimumCents" INTEGER NOT NULL DEFAULT 15000,
|
||||
"dryCleaningUrgentSurchargePct" INTEGER NOT NULL DEFAULT 50,
|
||||
"detergentAddonCents" INTEGER NOT NULL DEFAULT 500,
|
||||
"softenerAddonCents" INTEGER NOT NULL DEFAULT 500,
|
||||
"bleachAddonCents" INTEGER NOT NULL DEFAULT 500,
|
||||
"loyaltyEveryNTransactions" INTEGER NOT NULL DEFAULT 10,
|
||||
"loyaltyDiscountPct" INTEGER NOT NULL DEFAULT 50,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
INSERT INTO "new_AppConfig" ("businessName", "currency", "dryCleaningMinimumCents", "dryCleaningUrgentSurchargePct", "encargoMinimumChargeCents", "encargoPricePerKgCents", "id", "relayConnected", "relayMockMode", "selfServiceCycleMinutes", "selfServiceDryPriceCents", "selfServiceWashPriceCents", "serialBaudRate", "serialPortPath", "timezone", "updatedAt", "xlAlmohadaParCents", "xlCobijaGruesaCents", "xlEdredonIndividualCents", "xlEdredonKingCents", "xlEdredonMatrimonialCents") SELECT "businessName", "currency", "dryCleaningMinimumCents", "dryCleaningUrgentSurchargePct", "encargoMinimumChargeCents", "encargoPricePerKgCents", "id", "relayConnected", "relayMockMode", "selfServiceCycleMinutes", "selfServiceDryPriceCents", "selfServiceWashPriceCents", "serialBaudRate", "serialPortPath", "timezone", "updatedAt", "xlAlmohadaParCents", "xlCobijaGruesaCents", "xlEdredonIndividualCents", "xlEdredonKingCents", "xlEdredonMatrimonialCents" FROM "AppConfig";
|
||||
DROP TABLE "AppConfig";
|
||||
ALTER TABLE "new_AppConfig" RENAME TO "AppConfig";
|
||||
CREATE TABLE "new_Transaction" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"ticketNumber" INTEGER NOT NULL,
|
||||
"machineId" TEXT NOT NULL,
|
||||
"employeeId" TEXT NOT NULL,
|
||||
"customerId" TEXT NOT NULL,
|
||||
"baseAmountCents" INTEGER NOT NULL,
|
||||
"discountCents" INTEGER NOT NULL DEFAULT 0,
|
||||
"loyaltyDiscountApplied" BOOLEAN NOT NULL DEFAULT false,
|
||||
"addonDetergentQty" INTEGER NOT NULL DEFAULT 0,
|
||||
"addonSoftenerQty" INTEGER NOT NULL DEFAULT 0,
|
||||
"addonBleachQty" INTEGER NOT NULL DEFAULT 0,
|
||||
"addonAmountCents" INTEGER NOT NULL DEFAULT 0,
|
||||
"amountCents" INTEGER NOT NULL,
|
||||
"paymentMethod" TEXT NOT NULL,
|
||||
"startedAt" DATETIME NOT NULL,
|
||||
"expectedEndAt" DATETIME NOT NULL,
|
||||
"status" TEXT NOT NULL DEFAULT 'pending_relay',
|
||||
"endedAt" DATETIME,
|
||||
"relayOnAttemptedAt" DATETIME,
|
||||
"relayTurnedOnAt" DATETIME,
|
||||
"relayOffAttemptedAt" DATETIME,
|
||||
"relayTurnedOffAt" DATETIME,
|
||||
"relayFailureReason" TEXT,
|
||||
"voidReason" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "Transaction_machineId_fkey" FOREIGN KEY ("machineId") REFERENCES "Machine" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Transaction_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Transaction_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "Customer" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_Transaction" (
|
||||
"id",
|
||||
"ticketNumber",
|
||||
"machineId",
|
||||
"employeeId",
|
||||
"customerId",
|
||||
"baseAmountCents",
|
||||
"discountCents",
|
||||
"loyaltyDiscountApplied",
|
||||
"addonDetergentQty",
|
||||
"addonSoftenerQty",
|
||||
"addonBleachQty",
|
||||
"addonAmountCents",
|
||||
"amountCents",
|
||||
"paymentMethod",
|
||||
"startedAt",
|
||||
"expectedEndAt",
|
||||
"status",
|
||||
"endedAt",
|
||||
"relayOnAttemptedAt",
|
||||
"relayTurnedOnAt",
|
||||
"relayOffAttemptedAt",
|
||||
"relayTurnedOffAt",
|
||||
"relayFailureReason",
|
||||
"voidReason",
|
||||
"createdAt",
|
||||
"updatedAt"
|
||||
)
|
||||
SELECT
|
||||
"id",
|
||||
ROW_NUMBER() OVER (ORDER BY "createdAt", "id") AS "ticketNumber",
|
||||
"machineId",
|
||||
"employeeId",
|
||||
'legacy-customer' AS "customerId",
|
||||
"amountCents" AS "baseAmountCents",
|
||||
0 AS "discountCents",
|
||||
false AS "loyaltyDiscountApplied",
|
||||
0 AS "addonDetergentQty",
|
||||
0 AS "addonSoftenerQty",
|
||||
0 AS "addonBleachQty",
|
||||
0 AS "addonAmountCents",
|
||||
"amountCents",
|
||||
"paymentMethod",
|
||||
"startedAt",
|
||||
"expectedEndAt",
|
||||
"status",
|
||||
"endedAt",
|
||||
"relayOnAttemptedAt",
|
||||
"relayTurnedOnAt",
|
||||
"relayOffAttemptedAt",
|
||||
"relayTurnedOffAt",
|
||||
"relayFailureReason",
|
||||
"voidReason",
|
||||
"createdAt",
|
||||
"updatedAt"
|
||||
FROM "Transaction";
|
||||
DROP TABLE "Transaction";
|
||||
ALTER TABLE "new_Transaction" RENAME TO "Transaction";
|
||||
CREATE UNIQUE INDEX "Transaction_ticketNumber_key" ON "Transaction"("ticketNumber");
|
||||
CREATE INDEX "Transaction_expectedEndAt_idx" ON "Transaction"("expectedEndAt");
|
||||
CREATE INDEX "Transaction_status_idx" ON "Transaction"("status");
|
||||
CREATE INDEX "Transaction_customerId_idx" ON "Transaction"("customerId");
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Customer_phone_key" ON "Customer"("phone");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Customer_lastName_firstName_idx" ON "Customer"("lastName", "firstName");
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "Transaction" ADD COLUMN "serviceType" TEXT NOT NULL DEFAULT 'autoservicio';
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "sqlite"
|
||||
162
prisma/schema.prisma
Normal file
162
prisma/schema.prisma
Normal file
@@ -0,0 +1,162 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
engineType = "binary"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Machine {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
type String
|
||||
relayChannel Int @unique
|
||||
defaultPriceCents Int
|
||||
defaultDurationMinutes Int
|
||||
outOfService Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
transactions Transaction[]
|
||||
}
|
||||
|
||||
model Employee {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
pin String
|
||||
isAdmin Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
shifts Shift[]
|
||||
transactions Transaction[]
|
||||
cashMovements CashMovement[]
|
||||
extensions TransactionExtension[]
|
||||
}
|
||||
|
||||
model Customer {
|
||||
id String @id @default(cuid())
|
||||
firstName String
|
||||
lastName String
|
||||
phone String @unique
|
||||
email String?
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
transactions Transaction[]
|
||||
|
||||
@@index([lastName, firstName])
|
||||
}
|
||||
|
||||
model Transaction {
|
||||
id String @id @default(cuid())
|
||||
ticketNumber Int @unique
|
||||
machineId String
|
||||
machine Machine @relation(fields: [machineId], references: [id])
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id])
|
||||
customerId String
|
||||
customer Customer @relation(fields: [customerId], references: [id])
|
||||
baseAmountCents Int
|
||||
discountCents Int @default(0)
|
||||
loyaltyDiscountApplied Boolean @default(false)
|
||||
addonDetergentQty Int @default(0)
|
||||
addonSoftenerQty Int @default(0)
|
||||
addonBleachQty Int @default(0)
|
||||
addonAmountCents Int @default(0)
|
||||
serviceType String @default("autoservicio")
|
||||
amountCents Int
|
||||
paymentMethod String
|
||||
startedAt DateTime
|
||||
expectedEndAt DateTime
|
||||
status String @default("pending_relay")
|
||||
endedAt DateTime?
|
||||
relayOnAttemptedAt DateTime?
|
||||
relayTurnedOnAt DateTime?
|
||||
relayOffAttemptedAt DateTime?
|
||||
relayTurnedOffAt DateTime?
|
||||
relayFailureReason String?
|
||||
voidReason String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
extensions TransactionExtension[]
|
||||
|
||||
@@index([expectedEndAt])
|
||||
@@index([status])
|
||||
@@index([customerId])
|
||||
}
|
||||
|
||||
model TransactionExtension {
|
||||
id String @id @default(cuid())
|
||||
transactionId String
|
||||
transaction Transaction @relation(fields: [transactionId], references: [id])
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id])
|
||||
extraMinutes Int
|
||||
extraAmountCents Int
|
||||
reason String?
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model Shift {
|
||||
id String @id @default(cuid())
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id])
|
||||
startTime DateTime @default(now())
|
||||
endTime DateTime?
|
||||
startingCashCents Int
|
||||
expectedCashCents Int?
|
||||
actualCashCents Int?
|
||||
differenceCashCents Int?
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
cashMovements CashMovement[]
|
||||
|
||||
@@index([startTime])
|
||||
}
|
||||
|
||||
model CashMovement {
|
||||
id String @id @default(cuid())
|
||||
shiftId String
|
||||
shift Shift @relation(fields: [shiftId], references: [id])
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id])
|
||||
type String
|
||||
amountCents Int
|
||||
reason String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
model AppConfig {
|
||||
id Int @id @default(1)
|
||||
businessName String @default("La Burbuja")
|
||||
timezone String @default("America/Monterrey")
|
||||
currency String @default("MXN")
|
||||
serialPortPath String @default("COM3")
|
||||
serialBaudRate Int @default(9600)
|
||||
relayMockMode Boolean @default(true)
|
||||
relayConnected Boolean @default(false)
|
||||
selfServiceWashPriceCents Int @default(4500)
|
||||
selfServiceDryPriceCents Int @default(4500)
|
||||
selfServiceCycleMinutes Int @default(50)
|
||||
encargoPricePerKgCents Int @default(3300)
|
||||
encargoMinimumChargeCents Int @default(12000)
|
||||
xlEdredonIndividualCents Int @default(15000)
|
||||
xlEdredonMatrimonialCents Int @default(18000)
|
||||
xlEdredonKingCents Int @default(20000)
|
||||
xlCobijaGruesaCents Int @default(12000)
|
||||
xlAlmohadaParCents Int @default(8000)
|
||||
dryCleaningMinimumCents Int @default(15000)
|
||||
dryCleaningUrgentSurchargePct Int @default(50)
|
||||
detergentAddonCents Int @default(500)
|
||||
softenerAddonCents Int @default(500)
|
||||
bleachAddonCents Int @default(500)
|
||||
loyaltyEveryNTransactions Int @default(10)
|
||||
loyaltyDiscountPct Int @default(50)
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
76
prisma/seed.ts
Normal file
76
prisma/seed.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
type ComboLabel = "Encargo" | "XL";
|
||||
|
||||
function buildMachineName(type: "washer" | "dryer", number: number, label?: ComboLabel) {
|
||||
const base = type === "washer" ? `Lavadora ${number}` : `Secadora ${number}`;
|
||||
return label ? `${base} (${label})` : base;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await prisma.appConfig.upsert({
|
||||
where: { id: 1 },
|
||||
update: {},
|
||||
create: {
|
||||
id: 1,
|
||||
businessName: "La Burbuja",
|
||||
timezone: "America/Monterrey",
|
||||
currency: "MXN",
|
||||
serialPortPath: "COM3",
|
||||
serialBaudRate: 9600,
|
||||
relayMockMode: true
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.employee.upsert({
|
||||
where: { id: "admin-default" },
|
||||
update: {},
|
||||
create: {
|
||||
id: "admin-default",
|
||||
name: "Administrador",
|
||||
pin: "1234",
|
||||
isAdmin: true
|
||||
}
|
||||
});
|
||||
|
||||
const existingMachineCount = await prisma.machine.count();
|
||||
|
||||
if (existingMachineCount === 0) {
|
||||
const combos = [
|
||||
...Array.from({ length: 12 }, (_, index) => ({ number: index + 1 as number, label: undefined as ComboLabel | undefined })),
|
||||
{ number: 13, label: "Encargo" as const },
|
||||
{ number: 14, label: "Encargo" as const },
|
||||
{ number: 15, label: "Encargo" as const },
|
||||
{ number: 16, label: "XL" as const }
|
||||
];
|
||||
|
||||
const washers = combos.map((combo, index) => ({
|
||||
name: buildMachineName("washer", combo.number, combo.label),
|
||||
type: "washer" as const,
|
||||
relayChannel: index,
|
||||
defaultPriceCents: 8000,
|
||||
defaultDurationMinutes: 35
|
||||
}));
|
||||
const dryers = combos.map((combo, index) => ({
|
||||
name: buildMachineName("dryer", combo.number, combo.label),
|
||||
type: "dryer" as const,
|
||||
relayChannel: index + combos.length,
|
||||
defaultPriceCents: 6000,
|
||||
defaultDurationMinutes: 45
|
||||
}));
|
||||
const machines = [...washers, ...dryers];
|
||||
await prisma.machine.createMany({ data: machines });
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (error) => {
|
||||
console.error(error);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user