update carton and cargo type

This commit is contained in:
tzw
2025-03-12 17:49:27 +06:30
parent 05e912ea68
commit e208734dfa
32 changed files with 1141 additions and 462 deletions

View File

@@ -11,6 +11,7 @@ class CargoType {
double calWeight;
int displayIndex;
bool isDefault;
bool isMixCargo;
double get calAmount => calRate * calWeight;
@@ -26,7 +27,8 @@ class CargoType {
this.isCutomDuty = false,
this.customDutyFee = 0,
this.displayIndex = 0,
this.isDefault = false});
this.isDefault = false,
this.isMixCargo = false});
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
return CargoType(
@@ -39,7 +41,8 @@ class CargoType {
isCutomDuty: map['custom_duty'] ?? false,
customDutyFee: (map['custom_duty_fee'] ?? 0).toDouble(),
displayIndex: map['display_index'] ?? 0,
isDefault: map['is_defalut'] ?? false);
isDefault: map['is_defalut'] ?? false,
isMixCargo: map['is_mix_cargo'] ?? false);
}
factory CargoType.fromMapForCargo(Map<String, dynamic> map, String id) {
@@ -62,18 +65,19 @@ class CargoType {
"id": id,
'name': name,
'rate': rate,
'weight': weight,
'cal_weight': calWeight,
'cal_rate': calRate,
'custom_duty': isCutomDuty,
'custom_duty_fee': customDutyFee,
'qty': qty,
// 'weight': weight,
// 'cal_weight': calWeight,
// 'cal_rate': calRate,
// 'custom_duty': isCutomDuty,
// 'custom_duty_fee': customDutyFee,
// 'qty': qty,
'is_defalut': isDefault,
'display_index': displayIndex
'display_index': displayIndex,
'is_mix_cargo': isMixCargo
};
}
Map<String, dynamic> toMapForCargo() {
Map<String, dynamic> toMapForCarton() {
return {"id": id, 'weight': weight};
}
@@ -82,7 +86,7 @@ class CargoType {
}
CargoType clone() {
return CargoType.fromMap(toMap(), this.id!);
return CargoType.fromMap(toMap(), id!);
}
@override
@@ -97,12 +101,16 @@ class CargoType {
}
bool isChangedForEdit(CargoType cargoType) {
return cargoType.name != this.name || cargoType.rate != this.rate;
return cargoType.name != name ||
cargoType.rate != rate ||
cargoType.displayIndex != displayIndex ||
cargoType.isDefault != isDefault ||
cargoType.isMixCargo != isMixCargo;
}
bool isChangedForEditCustomDuty(CargoType cargoType) {
return cargoType.name != this.name ||
cargoType.customDutyFee != this.customDutyFee ||
cargoType.rate != this.rate;
return cargoType.name != name ||
cargoType.customDutyFee != customDutyFee ||
cargoType.rate != rate;
}
}

View File

@@ -166,7 +166,7 @@ class Carton {
Map<String, dynamic> toMap() {
var _types = cargoTypes.where((t) => t.weight != 0).toList();
var _cargoTypes = _types.map((c) => c.toMapForCargo()).toList();
var _cargoTypes = _types.map((c) => c.toMapForCarton()).toList();
var _packagesIds = packages.map((c) => c.id).toList();

View File

@@ -24,3 +24,12 @@ List<LocalPopupMenu> shipFiteringMenu = <LocalPopupMenu>[
LocalPopupMenu(id: 7, text: "Delivered"),
LocalPopupMenu(id: 6, text: "Canceled"),
];
List<LocalPopupMenu> packageFiteringMenu = <LocalPopupMenu>[
LocalPopupMenu(id: 0, text: "All"),
LocalPopupMenu(id: 1, text: "Received"),
LocalPopupMenu(id: 2, text: "Processed"),
LocalPopupMenu(id: 3, text: "Packed"),
LocalPopupMenu(id: 4, text: "Shipped"),
LocalPopupMenu(id: 5, text: "Delivered"),
];