sozsoft-platform/configs/seeds/postgres/object/Prc_V_PurchaseOrderLine.sql

16 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

2026-10-12 11:07:18 +00:00
CREATE OR REPLACE VIEW public."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" = FALSE
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" = FALSE;