add structure
This commit is contained in:
44
lib/vo/inventory_taking.dart
Normal file
44
lib/vo/inventory_taking.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
import 'inventory_line.dart';
|
||||
|
||||
class InventoryTaking {
|
||||
String accountID;
|
||||
String id;
|
||||
DateTime dateTime;
|
||||
String userID;
|
||||
String userName;
|
||||
List<InventoryLine> inventoryLines = [];
|
||||
|
||||
bool linesLoaded = false;
|
||||
|
||||
InventoryTaking(
|
||||
{this.accountID, this.id, this.userID, this.userName, this.dateTime});
|
||||
|
||||
factory InventoryTaking.fromMap(Map<String, dynamic> map, String id) {
|
||||
var _dateTime = (map['date_time'] as Timestamp);
|
||||
|
||||
return InventoryTaking(
|
||||
id: id,
|
||||
accountID: map['account_id'],
|
||||
userID: map['user_id'],
|
||||
userName: map['user_name'],
|
||||
dateTime: _dateTime?.toDate(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List lines = inventoryLines.map((l) => l.toMap()).toList();
|
||||
return {
|
||||
'id': id,
|
||||
'user_id': userID,
|
||||
'user_name': userName,
|
||||
'inventory_lines': lines,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InventoryTaking{id:$id,name:$userName}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user