Files
fcs/lib/domain/entities/fcs_shipment.dart

101 lines
3.1 KiB
Dart
Raw Normal View History

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;
DateTime? etaDate;
2024-03-01 17:27:56 +06:30
String? shipmentTypeId;
String? shipmentTypeName;
2021-09-10 14:27:38 +06:30
DateTime? departureDate;
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;
DateTime? processingDate;
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,
this.processingDate});
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 =
map['eta_date'] == null ? null : (map['eta_date'] as Timestamp);
2020-10-08 03:32:52 +06:30
var processingDate = map['processing_date'] == null
? null
: (map['processing_date'] as Timestamp);
2020-10-08 03:32:52 +06:30
return FcsShipment(
id: docID,
2025-02-17 20:13:30 +06:30
cutoffDate: cutoffDate?.toDate(),
etaDate: arrivalDate?.toDate(),
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,
processingDate: processingDate?.toDate());
2020-10-08 03:32:52 +06:30
}
2020-10-07 17:22:01 +06:30
Map<String, dynamic> toMap() {
return {
'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(),
'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
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;
}
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
}