cleanup code

This commit is contained in:
tzw
2024-01-23 16:28:08 +06:30
parent a1e87cdbf6
commit f3f75a80c6
96 changed files with 232 additions and 439 deletions

View File

@@ -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;