-- Add agent billing settings to users
ALTER TABLE "User"
ADD COLUMN "agentBillingEnabled" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN "agentBankAccount" TEXT,
ADD COLUMN "agentVatBreakdownRequired" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN "agentUseListingOverrides" BOOLEAN NOT NULL DEFAULT false;

-- Listing-specific billing overrides
CREATE TABLE "ListingBillingSettings" (
  "id" TEXT NOT NULL,
  "listingId" TEXT NOT NULL,
  "bankAccount" TEXT,
  "vatBreakdownRequired" BOOLEAN NOT NULL DEFAULT false,
  "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT "ListingBillingSettings_pkey" PRIMARY KEY ("id"),
  CONSTRAINT "ListingBillingSettings_listingId_fkey" FOREIGN KEY ("listingId") REFERENCES "Listing"("id") ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT "ListingBillingSettings_listingId_key" UNIQUE ("listingId")
);
