Add article pack units with Redux-cached company unit list.

Edit amount/unit on the price tile (pc×1 = no pack unit), manage units in a dialog, and keep the default pc unit non-deletable.
This commit is contained in:
seb
2026-08-01 06:37:47 +02:00
parent 1b8652ceaf
commit 80f093649a
7 changed files with 841 additions and 25 deletions

View File

@@ -167,8 +167,9 @@ export const article = {
/**
* PATCH /api/article/:sku
* Body: partial fields, e.g. { name }
* → 200 { article }
* Body: at least one of { name, unitamount, unitSi }
* unitSi must exist for selected company → 404 Unit not found
* → 200 { article } (same detail shape as GET)
*/
update(sku, body) {
return http(`/api/article/${encodeURIComponent(sku)}`, {
@@ -250,6 +251,35 @@ export const thumb = {
},
};
/**
* Company-scoped units (selectedCompanyId from session).
* Shape: { si, basesi, basesifactor, symbol, name }
*/
export const unit = {
/** GET /api/unit → { units: [...] } · 400 No company selected */
list() {
return http('/api/unit');
},
/**
* PUT /api/unit
* Body: { si, basesi, basesifactor, symbol, name }
* → 200 { unit }
*/
upsert(body) {
return http('/api/unit', { method: 'PUT', body });
},
/**
* DELETE /api/unit?si=… → 204
* 409 Unit in use
*/
delete(si) {
const params = new URLSearchParams({ si });
return http(`/api/unit?${params}`, { method: 'DELETE' });
},
};
export const category = {
/** GET /api/category/tree → { languageId, tree, articles } (company from session) */
getTree() {
@@ -372,4 +402,4 @@ export const auth = {
},
};
export default { auth, article, category, company, thumb };
export default { auth, article, category, company, thumb, unit };