first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/// OCR 识别出的单条账单
|
||||
class OcrResult {
|
||||
final double amount; // 负数=支出,正数=收入(与 uniApp 语义一致)
|
||||
final String? merchant;
|
||||
final String? date;
|
||||
final double? confidence;
|
||||
|
||||
const OcrResult({
|
||||
required this.amount,
|
||||
this.merchant,
|
||||
this.date,
|
||||
this.confidence,
|
||||
});
|
||||
|
||||
bool get isExpense => amount < 0;
|
||||
|
||||
double get absAmount => amount.abs();
|
||||
|
||||
factory OcrResult.fromJson(Map<String, dynamic> json) => OcrResult(
|
||||
amount: (json['amount'] as num?)?.toDouble() ?? 0,
|
||||
merchant: json['merchant']?.toString(),
|
||||
date: json['date']?.toString(),
|
||||
confidence: (json['confidence'] as num?)?.toDouble(),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user