class FinanceRecord { final int id; final String type; // receivable | payable | receipt | payment final double amount; final double balance; final String? refType; final int? refId; final String? partnerName; final String? recordDate; final String? remark; const FinanceRecord({ required this.id, required this.type, required this.amount, required this.balance, this.refType, this.refId, this.partnerName, this.recordDate, this.remark, }); String get typeLabel { switch (type) { case 'receivable': return '应收账款'; case 'payable': return '应付账款'; case 'receipt': return '收款'; case 'payment': return '付款'; default: return type; } } factory FinanceRecord.fromJson(Map json) => FinanceRecord( id: (json['id'] as num).toInt(), type: json['type'] as String, amount: (json['amount'] as num).toDouble(), balance: (json['balance'] as num).toDouble(), refType: json['ref_type'] as String?, refId: json['ref_id'] != null ? (json['ref_id'] as num).toInt() : null, partnerName: (json['partner'] as Map?)?['name'] as String?, recordDate: json['record_date'] as String?, remark: json['remark'] as String?, ); }