sozsoft-platform/configs/seeds/sql/object/Prc_V_MaterialRequestPlanLine.sql
2026-10-14 12:07:11 +03:00

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

-- Planla diyaloğunun Karşılama Planı ızgarası (App.Prc.MaterialRequestPlanLine): talep kaleminin onay bekleyen taslak planı. Miktar kalemin
-- biriminde; satınalmada birim fiyat teklif kalemine yazılacak fiyattır (tedarikçinin en düşük minimum miktarlı satırı). BaseId kalemdir.
CREATE OR ALTER VIEW [dbo].[Prc_V_MaterialRequestPlanLine] AS
SELECT pl.Id, pl.TenantId, pl.MaterialRequestItemId AS BaseId, pl.PlanMethod, pl.SupplierId, pl.SourceLocationId, pl.Quantity, i.UomId,
ps.Price, ps.CurrencyId, pl.CreationTime, pl.CreatorId, pl.IsDeleted
FROM Prc_T_MaterialRequestPlanLine pl
INNER JOIN Prc_T_MaterialRequestItem i ON i.Id = pl.MaterialRequestItemId
OUTER APPLY (SELECT TOP 1 x.Price, x.CurrencyId
FROM Inv_T_ProductSupplier x
WHERE pl.PlanMethod = 'Purchase' AND x.ProductId = i.ProductId AND x.ContactId = pl.SupplierId AND x.IsDeleted = 0
ORDER BY x.MinQuantity) ps;
GO