fill
This commit is contained in:
61
lib/features/warehouse/domain/entities/warehouse_entity.dart
Normal file
61
lib/features/warehouse/domain/entities/warehouse_entity.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user