From 52c084129f2b98bc00b44c267ce751ef4b569540 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Mon, 11 Dec 2023 14:05:38 +0100 Subject: [PATCH] fix(core): Remove redundant constraint when creating allocations Fixes #2563. In an earlier version, before the concept of "allocations" was introduced, this method created "Sales" rather than "Allocations". As such, it had the constraint that the `order.active` must be `false` in order to create a Sale. Since we switched this to Allocations, this constraint no longer makes sense. For instance, a custom OrderProcess may introduce a new state before the order becomes inactive, yet which should allocated stock. --- packages/core/src/i18n/messages/en.json | 1 - packages/core/src/service/services/stock-movement.service.ts | 3 --- 2 files changed, 4 deletions(-) diff --git a/packages/core/src/i18n/messages/en.json b/packages/core/src/i18n/messages/en.json index dcab06c5b0..b8fb899e27 100644 --- a/packages/core/src/i18n/messages/en.json +++ b/packages/core/src/i18n/messages/en.json @@ -6,7 +6,6 @@ "cannot-delete-sole-superadmin": "The sole SuperAdmin cannot be deleted", "cannot-locate-customer-for-user": "Cannot locate a Customer for the user", "cannot-modify-role": "The role \"{ roleCode }\" cannot be modified", - "cannot-create-sales-for-active-order": "Cannot create a Sale for an Order which is still active", "cannot-move-collection-into-self": "Cannot move a Collection into itself", "cannot-transition-payment-from-to": "Cannot transition Payment from \"{ fromState }\" to \"{ toState }\"", "cannot-transition-refund-from-to": "Cannot transition Refund from \"{ fromState }\" to \"{ toState }\"", diff --git a/packages/core/src/service/services/stock-movement.service.ts b/packages/core/src/service/services/stock-movement.service.ts index e38fa9503d..f642286408 100644 --- a/packages/core/src/service/services/stock-movement.service.ts +++ b/packages/core/src/service/services/stock-movement.service.ts @@ -137,9 +137,6 @@ export class StockMovementService { * increased, indicating that this quantity of stock is allocated and cannot be sold. */ async createAllocationsForOrder(ctx: RequestContext, order: Order): Promise { - if (order.active !== false) { - throw new InternalServerError('error.cannot-create-allocations-for-active-order'); - } const lines = order.lines.map(orderLine => ({ orderLineId: orderLine.id, quantity: orderLine.quantity,