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

@@ -6,11 +6,10 @@ import {
CREATE as SQLITE_CREATE_PRICE,
DELETE_BY_ARTICLE_AND_CUSTOMERGROUP as SQLITE_DELETE_PRICE,
} from '../../providers/sqlite3/queries/price.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 taxEnsure from '../tax/ensure.js';
import queryBySku from './queryBySku.js';
import resolveArticleBySku from './resolveArticleBySku.js';
import { recordPriceChangeHistory } from '../articlehistory/record.js';
import makeRunner from '../runner.js';
function normalizePrices(prices) {
@@ -66,7 +65,6 @@ export default function setPricesBySku(provider) {
const createPriceSql = isSqlite ? SQLITE_CREATE_PRICE : MSSQL_CREATE_PRICE;
const deletePriceSql = isSqlite ? SQLITE_DELETE_PRICE : MSSQL_DELETE_PRICE;
const insertHistorySql = isSqlite ? SQLITE_INSERT_HISTORY : MSSQL_INSERT_HISTORY;
/**
* Replaces the price list of an article by its SKU.
@@ -136,16 +134,12 @@ export default function setPricesBySku(provider) {
}
// Write history if prices changed
const fmtPrice = (p) => `${p.net}@${p.taxRate ?? 0}%`;
const oldStr = oldPrices.map(fmtPrice).join(', ');
const newStr = normalized.map((e) => `${e.price}@${e.tax}%`).join(', ');
if (oldStr !== newStr) {
await runner.query(insertHistorySql, {
articleId,
companyuserId,
text: `Preise geändert von [${oldStr}] auf [${newStr}]`,
});
}
await recordPriceChangeHistory(runner, {
articleId,
companyuserId,
oldPrices,
newPrices: normalized,
});
const article = await load(articleId, languageId, runner);
if (!article) {