update cargo type form from rate, update carton info and form
This commit is contained in:
@@ -10,33 +10,34 @@ import 'package.dart';
|
||||
|
||||
class Carton {
|
||||
String? id;
|
||||
String? shipmentID;
|
||||
String? shipmentNumber;
|
||||
String? cartonNumber;
|
||||
String? fcsShipmentID;
|
||||
String? fcsShipmentNumber;
|
||||
|
||||
String? senderID;
|
||||
String? senderFCSID;
|
||||
String? senderName;
|
||||
|
||||
String? boxNumber;
|
||||
String? status;
|
||||
String? cargoDesc;
|
||||
String? desc;
|
||||
String? consigneeFCSID;
|
||||
String? consigneeName;
|
||||
String? consigneeID;
|
||||
|
||||
double width;
|
||||
double height;
|
||||
double length;
|
||||
|
||||
String? status;
|
||||
String? cargoDesc;
|
||||
String? desc;
|
||||
|
||||
int? shipmentWeight;
|
||||
bool? isChecked;
|
||||
bool? isShipmentCarton;
|
||||
String? cartonType;
|
||||
String? fcsID;
|
||||
String? userName;
|
||||
String? userID;
|
||||
String? fcsShipmentID;
|
||||
String? fcsShipmentNumber;
|
||||
String? mixCartonID;
|
||||
|
||||
String? mixCartonNumber;
|
||||
String? cartonSizeID;
|
||||
String? cartonSizeName;
|
||||
String? deliveryType;
|
||||
|
||||
String? lastMile;
|
||||
String? cartonSizeType;
|
||||
|
||||
double cartonWeight;
|
||||
@@ -50,19 +51,18 @@ class Carton {
|
||||
List<String> photoUrls;
|
||||
String? remark;
|
||||
DateTime? arrivedDate;
|
||||
String? cartonNumber;
|
||||
|
||||
List<String> packageIDs;
|
||||
List<Package> packages;
|
||||
List<CargoType> cargoTypes = [];
|
||||
List<CargoType> surchareItems = [];
|
||||
|
||||
DeliveryAddress? deliveryAddress;
|
||||
Shipment? shipment;
|
||||
|
||||
//for mix box
|
||||
String? mixBoxType;
|
||||
List<Carton> mixCartons;
|
||||
List<String> mixCartonIDs;
|
||||
//for mix carton
|
||||
List<Carton> cartons;
|
||||
List<String> cartonIDs;
|
||||
|
||||
int get amount => (rate * weight);
|
||||
|
||||
@@ -123,12 +123,9 @@ class Carton {
|
||||
|
||||
Carton(
|
||||
{this.id,
|
||||
this.shipmentID,
|
||||
this.shipmentNumber,
|
||||
this.senderID,
|
||||
this.senderFCSID,
|
||||
this.senderName,
|
||||
this.boxNumber,
|
||||
this.desc,
|
||||
this.width = 0,
|
||||
this.height = 0,
|
||||
@@ -136,9 +133,9 @@ class Carton {
|
||||
this.shipmentWeight,
|
||||
this.isChecked = false,
|
||||
this.cartonType,
|
||||
this.fcsID,
|
||||
this.userID,
|
||||
this.userName,
|
||||
this.consigneeFCSID,
|
||||
this.consigneeID,
|
||||
this.consigneeName,
|
||||
this.rate = 0,
|
||||
this.weight = 0,
|
||||
this.packageType,
|
||||
@@ -150,47 +147,60 @@ class Carton {
|
||||
this.shipmentHistory = const [],
|
||||
this.packages = const [],
|
||||
this.cargoTypes = const [],
|
||||
this.surchareItems = const [],
|
||||
this.cartonNumber,
|
||||
this.billTo,
|
||||
this.fcsShipmentID,
|
||||
this.fcsShipmentNumber,
|
||||
this.packageIDs = const [],
|
||||
this.mixCartonID,
|
||||
this.mixCartonNumber,
|
||||
this.isShipmentCarton = false,
|
||||
this.deliveryAddress,
|
||||
this.cartonSizeID,
|
||||
this.cartonSizeName,
|
||||
this.cartonSizeType,
|
||||
this.deliveryType,
|
||||
this.mixBoxType,
|
||||
this.mixCartons = const [],
|
||||
this.mixCartonIDs = const [],
|
||||
this.lastMile,
|
||||
this.cartons = const [],
|
||||
this.cartonIDs = const [],
|
||||
this.cartonWeight = 0,
|
||||
this.photoUrls = const [],
|
||||
this.isSelected = false});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
||||
List _packages = packages.map((c) => c.toJson()).toList();
|
||||
List _mixCartons = mixCartons.map((c) => c.toJson()).toList();
|
||||
var _types = cargoTypes.where((t) => t.weight != 0).toList();
|
||||
var _cargoTypes = _types.map((c) => c.toMapForCargo()).toList();
|
||||
|
||||
var _packagesIds = packages.map((c) => c.id).toList();
|
||||
|
||||
var _surchareItems =
|
||||
surchareItems.map((c) => c.toMapForSurcharge()).toList();
|
||||
|
||||
return {
|
||||
'id': id,
|
||||
'carton_type': cartonType,
|
||||
'fcs_shipment_id': fcsShipmentID,
|
||||
'user_id': userID,
|
||||
'cargo_types': _cargoTypes,
|
||||
'packages': _packages,
|
||||
'sender_user_id': senderID,
|
||||
'consignee_user_id': consigneeID,
|
||||
'bill_to': billTo,
|
||||
'last_mile': lastMile,
|
||||
'length': length,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'delivery_address': deliveryAddress?.toMap(),
|
||||
'package_ids': _packagesIds,
|
||||
'cargo_types': _cargoTypes,
|
||||
'surcharge_items': _surchareItems,
|
||||
};
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMapForMix() {
|
||||
var _cartonIds = cartons.map((c) => c.id).toList();
|
||||
|
||||
return {
|
||||
'id': id,
|
||||
'carton_type': cartonType,
|
||||
'mix_carton_id': mixCartonID,
|
||||
'mix_box_type': mixBoxType,
|
||||
'mix_cartons': _mixCartons,
|
||||
'sender_id': senderID,
|
||||
'sender_fcs_id': senderFCSID,
|
||||
'sender_name': senderName
|
||||
'fcs_shipment_id': fcsShipmentID,
|
||||
'length': length,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'carton_ids': _cartonIds,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -199,75 +209,48 @@ class Carton {
|
||||
map['arrived_date'] == null ? null : (map['arrived_date'] as Timestamp);
|
||||
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();
|
||||
var mixCartonsMaps =
|
||||
List<Map<String, dynamic>>.from(map['mix_cartons'] ?? []);
|
||||
var _mixCartons =
|
||||
mixCartonsMaps.map((e) => Carton.fromMap(e, e["id"])).toList();
|
||||
var cargoTypes = cargoTypesMaps
|
||||
.map((e) => CargoType.fromMapForCargo(e, e["id"]))
|
||||
.toList();
|
||||
|
||||
var surchargeItemMaps =
|
||||
List<Map<String, dynamic>>.from(map['surcharge_items'] ?? []);
|
||||
var surchageItems = surchargeItemMaps
|
||||
.map((e) => CargoType.fromMapForsurcharge(e, e["id"]))
|
||||
.toList();
|
||||
|
||||
List<String> _photoUrls =
|
||||
map['photo_urls'] == null ? [] : List.from(map['photo_urls']);
|
||||
|
||||
return Carton(
|
||||
id: docID,
|
||||
arrivedDate: _arrivedDate != null ? _arrivedDate.toDate() : null,
|
||||
shipmentID: map['shipment_id'],
|
||||
shipmentNumber: map['shipment_number'],
|
||||
// receiverNumber: map['receiver_number'],
|
||||
boxNumber: map['box_number'],
|
||||
length: double.tryParse(map['length'].toString()) ?? 0,
|
||||
width: double.tryParse(map['width'].toString()) ?? 0,
|
||||
height: double.tryParse(map['height'].toString()) ?? 0,
|
||||
userName: map['user_name'],
|
||||
fcsID: map['fcs_id'],
|
||||
cartonType: map['carton_type'],
|
||||
cartonNumber: map['carton_number'],
|
||||
userID: map['user_id'],
|
||||
fcsShipmentID: map['fcs_shipment_id'],
|
||||
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||
isShipmentCarton: map['is_shipment_carton'],
|
||||
mixCartonID: map['mix_carton_id'],
|
||||
mixCartonNumber: map['mix_carton_number'],
|
||||
status: map['status'],
|
||||
packageIDs: List<String>.from(map['package_ids'] ?? []),
|
||||
deliveryAddress: _da,
|
||||
cargoTypes: cargoTypes,
|
||||
mixBoxType: map['mix_box_type'],
|
||||
mixCartons: _mixCartons,
|
||||
senderID: map['sender_id'],
|
||||
senderFCSID: map['sender_fcs_id'],
|
||||
senderName: map['sender_name'],
|
||||
mixCartonIDs: List<String>.from(map['mix_carton_ids'] ?? []),
|
||||
cartonWeight: (map['carton_weight'] ?? 0).toDouble(),
|
||||
photoUrls: _photoUrls,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
||||
List _packages = packages.map((c) => c.toJson()).toList();
|
||||
List _mixCartons = mixCartons.map((c) => c.toJson()).toList();
|
||||
return {
|
||||
'id': id,
|
||||
'fcs_shipment_id': fcsShipmentID,
|
||||
'user_id': userID,
|
||||
'cargo_types': _cargoTypes,
|
||||
'packages': _packages,
|
||||
'length': length,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'delivery_address': deliveryAddress?.toMap(),
|
||||
'carton_type': cartonType,
|
||||
'mix_carton_id': mixCartonID,
|
||||
'mix_box_type': mixBoxType,
|
||||
'mix_cartons': _mixCartons,
|
||||
'sender_id': senderID,
|
||||
'sender_fcs_id': senderFCSID,
|
||||
'sender_name': senderName,
|
||||
"photo_urls": photoUrls
|
||||
};
|
||||
id: docID,
|
||||
arrivedDate: _arrivedDate != null ? _arrivedDate.toDate() : null,
|
||||
length: double.tryParse(map['length'].toString()) ?? 0,
|
||||
width: double.tryParse(map['width'].toString()) ?? 0,
|
||||
height: double.tryParse(map['height'].toString()) ?? 0,
|
||||
cartonType: map['carton_type'],
|
||||
cartonNumber: map['carton_number'],
|
||||
fcsShipmentID: map['fcs_shipment_id'],
|
||||
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||
status: map['status'],
|
||||
packageIDs: List<String>.from(map['package_ids'] ?? []),
|
||||
deliveryAddress: _da,
|
||||
cargoTypes: cargoTypes,
|
||||
surchareItems: surchageItems,
|
||||
senderID: map['sender_user_id'],
|
||||
senderFCSID: map['sender_fcs_id'],
|
||||
senderName: map['sender_user_name'],
|
||||
consigneeID: map['consignee_user_id'],
|
||||
consigneeName: map['consignee_user_name'],
|
||||
consigneeFCSID: map['consignee_fcs_id'],
|
||||
cartonIDs: List<String>.from(map['carton_ids'] ?? []),
|
||||
cartonWeight: (map['carton_weight'] ?? 0).toDouble(),
|
||||
photoUrls: _photoUrls,
|
||||
billTo: map['bill_to'] ?? '',
|
||||
lastMile: map['last_mile'] ?? "");
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user