improve parsing
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
/// A parsed receipt row shown on the review screen.
|
||||
library;
|
||||
|
||||
import 'receipt_bounds.dart';
|
||||
|
||||
class LineItem {
|
||||
LineItem({
|
||||
required this.id,
|
||||
@@ -9,6 +11,8 @@ class LineItem {
|
||||
this.quantity,
|
||||
this.unitPrice,
|
||||
this.discount = 0,
|
||||
this.sourceBounds,
|
||||
this.needsManualReview = false,
|
||||
});
|
||||
|
||||
final String id;
|
||||
@@ -22,6 +26,12 @@ class LineItem {
|
||||
/// Negative amount when a discount was folded into [price].
|
||||
final double discount;
|
||||
|
||||
/// Region on the receipt photo (normalized 0–1) used when parsing this line.
|
||||
final ReceiptBounds? sourceBounds;
|
||||
|
||||
/// True when the parser could not confidently resolve price/qty for this line.
|
||||
final bool needsManualReview;
|
||||
|
||||
bool get hasDiscount => discount != 0;
|
||||
|
||||
/// List price before a folded discount. Equals [price] when there is none.
|
||||
@@ -37,7 +47,10 @@ class LineItem {
|
||||
int? quantity,
|
||||
double? unitPrice,
|
||||
double? discount,
|
||||
ReceiptBounds? sourceBounds,
|
||||
bool? needsManualReview,
|
||||
bool clearQuantity = false,
|
||||
bool clearSourceBounds = false,
|
||||
}) {
|
||||
return LineItem(
|
||||
id: id ?? this.id,
|
||||
@@ -46,6 +59,8 @@ class LineItem {
|
||||
quantity: clearQuantity ? null : (quantity ?? this.quantity),
|
||||
unitPrice: clearQuantity ? null : (unitPrice ?? this.unitPrice),
|
||||
discount: discount ?? this.discount,
|
||||
sourceBounds: clearSourceBounds ? null : (sourceBounds ?? this.sourceBounds),
|
||||
needsManualReview: needsManualReview ?? this.needsManualReview,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user