/// Model Saham master dari saat.saham. class Saham { final int id; final String kode; final String? perusahaan; final String? sektor; Saham({required this.id, required this.kode, this.perusahaan, this.sektor}); factory Saham.fromOdoo(Map m) => Saham( id: (m['id'] as num).toInt(), kode: (m['name'] as String?) ?? '', perusahaan: m['perusahaan'] as String?, sektor: m['sector'] as String?, ); } /// Model Transaksi dari saat.transaksi. class Transaksi { final int id; final String tanggal; final String tipe; // buy | sell final int sahamId; final String sahamTicker; final int volume; final double harga; final double fee; final double total; Transaksi({ required this.id, required this.tanggal, required this.tipe, required this.sahamId, required this.sahamTicker, required this.volume, required this.harga, required this.fee, required this.total, }); bool get isBuy => tipe == 'buy'; factory Transaksi.fromOdoo(Map m) { String ticker = ''; final s = m['saham_id']; if (s is List && s.isNotEmpty) { ticker = s.length > 1 ? s[1].toString() : '${s[0]}'; } final sid = s is List ? (s.first as num).toInt() : (s as num?)?.toInt() ?? 0; return Transaksi( id: (m['id'] as num).toInt(), tanggal: (m['tanggal'] as String?) ?? '', tipe: (m['tipe'] as String?) ?? 'buy', sahamId: sid, sahamTicker: ticker, volume: (m['volume'] as num?)?.toInt() ?? 0, harga: (m['harga'] as num?)?.toDouble() ?? 0, fee: (m['fee'] as num?)?.toDouble() ?? 0, total: (m['total'] as num?)?.toDouble() ?? 0, ); } }