import 'package:equatable/equatable.dart';

/// Product stage entity - pure domain model
/// Represents a product at a specific production stage with quantities
class ProductStageEntity extends Equatable {
  final int productId;
  final int? productStageId;
  final int? actionTypeId;
  final int passedQuantity;
  final int issuedQuantity;
  final double issuedQuantityWeight;
  final double passedQuantityWeight;
  final String? stageName;
  final String createdDate;
  final String productName;
  final String productCode;
  final int? stageId;

  const ProductStageEntity({
    required this.productId,
    required this.productStageId,
    required this.actionTypeId,
    required this.passedQuantity,
    required this.issuedQuantity,
    required this.issuedQuantityWeight,
    required this.passedQuantityWeight,
    required this.stageName,
    required this.createdDate,
    this.productName = '',
    this.productCode = '',
    this.stageId,
  });

  /// Get display name for the stage
  /// Returns "No Stage" if stageName is null
  String get displayName => stageName ?? 'Không tên';

  /// Check if this is a valid stage (has a stage name)
  bool get hasStage => stageName != null && stageName!.isNotEmpty;

  /// Check if this stage has any passed quantity
  bool get hasPassedQuantity => passedQuantity > 0;

  /// Check if this stage has any issued quantity
  bool get hasIssuedQuantity => issuedQuantity > 0;

  @override
  List<Object?> get props => [
        productId,
        productStageId,
        actionTypeId,
        passedQuantity,
        issuedQuantity,
        issuedQuantityWeight,
        passedQuantityWeight,
        stageName,
        createdDate,
        productName,
        productCode,
        stageId,
      ];

  @override
  String toString() {
    return 'ProductStageEntity(productId: $productId, stageName: $stageName, passedQuantity: $passedQuantity)';
  }
}
