Add Lieferungen section with supplier CRUD and delivery create/list.

Wire /lieferung sub-nav (list, neu, lieferanten) to supplier and delivery APIs.
This commit is contained in:
seb
2026-08-06 05:32:59 +02:00
parent 1e0fedca3d
commit 1ee29399ff
8 changed files with 1014 additions and 8 deletions

View File

@@ -521,6 +521,84 @@ export const brand = {
},
};
/**
* Company-scoped suppliers / Lieferanten (selectedCompanyId from session).
* Shape: Supplier = { id, name, createdAt, updatedAt }
*/
export const supplier = {
/** GET /api/supplier → { suppliers: Supplier[] } */
list() {
return http('/api/supplier');
},
/**
* POST /api/supplier
* Body: { name } — empty name ⇒ 400 Name required.
* → 201 { supplier: Supplier }
*/
create(body) {
return http('/api/supplier', { method: 'POST', body });
},
/**
* PATCH /api/supplier/:id
* Body: { name } — empty name ⇒ 400 Name required.
* → 200 { supplier: Supplier }
*/
update(id, body) {
return http(`/api/supplier/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/supplier/:id → 204 */
delete(id) {
return http(`/api/supplier/${id}`, { method: 'DELETE' });
},
};
/**
* Company-scoped goods receipts (manifest type = delivery).
* DeliverySummary = { id, number, type: 'delivery', supplierId, date }
* DeliveryLine = { id, articleId, sku, amount, net, transactedAmount, rebate, tax, comment }
* Delivery = DeliverySummary & { lines: DeliveryLine[] }
* DeliveryLineInput = { sku, amount, net, tax, rebate?, transactedAmount?, comment? }
*/
export const delivery = {
/** GET /api/delivery → { deliveries: DeliverySummary[] } */
list() {
return http('/api/delivery');
},
/** GET /api/delivery/:id → { delivery: Delivery } */
get(id) {
return http(`/api/delivery/${id}`);
},
/**
* POST /api/delivery
* Body: { number, date, supplierId?, lines: DeliveryLineInput[] }
* Line requires sku, amount, net, tax. rebate→0, transactedAmount→amount.
* → 201 { delivery: Delivery }
*/
create(body) {
return http('/api/delivery', { method: 'POST', body });
},
/**
* PATCH /api/delivery/:id
* Body: partial { number?, date?, supplierId?, lines? }.
* If lines present, replaces all lines; if omitted, lines unchanged.
* → 200 { delivery: Delivery }
*/
update(id, body) {
return http(`/api/delivery/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/delivery/:id → 204 */
delete(id) {
return http(`/api/delivery/${id}`, { method: 'DELETE' });
},
};
export const company = {
/** GET /api/company → { companies: [...] } */
list() {
@@ -697,6 +775,8 @@ export default {
category,
company,
posterminal,
supplier,
delivery,
thumb,
unit,
};