add update shipments
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CargoType {
|
||||
String id;
|
||||
String name;
|
||||
@@ -11,7 +13,8 @@ class CargoType {
|
||||
return CargoType(
|
||||
id: id,
|
||||
name: map['name'],
|
||||
rate: (map['rate'] ?? 0).toDouble(),
|
||||
rate: map['rate']?.toDouble() ?? 0,
|
||||
weight: map['weight']?.toDouble() ?? 0,
|
||||
);
|
||||
}
|
||||
CargoType({this.id, this.name, this.rate, this.weight});
|
||||
@@ -25,6 +28,10 @@ class CargoType {
|
||||
};
|
||||
}
|
||||
|
||||
CargoType clone() {
|
||||
return CargoType.fromMap(toMap(), this.id);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => other is CargoType && other.id == id;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'cargo_type.dart';
|
||||
import 'package.dart';
|
||||
|
||||
class Box {
|
||||
class Carton {
|
||||
String id;
|
||||
String shipmentNumber;
|
||||
String senderFCSID;
|
||||
@@ -91,7 +91,7 @@ class Box {
|
||||
|
||||
List<ShipmentStatus> shipmentHistory;
|
||||
|
||||
Box(
|
||||
Carton(
|
||||
{this.id,
|
||||
this.shipmentNumber,
|
||||
this.senderFCSID,
|
||||
@@ -132,13 +132,18 @@ class Box {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'delivery_address': deliveryAddress.toMap(),
|
||||
'carton_type': cartonType,
|
||||
};
|
||||
}
|
||||
|
||||
factory Box.fromMap(Map<String, dynamic> map, String docID) {
|
||||
factory Carton.fromMap(Map<String, dynamic> map, String docID) {
|
||||
var _arrivedDate = (map['arrived_date'] as Timestamp);
|
||||
|
||||
return Box(
|
||||
var da = map['delivery_address'];
|
||||
var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
|
||||
var cargoTypesMaps = List<Map<String, dynamic>>.from(map['cargo_types']);
|
||||
var cargoTypes =
|
||||
cargoTypesMaps.map((e) => CargoType.fromMap(e, e["id"])).toList();
|
||||
return Carton(
|
||||
id: docID,
|
||||
arrivedDate: _arrivedDate != null ? _arrivedDate.toDate() : null,
|
||||
shipmentNumber: map['shipment_number'],
|
||||
@@ -149,6 +154,8 @@ class Box {
|
||||
height: map['height'],
|
||||
userName: map['user_name'],
|
||||
fcsID: map['fcs_id'],
|
||||
cartonType: map['carton_type']);
|
||||
cartonType: map['carton_type'],
|
||||
deliveryAddress: _da,
|
||||
cargoTypes: cargoTypes);
|
||||
}
|
||||
}
|
||||
@@ -23,24 +23,25 @@ class Setting {
|
||||
final String termsEng;
|
||||
final String termsMm;
|
||||
String about;
|
||||
String courierWebsite;
|
||||
|
||||
List<String> shipmentTypes;
|
||||
|
||||
Setting({
|
||||
this.supportBuildNum,
|
||||
this.usaAddress,
|
||||
this.mmAddress,
|
||||
this.usaContactNumber,
|
||||
this.mmContactNumber,
|
||||
this.emailAddress,
|
||||
this.facebookLink,
|
||||
this.inviteRequired,
|
||||
this.appUrl,
|
||||
this.termsEng,
|
||||
this.termsMm,
|
||||
this.about,
|
||||
this.shipmentTypes,
|
||||
});
|
||||
Setting(
|
||||
{this.supportBuildNum,
|
||||
this.usaAddress,
|
||||
this.mmAddress,
|
||||
this.usaContactNumber,
|
||||
this.mmContactNumber,
|
||||
this.emailAddress,
|
||||
this.facebookLink,
|
||||
this.inviteRequired,
|
||||
this.appUrl,
|
||||
this.termsEng,
|
||||
this.termsMm,
|
||||
this.about,
|
||||
this.shipmentTypes,
|
||||
this.courierWebsite});
|
||||
|
||||
factory Setting.fromMap(Map<String, dynamic> map) {
|
||||
return Setting(
|
||||
@@ -57,6 +58,7 @@ class Setting {
|
||||
termsEng: map['terms_eng'],
|
||||
termsMm: map['terms_mm'],
|
||||
shipmentTypes: List.from(map['shipment_types']),
|
||||
courierWebsite: map['courier_website'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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