update carton form ,info and filter

This commit is contained in:
tzw
2024-10-01 18:15:53 +06:30
parent 02e079c514
commit 41fdc3ef43
13 changed files with 123 additions and 109 deletions

View File

@@ -48,8 +48,8 @@ class MixCartonSubmit extends StatefulWidget {
class _MixCartonSubmitState extends State<MixCartonSubmit> {
final NumberFormat numberFormatter = NumberFormat("#,###");
Map<String?, double> _mapCargosByWeight = {};
Map<String?, double> _mapCargosByCustomDutyFee = {};
Map<String?, double> _mapCargos = {};
Map<String?, double> _mapSurchargeItems = {};
double totalWeight = 0;
@override
@@ -59,30 +59,37 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
}
_init() {
// get cargos by weight
List<CargoType> _cargoTypes = [];
for (var c in widget.cartons) {
_cargoTypes.addAll(c.cargoTypes);
}
// get cargos by weight
Map<String?, List<CargoType>> _cargosByWeight =
groupCargos(_cargoTypes.where((e) => !e.isCutomDuty).toList());
_cargoTypes.sort((a, b) => a.name!.compareTo(b.name!));
Map<String?, List<CargoType>> _cargosByWeight = groupCargos(_cargoTypes);
_cargosByWeight.forEach((key, value) {
double total = value.fold(0, (sum, item) => sum + item.weight);
_mapCargosByWeight[key] = total;
_mapCargos[key] = total;
});
totalWeight =
_mapCargosByWeight.entries.fold(0, (sum, value) => sum + value.value);
totalWeight = _mapCargos.entries.fold(0, (sum, value) => sum + value.value);
// get surcharge items
List<CargoType> _surchargeItems = [];
for (var c in widget.cartons) {
_surchargeItems.addAll(c.surchareItems);
}
_surchargeItems.sort((a, b) => a.name!.compareTo(b.name!));
// get cargos by custom duty fee
Map<String?, List<CargoType>> _cargosByCustomDutyFee =
groupCargos(_cargoTypes.where((e) => e.isCutomDuty).toList());
groupCargos(_surchargeItems);
_cargosByCustomDutyFee.forEach((key, value) {
double total = value.fold(0, (sum, item) => sum + item.qty);
_mapCargosByCustomDutyFee[key] = total;
_mapSurchargeItems[key] = total;
});
if (mounted) {
@@ -116,7 +123,7 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
final cartonSizeBox = Padding(
padding: const EdgeInsets.only(top: 10),
child: SubmitTextWidget(
labelKey: 'box.carton_size',
labelKey: 'box.select_carton_size',
text: boxDimension ?? 'No defined size',
),
);
@@ -195,7 +202,7 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _mapCargosByWeight.entries.map((e) {
children: _mapCargos.entries.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Row(
@@ -216,7 +223,7 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
const SizedBox(height: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _mapCargosByCustomDutyFee.entries.map((e) {
children: _mapSurchargeItems.entries.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Row(