W048: Delete customer
Removes a customer if nothing references it. Triggered from Customer Detail. Delete is conservative: any SO or child customer blocks the operation. UI typically routes users to archive instead.
Steps
-
Load the customer. Call
Customers.getCustomerById. -
Block if SOs reference it. Call
SalesOrders.listSos({ customerId }); refuse if non-empty. Customers are part of every SO's audit trail. -
Block if children reference it. Refuse if this customer is the parent of any other customer; deleting would orphan the children.
-
Delete the row. Call
Customers.deleteCustomer.
Returns
Nothing.
Business rules
- Order history blocks deletion. A customer with any SO cannot be deleted; archive instead.
- Children block deletion. Re-parent or delete children first.
Errors
NotFoundError. The customer was not found.InUseError. SOs or child customers still reference this customer.