This commit is contained in:
seb
2026-10-16 20:46:26 +02:00
parent 7ad8a3a301
commit 23a198b0c1
2 changed files with 29 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
- `T47` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }` - `T47` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }`
- `T48` = `{ id: int, entityId: int, contactType: str, contact: str }` - `T48` = `{ id: int, entityId: int, contactType: str, contact: str }`
- `T49` = `{ id: int, name: str, createdAt: str, updatedAt: 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 }` - `T51` = `{ name: str, sizeBytes: int, sourceExists: bool }`
- `T52` = `{ warehouse: T54 }` - `T52` = `{ warehouse: T54 }`
- `T53` = `{ net: num, taxId: int, taxRate?: num|null }` - `T53` = `{ net: num, taxId: int, taxRate?: num|null }`
@@ -399,8 +399,10 @@ _none_
### Section: /delivery ### Section: /delivery
#### List deliveries — `GET /delivery` #### List deliveries — `GET /delivery`
_none_ - 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, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T50 }[] }` - 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` #### 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 } }[] }` - 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` - Returns: `201 T9`

View File

@@ -10,13 +10,35 @@ import { http, clientIdHeaders } from './http.js';
* DeliveryLineInput = { sku, amount, net, tax, rebate?, transactedAmount?, comment? } * DeliveryLineInput = { sku, amount, net, tax, rebate?, transactedAmount?, comment? }
*/ */
export const delivery = { 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 // #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'); return http('/api/delivery');
}, },
// #endregion // #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 } */ /** GET /api/delivery/:id → { delivery: Delivery } */
// #region GET /api/delivery/:id — get // #region GET /api/delivery/:id — get
get(id) { get(id) {