Files
minhthu/lib/features/warehouse/domain/entities/warehouse_entity.dart
2025-10-28 00:09:46 +07:00

62 lines
1.4 KiB
Dart

import 'package:equatable/equatable.dart';
/// Warehouse domain entity
/// Pure business model with no dependencies on data layer
class WarehouseEntity extends Equatable {
final int id;
final String name;
final String code;
final String? description;
final bool isNGWareHouse;
final int totalCount;
const WarehouseEntity({
required this.id,
required this.name,
required this.code,
this.description,
required this.isNGWareHouse,
required this.totalCount,
});
@override
List<Object?> get props => [
id,
name,
code,
description,
isNGWareHouse,
totalCount,
];
@override
String toString() {
return 'WarehouseEntity(id: $id, name: $name, code: $code, totalCount: $totalCount)';
}
/// Check if warehouse has items
bool get hasItems => totalCount > 0;
/// Check if this is an NG (Not Good/Defect) warehouse
bool get isNGType => isNGWareHouse;
/// Create a copy with modified fields
WarehouseEntity copyWith({
int? id,
String? name,
String? code,
String? description,
bool? isNGWareHouse,
int? totalCount,
}) {
return WarehouseEntity(
id: id ?? this.id,
name: name ?? this.name,
code: code ?? this.code,
description: description ?? this.description,
isNGWareHouse: isNGWareHouse ?? this.isNGWareHouse,
totalCount: totalCount ?? this.totalCount,
);
}
}