From 5fe273f9bab5b10fe909a7afd6aea2c468a3305d Mon Sep 17 00:00:00 2001 From: Iki Date: Tue, 16 Jun 2026 19:53:20 +0900 Subject: [PATCH] upd --- adapter/poadapter.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/adapter/poadapter.js b/adapter/poadapter.js index 3336bf2..bbfaa94 100644 --- a/adapter/poadapter.js +++ b/adapter/poadapter.js @@ -1993,26 +1993,27 @@ class PoAdapter extends Adapter { let resultJson = JSON.stringify(result); resultJson = JSON.parse(resultJson); - // PO BOQ - let qry = "select * from vw_poboq where idxpo='" + resultJson[0]._idx + "'"; + // PO BOQ — use vw_poheaderdetail (vw_poboq filters PR status and may return no rows) + let qry = + "select idxpo, idxpoboq, description, qty as qtypoboq, units, poamount, " + + "unitprice, total, vendorname, startdate, enddate, ponumber, status, statusdescription " + + "from vw_poheaderdetail where idxpo='" + + resultJson[0]._idx + + "' and isdeleted=0"; db.query(qry, [], function (err, result, fields) { if (err) { apires.meta["message"] = err.toString(); apires.meta["code"] = 500; callback("err", apires); } else { - if (result.length <= 0) { - apires.meta.message = "Record not found"; - callback("", apires); - } else { - let resultJsonBoq = JSON.stringify(result); - resultJsonBoq = JSON.parse(resultJsonBoq); - resultJson[0]["boq"] = resultJsonBoq; + resultJson[0]["boq"] = + result.length > 0 + ? JSON.parse(JSON.stringify(result)) + : []; - apires.success = true; - apires.data = resultJson; - callback(null, apires); - } + apires.success = true; + apires.data = resultJson; + callback(null, apires); } });