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
+10 -1
View File
@@ -55,7 +55,16 @@ router.get('/', verifyToken, async (req, res) => {
try {
const result = await getSap().sapRequest('GET', endpoint, null, companyDB, true, { Prefer: `odata.maxpagesize=${top}` });
res.json({ success: true, data: result.value || [], count: result['odata.count'] });
// Genuine total (same filter, no paging) — drives "Page X of Y" on the
// client instead of an open-ended "Page X".
let total = null;
try {
const countEndpoint = `BusinessPartners/$count${filters.length ? `?$filter=${encodeURIComponent(filters.join(' and '))}` : ''}`;
const c = await getSap().sapRequest('GET', countEndpoint, null, companyDB);
const n = Number(c);
if (!isNaN(n)) total = n;
} catch (e) { console.warn('[BUSINESS-MASTER] $count failed — pager will show no total:', e.message); }
res.json({ success: true, data: result.value || [], count: result['odata.count'], total });
} catch (err) {
res.status(500).json({ success: false, message: err.message });
}