u
This commit is contained in:
@@ -47,8 +47,9 @@ const log = createLogger('import');
|
||||
* @param {number} opts.googleAuthId
|
||||
* @param {number} opts.companyId
|
||||
* @param {string} opts.importDir
|
||||
* @param {function} [opts.onProgress] - (counts) => void; throttled to 200ms
|
||||
* @param {function} [opts.onProgress] - (counts) => void; throttled to 50ms
|
||||
* @param {function} [opts.onImages] - (skelehashes: string[]) => void; batched every 50ms
|
||||
* @param {number} [opts.progressThrottleMs=50] - Progress emission throttle/debounce interval in ms
|
||||
* @returns {Promise<object>} Summary outcome with statistics
|
||||
*/
|
||||
export async function executeCompanyImport({
|
||||
@@ -57,6 +58,7 @@ export async function executeCompanyImport({
|
||||
importDir,
|
||||
onProgress = () => {},
|
||||
onImages = () => {},
|
||||
progressThrottleMs = 50,
|
||||
}) {
|
||||
const store = await getStore();
|
||||
|
||||
@@ -105,6 +107,7 @@ export async function executeCompanyImport({
|
||||
},
|
||||
onProgress,
|
||||
onImages,
|
||||
progressThrottleMs,
|
||||
});
|
||||
|
||||
// Emit baseline counts immediately
|
||||
@@ -133,12 +136,13 @@ export async function executeCompanyImport({
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// MARK: - Phase 3: Articles
|
||||
// MARK: - Phase 3: Articles (base data, variants, pfand, pictures)
|
||||
// #region Phase 3: Articles
|
||||
const articlesResult = await importArticles({
|
||||
store,
|
||||
googleAuthId,
|
||||
includedArticles,
|
||||
articleImageTasks,
|
||||
jtlCatIdToDashCatId: categoriesResult.jtlCatIdToDashCatId,
|
||||
hauptDashId: categoriesResult.hauptDashId,
|
||||
brandNameToId: brandsResult.brandNameToId,
|
||||
@@ -146,39 +150,8 @@ export async function executeCompanyImport({
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// MARK: - Phase 4: Variants
|
||||
// #region Phase 4: Variants
|
||||
const variantsResult = await importVariants({
|
||||
store,
|
||||
googleAuthId,
|
||||
includedArticles,
|
||||
jtlArtIdToSku: articlesResult.jtlArtIdToSku,
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// MARK: - Phase 5: Pfand / Deposit Options
|
||||
// #region Phase 5: Pfand
|
||||
const pfandResult = await importPfand({
|
||||
store,
|
||||
googleAuthId,
|
||||
includedArticles,
|
||||
hauptDashId: categoriesResult.hauptDashId,
|
||||
parentSkus: variantsResult.parentSkus,
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// MARK: - Phase 6: Article Pictures
|
||||
// #region Phase 6: Article Pictures
|
||||
const imagesResult = await importArticleImages({
|
||||
store,
|
||||
googleAuthId,
|
||||
articleImageTasks,
|
||||
progressTracker,
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// MARK: - Phase 7: Orders / Receipts
|
||||
// #region Phase 7: Orders / Receipts
|
||||
// MARK: - Phase 4: Orders / Receipts
|
||||
// #region Phase 4: Orders / Receipts
|
||||
const allArtIdToSku = new Map();
|
||||
for (const a of artRecords) {
|
||||
const kArt = cleanValue(a.id ?? a.kArtikel);
|
||||
@@ -213,11 +186,11 @@ export async function executeCompanyImport({
|
||||
articlesTotal: includedArticles.length,
|
||||
articlesImported: articlesResult.articlesImported,
|
||||
articlesUpdated: articlesResult.articlesUpdated,
|
||||
variantsLinked: variantsResult.variantsLinked,
|
||||
pfandArticlesCreated: pfandResult.pfandArticlesCreated,
|
||||
pfandArticlesUpdated: pfandResult.pfandArticlesUpdated,
|
||||
pfandOptionsLinked: pfandResult.pfandOptionsLinked,
|
||||
articlePictures: imagesResult.totalImagesImported,
|
||||
variantsLinked: articlesResult.variantsLinked,
|
||||
pfandArticlesCreated: articlesResult.pfandArticlesCreated,
|
||||
pfandArticlesUpdated: articlesResult.pfandArticlesUpdated,
|
||||
pfandOptionsLinked: articlesResult.pfandOptionsLinked,
|
||||
articlePictures: articlesResult.totalImagesImported,
|
||||
ordersTotal: totalReceiptsCount,
|
||||
ordersImported: ordersResult.ordersImported,
|
||||
ordersSkipped: ordersResult.ordersSkipped,
|
||||
|
||||
Reference in New Issue
Block a user