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

12 lines
846 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.

CREATE OR ALTER VIEW [dbo].[Prc_V_MaterialRequestLine]
AS
-- Tüm Talepler listesinin kaynağı: talep başlığı × kalem, her kalem bir satır. Kalemi olmayan talep de
-- listeden düşmesin diye LEFT JOIN; o satırın anahtarı talebin kendi Id'sidir.
SELECT COALESCE(i.Id, r.Id) AS Id, r.Id AS MaterialRequestId, r.TenantId, r.IsDeleted,
r.RequestNo, r.Priority, r.RequesterUserId, r.DepartmentId, r.WarehouseId, r.LocationId, r.RequestDate,
r.Description, r.ApprovalStatus, r.ApprovalUserName, r.ApprovalDate, r.ApprovalDescription,
i.ProductId, i.Quantity, i.UomId, i.FulfillmentMethod, i.DueDate, i.RequestReason, i.DeliveredQuantity,
i.PurchaseResponsibleUserId, i.LineStatus, r.BranchId
FROM Prc_T_MaterialRequest r
LEFT JOIN Prc_T_MaterialRequestItem i ON i.MaterialRequestId = r.Id AND i.IsDeleted = 0;
GO