feat(articlesupplier): implement store methods, schema constraints, and embed in getBySku
This commit is contained in:
@@ -13,7 +13,7 @@ export default function getBySku(pool) {
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth user.
|
||||
* @param {string} sku - The article SKU.
|
||||
* @returns {Promise<{article: object}>} The full article detail.
|
||||
* @returns {Promise<{article: {id: number, sku: string, name: string, slug: string, unitamount: number|null, weight: number|null, unit: {si: string|null, basesi: string|null, basesifactor: number|null, symbol: string|null, name: string|null}, brand: {name: string, thumbW: number, thumbH: number, thumbHash: string}|null, categoryIds: number[], photos: Array<{sort: number, fullHash: string, fullW: number, fullH: number, fullSize: number, thumbW: number, thumbH: number, thumbHash: string}>, eans: string[], prices: Array<{minmultiplier: number, net: number, taxRate: number, customergroupId: number}>, suppliers: Array<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, priceId: number|null, price: {net: number, taxId: number, taxRate?: number}|null}>, optionsCount: number, articleListCount: number, childCount: number, fatherArticleId: number|null, fatherSku: string|null}}>} The full article detail.
|
||||
* @throws {Error} If the article is not found or the user is not authorized.
|
||||
*
|
||||
* @example
|
||||
@@ -72,6 +72,17 @@ export default function getBySku(pool) {
|
||||
photos: parseJsonArray(a.photosJson),
|
||||
eans: parseJsonArray(a.eansJson).map((r) => r.ean),
|
||||
prices: parseJsonArray(a.pricesJson),
|
||||
suppliers: parseJsonArray(a.suppliersJson).map((s) => ({
|
||||
id: s.id,
|
||||
articleId: s.articleId,
|
||||
entityId: s.entityId,
|
||||
supplierName: s.supplierName,
|
||||
sku: s.sku ?? null,
|
||||
pu: s.pu,
|
||||
stock: s.stock ?? null,
|
||||
priceId: s.priceId ?? null,
|
||||
price: s.priceId != null && s.price?.net != null ? s.price : null,
|
||||
})),
|
||||
optionsCount: a.optionsCount,
|
||||
articleListCount: a.articleListCount,
|
||||
childCount: a.childCount,
|
||||
|
||||
Reference in New Issue
Block a user