<?php

namespace App\DTOs\ProductOwner;

class WalletLedgerData
{
    /**
     * @param  list<array<string, mixed>>  $entries
     */
    public function __construct(
        public float $balance,
        public string $currency,
        public array $entries = [],
    ) {}

    public static function fromArray(array $data): self
    {
        return new self(
            balance: (float) ($data['balance'] ?? 0),
            currency: (string) ($data['currency'] ?? config('platform.currency', 'INR')),
            entries: $data['ledger'] ?? [],
        );
    }
}
