Add shared Manifest UI for delivery, quote, and order.

Wire quote/order API clients and routes, then unify list/create/edit behind ManifestList/Form tiles so Lieferungen and Auftrag share one stack.
This commit is contained in:
seb
2026-08-06 20:08:56 +02:00
parent 8d50d083f5
commit 4896b1dc36
26 changed files with 1356 additions and 1103 deletions

View File

@@ -95,6 +95,32 @@ export class ApiClient {
delete: (id) => this.#empty('DELETE', `/api/delivery/${enc(id)}`),
};
this.quote = {
/** GET /api/quote → { quotes } */
list: () => this.#json('GET', '/api/quote'),
/** GET /api/quote/{id} → { quote } */
get: (id) => this.#json('GET', `/api/quote/${enc(id)}`),
/** POST /api/quote → 201 { quote } */
create: (body) => this.#json('POST', '/api/quote', { body }),
/** PATCH /api/quote/{id} → { quote } */
update: (id, body) => this.#json('PATCH', `/api/quote/${enc(id)}`, { body }),
/** DELETE /api/quote/{id} → 204 */
delete: (id) => this.#empty('DELETE', `/api/quote/${enc(id)}`),
};
this.order = {
/** GET /api/order → { orders } */
list: () => this.#json('GET', '/api/order'),
/** GET /api/order/{id} → { order } */
get: (id) => this.#json('GET', `/api/order/${enc(id)}`),
/** POST /api/order → 201 { order } */
create: (body) => this.#json('POST', '/api/order', { body }),
/** PATCH /api/order/{id} → { order } */
update: (id, body) => this.#json('PATCH', `/api/order/${enc(id)}`, { body }),
/** DELETE /api/order/{id} → 204 */
delete: (id) => this.#empty('DELETE', `/api/order/${enc(id)}`),
};
this.customergroup = {
/** GET /api/customergroup → { customergroups } */
list: () => this.#json('GET', '/api/customergroup'),

View File

@@ -297,6 +297,8 @@ export class StorageManager extends ApiClient {
this.#loadCustomergroups(),
);
const entityCache = createCache('GET /entity', () => this.#loadEntities());
const quoteCache = createCache('GET /quote', () => this.#loadQuotes());
const orderCache = createCache('GET /order', () => this.#loadOrders());
Object.defineProperties(this, {
authMePromise: { get: () => authMeCache.promise },
@@ -350,6 +352,16 @@ export class StorageManager extends ApiClient {
/** Settled GET /entity list, or undefined. */
entities: { get: () => entityCache.value },
quotePromise: { get: () => quoteCache.promise },
updateQuote: { value: quoteCache.update },
/** Settled GET /quote list, or undefined. */
quotes: { get: () => quoteCache.value },
orderPromise: { get: () => orderCache.promise },
updateOrder: { value: orderCache.update },
/** Settled GET /order list, or undefined. */
orders: { get: () => orderCache.value },
/** Close and reopen GET /api/events (required after selected-company change). */
reconnectEvents: { value: () => this.#reconnectEvents() },
});
@@ -494,6 +506,18 @@ export class StorageManager extends ApiClient {
return requireArray(data.entities, 'entities');
}
async #loadQuotes() {
const data = await this.quote.list();
requireObject(data, 'GET /api/quote');
return requireArray(data.quotes, 'quotes');
}
async #loadOrders() {
const data = await this.order.list();
requireObject(data, 'GET /api/order');
return requireArray(data.orders, 'orders');
}
async doSearch({ target, filter, offset, maxCount, onUpdate }) {
const articles = await this.articleIndexPromise;
const query = target.trim().toLowerCase();

View File

@@ -599,6 +599,87 @@ export const delivery = {
},
};
/**
* Sales quotes (manifest type = quote).
* Summary = { id, number, type: 'quote', entityId, date }
* Line = { id, articleId, sku, amount, net, rebate, tax, comment } — no transactedAmount
* LineInput = { sku, amount, net, tax, rebate?, comment? }
*/
export const quote = {
/** GET /api/quote → { quotes: QuoteSummary[] } */
list() {
return http('/api/quote');
},
/** GET /api/quote/:id → { quote: Quote } */
get(id) {
return http(`/api/quote/${id}`);
},
/**
* POST /api/quote
* Body: { number, date, entityId?, lines }
* → 201 { quote: Quote }
*/
create(body) {
return http('/api/quote', { method: 'POST', body });
},
/**
* PATCH /api/quote/:id
* Body: partial { number?, date?, entityId?, lines? }
* → 200 { quote: Quote }
*/
update(id, body) {
return http(`/api/quote/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/quote/:id → 204 */
delete(id) {
return http(`/api/quote/${id}`, { method: 'DELETE' });
},
};
/**
* Sales orders (manifest type = order).
* Summary = { id, number, type: 'order', entityId, date }
* Line shape same as quote (no transactedAmount).
*/
export const order = {
/** GET /api/order → { orders: OrderSummary[] } */
list() {
return http('/api/order');
},
/** GET /api/order/:id → { order: Order } */
get(id) {
return http(`/api/order/${id}`);
},
/**
* POST /api/order
* Body: { number, date, entityId?, lines }
* → 201 { order: Order }
*/
create(body) {
return http('/api/order', { method: 'POST', body });
},
/**
* PATCH /api/order/:id
* Body: partial { number?, date?, entityId?, lines? }
* → 200 { order: Order }
*/
update(id, body) {
return http(`/api/order/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/order/:id → 204 */
delete(id) {
return http(`/api/order/${id}`, { method: 'DELETE' });
},
};
/**
* Company-scoped customer groups.
* Shape: CustomerGroup = { id, name }
@@ -903,7 +984,9 @@ export default {
customergroup,
delivery,
entity,
order,
posterminal,
quote,
supplier,
thumb,
unit,