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