sozsoft-platform/configs/seeds/postgres/object/Prc_V_PurchaseRfqAlternativeSupplier.sql

12 lines
934 B
MySQL
Raw Permalink Normal View History

2026-10-12 10:27:54 +00:00
-- 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');