From 23a198b0c1d121030abc90f6d3064c9fbc2a29d5 Mon Sep 17 00:00:00 2001 From: seb Date: Fri, 16 Oct 2026 20:46:26 +0200 Subject: [PATCH] u --- .agents/skills/backend/SKILL.md | 8 +++++--- src/api/delivery.js | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.agents/skills/backend/SKILL.md b/.agents/skills/backend/SKILL.md index 9198568..959d534 100644 --- a/.agents/skills/backend/SKILL.md +++ b/.agents/skills/backend/SKILL.md @@ -65,7 +65,7 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body). - `T47` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }` - `T48` = `{ id: int, entityId: int, contactType: str, contact: str }` - `T49` = `{ id: int, name: str, createdAt: str, updatedAt: str }` -- `T50` = `{ totalPositions: int, completelyOnLedgerPositions: int }` +- `T50` = `{ totalPositions: int, completelyOnLedgerPositions: int, bookedPositions?: int, unbookedPositions?: int, totalQuantity?: num, bookedQuantity?: num, unbookedQuantity?: num, isBooked?: bool }` - `T51` = `{ name: str, sizeBytes: int, sourceExists: bool }` - `T52` = `{ warehouse: T54 }` - `T53` = `{ net: num, taxId: int, taxRate?: num|null }` @@ -399,8 +399,10 @@ _none_ ### Section: /delivery #### List deliveries — `GET /delivery` -_none_ -- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T50 }[] }` +- Params: `query: offset?: int, limit?: int, search?: str, onlyUnbooked?: bool, supplierId?: int, seekMonths?: int` +- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, supplierName?: str|null, date: str, externalNumber?: str|null, createdAt?: str, summary?: object, ledger?: T50 }[], total?: int, unfilteredTotal?: int, offset?: int, limit?: int }` +#### Rebuild delivery summaries — `POST /delivery/rebuild-summaries` +- Returns: `200 { ok: bool, companyId: int }` #### Create delivery — `POST /delivery` - Params: `body: { externalNumber: str, date: str, lines: T33[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` - Returns: `201 T9` diff --git a/src/api/delivery.js b/src/api/delivery.js index 03db559..6c8c585 100644 --- a/src/api/delivery.js +++ b/src/api/delivery.js @@ -10,13 +10,35 @@ import { http, clientIdHeaders } from './http.js'; * DeliveryLineInput = { sku, amount, net, tax, rebate?, transactedAmount?, comment? } */ export const delivery = { - /** GET /api/delivery → { deliveries: DeliverySummary[] } */ + /** + * GET /api/delivery + * @param {{ offset?: number, limit?: number, search?: string, onlyUnbooked?: boolean, supplierId?: number, seekMonths?: number }} [opts] + * → { deliveries: DeliverySummary[], total?: number, unfilteredTotal?: number, offset?: number, limit?: number } + */ // #region GET /api/delivery — list - list() { + list(opts) { + if (opts && typeof opts === 'object') { + const params = new URLSearchParams(); + if (opts.offset != null) params.set('offset', String(Math.max(0, Math.floor(Number(opts.offset) || 0)))); + if (opts.limit != null) params.set('limit', String(Math.max(1, Math.floor(Number(opts.limit) || 50)))); + if (opts.search && String(opts.search).trim()) params.set('search', String(opts.search).trim()); + if (opts.onlyUnbooked === true || opts.onlyUnbooked === 'true') params.set('onlyUnbooked', 'true'); + if (opts.supplierId != null) params.set('supplierId', String(opts.supplierId)); + if (opts.seekMonths != null && Number(opts.seekMonths) < 0) { + params.set('seekMonths', String(Math.floor(Number(opts.seekMonths)))); + } + const qs = params.toString(); + return http(`/api/delivery${qs ? `?${qs}` : ''}`); + } return http('/api/delivery'); }, // #endregion + /** POST /api/delivery/rebuild-summaries → { ok: boolean, companyId: number } */ + rebuildSummaries() { + return http('/api/delivery/rebuild-summaries', { method: 'POST' }); + }, + /** GET /api/delivery/:id → { delivery: Delivery } */ // #region GET /api/delivery/:id — get get(id) {