feat: implement alias strategy for receipt import with user-scoped and global fallback, enhance validation and normalization, and update UI components
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:
@@ -265,7 +265,6 @@ class ImportRepository {
|
||||
/// - Learning unit mappings
|
||||
Future<Map<String, dynamic>> saveReceipt({
|
||||
required List<Map<String, dynamic>> items,
|
||||
bool isAdminLearning = false,
|
||||
String? token,
|
||||
}) async {
|
||||
try {
|
||||
@@ -280,7 +279,6 @@ class ImportRepository {
|
||||
},
|
||||
body: jsonEncode({
|
||||
'items': items,
|
||||
if (isAdminLearning) 'isAdminLearning': true,
|
||||
}),
|
||||
).timeout(
|
||||
const Duration(seconds: 60),
|
||||
|
||||
@@ -16,6 +16,8 @@ enum CategorySelectionSource { ai, manual }
|
||||
class ItemEdit {
|
||||
final int? productId;
|
||||
final String? productName;
|
||||
final bool learnAlias;
|
||||
final bool learnAliasGlobally;
|
||||
final int? categoryId;
|
||||
final String? categoryPath;
|
||||
final CategorySelectionSource? categorySource;
|
||||
@@ -29,6 +31,8 @@ class ItemEdit {
|
||||
const ItemEdit({
|
||||
this.productId,
|
||||
this.productName,
|
||||
this.learnAlias = false,
|
||||
this.learnAliasGlobally = false,
|
||||
this.categoryId,
|
||||
this.categoryPath,
|
||||
this.categorySource,
|
||||
@@ -85,6 +89,8 @@ class ReceiptImportSession {
|
||||
'edits': edits.map((key, value) => MapEntry(key.toString(), {
|
||||
'productId': value.productId,
|
||||
'productName': value.productName,
|
||||
'learnAlias': value.learnAlias,
|
||||
'learnAliasGlobally': value.learnAliasGlobally,
|
||||
'categoryId': value.categoryId,
|
||||
'categoryPath': value.categoryPath,
|
||||
'categorySource': value.categorySource?.name,
|
||||
@@ -114,6 +120,8 @@ class ReceiptImportSession {
|
||||
edits[idx] = ItemEdit(
|
||||
productId: (value['productId'] as num?)?.toInt(),
|
||||
productName: value['productName'] as String?,
|
||||
learnAlias: value['learnAlias'] == true,
|
||||
learnAliasGlobally: value['learnAliasGlobally'] == true,
|
||||
categoryId: (value['categoryId'] as num?)?.toInt(),
|
||||
categoryPath: value['categoryPath'] as String?,
|
||||
categorySource: switch (value['categorySource']) {
|
||||
|
||||
Reference in New Issue
Block a user