This commit is contained in:
tzw
2021-09-13 09:57:02 +06:30
8 changed files with 37 additions and 24 deletions

View File

@@ -109,7 +109,6 @@ 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;

View File

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