import 'package:pshared/models/describable.dart';
import 'package:pshared/models/ledger/balance.dart';
import 'package:pshared/models/ledger/role.dart';
import 'package:pshared/models/ledger/status.dart';
import 'package:pshared/models/ledger/type.dart';


class LedgerAccount implements Describable {
  final String ledgerAccountRef;
  final String organizationRef;
  final String? ownerRef;
  final String accountCode;
  final LedgerAccountType accountType;
  final String currency;
  final LedgerAccountStatus status;
  final bool allowNegative;
  final LedgerAccountRole role;
  final Map<String, String>? metadata;
  final DateTime? createdAt;
  final DateTime? updatedAt;
  final Describable describable;
  final LedgerBalance? balance;

  @override
  String get name => describable.name;

  @override
  String? get description => describable.description;

  const LedgerAccount({
    required this.ledgerAccountRef,
    required this.organizationRef,
    this.ownerRef,
    required this.accountCode,
    required this.accountType,
    required this.currency,
    required this.status,
    required this.allowNegative,
    required this.role,
    this.metadata,
    this.createdAt,
    this.updatedAt,
    required this.describable,
    this.balance,
  });

  LedgerAccount copyWith({
    Describable? describable,
    LedgerBalance? balance,
  }) => LedgerAccount(
    ledgerAccountRef: ledgerAccountRef,
    organizationRef: organizationRef,
    ownerRef: ownerRef,
    accountCode: accountCode,
    accountType: accountType,
    currency: currency,
    status: status,
    allowNegative: allowNegative,
    role: role,
    metadata: metadata,
    createdAt: createdAt,
    updatedAt: updatedAt,
    describable: describable ?? this.describable,
    balance: balance ?? this.balance,
  );
}
