add update shipments
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
|
||||
import 'cargo_type.dart';
|
||||
|
||||
class Shipment {
|
||||
String id;
|
||||
String shipmentNumber;
|
||||
@@ -22,7 +20,7 @@ class Shipment {
|
||||
String currentStatus;
|
||||
bool isCourier;
|
||||
int radioIndex;
|
||||
List<Box> boxes;
|
||||
List<Carton> boxes;
|
||||
|
||||
Shipment(
|
||||
{this.id,
|
||||
@@ -40,12 +38,15 @@ class Shipment {
|
||||
this.pickupDate,
|
||||
this.isCourier = false,
|
||||
this.radioIndex = 1,
|
||||
this.pickupAddress,
|
||||
this.boxes});
|
||||
|
||||
int get last => DateTime.now().difference(pickupDate).inDays;
|
||||
|
||||
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
||||
var pd = (map['pickup_date'] as Timestamp);
|
||||
var pa = map['pickup_address'];
|
||||
var _pa = pa != null ? DeliveryAddress.fromMap(pa, pa["id"]) : null;
|
||||
return Shipment(
|
||||
id: id,
|
||||
userName: map['user_name'],
|
||||
@@ -54,14 +55,17 @@ class Shipment {
|
||||
pickupDate: pd == null ? null : pd.toDate(),
|
||||
pickupTimeStart: map['pickup_time_start'],
|
||||
pickupTimeEnd: map['pickup_time_end'],
|
||||
currentStatus: map['current_status']);
|
||||
currentStatus: map['current_status'],
|
||||
shipmentType: map['shipment_type'],
|
||||
pickupAddress: _pa);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List _boxes = boxes.map((l) => l.toMap()).toList();
|
||||
|
||||
return {
|
||||
"id": id,
|
||||
'boxes': _boxes,
|
||||
'cartons': _boxes,
|
||||
'shipment_type': shipmentType,
|
||||
'pickup_address': pickupAddress.toMap(),
|
||||
"pickup_date": pickupDate?.toUtc()?.toIso8601String(),
|
||||
|
||||
Reference in New Issue
Block a user