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

10 lines
1 KiB
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; belge yalnız kendi şubesinin talebini alır. Id = belge|kalem; seçilen satırları Seçilenleri Aktar ile 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
FROM (SELECT Id, TenantId, BranchId FROM Prc_T_PurchaseRfq WHERE IsDeleted = 0 AND Status IN ('Draft', 'Sent')
UNION ALL
SELECT Id, TenantId, BranchId FROM Prc_T_PurchaseOrder WHERE IsDeleted = 0 AND Status = 'Draft') d
INNER JOIN Prc_V_MaterialRequestAvailableItem a ON a.BranchId = d.BranchId
AND (a.TenantId = d.TenantId OR (a.TenantId IS NULL AND d.TenantId IS NULL))