This commit is contained in:
seb
2026-09-28 06:49:46 +02:00
parent 0daf9fef3d
commit c4f8ebb41b
15 changed files with 2659 additions and 324 deletions

View File

@@ -216,16 +216,20 @@ export const article = {
},
/** POST /api/article → 201 { article } */
create({ parentId, name }) {
create({ parentId, name, track_stock }) {
return http('/api/article', {
method: 'POST',
body: { parentId, name },
body: {
parentId,
name,
...(track_stock !== undefined ? { track_stock } : {}),
},
});
},
/**
* PATCH /api/article/:sku
* Body: at least one of { name, unitamount, unitSi }
* Body: at least one of { name, unitamount, unitSi, track_stock }
* unitSi must exist for selected company → 404 Unit not found
* → 200 { article } (same detail shape as GET)
*/
@@ -236,6 +240,19 @@ export const article = {
});
},
/**
* PUT /api/article/:sku/track_stock
* Body: { track_stock: boolean }
* → 200 { article }
*/
setTrackStock(sku, body) {
const payload = typeof body === 'boolean' ? { track_stock: body } : body;
return http(`/api/article/${encodeURIComponent(sku)}/track_stock`, {
method: 'PUT',
body: payload,
});
},
/**
* DELETE /api/article/:sku → 204
* Errors: 400 Article has children, 401, 403, 404 Article not found
@@ -404,6 +421,56 @@ export const article = {
const qs = params.toString();
return httpGetBinary(`/api/article/export.zip${qs ? `?${qs}` : ''}`);
},
/**
* POST /api/article/:sku/print
* Body: { printerId, templateId, quantity }
* Prints the given template to the specified printer for this article.
*/
printLabel(sku, body) {
return http(`/api/article/${encodeURIComponent(sku)}/print`, {
method: 'POST',
body,
});
},
};
/**
* Company-scoped printers (selectedCompanyId from session).
* Shape: Printer = { id, address, type, model, serial, sort, desc }
*/
export const printer = {
/** GET /api/printer → { printers: Printer[] } */
list() {
return http('/api/printer');
},
/** GET /api/printer/:id → { printer: Printer } */
getById(id) {
return http(`/api/printer/${id}`);
},
/**
* POST /api/printer
* Body: { address, type, model, serial, sort, desc }
* → 201 { printer: Printer }
*/
create(body) {
return http('/api/printer', { method: 'POST', body });
},
/**
* PATCH /api/printer/:id
* Body: partial printer fields
* → 200 { printer: Printer }
*/
update(id, body) {
return http(`/api/printer/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/printer/:id → 204 */
delete(id) {
return http(`/api/printer/${id}`, { method: 'DELETE' });
},
};
/**
@@ -679,7 +746,7 @@ export const warehouse = {
/**
* POST /api/warehouse
* Body: { name } — empty name ⇒ 400 Name required.
* Body: { name, sort? } — empty name ⇒ 400 Name required.
* → 201 { warehouse: Warehouse }
*/
create(body) {
@@ -688,13 +755,22 @@ export const warehouse = {
/**
* PATCH /api/warehouse/:id
* Body: { name } — empty name ⇒ 400 Name required.
* Body: { name?, sort? }
* → 200 { warehouse: Warehouse }
*/
update(id, body) {
return http(`/api/warehouse/${id}`, { method: 'PATCH', body });
},
/**
* PUT /api/warehouse/order
* Body: { warehouseIds: number[] }
* → 200 { warehouseIds: number[] }
*/
order(body) {
return http('/api/warehouse/order', { method: 'PUT', body });
},
/** DELETE /api/warehouse/:id → 204 */
delete(id) {
return http(`/api/warehouse/${id}`, { method: 'DELETE' });
@@ -1466,6 +1542,47 @@ export const auth = {
},
};
/**
* Company-scoped ZPL label templates (selectedCompanyId from session).
* Shape: LabelTemplate = { id, company_id, name, width, height, dpi, type, content, thumb }
*/
export const labeltemplate = {
/** GET /api/labeltemplate → { labeltemplates: LabelTemplate[] } */
list() {
return http('/api/labeltemplate');
},
/** GET /api/labeltemplate/:id → { labeltemplate: LabelTemplate } */
get(id) {
return http(`/api/labeltemplate/${encodeURIComponent(id)}`);
},
/**
* POST /api/labeltemplate
* Body: { name, width, height, dpi, type, content }
* → 201 { labeltemplate: LabelTemplate }
*/
create(body) {
return http('/api/labeltemplate', { method: 'POST', body });
},
/**
* PATCH /api/labeltemplate/:id
* Body: partial { name?, width?, height?, dpi?, type?, content? }
* → 200 { labeltemplate: LabelTemplate }
*/
update(id, body) {
return http(`/api/labeltemplate/${encodeURIComponent(id)}`, { method: 'PATCH', body });
},
/** DELETE /api/labeltemplate/:id → 204 */
delete(id) {
return http(`/api/labeltemplate/${encodeURIComponent(id)}`, { method: 'DELETE' });
},
// thumb is returned inline as a base64 string in list/get responses
};
export default {
auth,
article,
@@ -1476,10 +1593,12 @@ export default {
customergroup,
delivery,
entity,
labeltemplate,
ledger,
number,
order,
posterminal,
printer,
quote,
supplier,
thumb,