This commit is contained in:
seb
2026-10-16 01:11:17 +02:00
parent 78ad8f12e4
commit 0039b80d31
2 changed files with 48 additions and 2 deletions

View File

@@ -153,10 +153,27 @@ export async function executeCompanyImport({
// MARK: - Phase 4: Orders / Receipts
// #region Phase 4: Orders / Receipts
const allArtIdToSku = new Map();
const parentSkus = new Set(articlesResult.parentSkus || []);
const parentIds = new Set();
for (const a of artRecords) {
const kArt = cleanValue(a.id ?? a.kArtikel);
const sku = cleanValue(a.sku ?? a.cArtNr);
if (kArt && sku) allArtIdToSku.set(kArt, sku);
const pid = cleanValue(a.parentid ?? a.kVaterArtikel);
if (pid && pid !== '0') parentIds.add(pid);
const isParent = a.is_parent === '1' || a.nIstVater === '1';
if (isParent) {
if (kArt) parentIds.add(kArt);
if (sku) parentSkus.add(sku);
}
}
for (const a of artRecords) {
const kArt = cleanValue(a.id ?? a.kArtikel);
if (kArt && parentIds.has(kArt)) {
const sku = cleanValue(a.sku ?? a.cArtNr);
if (sku) parentSkus.add(sku);
}
}
const ordersResult = await importOrders({
@@ -165,6 +182,7 @@ export async function executeCompanyImport({
manRecords,
itemRecords,
jtlArtIdToSku: allArtIdToSku,
parentSkus,
progressTracker,
});
// #endregion