Let cheques be received or paid without an invoice, and remind staff three days before due date.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-11 11:34:49 +03:30
co-authored by Cursor
parent 9a991fc1f1
commit 9beaed96e8
18 changed files with 982 additions and 61 deletions
@@ -0,0 +1,31 @@
-- AlterTable
ALTER TABLE "Cheque" ALTER COLUMN "paymentId" DROP NOT NULL;
ALTER TABLE "Cheque" ALTER COLUMN "invoiceId" DROP NOT NULL;
ALTER TABLE "Cheque" ADD COLUMN "amount" DECIMAL(18,2);
ALTER TABLE "Cheque" ADD COLUMN "currency" TEXT NOT NULL DEFAULT 'IRR';
ALTER TABLE "Cheque" ADD COLUMN "personId" TEXT;
ALTER TABLE "Cheque" ADD COLUMN "ownerId" TEXT;
UPDATE "Cheque" AS c
SET
"amount" = p."amount",
"currency" = p."currency"
FROM "Payment" AS p
WHERE c."paymentId" = p."id";
UPDATE "Cheque" AS c
SET
"personId" = i."personId",
"ownerId" = i."ownerId"
FROM "Invoice" AS i
WHERE c."invoiceId" = i."id";
UPDATE "Cheque" SET "amount" = 0 WHERE "amount" IS NULL;
ALTER TABLE "Cheque" ALTER COLUMN "amount" SET NOT NULL;
CREATE INDEX "Cheque_personId_idx" ON "Cheque"("personId");
CREATE INDEX "Cheque_ownerId_idx" ON "Cheque"("ownerId");
ALTER TABLE "Cheque" ADD CONSTRAINT "Cheque_personId_fkey" FOREIGN KEY ("personId") REFERENCES "Person"("id") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "Cheque" ADD CONSTRAINT "Cheque_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Cheque" ADD COLUMN "direction" TEXT NOT NULL DEFAULT 'in';
ALTER TABLE "Cheque" ADD COLUMN "reminderNotifiedAt" TIMESTAMP(3);
CREATE INDEX "Cheque_organizationId_direction_dueDate_idx" ON "Cheque"("organizationId", "direction", "dueDate");