This commit is contained in:
Rizki
2026-04-23 14:35:15 +07:00
parent 0d15a93b8d
commit 7882040e56
3 changed files with 58 additions and 0 deletions

View File

@ -1067,6 +1067,48 @@ class ProcJustificationAdapter extends Adapter {
}
}
async queryUpdateProcJustificationBoq(req, callback) {
var apires = this.getApiResultDefined();
try {
let nik = req.body.nik;
let vendors = JSON.parse(req.body.vendors);
let boqList = [];
vendors.forEach(function (vendor) {
if (vendor.boq && vendor.boq.length > 0) {
vendor.boq.forEach(function (boq) {
boqList.push(boq);
});
}
});
if (boqList.length === 0) {
apires.success = true;
apires.meta.message = "No BOQ to update";
callback(null, apires);
return;
}
let pending = boqList.length;
boqList.forEach(function (boq) {
let qry = "update tbl_procjustificationvendorboq ";
qry += "set items='" + boq.items + "',qty='" + boq.qty + "',unitprice='" + boq.unitprice + "',units='" + boq.units + "',total='" + boq.total + "',uby='" + nik + "',udt=now() ";
qry += "where _idx='" + boq._idx + "'";
db.query(qry, [], function (err) {
if (--pending === 0) {
apires.success = true;
apires.meta.message = "BOQ Updated";
callback(null, apires);
}
});
});
} catch (err) {
apires.meta.code = 500;
apires.meta.message = err.toString();
callback("error", apires);
}
}
async queryUpdateStatusProcJustification(req, callback) {
try {
var apires = this.getApiResultDefined();