62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
async function testRemaining() {
|
|
console.log("1. Logging in as jayam_web_ai...");
|
|
|
|
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
grant_type: "client_credentials",
|
|
client_id: "jayam_web_ai",
|
|
client_secret: "my_secret_key"
|
|
})
|
|
});
|
|
|
|
const token = (await tokenResponse.json()).access_token;
|
|
|
|
console.log("\n2. Executing Goods Receipt Note (GRN)...");
|
|
const grnResponse = await fetch("http://localhost:8080/v1/inventory/grn", {
|
|
method: "POST",
|
|
headers: {
|
|
"Authorization": `Bearer ${token}`,
|
|
"X-Actor-Id": "usr_mgr_1234",
|
|
"Idempotency-Key": "grn-uuid-" + Date.now(),
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
supplier_id: "sup_120",
|
|
invoice_no: "INV/2026/9999",
|
|
invoice_date: "2026-07-24",
|
|
po_ref: "po_8891",
|
|
lines: [
|
|
{
|
|
product_id: "prd_4410",
|
|
batch_no: "B9999-" + Date.now(),
|
|
expiry: "2028-12-31",
|
|
qty: 500,
|
|
purchase_price: 54.20,
|
|
mrp: 78.50
|
|
}
|
|
]
|
|
})
|
|
});
|
|
|
|
console.log("GRN Status:", grnResponse.status);
|
|
console.log("GRN Results:", JSON.stringify(await grnResponse.json(), null, 2));
|
|
|
|
console.log("\n3. Fetching Audit Logs...");
|
|
const auditResponse = await fetch("http://localhost:8080/v1/audit/logs", {
|
|
method: "GET",
|
|
headers: {
|
|
"Authorization": `Bearer ${token}`,
|
|
"X-Actor-Id": "usr_mgr_1234"
|
|
}
|
|
});
|
|
|
|
console.log("Audit Status:", auditResponse.status);
|
|
const auditData = await auditResponse.json();
|
|
console.log("Found Stock Movements:", auditData.stock_movements.length);
|
|
console.log("Latest Stock Movement:", JSON.stringify(auditData.stock_movements[0], null, 2));
|
|
}
|
|
|
|
testRemaining();
|