CREATE TABLE "payment" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" BIGINT NOT NULL,
    "amount" NUMERIC,
    "payment_date" DATE,
    "method" TEXT,
    "payment_signature" TEXT,
    "from_account" TEXT,
    "to_account" TEXT,
    "remaining_amount" NUMERIC,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "plans_ref" (
    "id" BIGSERIAL PRIMARY KEY,
    "name" TEXT,
    "price" NUMERIC,
    "duration" DATE, 
    "description" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "invoice" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" BIGINT NOT NULL,
    "payment_id" BIGINT NOT NULL,
    "invoice_number" TEXT,
    "amount" NUMERIC,
    "remaining_balance" NUMERIC,
    "tax" NUMERIC,
    "issue_date" DATE,
    "due_date" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "refund" (
    "id" BIGSERIAL PRIMARY KEY,
    "payment_id" BIGINT NOT NULL,
    "amount" NUMERIC,
    "refund_date" DATE,
    "reason" TEXT,
    "to_account" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "plan_usage" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" BIGINT NOT NULL,
    "plan_id" BIGINT NOT NULL,
    "usage_type" TEXT,
    "usage_quantity" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "offers" (
    "id" BIGSERIAL PRIMARY KEY,
    "code" TEXT,
    "description" TEXT,
    "discount_value" NUMERIC,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "offers_redemption" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" BIGINT NOT NULL,
    "offer_id" BIGINT NOT NULL,
    "payment_id" BIGINT NOT NULL,
    "redemption_date" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "quotes" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" BIGINT NOT NULL,
    "user_email" TEXT,
    "institute_id" BIGINT,
    "quote_type" TEXT,
    "quote_est" NUMERIC,
    "cust_estimate" NUMERIC,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);
