-- Table: public.PackageModule

-- DROP TABLE IF EXISTS public."PackageModule";
create sequence "PackageModule_PackageIdModule_Seq"



CREATE TABLE IF NOT EXISTS public."PackageModule"
(
    "PackageModuleId" integer NOT NULL DEFAULT nextval('"PackageModule_PackageIdModule_Seq"'::regclass),
    "PackageName" character varying(50) COLLATE pg_catalog."default" NOT NULL,
    "LocationId" integer NOT NULL,
    "ChargeModuleTemplateId" integer NOT NULL,
    "ChargeCategoryId" integer NOT NULL,
    "ChargeModuleCategoryIds" text COLLATE pg_catalog."default" NOT NULL,
    "ModulesMasterIds" text COLLATE pg_catalog."default" NOT NULL,
    "Active" boolean NOT NULL DEFAULT true,
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp without time zone NOT NULL DEFAULT now(),
    "ModifiedBy" integer,
    "ModifiedDate" timestamp without time zone,
    "SubTotal" numeric(8,2) NOT NULL,
    "DiscountPerc" numeric(4,2),
    "Discount" numeric(8,2),
    "Total" numeric(8,2) NOT NULL,
    "Notes" character varying(250) COLLATE pg_catalog."default",
    "PackageType" character varying(2) COLLATE pg_catalog."default" NOT NULL,
    "Quantity" numeric(4,0) NOT NULL,
    CONSTRAINT "PK_Package_PackageId" PRIMARY KEY ("PackageModuleId"),
    CONSTRAINT "FK_PackageModule_ChargeCategoryId" FOREIGN KEY ("ChargeCategoryId")
        REFERENCES public."ChargeCategory" ("ChargeCategoryId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "FK_PackageModule_ChargeModuleTemplateId" FOREIGN KEY ("ChargeModuleTemplateId")
        REFERENCES public."ChargeModuleTemplate" ("ChargeModuleTemplateId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."PackageModule"
    OWNER to postgres;

------------------------------------------------------------------------------------------------------------------------


-- Table: public.PackageModuleDetail

-- DROP TABLE IF EXISTS public."PackageModuleDetail";
create sequence "PackageModuleDetail_PackageIdModuleDetail_Seq"



CREATE TABLE IF NOT EXISTS public."PackageModuleDetail"
(
    "PackageModuleDetailId" integer NOT NULL DEFAULT nextval('"PackageModuleDetail_PackageIdModuleDetail_Seq"'::regclass),
    "PackageModuleId" integer NOT NULL,
    "ChargeModuleDetailsId" bigint,
    "Amount" numeric(8,2) NOT NULL,
    "ChargeModuleCategoryId" integer,
    "ModulesMasterId" integer,
    "Quantity" smallint NOT NULL DEFAULT 1,
    "Active" boolean NOT NULL DEFAULT true,
    "CreatedBy" numeric NOT NULL,
    "CreatedDate" time without time zone NOT NULL DEFAULT now(),
    "ModifiedBy" numeric,
    "ModifiedDate" time without time zone,
    "IsFree" boolean NOT NULL DEFAULT false,
    CONSTRAINT "PackageModuleDetail_pkey" PRIMARY KEY ("PackageModuleDetailId"),
    CONSTRAINT "FK_PackageModuleDetail_ChargeModuleDetailId" FOREIGN KEY ("ChargeModuleDetailsId")
        REFERENCES public."ChargeModuleDetails" ("ChargeModuleDetailsId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT "FK_PackageModuleDetail_PackageModuleId" FOREIGN KEY ("PackageModuleId")
        REFERENCES public."PackageModule" ("PackageModuleId") MATCH SIMPLE
        ON UPDATE CASCADE
        ON DELETE CASCADE
        NOT VALID
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."PackageModuleDetail"
    OWNER to postgres;