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

12 lines
929 B
MySQL
Raw 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 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')