Browse Source

fix(core): Fix stock movements when multiple OrderLines have same ProductVariant

fixes #1028
simpian 4 years ago
parent
commit
1b05f380a2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      packages/core/src/service/services/stock-movement.service.ts

+ 2 - 2
packages/core/src/service/services/stock-movement.service.ts

@@ -83,7 +83,7 @@ export class StockMovementService {
         const allocations: Allocation[] = [];
         const globalTrackInventory = (await this.globalSettingsService.getSettings(ctx)).trackInventory;
         for (const line of order.lines) {
-            const { productVariant } = line;
+            const productVariant = await this.connection.getEntityOrThrow(ctx, ProductVariant, line.productVariant.id);
             const allocation = new Allocation({
                 productVariant,
                 quantity: line.quantity,
@@ -125,7 +125,7 @@ export class StockMovementService {
             value.items.push(orderItem);
         }
         for (const lineRow of orderLinesMap.values()) {
-            const { productVariant } = lineRow.line;
+            const productVariant = await this.connection.getEntityOrThrow(ctx, ProductVariant, lineRow.line.productVariant.id);
             const sale = new Sale({
                 productVariant,
                 quantity: lineRow.items.length * -1,