feat: add payment for split

This commit is contained in:
Methapon Metanipat 2024-10-15 13:29:40 +07:00
parent ca6b1e74d0
commit 20b7e56a0d
4 changed files with 151 additions and 30 deletions

View file

@ -0,0 +1,37 @@
/*
Warnings:
- The values [PaymentWait] on the enum `QuotationStatus` will be removed. If these variants are still used in the database, this will fail.
*/
-- CreateEnum
CREATE TYPE "PaymentStatus" AS ENUM ('PaymentWait', 'PaymentSuccess');
-- AlterEnum
BEGIN;
CREATE TYPE "QuotationStatus_new" AS ENUM ('PaymentPending', 'PaymentInProcess', 'PaymentSuccess', 'ProcessComplete', 'Canceled');
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" DROP DEFAULT;
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" TYPE "QuotationStatus_new" USING ("quotationStatus"::text::"QuotationStatus_new");
ALTER TYPE "QuotationStatus" RENAME TO "QuotationStatus_old";
ALTER TYPE "QuotationStatus_new" RENAME TO "QuotationStatus";
DROP TYPE "QuotationStatus_old";
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" SET DEFAULT 'PaymentPending';
COMMIT;
-- AlterTable
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" SET DEFAULT 'PaymentPending';
-- CreateTable
CREATE TABLE "QuotationPayment" (
"id" TEXT NOT NULL,
"paymentStatus" "PaymentStatus" NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"amount" DOUBLE PRECISION NOT NULL,
"remark" TEXT,
"quotationId" TEXT NOT NULL,
CONSTRAINT "QuotationPayment_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "QuotationPayment" ADD CONSTRAINT "QuotationPayment_quotationId_fkey" FOREIGN KEY ("quotationId") REFERENCES "Quotation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;