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

80 lines
2.2 KiB
Dart
Raw Normal View History

2020-10-08 03:32:52 +06:30
import 'package:cloud_firestore/cloud_firestore.dart';
import '../constants.dart';
2020-10-07 14:42:07 +06:30
class FcsShipment {
2020-10-07 17:22:01 +06:30
String id;
2020-09-15 07:13:41 +06:30
String shipmentNumber;
DateTime cutoffDate;
String shipType;
DateTime arrivalDate;
DateTime departureDate;
String consignee;
String port;
String destination;
String status;
2020-10-28 05:11:06 +06:30
String reportName;
2020-10-08 03:32:52 +06:30
FcsShipment({
this.id,
this.shipmentNumber,
this.cutoffDate,
this.shipType,
this.status,
this.arrivalDate,
this.departureDate,
this.consignee,
this.port,
this.destination,
2020-10-28 05:11:06 +06:30
this.reportName,
2020-10-08 03:32:52 +06:30
});
factory FcsShipment.fromMap(Map<String, dynamic> map, String docID) {
var _cutoffDate = (map['cutoff_date'] as Timestamp);
var _arrivalDate = (map['arrival_date'] as Timestamp);
var _departureDate = (map['departure_date'] as Timestamp);
return FcsShipment(
id: docID,
cutoffDate: _cutoffDate != null ? _cutoffDate.toDate() : null,
arrivalDate: _arrivalDate != null ? _arrivalDate.toDate() : null,
departureDate: _departureDate != null ? _departureDate.toDate() : null,
shipmentNumber: map['shipment_number'],
shipType: map['shipment_type'],
status: map['status'],
consignee: map['consignee'],
port: map['port'],
destination: map['destination'],
);
}
2020-10-07 17:22:01 +06:30
Map<String, dynamic> toMap() {
return {
"id": id,
'shipment_number': shipmentNumber,
'cutoff_date': cutoffDate?.toUtc()?.toIso8601String(),
'shipment_type': shipType,
'arrival_date': arrivalDate?.toUtc()?.toIso8601String(),
'departure_date': departureDate?.toUtc()?.toIso8601String(),
'consignee': consignee,
'port': port,
'destination': destination,
'status': status,
2020-10-28 05:11:06 +06:30
'report_name': reportName,
2020-10-07 17:22:01 +06:30
};
}
2020-10-08 03:32:52 +06:30
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.shipType != this.shipType ||
fcsShipment.consignee != this.consignee ||
fcsShipment.port != this.port ||
fcsShipment.destination != this.destination;
}
2020-09-15 07:13:41 +06:30
}