Record articlehistory entry on article creation
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -24,6 +24,7 @@ export default function resolveCategoryAccess(pool) {
|
||||
rootCategoryId: row.rootCategoryId,
|
||||
languageId: row.languageId,
|
||||
posCustomerGroupId: row.posCustomerGroupId ?? null,
|
||||
companyuserId: row.companyuserId,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user