u
This commit is contained in:
@@ -36,8 +36,8 @@ export async function importArticles({
|
||||
let articlesUpdated = 0;
|
||||
|
||||
for (const a of includedArticles) {
|
||||
const jtlArtId = String(a.kArtikel);
|
||||
const sku = cleanValue(a.cArtNr);
|
||||
const jtlArtId = String(a.id ?? a.kArtikel);
|
||||
const sku = cleanValue(a.sku ?? a.cArtNr);
|
||||
if (!sku) {
|
||||
progressTracker.counts.articlesdone++;
|
||||
continue;
|
||||
@@ -45,15 +45,15 @@ export async function importArticles({
|
||||
|
||||
jtlArtIdToSku.set(jtlArtId, sku);
|
||||
|
||||
let name = cleanValue(a.cName);
|
||||
let desc = cleanValue(a.descriptions);
|
||||
let name = cleanValue(a.name ?? a.cName);
|
||||
let desc = cleanValue(a.desc ?? a.descriptions);
|
||||
|
||||
if (!name && desc) {
|
||||
try {
|
||||
const parsed = JSON.parse(desc);
|
||||
const item = Array.isArray(parsed) ? parsed[0] : parsed;
|
||||
if (item?.cName) name = String(item.cName).trim();
|
||||
if (item?.cBeschreibung) desc = String(item.cBeschreibung).trim();
|
||||
if (item?.cName || item?.name) name = String(item.cName || item.name).trim();
|
||||
if (item?.cBeschreibung || item?.desc) desc = String(item.cBeschreibung || item.desc).trim();
|
||||
} catch {}
|
||||
}
|
||||
if (!name) name = `Artikel ${sku}`;
|
||||
@@ -66,7 +66,7 @@ export async function importArticles({
|
||||
if (rawCatStr.startsWith('[') || rawCatStr.startsWith('{')) {
|
||||
try {
|
||||
const raw = JSON.parse(rawCatStr);
|
||||
parsedIds = (Array.isArray(raw) ? raw : [raw]).map((it) => String(it.kKategorie || it));
|
||||
parsedIds = (Array.isArray(raw) ? raw : [raw]).map((it) => String(it.id ?? it.kKategorie ?? it));
|
||||
} catch {
|
||||
parsedIds = rawCatStr.split(/[\r\n,;]+/).map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
@@ -81,12 +81,13 @@ export async function importArticles({
|
||||
}
|
||||
const primaryCatId = assignedDashCatIds[0] || hauptDashId;
|
||||
|
||||
const trackStock = a.cLagerAktiv === 'Y' ? 1 : 0;
|
||||
const netPrice = parseGermanFloat(a.fVKNetto, 0);
|
||||
const taxRate = a.kSteuerklasse === '3' ? 7 : 19;
|
||||
const barcode = cleanValue(a.cBarcode);
|
||||
const rawTrack = cleanValue(a.track_strock ?? a.track_stock ?? a.cLagerAktiv);
|
||||
const trackStock = (rawTrack === 'Y' || rawTrack === '1' || rawTrack === 'true') ? 1 : 0;
|
||||
const netPrice = parseGermanFloat(a.net ?? a.fVKNetto, 0);
|
||||
const taxRate = a.taxrate != null && String(a.taxrate).trim() !== '' ? parseGermanFloat(a.taxrate, 19) : (a.kSteuerklasse === '3' ? 7 : 19);
|
||||
const barcode = cleanValue(a.ean ?? a.cBarcode);
|
||||
|
||||
const hersteller = cleanValue(a.Hersteller);
|
||||
const hersteller = cleanValue(a.brand ?? a.Hersteller);
|
||||
const brandId = hersteller ? (brandNameToId.get(hersteller.toLowerCase()) || null) : null;
|
||||
|
||||
let existingArticle = null;
|
||||
|
||||
Reference in New Issue
Block a user