class ReceiptItem {
  final String description;
  final double quantity;
  final double price;

  ReceiptItem({
    required this.description,
    required this.quantity,
    required this.price,
  });

  double get total => quantity * price;

  Map<String, dynamic> toJson() {
    return {
      'description': description,
      'quantity': quantity,
      'price': price,
    };
  }

  factory ReceiptItem.fromJson(Map<String, dynamic> json) {
    return ReceiptItem(
      description: json['description'],
      quantity: json['quantity'].toDouble(),
      price: json['price'].toDouble(),
    );
  }

  @override
  String toString() {
    return 'ReceiptItem(description: $description, quantity: $quantity, price: $price)';
  }
}
