From ed91ccbaee46c2dcaa8c5331a03e6f9920053101 Mon Sep 17 00:00:00 2001 From: seb Date: Wed, 30 Sep 2026 21:12:32 +0200 Subject: [PATCH] u --- .../mssql/queries/articlesupplier.js | 8 +- .../sqlite3/queries/articlesupplier.js | 4 +- .../articlesupplier/listByEntityAndSkus.js | 77 +++++++------------ 3 files changed, 35 insertions(+), 54 deletions(-) diff --git a/src/providers/mssql/queries/articlesupplier.js b/src/providers/mssql/queries/articlesupplier.js index 60f81b6..ee7c304 100644 --- a/src/providers/mssql/queries/articlesupplier.js +++ b/src/providers/mssql/queries/articlesupplier.js @@ -139,10 +139,10 @@ SELECT ( SELECT ap.sort, - p.hash, - p.thumbhash, - p.thumbw, - p.thumbh + p.hash AS fullHash, + p.thumbhash AS thumbHash, + p.thumbw AS thumbW, + p.thumbh AS thumbH FROM articlepic ap INNER JOIN pic p ON p.id = ap.pic_id WHERE ap.article_id = a.id diff --git a/src/providers/sqlite3/queries/articlesupplier.js b/src/providers/sqlite3/queries/articlesupplier.js index a9b7439..40e6891 100644 --- a/src/providers/sqlite3/queries/articlesupplier.js +++ b/src/providers/sqlite3/queries/articlesupplier.js @@ -17,8 +17,8 @@ SELECT t.rate AS priceTaxRate, a.id AS a_id, a.sku AS a_sku, at.name AS a_name, at.slug AS a_slug, (SELECT COALESCE(json_group_array(json_object( - 'sort', sort, 'hash', hash, 'thumbhash', thumbhash, - 'thumbw', thumbw, 'thumbh', thumbh + 'sort', sort, 'fullHash', hash, 'thumbHash', thumbhash, + 'thumbW', thumbw, 'thumbH', thumbh )), '[]') FROM ( SELECT ap.sort, pic.hash, pic.thumbhash, pic.thumbw, pic.thumbh FROM articlepic ap INNER JOIN pic ON pic.id = ap.pic_id diff --git a/src/store/articlesupplier/listByEntityAndSkus.js b/src/store/articlesupplier/listByEntityAndSkus.js index 9bc51a9..b716914 100644 --- a/src/store/articlesupplier/listByEntityAndSkus.js +++ b/src/store/articlesupplier/listByEntityAndSkus.js @@ -20,13 +20,13 @@ export default function listByEntityAndSkus(provider) { /** * Lists article-supplier assignments for a given supplier (entityId) and SKU list, - * including linked article details (name, slug, photos/articlepic, eans/articleean). + * including linked article details (name, slug, photos, eans). * * @param {number} googleAuthId - The id of the Google auth user. * @param {number|{entityId?: number, supplierId?: number, skus?: string[]|string}} entityIdOrOptions - The supplier entity id or an options object. * @param {string[]|string} [maybeSkus] - The list of SKUs to filter by (or single SKU string). * @param {object} [tx] - Optional transaction. - * @returns {Promise, articlepic: Array<{sort: number, thumbhash: string, hash: string, thumbw: number, thumbh: number}>, eans: string[], articleean: string[]}}>>} The supplier assignments with article details. + * @returns {Promise, eans: string[]}}>>} The supplier assignments with article details. * @throws {Error} If user is not authorized, entityId is missing, or supplier does not exist. * * @example @@ -84,52 +84,33 @@ export default function listByEntityAndSkus(provider) { skusJson, }); - return result.rows.map((row) => { - const rawPhotos = parseJsonArray(row.photosJson); - const photos = rawPhotos.map((p) => ({ - sort: p.sort, - thumbhash: p.thumbhash, - hash: p.hash, - thumbw: p.thumbw, - thumbh: p.thumbh, - thumbHash: p.thumbhash, - fullHash: p.hash, - thumbW: p.thumbw, - thumbH: p.thumbh, - })); - - const eans = parseJsonArray(row.eansJson).map((r) => r.ean); - - return { - id: row.id, - articleId: row.articleId, - entityId: row.entityId, - supplierName: row.supplierName ?? null, - sku: row.sku ?? null, - pu: row.pu, - stock: row.stock ?? null, - sort: row.sort, - priceId: row.priceId ?? null, - price: - row.priceId != null && row.priceNet != null - ? { - net: row.priceNet, - taxId: row.priceTaxId, - ...(row.priceTaxRate != null ? { taxRate: row.priceTaxRate } : {}), - } - : null, - article: { - id: row.a_id, - sku: row.a_sku, - name: row.a_name ?? null, - slug: row.a_slug ?? null, - photos, - articlepic: photos, - eans, - articleean: eans, - }, - }; - }); + return result.rows.map((row) => ({ + id: row.id, + articleId: row.articleId, + entityId: row.entityId, + supplierName: row.supplierName ?? null, + sku: row.sku ?? null, + pu: row.pu, + stock: row.stock ?? null, + sort: row.sort, + priceId: row.priceId ?? null, + price: + row.priceId != null && row.priceNet != null + ? { + net: row.priceNet, + taxId: row.priceTaxId, + ...(row.priceTaxRate != null ? { taxRate: row.priceTaxRate } : {}), + } + : null, + article: { + id: row.a_id, + sku: row.a_sku, + name: row.a_name ?? null, + slug: row.a_slug ?? null, + photos: parseJsonArray(row.photosJson), + eans: parseJsonArray(row.eansJson).map((r) => r.ean), + }, + })); }; }