add carton from mix_box & from cargos

This commit is contained in:
Thinzar Win
2021-01-09 19:11:47 +06:30
parent 0bbd568adc
commit 9d2f9a671f
16 changed files with 583 additions and 322 deletions

View File

@@ -12,8 +12,10 @@ class Carton {
String id;
String shipmentID;
String shipmentNumber;
String senderID;
String senderFCSID;
String senderName;
String receiverID;
String receiverFCSID;
String receiverName;
String receiverAddress;
@@ -38,7 +40,6 @@ class Carton {
String mixCartonNumber;
String cartonSizeID;
String cartonSizeName;
String mixBoxType;
int rate;
int weight;
@@ -56,6 +57,10 @@ class Carton {
DeliveryAddress deliveryAddress;
Shipment shipment;
//for mix box
String mixBoxType;
List<Carton> mixCartons;
int get amount => rate != null && weight != null ? rate * weight : 0;
String get packageNumber =>
@@ -126,8 +131,10 @@ class Carton {
{this.id,
this.shipmentID,
this.shipmentNumber,
this.senderID,
this.senderFCSID,
this.senderName,
this.receiverID,
this.receiverFCSID,
this.receiverName,
this.receiverNumber,
@@ -164,13 +171,15 @@ class Carton {
this.deliveryAddress,
this.cartonSizeID,
this.cartonSizeName,
this.mixBoxType});
this.mixBoxType,
this.mixCartons});
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();
return {
"id": id,
'id': id,
'fcs_shipment_id': fcsShipmentID,
'user_id': userID,
'cargo_types': _cargoTypes,
@@ -181,6 +190,14 @@ class Carton {
'delivery_address': deliveryAddress?.toMap(),
'carton_type': cartonType,
'mix_carton_id': mixCartonID,
'mix_box_type': mixBoxType,
'mix_cartons': _mixCartons,
'receiver_id': receiverID,
'receiver_fcs_id': receiverFCSID,
'receiver_name': receiverName,
'sender_id': senderID,
'sender_fcs_id': senderFCSID,
'sender_name': senderName
};
}
@@ -192,30 +209,71 @@ class Carton {
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();
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()),
width: double.tryParse(map['width']?.toString()),
height: double.tryParse(map['height']?.toString()),
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);
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()),
width: double.tryParse(map['width']?.toString()),
height: double.tryParse(map['height']?.toString()),
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,
receiverID: map['receiver_id'],
receiverFCSID: map['receiver_fcs_id'],
receiverName: map['receiver_name'],
senderID: map['sender_id'],
senderFCSID: map['sender_fcs_id'],
senderName: map['sender_name'],
);
}
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,
'receiver_id': receiverID,
'receiver_fcs_id': receiverFCSID,
'receiver_name': receiverName,
'sender_id': senderID,
'sender_fcs_id': senderFCSID,
'sender_name': senderName
};
}
@override