This commit is contained in:
seb
2026-10-23 02:43:35 +02:00
parent 919713fa53
commit 8a085986e5
6 changed files with 218 additions and 0 deletions

View File

@@ -239,6 +239,17 @@ WHERE optionslist_id IN (
)
`;
export const TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT = `
UPDATE article
SET updated_at = SYSUTCDATETIME()
WHERE articlelist_id IN (
SELECT ala.articlelist_id
FROM articlelistarticle ala
WHERE ala.article_id = @articleId
)
`;
export const CREATE = `
INSERT INTO article (company_id, sku, unit_id, unitamount, weight, track_stock)
OUTPUT INSERTED.id

View File

@@ -12,6 +12,7 @@ export const {
LIST_CHILDREN_BY_PARENT_ID, LIST_PAIRED_POSTERMINAL_IDS_BY_ARTICLE,
SET_PARENT_SORT,
SET_IS_PARENT, TOGGLE_PARENT, TOUCH_UPDATED_AT, TOUCH_OPTION_PARENT_ARTICLES_UPDATED_AT,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT,
UNLINK_CHILD, UPDATE_BRAND, UPDATE_PARENT_BY_SKU, UPDATE_TRACK_STOCK, UPDATE_UNIT,
UPDATE_UNITAMOUNT, UPDATE_UNIT_AND_AMOUNT, UPDATE_WEIGHT,
} = queries;

View File

@@ -1,3 +1,12 @@
import {
TOUCH_UPDATED_AT as MSSQL_TOUCH,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT as MSSQL_TOUCH_STUECKLISTE,
} from '../../providers/mssql/queries/article.js';
import {
TOUCH_UPDATED_AT as SQLITE_TOUCH,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT as SQLITE_TOUCH_STUECKLISTE,
} from '../../providers/sqlite3/queries/article.js';
/**
* Centralized sync and rebuild logic for the materialized `articlewarehousesummary` table.
*
@@ -142,6 +151,11 @@ export async function syncArticleWarehouseSummaryForLedger(runner, { companyId,
warehouseId,
stock,
});
const touchSql = isSqlite ? SQLITE_TOUCH : MSSQL_TOUCH;
const touchStuecklisteSql = isSqlite ? SQLITE_TOUCH_STUECKLISTE : MSSQL_TOUCH_STUECKLISTE;
await runner.query(touchSql, { articleId });
await runner.query(touchStuecklisteSql, { articleId });
}
}

View File

@@ -11,6 +11,14 @@ import {
recordWarehouseHistory,
} from '../articlehistory/record.js';
import makeRunner from '../runner.js';
import {
TOUCH_UPDATED_AT as MSSQL_TOUCH,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT as MSSQL_TOUCH_STUECKLISTE,
} from '../../providers/mssql/queries/article.js';
import {
TOUCH_UPDATED_AT as SQLITE_TOUCH,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT as SQLITE_TOUCH_STUECKLISTE,
} from '../../providers/sqlite3/queries/article.js';
export const INIT_HASH = 'TODO_TSE_BASED_INITHASH';
@@ -202,6 +210,10 @@ export default function add(provider) {
// Record history for acceptance
for (const match of articleMatches) {
const touchSql = isSqlite ? SQLITE_TOUCH : MSSQL_TOUCH;
const touchStuecklisteSql = isSqlite ? SQLITE_TOUCH_STUECKLISTE : MSSQL_TOUCH_STUECKLISTE;
await runner.query(touchSql, { articleId: match.id });
await runner.query(touchStuecklisteSql, { articleId: match.id });
await recordAcceptanceHistory(runner, {
articleId: match.id,
companyuserId,
@@ -287,6 +299,10 @@ export default function add(provider) {
});
for (const match of articleMatches) {
const touchSql = isSqlite ? SQLITE_TOUCH : MSSQL_TOUCH;
const touchStuecklisteSql = isSqlite ? SQLITE_TOUCH_STUECKLISTE : MSSQL_TOUCH_STUECKLISTE;
await runner.query(touchSql, { articleId: match.id });
await runner.query(touchStuecklisteSql, { articleId: match.id });
await recordShipmentHistory(runner, {
articleId: match.id,
companyuserId,

View File

@@ -11,6 +11,14 @@ import ledgerAdd from '../ledger/add.js';
import makeRunner from '../runner.js';
import { parseDate } from '../manifestLines.js';
import { syncArticleWarehouseSummaryForLedger } from '../articlewarehousesummary/syncSummary.js';
import {
TOUCH_UPDATED_AT as MSSQL_TOUCH,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT as MSSQL_TOUCH_STUECKLISTE,
} from '../../providers/mssql/queries/article.js';
import {
TOUCH_UPDATED_AT as SQLITE_TOUCH,
TOUCH_STUECKLISTE_ARTICLES_UPDATED_AT as SQLITE_TOUCH_STUECKLISTE,
} from '../../providers/sqlite3/queries/article.js';
const ADJUSTMENT_TYPE = 'adjustment';
@@ -160,6 +168,11 @@ export default function adjust(provider) {
warehouseId,
});
const touchSql = isSqlite ? SQLITE_TOUCH : MSSQL_TOUCH;
const touchStuecklisteSql = isSqlite ? SQLITE_TOUCH_STUECKLISTE : MSSQL_TOUCH_STUECKLISTE;
await runner.query(touchSql, { articleId: art.id });
await runner.query(touchStuecklisteSql, { articleId: art.id });
// Write warehouse history for tracked article
if (manifestArticle.manifest_type === 'delivery') {
await recordWarehouseHistory(runner, {
@@ -369,6 +382,10 @@ export default function adjust(provider) {
// Write article history for the adjusted article
if (item.articleId) {
const touchSql = isSqlite ? SQLITE_TOUCH : MSSQL_TOUCH;
const touchStuecklisteSql = isSqlite ? SQLITE_TOUCH_STUECKLISTE : MSSQL_TOUCH_STUECKLISTE;
await runner.query(touchSql, { articleId: item.articleId });
await runner.query(touchStuecklisteSql, { articleId: item.articleId });
await recordStockAdjustmentHistory(runner, {
articleId: item.articleId,
companyuserId,