Add company-scoped delivery store on manifest

This commit is contained in:
seb
2026-08-06 05:32:48 +02:00
parent 4f46967f28
commit 0b7e40ac9c
14 changed files with 2133 additions and 1375 deletions

View File

@@ -0,0 +1,25 @@
import { DELETE_MANIFEST, DELIVERY_TYPE } from '../../sql/delivery.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
export default function del(pool) {
const access = resolveCompanyAccess(pool);
return async (googleAuthId, companyId, id) => {
if (!Number.isFinite(id)) {
throw new Error('Delivery not found');
}
await access(googleAuthId, companyId);
const result = await pool
.request()
.input('id', id)
.input('companyId', companyId)
.input('type', DELIVERY_TYPE)
.query(DELETE_MANIFEST);
if (!result.rowsAffected[0]) {
throw new Error('Delivery not found');
}
};
}