From 91e7c03655dcc4a4ad5cd9ad1fda3ab8469761ac Mon Sep 17 00:00:00 2001 From: seb Date: Sat, 8 Aug 2026 10:09:02 +0200 Subject: [PATCH] Record articlehistory entry on article creation --- src/store/article/createUnderParent.js | 12 +++++++++++- src/store/category/resolveCategoryAccess.js | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/store/article/createUnderParent.js b/src/store/article/createUnderParent.js index 03850a9..c200709 100644 --- a/src/store/article/createUnderParent.js +++ b/src/store/article/createUnderParent.js @@ -1,6 +1,7 @@ import { CREATE } from '../../sql/article.js'; import { ADD as ADD_CATEGORYARTICLE } from '../../sql/categoryarticle.js'; import { CREATE as CREATE_ARTICLETEXT } from '../../sql/articletext.js'; +import { INSERT as INSERT_HISTORY } from '../../sql/articlehistory.js'; import resolveCategoryAccess from '../category/resolveCategoryAccess.js'; import ensureDefaultUnit from '../unit/ensureDefault.js'; import nextSku from '../numbers/nextSku.js'; @@ -27,7 +28,10 @@ export default function createUnderParent(pool) { * // => { id, parentId, name, sku } */ return async ({ googleAuthId, parentId, name }) => { - const { companyId, languageId } = await access(googleAuthId, parentId); + const { companyId, languageId, companyuserId } = await access( + googleAuthId, + parentId + ); const tx = pool.transaction(); await tx.begin(); @@ -58,6 +62,12 @@ export default function createUnderParent(pool) { .input('slug', slug) .query(CREATE_ARTICLETEXT); + await request(pool, tx) + .input('articleId', id) + .input('companyuserId', companyuserId) + .input('text', `Artikel "${name}" angelegt`) + .query(INSERT_HISTORY); + await tx.commit(); return { diff --git a/src/store/category/resolveCategoryAccess.js b/src/store/category/resolveCategoryAccess.js index f919da5..8d3536c 100644 --- a/src/store/category/resolveCategoryAccess.js +++ b/src/store/category/resolveCategoryAccess.js @@ -24,6 +24,7 @@ export default function resolveCategoryAccess(pool) { rootCategoryId: row.rootCategoryId, languageId: row.languageId, posCustomerGroupId: row.posCustomerGroupId ?? null, + companyuserId: row.companyuserId, }; }; }