add shipments
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
|
||||
@@ -15,13 +16,21 @@ class Shipment {
|
||||
String phoneNumber;
|
||||
int numberOfPackage;
|
||||
int weight;
|
||||
int handlingFee;
|
||||
double handlingFee;
|
||||
String address;
|
||||
String currentStatus;
|
||||
String status;
|
||||
bool isCourier;
|
||||
int radioIndex;
|
||||
List<Carton> boxes;
|
||||
|
||||
String pickupUserID;
|
||||
String pickupUserName;
|
||||
String pickupUserPhoneNumber;
|
||||
|
||||
String fcsShipmentID;
|
||||
String fcsShipmentNumber;
|
||||
String shipmentLabelUrl;
|
||||
|
||||
Shipment(
|
||||
{this.id,
|
||||
this.shipmentNumber,
|
||||
@@ -34,15 +43,31 @@ class Shipment {
|
||||
this.weight,
|
||||
this.handlingFee,
|
||||
this.address,
|
||||
this.currentStatus,
|
||||
this.status,
|
||||
this.pickupDate,
|
||||
this.isCourier = false,
|
||||
this.radioIndex = 1,
|
||||
this.pickupAddress,
|
||||
this.pickupUserID,
|
||||
this.pickupUserName,
|
||||
this.pickupUserPhoneNumber,
|
||||
this.fcsShipmentID,
|
||||
this.fcsShipmentNumber,
|
||||
this.shipmentLabelUrl,
|
||||
this.boxes});
|
||||
|
||||
int get last => DateTime.now().difference(pickupDate).inDays;
|
||||
|
||||
double get totalWeight => boxes?.fold(0, (p, e) => p + e.actualWeight);
|
||||
int get totalCount => boxes?.length;
|
||||
|
||||
bool get isPending => status == shipment_pending_status;
|
||||
bool get isAssigned => status == shipment_assigned_status;
|
||||
bool get isPickuped => status == shipment_pickuped_status;
|
||||
bool get isPacked => status == shipment_packed_status;
|
||||
bool get isConfirmed => status == shipment_confirmed_status;
|
||||
bool get isReceived => status == shipment_received_status;
|
||||
|
||||
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
||||
var pd = (map['pickup_date'] as Timestamp);
|
||||
var pa = map['pickup_address'];
|
||||
@@ -55,8 +80,15 @@ class Shipment {
|
||||
pickupDate: pd == null ? null : pd.toDate(),
|
||||
pickupTimeStart: map['pickup_time_start'],
|
||||
pickupTimeEnd: map['pickup_time_end'],
|
||||
currentStatus: map['current_status'],
|
||||
status: map['status'],
|
||||
shipmentType: map['shipment_type'],
|
||||
pickupUserID: map['pickup_user_id'],
|
||||
pickupUserName: map['pickup_user_name'],
|
||||
pickupUserPhoneNumber: map['pickup_user_phone_number'],
|
||||
handlingFee: map['handling_fee'],
|
||||
fcsShipmentID: map['fcs_shipment_id'],
|
||||
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||
shipmentLabelUrl: map['shipment_label_url'],
|
||||
pickupAddress: _pa);
|
||||
}
|
||||
|
||||
@@ -71,11 +103,17 @@ class Shipment {
|
||||
"pickup_date": pickupDate?.toUtc()?.toIso8601String(),
|
||||
'pickup_time_start': pickupTimeStart,
|
||||
'pickup_time_end': pickupTimeEnd,
|
||||
'pickup_user_id': pickupUserID,
|
||||
'pickup_user_name': pickupUserName,
|
||||
'pickup_user_phone_number': pickupUserPhoneNumber,
|
||||
'handling_fee': handlingFee,
|
||||
'fcs_shipment_id': fcsShipmentID,
|
||||
'shipment_label_url': shipmentLabelUrl
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,numberOfPackage:$numberOfPackage,weight:$weight,currentStatus:$currentStatus}';
|
||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,numberOfPackage:$numberOfPackage,weight:$weight,status:$status}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user