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

9 lines
911 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.

-- Talep Kalemleri sekmesi: aktarılabilir her talep kalemi, kalem alabilecek açık belgeyle (teklif aşamasındaki
-- teklif talebi ya da taslak sipariş) eşlenir. Id = belge|kalem; satır işaretlenip kaydedilince Prc_P_PurchaseImportItem kopyalar.
CREATE OR ALTER VIEW [dbo].[Prc_V_PurchaseImportItem] AS
SELECT CONCAT(CAST(d.Id AS nvarchar(36)), '|', CAST(a.Id AS nvarchar(36))) AS Id, d.Id AS BaseId, a.TenantId, a.MaterialRequestId,
a.RequestNo, a.RequesterUserId, a.ProductId, a.Quantity, a.UomId, a.RequestReason, a.DueDate, CAST(0 AS bit) AS Transfer
FROM (SELECT Id, TenantId FROM Prc_T_PurchaseRfq WHERE IsDeleted = 0 AND Status IN ('Draft', 'Sent')
UNION ALL
SELECT Id, TenantId FROM Prc_T_PurchaseOrder WHERE IsDeleted = 0 AND Status = 'Draft') d
INNER JOIN Prc_V_MaterialRequestAvailableItem a ON a.TenantId = d.TenantId OR (a.TenantId IS NULL AND d.TenantId IS NULL)