sozsoft-platform/configs/seeds/postgres/object/Prc_T_MaterialRequestPlanLine.sql
2026-10-14 22:26:03 +03:00

31 lines
1.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Planla diyaloğunun taslak karşılama planı: talep kaleminin onaylanmamış dağıtımı (iç transfer: kaynak konum, satınalma: tedarikçi) ve
-- miktarı. İç transferde lot/seri takipli ürünün satırı lotu da taşır (LotNo; takipsiz üründe boş). Onay (Prc_P_MaterialRequestPlanConfirm) satırları teklif talebine ya da iç transfere çevirir ve siler.
CREATE TABLE IF NOT EXISTS public."Prc_T_MaterialRequestPlanLine"
(
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
"TenantId" uuid NULL,
"MaterialRequestItemId" uuid NOT NULL,
"PlanMethod" varchar(16) NOT NULL,
"SupplierId" uuid NULL,
"SourceLocationId" uuid NULL,
"LotNo" varchar(64) NOT NULL DEFAULT '',
"Quantity" numeric(18, 4) NOT NULL DEFAULT 0,
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
"CreatorId" uuid NULL,
"LastModificationTime" timestamp NULL,
"LastModifierId" uuid NULL,
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
"DeletionTime" timestamp NULL,
"DeleterId" uuid NULL,
CONSTRAINT "PK_Prc_T_MaterialRequestPlanLine" PRIMARY KEY ("Id")
);
CREATE INDEX IF NOT EXISTS "IX_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId" ON public."Prc_T_MaterialRequestPlanLine" ("MaterialRequestItemId");
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'FK_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId') THEN
ALTER TABLE public."Prc_T_MaterialRequestPlanLine" ADD CONSTRAINT "FK_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId" FOREIGN KEY ("MaterialRequestItemId") REFERENCES public."Prc_T_MaterialRequestItem" ("Id") ON DELETE CASCADE ON UPDATE NO ACTION;
END IF;
END
$$;