From ee040326d1307e70fb41c48f5e7d0c1eceb3cf3d Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Mon, 11 Dec 2023 13:52:06 +0100 Subject: [PATCH] fix(core): OrderLineEvent includes ID of deleted OrderLine Fixes #2574 --- packages/core/src/service/services/order.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/service/services/order.service.ts b/packages/core/src/service/services/order.service.ts index 715db9857b..0604c0feda 100644 --- a/packages/core/src/service/services/order.service.ts +++ b/packages/core/src/service/services/order.service.ts @@ -588,8 +588,9 @@ export class OrderService { let updatedOrderLines = [orderLine]; if (correctedQuantity === 0) { order.lines = order.lines.filter(l => !idsAreEqual(l.id, orderLine.id)); + const deletedOrderLine = new OrderLine(orderLine); await this.connection.getRepository(ctx, OrderLine).remove(orderLine); - this.eventBus.publish(new OrderLineEvent(ctx, order, orderLine, 'deleted')); + this.eventBus.publish(new OrderLineEvent(ctx, order, deletedOrderLine, 'deleted')); updatedOrderLines = []; } else { await this.orderModifier.updateOrderLineQuantity(ctx, orderLine, correctedQuantity, order); @@ -620,8 +621,9 @@ export class OrderService { const orderLine = this.getOrderLineOrThrow(order, orderLineId); order.lines = order.lines.filter(line => !idsAreEqual(line.id, orderLineId)); const updatedOrder = await this.applyPriceAdjustments(ctx, order); + const deletedOrderLine = new OrderLine(orderLine); await this.connection.getRepository(ctx, OrderLine).remove(orderLine); - this.eventBus.publish(new OrderLineEvent(ctx, order, orderLine, 'deleted')); + this.eventBus.publish(new OrderLineEvent(ctx, order, deletedOrderLine, 'deleted')); return updatedOrder; }