Map<String, dynamic> toJson() => { 'code': code, 'quantity': quantity, if (reasons != null) 'reasons': [for (final g in reasons!) {'code': g.code, 'quantity': g.quantity}], };