Files
fcs/lib/vo/pd.dart

91 lines
2.0 KiB
Dart
Raw Normal View History

2020-05-29 07:45:27 +06:30
import 'package:cloud_firestore/cloud_firestore.dart';
class PD {
String id;
DateTime date;
String userID;
String userName;
String pdNumber;
List<PDLine> pdLines = [];
PD({this.id, this.date, this.userID, this.userName, this.pdNumber});
factory PD.fromMap(Map<String, dynamic> map, String id) {
var _dateTime = (map['date'] as Timestamp);
return PD(
id: id,
userID: map['user_id'],
userName: map['user_name'],
date: _dateTime?.toDate(),
pdNumber: map['pd_number']);
}
Map<String, dynamic> toMap() {
List lines = pdLines.map((l) => l.toMap()).toList();
return {
'id': id,
'date': date,
'pd_lines': lines,
};
}
@override
String toString() {
return 'PD{id:$id, date:$date,pdLines:$pdLines}';
}
}
class PDLine {
String storageID, storageName, productID, productName;
int quantity;
String action;
PDLine(
{this.storageID,
this.storageName,
this.productID,
this.productName,
this.quantity});
Map<String, dynamic> toMap() {
return {
'storage_id': storageID,
'storage_name': storageName,
'product_id': productID,
'product_name': productName,
'quantity': quantity
};
}
factory PDLine.fromMap(Map<String, dynamic> map) {
return PDLine(
storageID: map['storage_id'],
storageName: map['storage_name'],
productID: map['product_id'],
productName: map['product_name'],
quantity: map['quantity'],
);
}
@override
bool operator ==(other) {
if (identical(this, other)) {
return true;
}
return (other.storageID == this.storageID &&
other.productID == this.productID);
}
@override
int get hashCode {
int result = 17;
result = 37 * result + storageID.hashCode;
result = 37 * result + productID.hashCode;
return result;
}
@override
String toString() {
return 'PDLine{storageName:$storageName,productName:$productName,quantity:$quantity}';
}
}