This commit is contained in:
seb
2026-10-10 02:08:10 +02:00
parent d4e2b05cb0
commit 7f8661be3e
43 changed files with 3312 additions and 2339 deletions

View File

@@ -1,6 +1,8 @@
import * as db from '../../db/stock.js';
import { emit } from '../sse.js';
// #region Helpers
function requireSelectedCompany(req) {
const companyId = req.user?.selectedCompanyId;
if (companyId == null) {
@@ -49,6 +51,8 @@ function emitStockEvents(companyId, body, result) {
}
}
// #endregion
/**
* Registers stock adjustment routes for the authenticated user's selected company.
* All operations append to the append-only ledger under an implicit "adjustment" manifest.
@@ -111,6 +115,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region POST /stock/adjust
app.post(`${basePath}/stock/adjust`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -127,4 +133,6 @@ export function register(app, basePath = '') {
res.status(status).json({ error: error.message });
}
});
// #endregion
}