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

23 lines
1.5 KiB
PL/PgSQL
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.

-- Tamamlanmış hareket belgesinin stoğu belirleyen başlık alanları değiştirilemez (Alımlar, Teslimatlar, İç Transferler ve ortak sekmeleri):
-- stok eski konumda kalır, İade Et yeni konumdan düşmeye çalışırdı. Kural ekranın UpdateBeforeCommand'ında değil burada, çünkü durum
-- butonları yalnız PendingAction ile aynı güncelleme yolundan yazar. Açıklama, nakliye ve not alanları serbesttir;
-- satırların kuralı Transfer Satırları'nın Update/DeleteBeforeCommand'ındadır (50313).
CREATE OR REPLACE FUNCTION public."Inv_TR_TransferLock"() RETURNS trigger
LANGUAGE plpgsql AS $$
BEGIN
IF OLD."Status" = 'Done'
AND (NEW."Status", NEW."BranchId", NEW."WarehouseId", NEW."OperationTypeId", NEW."OperationKind", NEW."SourceLocationId",
NEW."DestinationLocationId", NEW."PartnerId", NEW."IsDeleted")
IS DISTINCT FROM
(OLD."Status", OLD."BranchId", OLD."WarehouseId", OLD."OperationTypeId", OLD."OperationKind", OLD."SourceLocationId",
OLD."DestinationLocationId", OLD."PartnerId", OLD."IsDeleted") THEN
RAISE EXCEPTION 'Tamamlanmış belgenin konumu, türü ve durumu değiştirilemez; düzeltme için İade Et kullanın.'
USING ERRCODE = 'P0001', DETAIL = '50328';
END IF;
RETURN NEW;
END;
$$;
DROP TRIGGER IF EXISTS "Inv_TR_TransferLock" ON public."Inv_T_Transfer";
CREATE TRIGGER "Inv_TR_TransferLock" BEFORE UPDATE ON public."Inv_T_Transfer"
FOR EACH ROW EXECUTE FUNCTION public."Inv_TR_TransferLock"();