-- Creating table for acknowledgment of issued products.
create table "PharmacyIssuedStockHeader"(
  	"PharmacyIssuedStockHeaderId" bigserial primary key,
  	"IssuedDate" timestamp without time zone,
  	"IssuedBy" int references "Account"("AccountId"),
  	"HandOverTo" int references "Account"("AccountId"),
  	"Comment" text,
  	"RetailWareHouseLinkId" int references "RetailWareHouseLink"("RetailWareHouseLinkId") default null,
  	"PharmacyDepartmentId" int references "PharmacyDepartment"("PharmacyDepartmentId") default null,
  	"ReceivedBy" int references "Account"("AccountId") default null,
  	"ReceivedDate" timestamp without time zone default null
);

alter table "PharmacyIssuedStockHeader" add column "IssueHeaderId" int references "IssueHeader"("IssueHeaderId");

alter table "PharmacyIssuedStockHeader" add column "IssueNumber" text;

CREATE TABLE "PharmacyIssuedStockDetail" (
	"PharmacyIssuedStockDetailId" bigserial primary key,
	"PharmacyIssuedStockHeaderId" bigint references "PharmacyIssuedStockHeader"("PharmacyIssuedStockHeaderId"),
	"PharmacyProductId" int4 NULL,
	"TaxId" int4 NULL,
	"QuantityIn" int4 NULL,
	"BatchNumber" varchar(50) NULL,
	"ExpiryDate" date NULL,
	"PurchaseRate" numeric(8, 2) NULL,
	"Mrp" numeric(8, 2) NULL,
	"Barcode" varchar(50) NULL,
	"PharmacyStockId" int4 NULL
);

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