sale order
SAP-ERP Portal CI/CD / build (push) Successful in 3m57s

This commit is contained in:
John
2026-10-05 18:45:17 +05:30
parent e725a6571b
commit eead8f5ffd
129 changed files with 14252 additions and 452 deletions
+14 -4
View File
@@ -246,13 +246,23 @@ router.get('/:id/linked-work-orders', verifyToken, async (req, res) => {
router.get('/linked-work-orders/all', verifyToken, async (req, res) => {
try {
const wos = await workOrderStore().listWorkOrders({});
const map = {};
const map = {}; // non-rejected only — whole-row/whole-document lock (Edit/Delete gating)
const allMap = {}; // every non-deleted status, REJECTED included — used only to keep a
// batch's own Batch No. (and its row) from being changed/removed once
// ANY Work Order, even a rejected one awaiting edit+resubmit, already
// references it by that number. Without this, correcting other fields
// on a rejected batch's row (which IS meant to stay editable) could also
// let the Batch No. itself drift, silently breaking the (productCode,
// batchNumber) link back to that rejected Work Order.
wos.forEach(w => {
if (!w.intimationId || w.isDeleted || w.status === 'REJECTED') return;
if (!w.intimationId || w.isDeleted) return;
const k = String(w.intimationId);
(map[k] || (map[k] = [])).push({ id: w.id, woNo: w.woNo, productCode: w.productCode || '', batchNumber: w.batchNumber || '' });
const entry = { id: w.id, woNo: w.woNo, productCode: w.productCode || '', batchNumber: w.batchNumber || '' };
(allMap[k] || (allMap[k] = [])).push(entry);
if (w.status === 'REJECTED') return;
(map[k] || (map[k] = [])).push(entry);
});
res.json({ success: true, data: map });
res.json({ success: true, data: map, allData: allMap });
} catch (err) { res.status(500).json({ success: false, message: err.message }); }
});