diff --git a/flutter/lib/features/import/presentation/receipt_import_tab.dart b/flutter/lib/features/import/presentation/receipt_import_tab.dart index 63d3085a..24064c96 100644 --- a/flutter/lib/features/import/presentation/receipt_import_tab.dart +++ b/flutter/lib/features/import/presentation/receipt_import_tab.dart @@ -299,16 +299,18 @@ class _ReceiptImportTabState extends ConsumerState { 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 inferred = inferPackageFields( + rawName: it.rawName, + quantity: it.quantity, + unit: it.unit, + ); + final name = it.matchedProductName ?? it.suggestedProductName; + 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, ),