mirrored_repositories/Expenses_Tracker_App/packages/expense_repository/lib/src
import 'package:expense_repository/expense_repository.dart';

class Expense {
  String? userId;
  String? howExpense;
  String? categoryId;
  String? currency;
  String expenseId;
  String categoryImagePath;
  String categoryName;
  String? explain;
  DateTime date;
  int amount;

  Expense({
    this.userId,
    this.explain,
    this.howExpense,
    this.categoryId,
    this.currency,
    required this.categoryImagePath,
    required this.expenseId,
    required this.categoryName,
    required this.date,
    required this.amount,
  });

  static final empty = Expense(
    currency: '',
    categoryId: '',
    explain: '',
    userId: '',
    howExpense: '',
    expenseId: '',
    categoryName: '',
    categoryImagePath: '',
    date: DateTime.now(),
    amount: 0,
  );

  Map<String, dynamic> toMap() {
    return {
      'currency': currency,
      'userId': userId,
      'howExpense': howExpense,
      'categoryId': categoryId,
      'expenseId': expenseId,
      'categoryImagePath': categoryImagePath,
      'categoryName': categoryName,
      'explain': explain,
      'date': date.toIso8601String(),
      'amount': amount,
    };
  }

  ExpenseEntity toEntity() {
    return ExpenseEntity(
      currency: currency,
      categoryId: categoryId,
      explain: explain,
      userId: userId,
      howExpense: howExpense,
      expenseId: expenseId,
      categoryName: categoryName,
      categoryImagePath: categoryImagePath,
      date: date,
      amount: amount,
    );
  }

  static Expense fromEntity(ExpenseEntity entity) {
    return Expense(
      currency: entity.currency,
      categoryId: entity.categoryId,
      explain: entity.explain,
      userId: entity.userId,
      howExpense: entity.howExpense,
      expenseId: entity.expenseId,
      categoryName: entity.categoryName,
      categoryImagePath: entity.categoryImagePath,
      date: entity.date,
      amount: entity.amount,
    );
  }
}
