cleanup code
This commit is contained in:
@@ -59,23 +59,17 @@ class Carton {
|
||||
List<Carton> mixCartons;
|
||||
List<String> mixCartonIDs;
|
||||
|
||||
int get amount => rate != null && weight != null ? (rate * weight) : 0;
|
||||
int get amount => (rate * weight);
|
||||
|
||||
// String get packageNumber =>
|
||||
// shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
|
||||
|
||||
double get actualWeight =>
|
||||
cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
|
||||
cargoTypes.isEmpty ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
|
||||
|
||||
int getShipmentWeight(double volumetricRatio) {
|
||||
if (length == null ||
|
||||
length <= 0 ||
|
||||
width == null ||
|
||||
width <= 0 ||
|
||||
height == null ||
|
||||
height <= 0 ||
|
||||
volumetricRatio == null ||
|
||||
volumetricRatio <= 0) return 0;
|
||||
if (length <= 0 || width <= 0 || height <= 0 || volumetricRatio <= 0)
|
||||
return 0;
|
||||
|
||||
return ((length * width * height) / volumetricRatio).round();
|
||||
}
|
||||
@@ -113,8 +107,7 @@ class Carton {
|
||||
|
||||
double total = 0;
|
||||
cargoTypes.forEach((e) {
|
||||
double r =
|
||||
e.rate - (discountByWeight != null ? (discountByWeight.discount) : 0);
|
||||
double r = e.rate - (discountByWeight.discount);
|
||||
double amount = e.weight * r;
|
||||
total += amount;
|
||||
});
|
||||
|
||||
@@ -30,9 +30,13 @@ class FcsShipment {
|
||||
});
|
||||
|
||||
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);
|
||||
var _cutoffDate =
|
||||
map['cutoff_date'] == null ? null : (map['cutoff_date'] as Timestamp);
|
||||
var _arrivalDate =
|
||||
map['arrival_date'] == null ? null : (map['arrival_date'] as Timestamp);
|
||||
var _departureDate = map['departure_date'] == null
|
||||
? null
|
||||
: (map['departure_date'] as Timestamp);
|
||||
|
||||
return FcsShipment(
|
||||
id: docID,
|
||||
|
||||
@@ -35,7 +35,7 @@ class Invoice {
|
||||
String? invoiceURL;
|
||||
|
||||
List<CargoType> getCargoTypes(Rate rate) {
|
||||
if (cargoTypes != null) return cargoTypes;
|
||||
if (cargoTypes.isNotEmpty) return cargoTypes;
|
||||
|
||||
List<CargoType> _cargoTypes = [];
|
||||
double totalCalWeight = 0;
|
||||
@@ -59,8 +59,7 @@ class Invoice {
|
||||
rate.getDiscountByWeight(totalCalWeight);
|
||||
|
||||
_cargoTypes.forEach((e) {
|
||||
double r =
|
||||
e.rate - (discountByWeight != null ? discountByWeight.discount : 0);
|
||||
double r = e.rate - discountByWeight.discount;
|
||||
e.calRate = r;
|
||||
});
|
||||
return _cargoTypes;
|
||||
@@ -95,11 +94,11 @@ class Invoice {
|
||||
}
|
||||
|
||||
double getCustomFee() {
|
||||
return customDuties == null ? 0 : customDuties.fold(0, (p, d) => p + d.fee);
|
||||
return customDuties.isEmpty ? 0 : customDuties.fold(0, (p, d) => p + d.fee);
|
||||
}
|
||||
|
||||
double getDeliveryFee() {
|
||||
return deliveryFee == null ? 0 : deliveryFee;
|
||||
return deliveryFee;
|
||||
}
|
||||
|
||||
double getDiscount() => discount == null ? 0 : discount!.amount;
|
||||
|
||||
@@ -38,7 +38,7 @@ class Package {
|
||||
//for packages in processing
|
||||
List<File?> photoFiles;
|
||||
|
||||
int get amount => rate != null && weight != null ? rate * weight : 0;
|
||||
int get amount => rate * weight;
|
||||
|
||||
double get price => rate.toDouble() * weight;
|
||||
|
||||
|
||||
@@ -74,7 +74,8 @@ class Shipment {
|
||||
bool get isReceived => status == shipment_received_status;
|
||||
|
||||
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
||||
var pd = (map['pickup_date'] as Timestamp);
|
||||
var pd =
|
||||
map['pickup_date'] == null ? null : (map['pickup_date'] as Timestamp);
|
||||
var pa = map['pickup_address'];
|
||||
var _pa = pa != null ? DeliveryAddress.fromMap(pa, pa["id"]) : null;
|
||||
return Shipment(
|
||||
|
||||
@@ -41,16 +41,10 @@ class User {
|
||||
}
|
||||
}
|
||||
|
||||
String get getUserUnseenCount => userUnseenCount != null
|
||||
? userUnseenCount > 100
|
||||
? "99+"
|
||||
: userUnseenCount.toString()
|
||||
: "0";
|
||||
String get getFcsUnseenCount => fcsUnseenCount != null
|
||||
? fcsUnseenCount > 100
|
||||
? "99+"
|
||||
: fcsUnseenCount.toString()
|
||||
: "0";
|
||||
String get getUserUnseenCount =>
|
||||
userUnseenCount > 100 ? "99+" : userUnseenCount.toString();
|
||||
String get getFcsUnseenCount =>
|
||||
fcsUnseenCount > 100 ? "99+" : fcsUnseenCount.toString();
|
||||
|
||||
List<String> privileges = [];
|
||||
|
||||
@@ -101,7 +95,8 @@ class User {
|
||||
}
|
||||
|
||||
factory User.fromMap(Map<String, dynamic> map, String docID) {
|
||||
var _date = (map['message_time'] as Timestamp);
|
||||
var _date =
|
||||
map['message_time'] == null ? null : (map['message_time'] as Timestamp);
|
||||
|
||||
List<String> _privileges =
|
||||
map['privileges'] == null ? [] : map['privileges'].cast<String>();
|
||||
@@ -127,7 +122,7 @@ class User {
|
||||
}
|
||||
|
||||
bool isCustomer() {
|
||||
return privileges == null || privileges.length == 0;
|
||||
return privileges.length == 0;
|
||||
}
|
||||
|
||||
bool hasSysAdmin() {
|
||||
@@ -183,7 +178,7 @@ class User {
|
||||
}
|
||||
|
||||
bool _has(String privilege) {
|
||||
return (privileges != null ? privileges.contains(privilege) : false);
|
||||
return (privileges.contains(privilege));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
class ServerException {
|
||||
@override
|
||||
List<Object>? get props => null;
|
||||
|
||||
call() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
bool? get stringify => null;
|
||||
}
|
||||
Reference in New Issue
Block a user