CREATE SEQUENCE IF NOT EXISTS public."MasterBill_Seq"
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- Table: public.MasterBill

-- DROP TABLE IF EXISTS public."MasterBill";

CREATE TABLE IF NOT EXISTS public."MasterBill"
(
    "MasterBillId" integer NOT NULL DEFAULT nextval('"MasterBill_Seq"'::regclass),
    "ModuleId" integer,
    "ModulesMasterId" integer NOT NULL,
    "Total" numeric(10,2) NOT NULL,
    "BillDate" timestamp without time zone NOT NULL,
    "BillNumber" character varying COLLATE pg_catalog."default",
    "BillStatusTypeId" integer NOT NULL,
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp without time zone NOT NULL,
    "ModifiedDate" timestamp without time zone,
    "ModifiedBy" integer,
    "Active" boolean NOT NULL DEFAULT true,
    "PatientId" integer,
    "NetTotal" numeric(10,2),
    "Tax" numeric(10,2),
    "Discount" numeric(10,2),
    "Deposit" numeric(10,2),
    "Refund" numeric(10,2),
    "Rounding" numeric(10,2),
    CONSTRAINT "MasterBill_pkey" PRIMARY KEY ("MasterBillId"),
    CONSTRAINT "FK_MasterBill_PatientId" FOREIGN KEY ("PatientId")
        REFERENCES public."Patient" ("PatientId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "FK_Receipt_BillStatusTypeId" FOREIGN KEY ("BillStatusTypeId")
        REFERENCES public."BillStatusType" ("BillStatusTypeId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
    CONSTRAINT "FK_Receipt_CreatedBy" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
    CONSTRAINT "FK_Receipt_ModifiedBy" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
    CONSTRAINT "FK_Receipt_ModulesMasterId" FOREIGN KEY ("ModulesMasterId")
        REFERENCES public."ModulesMaster" ("ModulesMasterId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE
)

TABLESPACE pg_default;

