add paginator
This commit is contained in:
@@ -1,54 +1,77 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
|
||||
import 'cargo_type.dart';
|
||||
|
||||
class Shipment {
|
||||
String id;
|
||||
String shipmentNumber;
|
||||
String shipmentType;
|
||||
DeliveryAddress pickupAddress;
|
||||
DateTime pickupDate;
|
||||
String pickupTimeStart;
|
||||
String pickupTimeEnd;
|
||||
|
||||
String userName;
|
||||
String phoneNumber;
|
||||
String fromTime;
|
||||
String toTime;
|
||||
int numberOfPackage;
|
||||
int weight;
|
||||
int handlingFee;
|
||||
String address;
|
||||
String status;
|
||||
DateTime date;
|
||||
List<CargoType> cargoTypes;
|
||||
String currentStatus;
|
||||
bool isCourier;
|
||||
int radioIndex;
|
||||
List<Box> boxes;
|
||||
|
||||
Shipment(
|
||||
{this.id,
|
||||
this.shipmentNumber,
|
||||
this.shipmentType,
|
||||
this.userName,
|
||||
this.phoneNumber,
|
||||
this.fromTime,
|
||||
this.toTime,
|
||||
this.pickupTimeStart,
|
||||
this.pickupTimeEnd,
|
||||
this.numberOfPackage,
|
||||
this.weight,
|
||||
this.handlingFee,
|
||||
this.address,
|
||||
this.status,
|
||||
this.date,
|
||||
this.cargoTypes,
|
||||
this.currentStatus,
|
||||
this.pickupDate,
|
||||
this.isCourier = false,
|
||||
this.radioIndex = 1});
|
||||
this.radioIndex = 1,
|
||||
this.boxes});
|
||||
|
||||
int get last => DateTime.now().difference(date).inDays;
|
||||
int get last => DateTime.now().difference(pickupDate).inDays;
|
||||
|
||||
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
||||
var pd = (map['pickup_date'] as Timestamp);
|
||||
return Shipment(
|
||||
id: id,
|
||||
userName: map['user_name'],
|
||||
shipmentNumber: map['shipment_number'],
|
||||
phoneNumber: map['phone_number'],
|
||||
fromTime: map['from_time'],
|
||||
toTime: map['to_time'],
|
||||
numberOfPackage: map['number_of_package'],
|
||||
weight: map['weight'],
|
||||
address: map['address'],
|
||||
status: map['status']);
|
||||
pickupDate: pd == null ? null : pd.toDate(),
|
||||
pickupTimeStart: map['pickup_time_start'],
|
||||
pickupTimeEnd: map['pickup_time_end'],
|
||||
currentStatus: map['current_status']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List _boxes = boxes.map((l) => l.toMap()).toList();
|
||||
return {
|
||||
"id": id,
|
||||
'boxes': _boxes,
|
||||
'shipment_type': shipmentType,
|
||||
'pickup_address': pickupAddress.toMap(),
|
||||
"pickup_date": pickupDate?.toUtc()?.toIso8601String(),
|
||||
'pickup_time_start': pickupTimeStart,
|
||||
'pickup_time_end': pickupTimeEnd,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,fromTime:$fromTime,toTime:$toTime,numberOfPackage:$numberOfPackage,weight:$weight,status:$status}';
|
||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,numberOfPackage:$numberOfPackage,weight:$weight,currentStatus:$currentStatus}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user