2020-10-08 03:32:52 +06:30
|
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
|
|
2020-10-07 14:42:07 +06:30
|
|
|
class FcsShipment {
|
2021-09-10 14:27:38 +06:30
|
|
|
String? id;
|
|
|
|
|
String? shipmentNumber;
|
|
|
|
|
DateTime? cutoffDate;
|
2024-09-25 21:49:09 +06:30
|
|
|
DateTime? etaDate;
|
2024-03-01 17:27:56 +06:30
|
|
|
String? shipmentTypeId;
|
2024-09-25 21:49:09 +06:30
|
|
|
String? shipmentTypeName;
|
2021-09-10 14:27:38 +06:30
|
|
|
DateTime? departureDate;
|
2024-09-25 21:49:09 +06:30
|
|
|
String? consigneeId;
|
|
|
|
|
String? consigneeName;
|
|
|
|
|
String? loadingPortId;
|
|
|
|
|
String? loadingPortName;
|
|
|
|
|
String? destinationPortId;
|
|
|
|
|
String? destinationPortName;
|
2021-09-10 14:27:38 +06:30
|
|
|
String? status;
|
|
|
|
|
String? reportName;
|
2025-02-17 20:13:30 +06:30
|
|
|
int packageCount;
|
|
|
|
|
int cartonCount;
|
2021-09-10 14:27:38 +06:30
|
|
|
|
2025-02-17 20:13:30 +06:30
|
|
|
FcsShipment(
|
|
|
|
|
{this.id,
|
|
|
|
|
this.shipmentNumber,
|
|
|
|
|
this.cutoffDate,
|
|
|
|
|
this.shipmentTypeId,
|
|
|
|
|
this.shipmentTypeName,
|
|
|
|
|
this.status,
|
|
|
|
|
this.etaDate,
|
|
|
|
|
this.departureDate,
|
|
|
|
|
this.consigneeId,
|
|
|
|
|
this.consigneeName,
|
|
|
|
|
this.loadingPortId,
|
|
|
|
|
this.loadingPortName,
|
|
|
|
|
this.destinationPortId,
|
|
|
|
|
this.destinationPortName,
|
|
|
|
|
this.reportName,
|
|
|
|
|
this.packageCount = 0,
|
|
|
|
|
this.cartonCount = 0});
|
2020-10-08 03:32:52 +06:30
|
|
|
|
|
|
|
|
factory FcsShipment.fromMap(Map<String, dynamic> map, String docID) {
|
2025-02-17 20:13:30 +06:30
|
|
|
var cutoffDate =
|
2024-01-23 16:28:08 +06:30
|
|
|
map['cutoff_date'] == null ? null : (map['cutoff_date'] as Timestamp);
|
2025-02-17 20:13:30 +06:30
|
|
|
var arrivalDate =
|
2024-09-25 21:49:09 +06:30
|
|
|
map['eta_date'] == null ? null : (map['eta_date'] as Timestamp);
|
2020-10-08 03:32:52 +06:30
|
|
|
|
|
|
|
|
return FcsShipment(
|
2024-09-25 21:49:09 +06:30
|
|
|
id: docID,
|
2025-02-17 20:13:30 +06:30
|
|
|
cutoffDate: cutoffDate?.toDate(),
|
|
|
|
|
etaDate: arrivalDate?.toDate(),
|
2024-09-25 21:49:09 +06:30
|
|
|
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'],
|
2025-02-17 20:13:30 +06:30
|
|
|
destinationPortName: map['destination_port_name'],
|
|
|
|
|
packageCount: map['package_count'] ?? 0,
|
|
|
|
|
cartonCount: map['carton_count'] ?? 0);
|
2020-10-08 03:32:52 +06:30
|
|
|
}
|
2020-10-07 17:22:01 +06:30
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
|
return {
|
2024-03-02 18:15:05 +06:30
|
|
|
'id': id,
|
2020-10-07 17:22:01 +06:30
|
|
|
'shipment_number': shipmentNumber,
|
2021-09-10 14:27:38 +06:30
|
|
|
'cutoff_date': cutoffDate?.toUtc().toIso8601String(),
|
2024-09-25 21:49:09 +06:30
|
|
|
'eta_date': etaDate?.toUtc().toIso8601String(),
|
|
|
|
|
'shipment_type_id': shipmentTypeId,
|
|
|
|
|
'shipment_consignee_id': consigneeId,
|
|
|
|
|
'loading_port_id': loadingPortId,
|
|
|
|
|
'destination_port_id': destinationPortId
|
2020-10-07 17:22:01 +06:30
|
|
|
};
|
|
|
|
|
}
|
2020-10-08 03:32:52 +06:30
|
|
|
|
2020-12-08 20:24:15 +06:30
|
|
|
bool isChangedForEdit(FcsShipment fcsShipment) {
|
2025-02-17 20:13:30 +06:30
|
|
|
return fcsShipment.shipmentNumber != shipmentNumber ||
|
|
|
|
|
fcsShipment.cutoffDate != cutoffDate ||
|
|
|
|
|
fcsShipment.etaDate != etaDate ||
|
|
|
|
|
fcsShipment.shipmentTypeId != shipmentTypeId ||
|
|
|
|
|
fcsShipment.consigneeId != consigneeId ||
|
|
|
|
|
fcsShipment.loadingPortId != loadingPortId ||
|
|
|
|
|
fcsShipment.destinationPortId != destinationPortId;
|
2020-12-08 20:24:15 +06:30
|
|
|
}
|
2024-02-02 18:00:51 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool operator ==(Object other) => other is FcsShipment && other.id == id;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
int get hashCode => id.hashCode;
|
2020-09-15 07:13:41 +06:30
|
|
|
}
|