sozsoft-platform/configs/seeds/postgres/object/Prc_V_PurchaseImportItem.sql
2026-10-12 13:27:54 +03:00

9 lines
999 B
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.

-- Talep Kalemleri sekmesi: aktarılabilir her talep kalemi, kalem alabilecek açık belgeyle (teklif aşamasındaki
-- teklif talebi ya da taslak sipariş) eşlenir; belge yalnız kendi şubesinin talebini alır. Id = belge|kalem; seçilen satırları Seçilenleri Aktar ile Prc_P_PurchaseImportItem kopyalar.
CREATE OR REPLACE VIEW public."Prc_V_PurchaseImportItem" AS
SELECT d."Id"::text || '|' || a."Id"::text AS "Id", d."Id" AS "BaseId", a."TenantId", a."MaterialRequestId",
a."RequestNo", a."RequesterUserId", a."ProductId", a."Quantity", a."UomId", a."RequestReason", a."DueDate"
FROM (SELECT "Id", "TenantId", "BranchId" FROM "Prc_T_PurchaseRfq" WHERE "IsDeleted" = false AND "Status" IN ('Draft', 'Sent')
UNION ALL
SELECT "Id", "TenantId", "BranchId" FROM "Prc_T_PurchaseOrder" WHERE "IsDeleted" = false AND "Status" = 'Draft') d
INNER JOIN "Prc_V_MaterialRequestAvailableItem" a ON a."BranchId" = d."BranchId" AND a."TenantId" IS NOT DISTINCT FROM d."TenantId";