u
This commit is contained in:
@@ -94,6 +94,24 @@ export class ApiClient {
|
||||
},
|
||||
};
|
||||
|
||||
this.warehouse = {
|
||||
/** GET /api/warehouse → { warehouses: Warehouse[] } */
|
||||
list: () => this.#json('GET', '/api/warehouse'),
|
||||
/** GET /api/warehouse/{id} → { warehouse: Warehouse } */
|
||||
getById: (id) => this.#json('GET', `/api/warehouse/${enc(id)}`),
|
||||
/** POST /api/warehouse → 201 { warehouse: Warehouse } */
|
||||
create: (body) => this.#json('POST', '/api/warehouse', { body }),
|
||||
/** PATCH /api/warehouse/{id} → 200 { warehouse: Warehouse } */
|
||||
update: (id, body) => this.#json('PATCH', `/api/warehouse/${enc(id)}`, { body }),
|
||||
/** DELETE /api/warehouse/{id} → 204 */
|
||||
delete: (id) => this.#empty('DELETE', `/api/warehouse/${enc(id)}`),
|
||||
};
|
||||
|
||||
this.stock = {
|
||||
/** POST /api/stock/adjust → 201 { manifest, lines, ledger } */
|
||||
adjust: (body) => this.#json('POST', '/api/stock/adjust', { body }),
|
||||
};
|
||||
|
||||
this.delivery = {
|
||||
/** GET /api/delivery → { deliveries: DeliverySummary[] } */
|
||||
list: () => this.#json('GET', '/api/delivery'),
|
||||
|
||||
@@ -8,6 +8,7 @@ import unitAutomat from '../automats/unitAutomat';
|
||||
import authAutomat from '../automats/authAutomat';
|
||||
import categoryAutomat, { invalidateAllCategoryViews } from '../automats/categoryAutomat';
|
||||
import posterminalAutomat from '../automats/posterminalAutomat';
|
||||
import warehouseAutomat from '../automats/warehouseAutomat';
|
||||
|
||||
|
||||
/**
|
||||
@@ -677,6 +678,11 @@ export class StorageManager extends ApiClient {
|
||||
console.error('[storageMgr] articles SSE refresh failed', err);
|
||||
});
|
||||
});
|
||||
es.addEventListener('warehouse', () => {
|
||||
void warehouseAutomat.actions.reload().catch((err) => {
|
||||
console.error('[storageMgr] warehouse SSE refresh failed', err);
|
||||
});
|
||||
});
|
||||
for (const sku of new Set([
|
||||
...this.#articleWatchers.keys(),
|
||||
...this.#historyWatchers.keys(),
|
||||
|
||||
@@ -633,6 +633,58 @@ export const supplier = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Company-scoped warehouses / Lager (selectedCompanyId from session).
|
||||
* Shape: Warehouse = { id, name }
|
||||
*/
|
||||
export const warehouse = {
|
||||
/** GET /api/warehouse → { warehouses: Warehouse[] } */
|
||||
list() {
|
||||
return http('/api/warehouse');
|
||||
},
|
||||
|
||||
/** GET /api/warehouse/:id → { warehouse: Warehouse } */
|
||||
getById(id) {
|
||||
return http(`/api/warehouse/${id}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* POST /api/warehouse
|
||||
* Body: { name } — empty name ⇒ 400 Name required.
|
||||
* → 201 { warehouse: Warehouse }
|
||||
*/
|
||||
create(body) {
|
||||
return http('/api/warehouse', { method: 'POST', body });
|
||||
},
|
||||
|
||||
/**
|
||||
* PATCH /api/warehouse/:id
|
||||
* Body: { name } — empty name ⇒ 400 Name required.
|
||||
* → 200 { warehouse: Warehouse }
|
||||
*/
|
||||
update(id, body) {
|
||||
return http(`/api/warehouse/${id}`, { method: 'PATCH', body });
|
||||
},
|
||||
|
||||
/** DELETE /api/warehouse/:id → 204 */
|
||||
delete(id) {
|
||||
return http(`/api/warehouse/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Stock operations (manual stock adjustment).
|
||||
*/
|
||||
export const stock = {
|
||||
/**
|
||||
* POST /api/stock/adjust
|
||||
* Body: { sku, warehouseId, amount, text?, date?, externalNumber?, lines? }
|
||||
*/
|
||||
adjust(body) {
|
||||
return http('/api/stock/adjust', { method: 'POST', body });
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Company-scoped goods receipts (manifest type = delivery).
|
||||
* DeliverySummary = { id, number, externalNumber, type: 'delivery', supplierId, date }
|
||||
@@ -1264,4 +1316,6 @@ export default {
|
||||
supplier,
|
||||
thumb,
|
||||
unit,
|
||||
warehouse,
|
||||
stock,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user