feat: implement user-scoped receipt aliases with global fallback; enhance alias management in admin panel
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:
@@ -0,0 +1,40 @@
|
||||
class ReceiptAlias {
|
||||
final int id;
|
||||
final String receiptName;
|
||||
final int productId;
|
||||
final String? productName;
|
||||
final String? productCanonicalName;
|
||||
|
||||
const ReceiptAlias({
|
||||
required this.id,
|
||||
required this.receiptName,
|
||||
required this.productId,
|
||||
this.productName,
|
||||
this.productCanonicalName,
|
||||
});
|
||||
|
||||
String get displayProductName {
|
||||
final canonical = productCanonicalName?.trim();
|
||||
if (canonical != null && canonical.isNotEmpty) return canonical;
|
||||
final fallback = productName?.trim();
|
||||
if (fallback != null && fallback.isNotEmpty) return fallback;
|
||||
return '#$productId';
|
||||
}
|
||||
|
||||
factory ReceiptAlias.fromJson(Map<String, dynamic> json) {
|
||||
final product = json['product'];
|
||||
final productMap = product is Map<String, dynamic>
|
||||
? product
|
||||
: const <String, dynamic>{};
|
||||
|
||||
return ReceiptAlias(
|
||||
id: (json['id'] as num).toInt(),
|
||||
receiptName: (json['receiptName'] ?? '').toString(),
|
||||
productId: (json['productId'] as num?)?.toInt() ??
|
||||
(productMap['id'] as num?)?.toInt() ??
|
||||
0,
|
||||
productName: productMap['name']?.toString(),
|
||||
productCanonicalName: productMap['canonicalName']?.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user