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

11 lines
929 B
Transact-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 ALTER VIEW [dbo].[Prc_V_PurchaseRfqAlternativeSupplier] AS
SELECT CONCAT(CAST(r.Id AS nvarchar(36)), '|', CAST(c.Id AS nvarchar(36))) 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 = r.TenantId OR (c.TenantId IS NULL AND r.TenantId IS NULL))
AND c.IsDeleted = 0 AND c.IsActive = 1
WHERE r.IsDeleted = 0 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 = 0 AND x.Status <> 'Cancelled')