u
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user