update carton form ,info and filter
This commit is contained in:
@@ -92,6 +92,8 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
_mixCartons = await context
|
||||
.read<CartonModel>()
|
||||
.getCartonsByIds(_carton.cartonIDs);
|
||||
_cargoTypes.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
_surchareItems.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
}
|
||||
|
||||
totalWeight =
|
||||
@@ -156,13 +158,17 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
);
|
||||
|
||||
final lastMileBox = DisplayText(
|
||||
text: _carton.lastMile == delivery_caton ? 'Delivery' : 'Pick-up',
|
||||
text: _carton.lastMile == delivery_caton
|
||||
? 'Delivery'
|
||||
: _carton.lastMile == pickup_carton
|
||||
? 'Pick-up'
|
||||
: '',
|
||||
labelTextKey: "box.delivery_type",
|
||||
);
|
||||
|
||||
final cartonSizeBox = DisplayText(
|
||||
subText: Text("${boxDimension ?? 'No defined size'}"),
|
||||
labelTextKey: "box.carton_size",
|
||||
labelTextKey: "box.select_carton_size",
|
||||
);
|
||||
|
||||
final senderBox = DisplayText(
|
||||
@@ -192,6 +198,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
|
||||
final userRowBox = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
@@ -228,7 +235,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
);
|
||||
|
||||
final cargosBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -237,10 +244,13 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
color: Colors.black54,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 50),
|
||||
child: Text("${removeTrailingZeros(totalWeight)} lb",
|
||||
style: TextStyle(color: Colors.black54, fontSize: 15)))
|
||||
_cargoTypes.isNotEmpty
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(right: 50),
|
||||
child: Text("${removeTrailingZeros(totalWeight)} lb",
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(color: Colors.black54, fontSize: 15)))
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
Container(
|
||||
@@ -262,68 +272,52 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
TextStyle(color: Colors.black, fontSize: 15),
|
||||
),
|
||||
Text("${removeTrailingZeros(e.weight)} lb",
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 15))
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
final surchargeItemBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
LocalText(context, 'box.surcharge.item',
|
||||
color: Colors.black54,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 50),
|
||||
child: Text("${removeTrailingZeros(totalSurchargeCount)} pcs",
|
||||
style: TextStyle(color: Colors.black54, fontSize: 15)))
|
||||
],
|
||||
),
|
||||
Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 60),
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _surchareItems.map((e) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
e.name ?? "",
|
||||
|
||||
final surchargeItemBox =
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 50),
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _surchareItems.map((e) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
e.name ?? "",
|
||||
style: TextStyle(color: Colors.black, fontSize: 15),
|
||||
),
|
||||
Text("${removeTrailingZeros((e.qty).toDouble())} pc",
|
||||
textAlign: TextAlign.end,
|
||||
style:
|
||||
TextStyle(color: Colors.black, fontSize: 15),
|
||||
),
|
||||
Text(
|
||||
"${removeTrailingZeros((e.qty).toDouble())} pc",
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 15))
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
TextStyle(color: Colors.black, fontSize: 15))
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
),
|
||||
]);
|
||||
|
||||
final img = MultiImageFile(
|
||||
enabled: false,
|
||||
@@ -447,10 +441,13 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
],
|
||||
),
|
||||
),
|
||||
_cargoTypes.isEmpty ? const SizedBox() : cargosBox,
|
||||
_surchareItems.isEmpty ? const SizedBox() : surchargeItemBox,
|
||||
cargosBox,
|
||||
surchargeItemBox,
|
||||
const SizedBox(height: 10),
|
||||
uploadImageBtn,
|
||||
const SizedBox(height: 30),
|
||||
_carton.photoUrls.isNotEmpty
|
||||
? const SizedBox(height: 10)
|
||||
: const SizedBox(),
|
||||
img,
|
||||
_carton.photoUrls.isNotEmpty
|
||||
? const SizedBox(height: 40)
|
||||
|
||||
@@ -89,15 +89,6 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
_cargoTypes = widget.carton.cargoTypes;
|
||||
_surchareItems = widget.carton.surchareItems;
|
||||
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
.getFcsShipment(widget.carton.fcsShipmentID ?? "");
|
||||
_shipment = s;
|
||||
|
||||
_packages = await context
|
||||
.read<PackageModel>()
|
||||
.getPackagesByIds(widget.carton.packageIDs);
|
||||
|
||||
// check carton size type
|
||||
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
|
||||
|
||||
@@ -120,8 +111,20 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
_cartonSizeType = packageCarton;
|
||||
} else {
|
||||
_cartonSizeType = customCarton;
|
||||
_length = widget.carton.length.toDouble();
|
||||
_width = widget.carton.width.toDouble();
|
||||
_height = widget.carton.height.toDouble();
|
||||
}
|
||||
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
.getFcsShipment(widget.carton.fcsShipmentID ?? "");
|
||||
_shipment = s;
|
||||
|
||||
_packages = await context
|
||||
.read<PackageModel>()
|
||||
.getPackagesByIds(widget.carton.packageIDs);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
@@ -328,7 +331,10 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
}
|
||||
|
||||
var carton = Carton(
|
||||
id: widget.carton.id,
|
||||
cartonType: carton_from_packages,
|
||||
senderID: widget.carton.senderID,
|
||||
consigneeID: widget.carton.consigneeID,
|
||||
billTo: _billToValue,
|
||||
lastMile: _selectedLastMile,
|
||||
fcsShipmentID: _shipment?.id,
|
||||
|
||||
@@ -61,8 +61,6 @@ class CartonSizeWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
// List<String> _deliveryTypes = [delivery_caton, pickup_carton];
|
||||
|
||||
FcsShipment? _shipment;
|
||||
String _cartonSizeType = standardCarton;
|
||||
|
||||
@@ -85,7 +83,6 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
_selectedLastmile = widget.lastMile;
|
||||
_billToValue = widget.billType;
|
||||
_cartonSizeType = widget.cartonSizeType;
|
||||
|
||||
_lengthController.text =
|
||||
widget.length == null ? "0" : removeTrailingZeros(widget.length ?? 0);
|
||||
_widthController.text =
|
||||
@@ -94,8 +91,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
widget.height == null ? "0" : removeTrailingZeros(widget.height ?? 0);
|
||||
|
||||
_getStandardCartonSize();
|
||||
_loadShipment();
|
||||
|
||||
_loadShipment();
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class CartonSubmit extends StatelessWidget {
|
||||
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',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -82,6 +82,9 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
_cartonSizeType = packageCarton;
|
||||
} else {
|
||||
_cartonSizeType = customCarton;
|
||||
_length = widget.carton.length.toDouble();
|
||||
_width = widget.carton.width.toDouble();
|
||||
_height = widget.carton.height.toDouble();
|
||||
}
|
||||
|
||||
var s = await context
|
||||
@@ -269,7 +272,7 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
width: width,
|
||||
height: height,
|
||||
cartons: _cartons);
|
||||
await context.read<CartonModel>().updateCarton(carton);
|
||||
await context.read<CartonModel>().updateMixCarton(carton);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -117,13 +117,15 @@ class CartonModel extends BaseModel {
|
||||
Query pageQuery = FirebaseFirestore.instance.collection(path);
|
||||
|
||||
if (filterByConsingee != null) {
|
||||
col = col.where("user_id", isEqualTo: filterByConsingee!.id);
|
||||
pageQuery = pageQuery.where("user_id", isEqualTo: filterByConsingee!.id);
|
||||
col = col.where("consignee_user_id", isEqualTo: filterByConsingee!.id);
|
||||
pageQuery = pageQuery.where("consignee_user_id",
|
||||
isEqualTo: filterByConsingee!.id);
|
||||
}
|
||||
|
||||
if (filterBySender != null) {
|
||||
col = col.where("sender_id", isEqualTo: filterBySender!.id);
|
||||
pageQuery = pageQuery.where("sender_id", isEqualTo: filterBySender!.id);
|
||||
col = col.where("sender_user_id", isEqualTo: filterBySender!.id);
|
||||
pageQuery =
|
||||
pageQuery.where("sender_user_id", isEqualTo: filterBySender!.id);
|
||||
}
|
||||
|
||||
if (filterByStatus != null) {
|
||||
@@ -208,7 +210,7 @@ class CartonModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<Carton> createMixCarton(Carton carton) {
|
||||
return Services.instance.cartonService.createCarton(carton);
|
||||
return Services.instance.cartonService.createMixCarton(carton);
|
||||
}
|
||||
|
||||
Future<void> updateMixCarton(Carton carton) {
|
||||
|
||||
@@ -91,8 +91,8 @@ class ConsigneeSelectionModel extends BaseModel {
|
||||
Query query = FirebaseFirestore.instance
|
||||
.collection(path)
|
||||
.where("is_sys_admin", isEqualTo: false)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.orderBy("message_time", descending: true);
|
||||
.where("delete_time", isEqualTo: 0)
|
||||
.orderBy("update_time", descending: true);
|
||||
|
||||
if (_lastDocument != null) {
|
||||
query = query.startAfterDocument(_lastDocument!);
|
||||
|
||||
@@ -93,8 +93,8 @@ class SenderSelectionModel extends BaseModel {
|
||||
Query query = FirebaseFirestore.instance
|
||||
.collection(path)
|
||||
.where("is_sys_admin", isEqualTo: false)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.orderBy("message_time", descending: true);
|
||||
.where("delete_time", isEqualTo: 0)
|
||||
.orderBy("update_time", descending: true);
|
||||
|
||||
if (_lastDocument != null) {
|
||||
query = query.startAfterDocument(_lastDocument!);
|
||||
|
||||
Reference in New Issue
Block a user