94 lines
2.1 KiB
Dart
94 lines
2.1 KiB
Dart
/// Domain Entity: Business Unit
|
|
///
|
|
/// Represents a business unit that a user can access.
|
|
library;
|
|
|
|
/// Business Unit Entity
|
|
///
|
|
/// Represents a business division or unit that a user has access to.
|
|
class BusinessUnit {
|
|
/// Unique business unit identifier
|
|
final String id;
|
|
|
|
/// Business unit code (e.g., "VIKD", "HSKD", "LPKD")
|
|
final String code;
|
|
|
|
/// Display name
|
|
final String name;
|
|
|
|
/// Description
|
|
final String? description;
|
|
|
|
/// Whether this is the default unit
|
|
final bool isDefault;
|
|
|
|
const BusinessUnit({
|
|
required this.id,
|
|
required this.code,
|
|
required this.name,
|
|
this.description,
|
|
this.isDefault = false,
|
|
});
|
|
|
|
/// Create from JSON map
|
|
factory BusinessUnit.fromJson(Map<String, dynamic> json) {
|
|
return BusinessUnit(
|
|
id: json['id'] as String,
|
|
code: json['code'] as String,
|
|
name: json['name'] as String,
|
|
description: json['description'] as String?,
|
|
isDefault: json['is_default'] as bool? ?? false,
|
|
);
|
|
}
|
|
|
|
/// Convert to JSON map
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'code': code,
|
|
'name': name,
|
|
'description': description,
|
|
'is_default': isDefault,
|
|
};
|
|
}
|
|
|
|
/// Copy with method for immutability
|
|
BusinessUnit copyWith({
|
|
String? id,
|
|
String? code,
|
|
String? name,
|
|
String? description,
|
|
bool? isDefault,
|
|
}) {
|
|
return BusinessUnit(
|
|
id: id ?? this.id,
|
|
code: code ?? this.code,
|
|
name: name ?? this.name,
|
|
description: description ?? this.description,
|
|
isDefault: isDefault ?? this.isDefault,
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
|
|
return other is BusinessUnit &&
|
|
other.id == id &&
|
|
other.code == code &&
|
|
other.name == name &&
|
|
other.description == description &&
|
|
other.isDefault == isDefault;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return Object.hash(id, code, name, description, isDefault);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'BusinessUnit(id: $id, code: $code, name: $name, isDefault: $isDefault)';
|
|
}
|
|
}
|