This commit is contained in:
seb
2026-10-16 22:27:34 +02:00
parent 0851c31970
commit 5d8ac3a8eb
6 changed files with 62 additions and 58 deletions

View File

@@ -30,15 +30,14 @@ export const article = {
/**
* GET /api/article/history?offset=0&limit=50&search=...&seekMonths=-1
* @param {{ offset?: number, limit?: number, search?: string, seekMonths?: number, startRow?: number, endRow?: number }} [params]
* @param {{ offset?: number, limit?: number, search?: string, seekMonths?: number, sortModel?: Array, filterModel?: object }} [params]
* → { history: ArticleHistoryEntry[], total: number, unfilteredTotal?: number }
*/
getHistory({ offset = 0, limit = 50, search, seekMonths, startRow, endRow, sortModel, filterModel } = {}) {
// #region GET /api/article/history — getHistory
getHistory({ offset = 0, limit = 50, search, seekMonths, sortModel, filterModel } = {}) {
const params = new URLSearchParams();
const finalOffset = offset != null ? offset : (startRow != null ? startRow : 0);
const finalLimit = limit != null ? limit : (endRow != null && startRow != null ? endRow - startRow : 50);
params.set('offset', String(Math.max(0, Math.floor(Number(finalOffset) || 0))));
params.set('limit', String(Math.max(1, Math.floor(Number(finalLimit) || 50))));
params.set('offset', String(Math.max(0, Math.floor(Number(offset) || 0))));
params.set('limit', String(Math.max(1, Math.floor(Number(limit) || 50))));
if (search && String(search).trim()) params.set('search', String(search).trim());
if (seekMonths != null && Number(seekMonths) < 0) {
params.set('seekMonths', String(Math.floor(Number(seekMonths))));
@@ -48,6 +47,7 @@ export const article = {
const qs = params.toString();
return http(`/api/article/history${qs ? `?${qs}` : ''}`);
},
// #endregion
/**
* GET /api/article/:sku/history

View File

@@ -4,16 +4,14 @@ export const globalHistory = {
/**
* GET /api/history?offset=0&limit=50&search=...&seekMonths=-1
* Global system/entity history with chunk paging and search/seek filtering
* @param {{ offset?: number, limit?: number, search?: string, seekMonths?: number, startRow?: number, endRow?: number }} [params]
* @param {{ offset?: number, limit?: number, search?: string, seekMonths?: number, sortModel?: Array, filterModel?: object }} [params]
* → { history: GlobalHistoryEntry[], total: number, unfilteredTotal?: number }
*/
// #region GET /api/history — list
list({ offset = 0, limit = 50, search, seekMonths, startRow, endRow, sortModel, filterModel } = {}) {
list({ offset = 0, limit = 50, search, seekMonths, sortModel, filterModel } = {}) {
const params = new URLSearchParams();
const finalOffset = offset != null ? offset : (startRow != null ? startRow : 0);
const finalLimit = limit != null ? limit : (endRow != null && startRow != null ? endRow - startRow : 50);
params.set('offset', String(Math.max(0, Math.floor(Number(finalOffset) || 0))));
params.set('limit', String(Math.max(1, Math.floor(Number(finalLimit) || 50))));
params.set('offset', String(Math.max(0, Math.floor(Number(offset) || 0))));
params.set('limit', String(Math.max(1, Math.floor(Number(limit) || 50))));
if (search && String(search).trim()) params.set('search', String(search).trim());
if (seekMonths != null && Number(seekMonths) < 0) {
params.set('seekMonths', String(Math.floor(Number(seekMonths))));

View File

@@ -6,16 +6,6 @@ import { http } from './http.js';
* Input = { manifestarticle_id, transaction_type, amount, transaction_text }
*/
export const ledger = {
/**
* POST /api/ledger
* Body: { manifestarticle_id, transaction_type, amount, transaction_text }
* → 201 { ledger: LedgerEntry }
*/
// #region POST /api/ledger — add
add(body) {
return http('/api/ledger', { method: 'POST', body });
},
// #endregion
/**
* GET /api/ledger/manifestarticle/:manifestarticleId
@@ -32,17 +22,15 @@ export const ledger = {
/**
* GET /api/ledger
* Query: { manifestarticle_id?, sku?, transaction_type? }
* Query: { manifestarticleId?, sku?, transactionType? }
* → 200 { ledger: LedgerEntry[] }
*/
// #region GET /api/ledger — list
list(query) {
list({ manifestarticleId, sku, transactionType } = {}) {
const params = new URLSearchParams();
if (query?.manifestarticle_id != null) params.set('manifestarticle_id', query.manifestarticle_id);
if (query?.manifestarticleId != null) params.set('manifestarticle_id', query.manifestarticleId);
if (query?.sku != null) params.set('sku', query.sku);
if (query?.transaction_type != null) params.set('transaction_type', query.transaction_type);
if (query?.transactionType != null) params.set('transaction_type', query.transactionType);
if (manifestarticleId != null) params.set('manifestarticle_id', String(manifestarticleId));
if (sku != null) params.set('sku', String(sku));
if (transactionType != null) params.set('transaction_type', String(transactionType));
const qs = params.toString();
return http(`/api/ledger${qs ? `?${qs}` : ''}`);
},

View File

@@ -13,4 +13,24 @@ export const stock = {
return http('/api/stock/adjust', { method: 'POST', body });
},
// #endregion
/**
* POST /api/stock/accept
* Body: { manifestarticleId, warehouseId?, text? } or { items: [...] } or { deliveryId, warehouseId? }
*/
// #region POST /api/stock/accept — accept
accept(body) {
return http('/api/stock/accept', { method: 'POST', body });
},
// #endregion
/**
* POST /api/stock/ship
* Body: { manifestarticleId, warehouseId?, text? } or { items: [...] } or { shipmentId, warehouseId? }
*/
// #region POST /api/stock/ship — ship
ship(body) {
return http('/api/stock/ship', { method: 'POST', body });
},
// #endregion
};