This commit is contained in:
seb
2026-10-13 13:21:11 +02:00
parent a5886b7c92
commit 8a626b17fc
15 changed files with 541 additions and 83 deletions

View File

@@ -3,6 +3,7 @@ import taxEnsure from '../tax/ensure.js';
import { insertLines, parseDate } from '../manifestLines.js';
import makeRunner from '../runner.js';
import { loadShipment, queriesFor } from './helpers.js';
import { syncOrderSummary } from '../order/syncSummary.js';
function requireId(val, name) {
const n = Number(val);
@@ -181,6 +182,8 @@ export default function create(provider) {
ensureTax,
});
await syncOrderSummary(runner, { companyId, manifestId: orderId });
return loadShipment(runner, q, companyId, manifestId);
};

View File

@@ -1,6 +1,7 @@
import resolveSelectedCompanyAccess from '../companyuser/resolveSelectedCompanyAccess.js';
import makeRunner from '../runner.js';
import { queriesFor } from './helpers.js';
import { syncOrderSummary } from '../order/syncSummary.js';
function requireId(val, name) {
const n = Number(val);
@@ -52,9 +53,19 @@ export default function del(provider) {
throw new Error('Shipped shipment cannot be deleted');
}
const shipmentNumber = String(check.rows[0].number || '');
const prefixRes = await runner.query(q.GET_SHIPMENT_PREFIX, { companyId });
const shipmentPrefix = prefixRes.rows[0]?.prefix?.trim?.() || '-L-';
const pIdx = shipmentNumber.indexOf(shipmentPrefix);
const orderNumber = pIdx > 0 ? shipmentNumber.slice(0, pIdx) : null;
await runner.query(q.DELETE_SHIPMENT, {
id: shipmentId,
companyId,
});
if (orderNumber) {
await syncOrderSummary(runner, { companyId, orderNumber });
}
};
}