2026-10-14 19:26:03 +00:00
|
|
|
|
-- Transfer belgesi kaydı sonrası: tür, şube, depo ve boş konumlar operasyon türünden gelir (formda olmayan alımın
|
|
|
|
|
|
-- kaynağı ve teslimatın hedefi her zaman, iade belgesi hariç); teslimat politikası yalnız teslimatta tutulur. Tamamlanmış belgenin başlığı
|
2026-10-19 14:35:08 +00:00
|
|
|
|
-- yeniden türetilmez: stoğu belirleyen alanlar kilitlidir (Stk_TR_TransferLock) ve sonradan değişen operasyon türü İade Et'i 50328'e düşürürdü.
|
2026-10-12 21:43:05 +00:00
|
|
|
|
-- Numara, özet ve durum butonunun işlemi (PendingAction) buradan çalışır.
|
2026-10-19 14:35:08 +00:00
|
|
|
|
CREATE OR REPLACE PROCEDURE public."Stk_P_TransferAfterSave"(p_id uuid, p_user_id uuid DEFAULT NULL)
|
2026-10-12 21:43:05 +00:00
|
|
|
|
LANGUAGE plpgsql AS $$
|
|
|
|
|
|
DECLARE v_act varchar(16);
|
|
|
|
|
|
BEGIN
|
2026-10-19 14:35:08 +00:00
|
|
|
|
SELECT "PendingAction" INTO v_act FROM "Stk_T_Transfer" WHERE "Id" = p_id;
|
2026-10-12 21:43:05 +00:00
|
|
|
|
|
2026-10-19 14:35:08 +00:00
|
|
|
|
UPDATE "Stk_T_Transfer" t SET
|
2026-10-12 21:43:05 +00:00
|
|
|
|
"OperationKind" = ot."OperationKind",
|
|
|
|
|
|
"BranchId" = ot."BranchId",
|
|
|
|
|
|
"WarehouseId" = ot."WarehouseId",
|
|
|
|
|
|
"SourceLocationId" = CASE WHEN t."ReturnOfId" IS NULL AND (ot."OperationKind" = 'Receipt' OR t."SourceLocationId" IS NULL)
|
|
|
|
|
|
THEN COALESCE(ot."SourceLocationId", t."SourceLocationId") ELSE t."SourceLocationId" END,
|
|
|
|
|
|
"DestinationLocationId" = CASE WHEN t."ReturnOfId" IS NULL AND (ot."OperationKind" = 'Delivery' OR t."DestinationLocationId" IS NULL)
|
|
|
|
|
|
THEN COALESCE(ot."DestinationLocationId", t."DestinationLocationId") ELSE t."DestinationLocationId" END,
|
|
|
|
|
|
"DeliveryPolicy" = CASE WHEN ot."OperationKind" = 'Delivery' THEN COALESCE(t."DeliveryPolicy", 'Direct') END
|
2026-10-19 14:35:08 +00:00
|
|
|
|
FROM "Stk_T_OperationType" ot
|
2026-10-14 19:26:03 +00:00
|
|
|
|
WHERE t."Id" = p_id AND ot."Id" = t."OperationTypeId" AND t."Status" <> 'Done';
|
2026-10-12 21:43:05 +00:00
|
|
|
|
|
2026-10-19 14:35:08 +00:00
|
|
|
|
CALL public."Stk_P_TransferNumber"(p_id);
|
|
|
|
|
|
CALL public."Stk_P_TransferRecalc"(p_id);
|
2026-10-12 21:43:05 +00:00
|
|
|
|
-- Durum butonları işlemi PendingAction alanına yazıp ekranın güncelleme ucuyla kaydeder.
|
|
|
|
|
|
IF v_act IS NOT NULL THEN
|
2026-10-19 14:35:08 +00:00
|
|
|
|
CALL public."Stk_P_TransferSetStatus"(p_id, v_act, p_user_id);
|
2026-10-12 21:43:05 +00:00
|
|
|
|
END IF;
|
|
|
|
|
|
END;
|
|
|
|
|
|
$$;
|