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

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

CREATE OR ALTER VIEW [dbo].[Prc_V_PurchaseOrderLine]
AS
-- Sipariş Ürünleri listesinin kaynağı: satınalma siparişi başlığı × kalem, her kalem bir satır; kalemi olmayan
-- sipariş gelmez. Vergi hariç ve KDV kalemin KDV dahil tutarından (Prc_P_PurchaseOrderRecalc) ayrıştırılır.
SELECT l.Id, l.PurchaseOrderId, o.TenantId, o.IsDeleted,
o.OrderNo, o.Status, o.SupplierId, o.BranchId, o.WarehouseId, o.OperationTypeId, o.CurrencyId,
o.ConfirmDate, o.ExpectedArrival, o.ArrivalDate, o.BuyerUserId, o.SourceDocument,
l.ProductId, l.Description, l.Quantity, l.UomId, l.UnitPrice, l.TaxRate,
ROUND(l.Quantity * l.UnitPrice, 2) AS UntaxedAmount, l.Amount - ROUND(l.Quantity * l.UnitPrice, 2) AS TaxAmount, l.Amount,
l.DeliveryDate, m.RequestNo
FROM Prc_T_PurchaseOrderLine l
INNER JOIN Prc_T_PurchaseOrder o ON o.Id = l.PurchaseOrderId AND o.IsDeleted = 0
LEFT JOIN Prc_T_MaterialRequestItem i ON i.Id = l.MaterialRequestItemId
LEFT JOIN Prc_T_MaterialRequest m ON m.Id = i.MaterialRequestId
WHERE l.IsDeleted = 0;
GO