feat: enhance receipt import matching logic to include category path resolution and improve edit handling
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -299,16 +299,18 @@ class _ReceiptImportTabState extends ConsumerState<ReceiptImportTab> {
|
||||
final it = items[i];
|
||||
final pid = it.matchedProductId ?? it.suggestedProductId;
|
||||
nextSelected[i] = pid != null;
|
||||
if (pid != null) {
|
||||
final inferred = inferPackageFields(
|
||||
rawName: it.rawName,
|
||||
quantity: it.quantity,
|
||||
unit: it.unit,
|
||||
);
|
||||
final name = it.matchedProductName ?? it.suggestedProductName;
|
||||
final resolvedCategoryId = it.categorySuggestionId ?? _categoryIdForProduct(pid);
|
||||
final resolvedCategoryPath = it.categorySuggestionPath ??
|
||||
_lookup.pathFor(resolvedCategoryId);
|
||||
final resolvedCategoryId =
|
||||
it.categorySuggestionId ?? (pid != null ? _categoryIdForProduct(pid) : null);
|
||||
final resolvedCategoryPath =
|
||||
it.categorySuggestionPath ?? _lookup.pathFor(resolvedCategoryId);
|
||||
|
||||
if (pid != null || resolvedCategoryPath != null) {
|
||||
nextEdits[i] = _ItemEdit(
|
||||
productId: pid,
|
||||
productName: name,
|
||||
@@ -833,6 +835,7 @@ class _ReceiptImportResultRow extends ConsumerWidget {
|
||||
);
|
||||
final theme = Theme.of(context);
|
||||
final hasProduct = edit?.productId != null;
|
||||
final categoryPath = edit?.categoryPath ?? item.categorySuggestionPath;
|
||||
final isMatched = item.matchedProductId != null;
|
||||
final isSuggested =
|
||||
item.suggestedProductId != null && item.matchedProductId == null;
|
||||
@@ -946,10 +949,10 @@ class _ReceiptImportResultRow extends ConsumerWidget {
|
||||
style: theme.textTheme.bodySmall
|
||||
?.copyWith(color: theme.colorScheme.tertiary),
|
||||
),
|
||||
if (hasProduct && edit?.categoryPath != null) ...[
|
||||
if (categoryPath != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'Kategori: ${edit!.categoryPath!}',
|
||||
'${hasProduct ? 'Kategori' : 'Kategoriförslag'}: $categoryPath',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user