sozsoft-platform/configs/seeds/postgres/object/Prc_V_PurchaseRfqAlternativeSupplier.sql
2026-10-12 13:27:54 +03:00

11 lines
934 B
SQL
Raw Permalink 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.

-- Alternatif Oluştur › Tedarikçiler: açık (teklif aşamasındaki) her teklif talebi, ihalesinde henüz iptal olmayan belgesi
-- bulunmayan aktif kontaklarla eşlenir. Id = teklif|kontak; seçilen satırlar için Prc_P_PurchaseRfqCreateAlternative belge açar.
CREATE OR REPLACE VIEW public."Prc_V_PurchaseRfqAlternativeSupplier" AS
SELECT r."Id"::text || '|' || c."Id"::text AS "Id", r."Id" AS "BaseId", c."TenantId",
c."Name", c."City", c."Phone", c."Email", c."SupplierCurrency"
FROM "Prc_T_PurchaseRfq" r
INNER JOIN "Adm_T_Contact" c ON c."TenantId" IS NOT DISTINCT FROM r."TenantId"
AND c."IsDeleted" = false AND c."IsActive" = true
WHERE r."IsDeleted" = false AND r."Status" IN ('Draft', 'Sent')
AND NOT EXISTS (SELECT 1 FROM "Prc_T_PurchaseRfq" x
WHERE x."TenderGroupId" = r."TenderGroupId" AND x."SupplierId" = c."Id" AND x."IsDeleted" = false AND x."Status" <> 'Cancelled');