update cargo type form from rate, update carton info and form
This commit is contained in:
@@ -9,6 +9,8 @@ class CargoType {
|
||||
double customDutyFee;
|
||||
double calRate;
|
||||
double calWeight;
|
||||
int displayIndex;
|
||||
bool isDefault;
|
||||
|
||||
double get calAmount => calRate * calWeight;
|
||||
|
||||
@@ -22,7 +24,9 @@ class CargoType {
|
||||
this.isChecked = false,
|
||||
this.qty = 0,
|
||||
this.isCutomDuty = false,
|
||||
this.customDutyFee = 0});
|
||||
this.customDutyFee = 0,
|
||||
this.displayIndex = 0,
|
||||
this.isDefault = false});
|
||||
|
||||
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
|
||||
return CargoType(
|
||||
@@ -33,8 +37,21 @@ class CargoType {
|
||||
calWeight: map['cal_weight']?.toDouble() ?? 0,
|
||||
calRate: map['cal_rate']?.toDouble() ?? 0,
|
||||
isCutomDuty: map['custom_duty'] ?? false,
|
||||
customDutyFee: (map['custom_duty_fee'] ?? 0).toDouble());
|
||||
//qty: (map['qty'] ?? 0).toInt());
|
||||
customDutyFee: (map['custom_duty_fee'] ?? 0).toDouble(),
|
||||
displayIndex: map['display_index'] ?? 0,
|
||||
isDefault: map['is_defalut'] ?? false);
|
||||
}
|
||||
|
||||
factory CargoType.fromMapForCargo(Map<String, dynamic> map, String id) {
|
||||
return CargoType(
|
||||
id: id, name: map['name'], weight: map['weight']?.toDouble() ?? 0);
|
||||
}
|
||||
|
||||
factory CargoType.fromMapForsurcharge(Map<String, dynamic> map, String id) {
|
||||
return CargoType(
|
||||
id: id,
|
||||
name: map['name'],
|
||||
qty: map['qty'] == null ? 0 : int.tryParse(map['qty'].toString()) ?? 0);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
@@ -47,10 +64,20 @@ class CargoType {
|
||||
'cal_rate': calRate,
|
||||
'custom_duty': isCutomDuty,
|
||||
'custom_duty_fee': customDutyFee,
|
||||
'qty': qty
|
||||
'qty': qty,
|
||||
'is_defalut': isDefault,
|
||||
'display_index': displayIndex
|
||||
};
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMapForCargo() {
|
||||
return {"id": id, 'weight': weight};
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMapForSurcharge() {
|
||||
return {"id": id, 'qty': qty};
|
||||
}
|
||||
|
||||
CargoType clone() {
|
||||
return CargoType.fromMap(toMap(), this.id!);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,13 +4,16 @@ class FcsShipment {
|
||||
String? id;
|
||||
String? shipmentNumber;
|
||||
DateTime? cutoffDate;
|
||||
DateTime? etaDate;
|
||||
String? shipmentTypeId;
|
||||
String? shipTypeName;
|
||||
DateTime? arrivalDate;
|
||||
String? shipmentTypeName;
|
||||
DateTime? departureDate;
|
||||
String? consignee;
|
||||
String? port;
|
||||
String? destination;
|
||||
String? consigneeId;
|
||||
String? consigneeName;
|
||||
String? loadingPortId;
|
||||
String? loadingPortName;
|
||||
String? destinationPortId;
|
||||
String? destinationPortName;
|
||||
String? status;
|
||||
String? reportName;
|
||||
|
||||
@@ -19,13 +22,16 @@ class FcsShipment {
|
||||
this.shipmentNumber,
|
||||
this.cutoffDate,
|
||||
this.shipmentTypeId,
|
||||
this.shipTypeName,
|
||||
this.shipmentTypeName,
|
||||
this.status,
|
||||
this.arrivalDate,
|
||||
this.etaDate,
|
||||
this.departureDate,
|
||||
this.consignee,
|
||||
this.port,
|
||||
this.destination,
|
||||
this.consigneeId,
|
||||
this.consigneeName,
|
||||
this.loadingPortId,
|
||||
this.loadingPortName,
|
||||
this.destinationPortId,
|
||||
this.destinationPortName,
|
||||
this.reportName,
|
||||
});
|
||||
|
||||
@@ -33,45 +39,45 @@ class FcsShipment {
|
||||
var _cutoffDate =
|
||||
map['cutoff_date'] == null ? null : (map['cutoff_date'] as Timestamp);
|
||||
var _arrivalDate =
|
||||
map['arrival_date'] == null ? null : (map['arrival_date'] as Timestamp);
|
||||
map['eta_date'] == null ? null : (map['eta_date'] as Timestamp);
|
||||
|
||||
return FcsShipment(
|
||||
id: docID,
|
||||
cutoffDate: _cutoffDate != null ? _cutoffDate.toDate() : null,
|
||||
arrivalDate: _arrivalDate != null ? _arrivalDate.toDate() : null,
|
||||
shipmentNumber: map['shipment_number'],
|
||||
shipTypeName: map['shipment_type_name'],
|
||||
shipmentTypeId: map['shipment_type_id'] ?? "",
|
||||
status: map['status'],
|
||||
consignee: map['consignee'],
|
||||
port: map['port'],
|
||||
destination: map['destination'],
|
||||
);
|
||||
id: docID,
|
||||
cutoffDate: _cutoffDate != null ? _cutoffDate.toDate() : null,
|
||||
etaDate: _arrivalDate != null ? _arrivalDate.toDate() : null,
|
||||
shipmentNumber: map['shipment_number'],
|
||||
shipmentTypeId: map['shipment_type_id'] ?? "",
|
||||
shipmentTypeName: map['shipment_type_name'],
|
||||
status: map['status'],
|
||||
consigneeId: map['shipment_consignee_id'],
|
||||
consigneeName: map['shipment_consignee_name'],
|
||||
loadingPortId: map['loading_port_id'],
|
||||
loadingPortName: map['loading_port_name'],
|
||||
destinationPortId: map['destination_port_id'],
|
||||
destinationPortName: map['destination_port_name']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'shipment_number': shipmentNumber,
|
||||
'shipment_type_id': shipmentTypeId,
|
||||
'cutoff_date': cutoffDate?.toUtc().toIso8601String(),
|
||||
'arrival_date': arrivalDate?.toUtc().toIso8601String(),
|
||||
'consignee': consignee,
|
||||
'port': port,
|
||||
'destination': destination,
|
||||
// 'status': status,
|
||||
// 'report_name': reportName,
|
||||
'eta_date': etaDate?.toUtc().toIso8601String(),
|
||||
'shipment_type_id': shipmentTypeId,
|
||||
'shipment_consignee_id': consigneeId,
|
||||
'loading_port_id': loadingPortId,
|
||||
'destination_port_id': destinationPortId
|
||||
};
|
||||
}
|
||||
|
||||
bool isChangedForEdit(FcsShipment fcsShipment) {
|
||||
return fcsShipment.shipmentNumber != this.shipmentNumber ||
|
||||
fcsShipment.cutoffDate != this.cutoffDate ||
|
||||
fcsShipment.arrivalDate != this.arrivalDate ||
|
||||
fcsShipment.etaDate != this.etaDate ||
|
||||
fcsShipment.shipmentTypeId != this.shipmentTypeId ||
|
||||
fcsShipment.consignee != this.consignee ||
|
||||
fcsShipment.port != this.port ||
|
||||
fcsShipment.destination != this.destination;
|
||||
fcsShipment.consigneeId != this.consigneeId ||
|
||||
fcsShipment.loadingPortId != this.loadingPortId ||
|
||||
fcsShipment.destinationPortId != this.destinationPortId;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
17
lib/domain/entities/shipment_consignee.dart
Normal file
17
lib/domain/entities/shipment_consignee.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class ShipmentConsignee {
|
||||
String id;
|
||||
String name;
|
||||
|
||||
ShipmentConsignee({required this.id, required this.name});
|
||||
|
||||
factory ShipmentConsignee.fromMap(Map<String, dynamic> map, String id) {
|
||||
return ShipmentConsignee(id: id, name: map['name'] ?? "");
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
other is ShipmentConsignee && other.id == id;
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
}
|
||||
17
lib/domain/entities/shipment_port.dart
Normal file
17
lib/domain/entities/shipment_port.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class ShipmentPort {
|
||||
String id;
|
||||
String name;
|
||||
|
||||
ShipmentPort({required this.id, required this.name});
|
||||
|
||||
factory ShipmentPort.fromMap(Map<String, dynamic> map, String id) {
|
||||
return ShipmentPort(id: id, name: map['name'] ?? "");
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
other is ShipmentPort && other.id == id;
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
}
|
||||
@@ -7,4 +7,10 @@ class ShipmentType {
|
||||
factory ShipmentType.fromMap(Map<String, dynamic> map, String id) {
|
||||
return ShipmentType(id: id, name: map['name'] ?? "");
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => other is ShipmentType && other.id == id;
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user