From 6623bf9bfd1d5ecf2759d11e28ca1651cae2d749 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Tue, 1 Sep 2026 15:51:25 +0100 Subject: [PATCH] Update stock audit level schema to require tags and improve code readability This commit modifies the `stockAuditLevel` schema by making the `tags` field required, ensuring that all stock audit levels have associated tags for better categorization. Additionally, it enhances the readability of the `normalizeAuditLevelLine` function by adjusting the formatting of the item and itemSku assignments, improving overall code clarity. --- src/database/schemas/management/stockauditlevel.schema.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/database/schemas/management/stockauditlevel.schema.js b/src/database/schemas/management/stockauditlevel.schema.js index 5fe3c06..91f647b 100644 --- a/src/database/schemas/management/stockauditlevel.schema.js +++ b/src/database/schemas/management/stockauditlevel.schema.js @@ -13,8 +13,8 @@ const toId = (value) => { export function normalizeAuditLevelLine(line) { const allItems = Boolean(line?.allItems); const allSkus = allItems ? true : Boolean(line?.allSkus); - const item = allItems ? null : line?.item?._id ?? line?.item ?? null; - const itemSku = allItems || allSkus ? null : line?.itemSku?._id ?? line?.itemSku ?? null; + const item = allItems ? null : (line?.item?._id ?? line?.item ?? null); + const itemSku = allItems || allSkus ? null : (line?.itemSku?._id ?? line?.itemSku ?? null); return { _id: line?._id, @@ -62,7 +62,7 @@ const stockAuditLevelSchema = new Schema( { _reference: { type: String, default: () => generateId()() }, name: { type: String, required: true }, - tags: [{ type: String }], + tags: [{ type: String, required: true }], auditLines: { type: [stockAuditLevelLineSchema], default: [] }, }, { timestamps: true }