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

13 lines
1.2 KiB
SQL
Raw Permalink 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 REPLACE VIEW public."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"
LEFT JOIN LATERAL (SELECT 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" = false
ORDER BY x."MinQuantity"
LIMIT 1) ps ON TRUE;