From 20390ca455951c0ad898914640932a5286e5c071 Mon Sep 17 00:00:00 2001 From: Martijn Date: Tue, 21 Nov 2023 15:01:52 +0100 Subject: [PATCH] feat(picqer): allocated + stockOnhand --- packages/vendure-plugin-picqer/CHANGELOG.md | 4 ++++ packages/vendure-plugin-picqer/package.json | 2 +- packages/vendure-plugin-picqer/src/api/picqer.service.ts | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/vendure-plugin-picqer/CHANGELOG.md b/packages/vendure-plugin-picqer/CHANGELOG.md index 1c2f6341..2320f041 100644 --- a/packages/vendure-plugin-picqer/CHANGELOG.md +++ b/packages/vendure-plugin-picqer/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.2.4 (2023-11-21) + +- Take Picqer allocated stock into account when setting stock on hand + # 2.2.3 (2023-11-21) - Log order code when order couldn't be added to push-order queue diff --git a/packages/vendure-plugin-picqer/package.json b/packages/vendure-plugin-picqer/package.json index 7fe52616..bae95611 100644 --- a/packages/vendure-plugin-picqer/package.json +++ b/packages/vendure-plugin-picqer/package.json @@ -1,6 +1,6 @@ { "name": "@pinelab/vendure-plugin-picqer", - "version": "2.2.3", + "version": "2.2.4", "description": "Vendure plugin syncing to orders and stock with Picqer", "icon": "truck", "author": "Martijn van de Brug ", diff --git a/packages/vendure-plugin-picqer/src/api/picqer.service.ts b/packages/vendure-plugin-picqer/src/api/picqer.service.ts index ba3ed09d..eb2b8d65 100644 --- a/packages/vendure-plugin-picqer/src/api/picqer.service.ts +++ b/packages/vendure-plugin-picqer/src/api/picqer.service.ts @@ -656,13 +656,15 @@ export class PicqerService implements OnApplicationBootstrap { variant.id, location.id ); - const delta = picqerStock.freestock - stockOnHand; + const allocated = picqerStock.reservedallocations ?? 0; + const newStockOnHand = allocated + picqerStock.freestock; + const delta = newStockOnHand - stockOnHand; const res = await this.connection .getRepository(ctx, StockLevel) .save({ id: stockLevelId, - stockOnHand: picqerStock.freestock, - stockAllocated: picqerStock.reservedallocations ?? 0, + stockOnHand: newStockOnHand, + stockAllocated: allocated, }); // Add stock adjustment stockAdjustments.push(