public synchronized boolean replacePart(WorkSheet ws, Part part) {
        PartType type = part.type;
        Integer inStockQuantity = stock.get(type);
        if (inStockQuantity != null && inStockQuantity > 0) {
            inStockQuantity = inStockQuantity - 1;
            stock.put(type, inStockQuantity);
            if (ws.replacedParts == null) {
                ws.replacedParts = new ArrayList<>();
            }
            ws.replacedParts.add(new ReplacedPart(type, part.name));
            ws.partsToReplace.remove(part);
            return true;
        } else {
            return false;
        }

    }