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