sozsoft-platform/configs/seeds/sql/object/Prc_V_MaterialRequestPlanLine.sql
2026-10-19 17:35:08 +03:00

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

-- Planla diyaloğunun Karşılama Planı ızgarası (Prc.MaterialRequestPlanLine): talep kaleminin onay bekleyen taslak planı. Miktar kalemin
-- biriminde; iç transferde lot/seri takipli ürünün lotu (LotNo); 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, NULLIF(pl.LotNo, '') AS LotNo
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 Stk_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