For: Customers · Partners · Integrators
A customer cancels an order, or an order was transferred twice. The order must be removed from production, even if its parts have already been assigned to a lot.
Challenge
A canceled order that remains in productionManager will still be produced, wasting material and machine time. Removing it is more than a data operation: if its parts are scheduled together with parts from other orders in a lot, and that lot has already been optimized or is being produced, the cutting plans and possibly parts already cut are also affected.
Solution
When an order is canceled in the ERP system, the integration deletes the order in productionManager. An order whose parts have been assigned to a lot can only be deleted after the lot has been dissolved. Otherwise, the request returns 422 Unprocessable Entity with the lot's name. Before dissolving it, the integration checks the status of each lot: only lots that have not yet been optimized can be dissolved and replanned automatically. For all other lots, production planning must decide what to do next.
Workflow
- Use the
orderIdsaved when the order was imported. - Read the order details. The order's lots are in
lots, and its parts are in theitemshierarchy. - Read the details of each lot, check its
status, and save itspartIds. - If a lot is not
New, stop and notify production planning (see below). - Dissolve the lots.
- Delete the order.
- Create new lots from the saved parts that do not belong to the deleted order.
Check the lot status first
Dissolving a lot removes the lot assignment from all its parts, including parts from other orders. The effect on production depends on the lot's status:
| Lot status | Meaning | Effect of dissolving |
|---|---|---|
New |
The lot is scheduled but has not been sent for optimization or exported. | No effect on production. The lot can be dissolved and its remaining parts can be replanned automatically. |
ReadyForProduction |
The lot has been sent for optimization or exported. Cutting or nesting plans already include the canceled order's parts. | The existing optimization no longer matches the lot. The remaining parts must be optimized again, and the old cutting or nesting plans must not be used for production. |
InProduction |
Production of the lot has started. Parts from the canceled order may already have been cut or processed. | Parts may already physically exist. They must be removed from production, and production of the remaining parts must be replanned in the workshop. |
Warning: Automatically dissolve and replan only lots with status
New. For lots with statusReadyForProductionorInProduction, notify production planning and let them decide. Check part feedback to see which parts have already been processed. Deleting an order cannot be undone.
// 2. Read the order details
// GetParts collects all parts in the hierarchy; see Use case: Create lots
var order = await productionManager.GetOrder(orderId);
var partsOfOrder = GetParts(order!.Items).Select(p => p.Id).ToHashSet();
// 3. Read the lots and check their status
var lots = new List<LotDetails>();
foreach (var lotReference in order.Lots ?? [])
{
lots.Add((await productionManager.GetLotDetails(lotReference.LotId.ToString()))!);
}
// 4. Stop if a lot has already been optimized or is in production
var lotsInProgress = lots.Where(l => l.Status != LotStatus.New).ToList();
if (lotsInProgress.Count > 0)
{
planning.NotifyCanceledOrderInProduction(order, lotsInProgress);
return;
}
foreach (var lot in lots)
{
var remainingParts = lot.PartIds.Where(id => !partsOfOrder.Contains(id)).ToArray();
// 5. Dissolve the lot
await productionManager.DeleteOrDecomposeLotByLotId(lot.Id);
// 7. Reschedule parts from the other orders
if (remainingParts.Length > 0)
{
await productionManager.CreateLotRequest(new CreateLotRequest
{
Name = lot.Name,
StartDatePlanned = lot.StartDatePlanned,
CompletionDatePlanned = lot.CompletionDatePlanned,
PartIds = remainingParts
});
}
}
// 6. Delete the order
await productionManager.DeleteOrderByOrderId(orderId);
# 2. Read the order details
GET /api/productionManager/orders/1f5d1f4d-2ab9-487a-8a17-2d6fd84fe228
# 3. Read the lot and check its status
GET /api/productionManager/lots/f6fd8084-29d1-4bba-a4b2-3c9c8d2fd6b1
200 OK
{
"id": "f6fd8084-29d1-4bba-a4b2-3c9c8d2fd6b1",
"name": "LOT-2026-12-11",
"status": "New",
"partIds": [ "10705921", "10705922", "10712004", "10712005" ]
}
# 4. If the status is "New", continue. Otherwise, notify production planning.
# Deleting the order is rejected while it belongs to a lot:
DELETE /api/productionManager/orders?orderId=1f5d1f4d-2ab9-487a-8a17-2d6fd84fe228
422 Unprocessable Entity
{
"Title": "Deletion not possible",
"SubTitle": "You can't delete the job Kitchen Block A because it's part of Lot LOT-2026-12-11. Please remove the order from the lot first."
}
# 5. Dissolve the lot
DELETE /api/productionManager/lots?lotId=f6fd8084-29d1-4bba-a4b2-3c9c8d2fd6b1
204 No Content
# 6. Delete the order
DELETE /api/productionManager/orders?orderId=1f5d1f4d-2ab9-487a-8a17-2d6fd84fe228
204 No Content
# 7. Reschedule parts from the other orders
POST /api/productionManager/lots
Content-Type: application/json
{
"name": "LOT-2026-12-11",
"partIds": [ "10712004", "10712005" ]
}
What you do not need to do
- You do not need to reset the order release before deleting it.
- The API does not prevent lots that are already in production from being dissolved. Checking the lot status is your integration's responsibility.
Integration architecture
Trigger deletion when the order is canceled in the ERP system. If all lots for the order have status New, or the order is not assigned to a lot, the integration can delete it automatically. Otherwise, create a task for production planning in your planning system, and delete the order only after production has been adjusted. Delete multiple orders in one request by passing multiple orderId or orderNumber values. Do not mix the two parameter types. If an order is not found, the request returns 422 Unprocessable Entity and no orders are deleted. After checking the order in your ERP system, handle this as “already deleted.”
Benefits
- Canceled orders are not produced.
- Parts from other orders remain scheduled even if they shared a lot with the canceled order.
- Lots that have already been optimized or are in production are not changed without production planning's knowledge.
API reference: See Endpoints → HOMAG Connect productionManager: Get lot details (
GET /api/productionManager/lots/{id}), Delete or dissolve lots (DELETE /api/productionManager/lots), Delete orders (DELETE /api/productionManager/orders), and Create a lot (POST /api/productionManager/lots).
