chore: upload parte 1 - logica
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 41s
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 41s
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getDb } from "@/lib/db";
|
||||
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const sql = getDb();
|
||||
const { id } = await params;
|
||||
|
||||
const rows = await sql(
|
||||
`SELECT poi.*,
|
||||
p.name AS product_name,
|
||||
p.sku AS product_sku,
|
||||
(poi.quantity * poi.unit_price) AS line_total,
|
||||
COALESCE(poi.shipped_quantity, 0) AS shipped_quantity,
|
||||
(poi.quantity - COALESCE(poi.shipped_quantity, 0)) AS remaining_quantity
|
||||
FROM purchase_order_items poi
|
||||
JOIN products p ON p.id = poi.product_id
|
||||
WHERE poi.purchase_order_id = $1
|
||||
ORDER BY poi.id ASC`,
|
||||
[Number(id)]
|
||||
);
|
||||
|
||||
return NextResponse.json(rows);
|
||||
} catch (error) {
|
||||
console.error("[v0] PO items GET error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: error instanceof Error ? error.message : "Failed to fetch PO items" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user