fix
This commit is contained in:
@@ -69,6 +69,7 @@ const privilege_delivery = "deli";
|
||||
const privilege_invoice = "inv";
|
||||
const privilege_processing = "pr";
|
||||
const privilege_receiving = "rc";
|
||||
const privilege_pickup = "pku";
|
||||
|
||||
// Pickup types
|
||||
const shipment_local_pickup = "Local pickup";
|
||||
|
||||
@@ -64,9 +64,8 @@ class Carton {
|
||||
// String get packageNumber =>
|
||||
// shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
|
||||
|
||||
double get actualWeight => cargoTypes == null
|
||||
? 0
|
||||
: cargoTypes.fold(0, (p, e) => e.weight + p);
|
||||
double get actualWeight =>
|
||||
cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
|
||||
|
||||
int getShipmentWeight(double volumetricRatio) {
|
||||
if (length == null ||
|
||||
@@ -110,13 +109,12 @@ class Carton {
|
||||
double wd = sw - aw;
|
||||
wd = wd - rate.diffDiscountWeight;
|
||||
double wdAmount = wd > 0 ? wd * rate.diffWeightRate : 0;
|
||||
|
||||
DiscountByWeight discountByWeight = rate.getDiscountByWeight(aw);
|
||||
|
||||
double total = 0;
|
||||
cargoTypes.forEach((e) {
|
||||
double r = e.rate -
|
||||
(discountByWeight != null ? (discountByWeight.discount) : 0);
|
||||
double r =
|
||||
e.rate - (discountByWeight != null ? (discountByWeight.discount) : 0);
|
||||
double amount = e.weight * r;
|
||||
total += amount;
|
||||
});
|
||||
@@ -194,7 +192,8 @@ class Carton {
|
||||
}
|
||||
|
||||
factory Carton.fromMap(Map<String, dynamic> map, String docID) {
|
||||
var _arrivedDate = (map['arrived_date'] as Timestamp);
|
||||
var _arrivedDate =
|
||||
map['arrived_date'] == null ? null : (map['arrived_date'] as Timestamp);
|
||||
var da = map['delivery_address'];
|
||||
var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
|
||||
var cargoTypesMaps =
|
||||
|
||||
@@ -16,10 +16,12 @@ class Rate {
|
||||
|
||||
DiscountByWeight getDiscountByWeight(double weight) {
|
||||
discountByWeights.sort((d1, d2) => d2.weight.compareTo(d1.weight));
|
||||
return discountByWeights.firstWhere((e) => e.weight < weight);
|
||||
return discountByWeights.firstWhere((e) => e.weight < weight,
|
||||
orElse: () => DiscountByWeight());
|
||||
}
|
||||
|
||||
CargoType get defaultCargoType => cargoTypes.firstWhere((e) => e.name == "General");
|
||||
CargoType get defaultCargoType =>
|
||||
cargoTypes.firstWhere((e) => e.name == "General");
|
||||
|
||||
Rate(
|
||||
{this.deliveryFee = 0,
|
||||
|
||||
@@ -43,6 +43,8 @@ class Privilege {
|
||||
iconData = FontAwesome.dropbox;
|
||||
} else if (this.id == privilege_receiving) {
|
||||
iconData = MaterialCommunityIcons.inbox_arrow_down;
|
||||
} else if (this.id == privilege_pickup) {
|
||||
iconData = FontAwesome.dropbox;
|
||||
} else {
|
||||
iconData = MaterialCommunityIcons.account_question;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user