Implement admin inventory management features including CRUD operations, merging, filtering, sorting, previewing, and security enhancements. Update documentation and add comprehensive test coverage for security and validation.
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,60 @@
|
||||
class AdminInventoryItem {
|
||||
final int id;
|
||||
final int userId;
|
||||
final String username;
|
||||
final String userEmail;
|
||||
final int productId;
|
||||
final String productName;
|
||||
final String? productCanonicalName;
|
||||
final double quantity;
|
||||
final String unit;
|
||||
final String? location;
|
||||
final String? brand;
|
||||
final String? receiptName;
|
||||
final String? suitableFor;
|
||||
final String? comment;
|
||||
|
||||
const AdminInventoryItem({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.username,
|
||||
required this.userEmail,
|
||||
required this.productId,
|
||||
required this.productName,
|
||||
this.productCanonicalName,
|
||||
required this.quantity,
|
||||
required this.unit,
|
||||
this.location,
|
||||
this.brand,
|
||||
this.receiptName,
|
||||
this.suitableFor,
|
||||
this.comment,
|
||||
});
|
||||
|
||||
String get displayName {
|
||||
final canonical = productCanonicalName?.trim();
|
||||
if (canonical != null && canonical.isNotEmpty) return canonical;
|
||||
return productName;
|
||||
}
|
||||
|
||||
factory AdminInventoryItem.fromJson(Map<String, dynamic> json) {
|
||||
final user = (json['user'] as Map<String, dynamic>?) ?? const {};
|
||||
final product = (json['product'] as Map<String, dynamic>?) ?? const {};
|
||||
return AdminInventoryItem(
|
||||
id: json['id'] as int,
|
||||
userId: json['userId'] as int,
|
||||
username: user['username'] as String? ?? '',
|
||||
userEmail: user['email'] as String? ?? '',
|
||||
productId: json['productId'] as int,
|
||||
productName: product['name'] as String? ?? '',
|
||||
productCanonicalName: product['canonicalName'] as String?,
|
||||
quantity: double.tryParse(json['quantity']?.toString() ?? '0') ?? 0,
|
||||
unit: json['unit'] as String? ?? '',
|
||||
location: json['location'] as String?,
|
||||
brand: json['brand'] as String?,
|
||||
receiptName: json['receiptName'] as String?,
|
||||
suitableFor: json['suitableFor'] as String?,
|
||||
comment: json['comment'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user