This commit is contained in:
seb
2026-10-12 17:29:29 +02:00
parent 3d6bc97411
commit 2e961252f7
44 changed files with 1166 additions and 374 deletions

View File

@@ -12,9 +12,8 @@ import {
import {
GET_BY_COMPANY_AND_ID as SQLITE_GET_PROP,
} from '../../providers/sqlite3/queries/propertyname.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 '../article/resolveArticleBySku.js';
import { recordPropertyChangeHistory } from '../articlehistory/record.js';
import makeRunner from '../runner.js';
export default function setByArticleSku(provider) {
@@ -23,7 +22,6 @@ export default function setByArticleSku(provider) {
const deleteSql = isSqlite ? SQLITE_DELETE : MSSQL_DELETE;
const insertSql = isSqlite ? SQLITE_INSERT : MSSQL_INSERT;
const getPropSql = isSqlite ? SQLITE_GET_PROP : MSSQL_GET_PROP;
const insertHistorySql = isSqlite ? SQLITE_INSERT_HISTORY : MSSQL_INSERT_HISTORY;
/**
* Replaces all properties for an article by its SKU.
@@ -119,16 +117,12 @@ export default function setByArticleSku(provider) {
}
// Write history if properties changed
const fmtProp = (p) => `${p.name}=${p.value}`;
const oldStr = oldProps.map(fmtProp).join(', ');
const newStr = validated.map(fmtProp).join(', ');
if (oldStr !== newStr) {
await runner.query(insertHistorySql, {
articleId,
companyuserId,
text: `Eigenschaften geändert von [${oldStr}] auf [${newStr}]`,
});
}
await recordPropertyChangeHistory(runner, {
articleId,
companyuserId,
oldProps,
newProps: validated,
});
return inserted;
};