add rate service

This commit is contained in:
Sai Naw Wun
2020-10-15 03:06:13 +06:30
parent 7b88658893
commit 47c07a6c88
45 changed files with 870 additions and 496 deletions

View File

@@ -1,31 +1,45 @@
import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/entities/discount_by_weight.dart';
import 'cargo_type.dart';
class Rate {
String id;
String name;
String description;
String fromTime;
String toTime;
int price;
double deliveryFee;
double freeDeliveryWeight;
double volumetricRatio;
Rate(
{this.id,
this.name,
this.description,
this.fromTime,
this.toTime,
this.price,});
List<CargoType> cargoTypes;
List<CustomDuty> customDuties;
List<DiscountByWeight> discountByWeights;
factory Rate.fromMap(Map<String, dynamic> map, String id) {
CargoType get defaultCargoType => cargoTypes == null
? null
: cargoTypes.firstWhere((e) => e.name == "General");
Rate({
this.deliveryFee,
this.freeDeliveryWeight,
this.volumetricRatio,
});
factory Rate.fromMap(Map<String, dynamic> map) {
return Rate(
id: id,
name: map['name'],
description: map['description'],
fromTime: map['from_time'],
toTime: map['to_time'],
price: map['price'],);
deliveryFee: (map['delivery_fee'] ?? 0).toDouble(),
freeDeliveryWeight: (map['free_delivery_weight'] ?? 0).toDouble(),
volumetricRatio: (map['volumetric_ratio'] ?? 0).toDouble(),
);
}
Map<String, dynamic> toMap() {
return {
"delivery_fee": deliveryFee,
'free_delivery_weight': freeDeliveryWeight,
'volumetric_ratio': volumetricRatio,
};
}
@override
String toString() {
return 'Rate{id:$id, name:$name,description:$description,fromTime:$fromTime,toTime:$toTime}';
return 'Rate{deliveryFee:$deliveryFee,freeDeliveryWeight:$freeDeliveryWeight,volumetricRatio:$volumetricRatio}';
}
}