add fcs shipment apis

This commit is contained in:
Sai Naw Wun
2020-10-08 03:32:52 +06:30
parent ad1999f5c9
commit 6105b45cb8
23 changed files with 442 additions and 531 deletions

View File

@@ -1,6 +1,9 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import '../constants.dart';
class FcsShipment {
String id;
DateTime shipDate;
String shipmentNumber;
DateTime cutoffDate;
String shipType;
@@ -10,25 +13,41 @@ class FcsShipment {
String port;
String destination;
String status;
String remark;
FcsShipment(
{this.id,
this.shipDate,
this.shipmentNumber,
this.cutoffDate,
this.shipType,
this.status,
this.arrivalDate,
this.departureDate,
this.consignee,
this.port,
this.destination,
this.remark});
FcsShipment({
this.id,
this.shipmentNumber,
this.cutoffDate,
this.shipType,
this.status,
this.arrivalDate,
this.departureDate,
this.consignee,
this.port,
this.destination,
});
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'],
);
}
Map<String, dynamic> toMap() {
return {
"id": id,
'shipment_date': shipDate?.toUtc()?.toIso8601String(),
'shipment_number': shipmentNumber,
'cutoff_date': cutoffDate?.toUtc()?.toIso8601String(),
'shipment_type': shipType,
@@ -38,7 +57,10 @@ class FcsShipment {
'port': port,
'destination': destination,
'status': status,
'remark': remark,
};
}
bool isConfirmed() {
return status == fcs_shipment_confirmed_status;
}
}