u
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import * as mssqlArticle from '../../providers/mssql/queries/article.js';
|
||||
import * as sqliteArticle from '../../providers/sqlite3/queries/article.js';
|
||||
import { INSERT as MSSQL_INSERT_HISTORY } from '../../providers/mssql/queries/articlehistory.js';
|
||||
import { INSERT as SQLITE_INSERT_HISTORY } from '../../providers/sqlite3/queries/articlehistory.js';
|
||||
import resolveArticleBySku from './resolveArticleBySku.js';
|
||||
import articleDelete from './delete.js';
|
||||
import {
|
||||
recordChildUnlinkedFromParentHistory,
|
||||
recordChildDeletedFromParentHistory,
|
||||
} from '../articlehistory/record.js';
|
||||
import makeRunner from '../runner.js';
|
||||
|
||||
export default function removeChild(provider) {
|
||||
@@ -12,7 +14,6 @@ export default function removeChild(provider) {
|
||||
const isSqlite = provider?.dialect === 'sqlite3';
|
||||
|
||||
const queries = isSqlite ? sqliteArticle : mssqlArticle;
|
||||
const insertHistorySql = isSqlite ? SQLITE_INSERT_HISTORY : MSSQL_INSERT_HISTORY;
|
||||
|
||||
/**
|
||||
* Removes a child article from a parent article, either by unlinking or deleting it.
|
||||
@@ -78,10 +79,11 @@ export default function removeChild(provider) {
|
||||
await recompactParentSort();
|
||||
|
||||
// History on parent (child article is gone so we can only log on parent)
|
||||
await runner.query(insertHistorySql, {
|
||||
articleId: parentId,
|
||||
await recordChildDeletedFromParentHistory(runner, {
|
||||
parentId,
|
||||
companyuserId,
|
||||
text: `Variante "${childName}" (${childSku}) gelöscht`,
|
||||
childName,
|
||||
childSku,
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -119,18 +121,14 @@ export default function removeChild(provider) {
|
||||
|
||||
await recompactParentSort();
|
||||
|
||||
// Add history on child
|
||||
await runner.query(insertHistorySql, {
|
||||
articleId: childId,
|
||||
// Add history on child and parent
|
||||
await recordChildUnlinkedFromParentHistory(runner, {
|
||||
childId,
|
||||
parentId,
|
||||
companyuserId,
|
||||
text: `Artikel "${childSku}" von Vaterartikel "${parentSku}" getrennt`,
|
||||
});
|
||||
|
||||
// Add history on parent
|
||||
await runner.query(insertHistorySql, {
|
||||
articleId: parentId,
|
||||
companyuserId,
|
||||
text: `Variante "${childName}" (${childSku}) getrennt`,
|
||||
childSku,
|
||||
childName,
|
||||
parentSku,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user