89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
import '../constants.dart';
|
|
|
|
class FcsShipment {
|
|
String? id;
|
|
String? shipmentNumber;
|
|
DateTime? cutoffDate;
|
|
String? shipmentTypeId;
|
|
String? shipTypeName;
|
|
DateTime? arrivalDate;
|
|
DateTime? departureDate;
|
|
String? consignee;
|
|
String? port;
|
|
String? destination;
|
|
String? status;
|
|
String? reportName;
|
|
|
|
FcsShipment({
|
|
this.id,
|
|
this.shipmentNumber,
|
|
this.cutoffDate,
|
|
this.shipmentTypeId,
|
|
this.shipTypeName,
|
|
this.status,
|
|
this.arrivalDate,
|
|
this.departureDate,
|
|
this.consignee,
|
|
this.port,
|
|
this.destination,
|
|
this.reportName,
|
|
});
|
|
|
|
factory FcsShipment.fromMap(Map<String, dynamic> map, String docID) {
|
|
var _cutoffDate =
|
|
map['cutoff_date'] == null ? null : (map['cutoff_date'] as Timestamp);
|
|
var _arrivalDate =
|
|
map['arrival_date'] == null ? null : (map['arrival_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'],
|
|
);
|
|
}
|
|
|
|
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,
|
|
};
|
|
}
|
|
|
|
bool isConfirmed() {
|
|
return status == fcs_shipment_confirmed_status;
|
|
}
|
|
|
|
bool isChangedForEdit(FcsShipment fcsShipment) {
|
|
return fcsShipment.shipmentNumber != this.shipmentNumber ||
|
|
fcsShipment.cutoffDate != this.cutoffDate ||
|
|
fcsShipment.arrivalDate != this.arrivalDate ||
|
|
fcsShipment.shipmentTypeId != this.shipmentTypeId ||
|
|
fcsShipment.consignee != this.consignee ||
|
|
fcsShipment.port != this.port ||
|
|
fcsShipment.destination != this.destination;
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) => other is FcsShipment && other.id == id;
|
|
|
|
@override
|
|
int get hashCode => id.hashCode;
|
|
}
|