sozsoft-platform/configs/seeds/sql/object/Prc_V_PurchaseRfqAlternative.sql
2026-10-11 22:57:23 +03:00

15 lines
948 B
Transact-SQL
Raw 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.

-- Aynı ihaledeki teklif talepleri. BaseId açık belgedir: teklif talebinde ihalenin diğer belgeleri,
-- satınalma siparişinde kaynak teklifin ihalesindeki bütün belgeler.
CREATE OR ALTER VIEW [dbo].[Prc_V_PurchaseRfqAlternative] AS
SELECT b.Id AS BaseId, x.Id, x.TenantId, x.RfqNo, x.SupplierId, x.Status, x.SupplierResponse,
x.OrderDeadline, x.ExpectedArrival, x.UntaxedAmount, x.TotalAmount, x.CurrencyId, x.IsDeleted
FROM Prc_T_PurchaseRfq b
INNER JOIN Prc_T_PurchaseRfq x ON x.TenderGroupId = b.TenderGroupId AND x.Id <> b.Id
WHERE b.IsDeleted = 0
UNION ALL
SELECT o.Id, x.Id, x.TenantId, x.RfqNo, x.SupplierId, x.Status, x.SupplierResponse,
x.OrderDeadline, x.ExpectedArrival, x.UntaxedAmount, x.TotalAmount, x.CurrencyId, x.IsDeleted
FROM Prc_T_PurchaseOrder o
INNER JOIN Prc_T_PurchaseRfq s ON s.Id = o.PurchaseRfqId
INNER JOIN Prc_T_PurchaseRfq x ON x.TenderGroupId = s.TenderGroupId
WHERE o.IsDeleted = 0