update carton from packages

This commit is contained in:
2021-01-08 17:13:51 +06:30
parent f0662ff1d0
commit 32b8c5ae93
17 changed files with 321 additions and 371 deletions

View File

@@ -5,23 +5,13 @@ class CargoType {
double weight;
bool isChecked;
int qty;
bool isCutomDuty = false;
bool isCutomDuty;
double customDutyFee;
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
double calRate;
double calWeight;
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
return CargoType(
id: id,
name: map['name'],
rate: map['rate']?.toDouble() ?? 0,
weight: map['weight']?.toDouble() ?? 0,
calWeight: map['cal_weight']?.toDouble() ?? 0,
calRate: map['cal_rate']?.toDouble() ?? 0,
);
}
CargoType(
{this.id,
this.name,
@@ -31,7 +21,21 @@ class CargoType {
this.calRate,
this.isChecked = false,
this.qty = 0,
this.isCutomDuty = false});
this.isCutomDuty,
this.customDutyFee});
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
return CargoType(
id: id,
name: map['name'],
rate: map['rate']?.toDouble() ?? 0,
weight: map['weight']?.toDouble() ?? 0,
calWeight: map['cal_weight']?.toDouble() ?? 0,
calRate: map['cal_rate']?.toDouble() ?? 0,
isCutomDuty: map['custom_duty'] ?? false,
customDutyFee: (map['custom_duty_fee'] ?? 0).toDouble(),
qty: (map['qty'] ?? 0).toInt());
}
Map<String, dynamic> toMap() {
return {
@@ -41,6 +45,9 @@ class CargoType {
'weight': weight,
'cal_weight': calWeight,
'cal_rate': calRate,
'custom_duty': isCutomDuty,
'custom_duty_fee': customDutyFee,
'qty': qty
};
}
@@ -62,4 +69,10 @@ class CargoType {
bool isChangedForEdit(CargoType cargoType) {
return cargoType.name != this.name || cargoType.rate != this.rate;
}
bool isChangedForEditCustomDuty(CargoType cargoType) {
return cargoType.name != this.name ||
cargoType.customDutyFee != this.customDutyFee ||
cargoType.rate != this.rate;
}
}

View File

@@ -26,6 +26,21 @@ class CartonSize {
);
}
@override
bool operator ==(other) {
if (identical(this, other)) {
return true;
}
return other.id == this.id;
}
@override
int get hashCode {
int result = 17;
result = 37 * result + id.hashCode;
return result;
}
bool isChangedForEdit(CartonSize cartonSize) {
return cartonSize.name != this.name ||
cartonSize.length != this.length ||

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/entities/discount_by_weight.dart';
import 'cargo_type.dart';
@@ -12,7 +12,7 @@ class Rate {
double diffWeightRate;
List<CargoType> cargoTypes;
List<CustomDuty> customDuties;
List<CargoType> customDuties;
List<DiscountByWeight> discountByWeights;
DiscountByWeight getDiscountByWeight(double weight) {