diff --git a/lib/domain/constants.dart b/lib/domain/constants.dart index f7cb5cf..865a62a 100644 --- a/lib/domain/constants.dart +++ b/lib/domain/constants.dart @@ -69,6 +69,7 @@ const privilege_delivery = "deli"; const privilege_invoice = "inv"; const privilege_processing = "pr"; const privilege_receiving = "rc"; +const privilege_pickup = "pku"; // Pickup types const shipment_local_pickup = "Local pickup"; diff --git a/lib/domain/entities/carton.dart b/lib/domain/entities/carton.dart index a9a89b9..c17940e 100644 --- a/lib/domain/entities/carton.dart +++ b/lib/domain/entities/carton.dart @@ -109,7 +109,6 @@ class Carton { double wd = sw - aw; wd = wd - rate.diffDiscountWeight; double wdAmount = wd > 0 ? wd * rate.diffWeightRate : 0; - DiscountByWeight discountByWeight = rate.getDiscountByWeight(aw); double total = 0; diff --git a/lib/domain/entities/rate.dart b/lib/domain/entities/rate.dart index 54442e8..50f0f8c 100644 --- a/lib/domain/entities/rate.dart +++ b/lib/domain/entities/rate.dart @@ -16,10 +16,12 @@ class Rate { DiscountByWeight getDiscountByWeight(double weight) { discountByWeights.sort((d1, d2) => d2.weight.compareTo(d1.weight)); - return discountByWeights.firstWhere((e) => e.weight < weight); + return discountByWeights.firstWhere((e) => e.weight < weight, + orElse: () => DiscountByWeight()); } - CargoType get defaultCargoType => cargoTypes.firstWhere((e) => e.name == "General"); + CargoType get defaultCargoType => + cargoTypes.firstWhere((e) => e.name == "General"); Rate( {this.deliveryFee = 0, diff --git a/lib/domain/vo/privilege.dart b/lib/domain/vo/privilege.dart index 85907a2..1a59a71 100644 --- a/lib/domain/vo/privilege.dart +++ b/lib/domain/vo/privilege.dart @@ -43,6 +43,8 @@ class Privilege { iconData = FontAwesome.dropbox; } else if (this.id == privilege_receiving) { iconData = MaterialCommunityIcons.inbox_arrow_down; + } else if (this.id == privilege_pickup) { + iconData = FontAwesome.dropbox; } else { iconData = MaterialCommunityIcons.account_question; } diff --git a/lib/pages/main/util.dart b/lib/pages/main/util.dart index 277bfe1..5018f59 100644 --- a/lib/pages/main/util.dart +++ b/lib/pages/main/util.dart @@ -42,7 +42,7 @@ Future showConfirmDialog( child: LocalText( context, translationKey, - translationVariables: translationVariables!, + translationVariables: translationVariables, color: primaryColor, ), ), diff --git a/lib/pages/processing/processing_info.dart b/lib/pages/processing/processing_info.dart index d15d0c9..2f15404 100644 --- a/lib/pages/processing/processing_info.dart +++ b/lib/pages/processing/processing_info.dart @@ -39,7 +39,8 @@ class _ProcessingInfoState extends State { initPackage(widget.package!); } - initPackage(Package package) { + initPackage(Package? package) { + if (package == null) return; setState(() { _package = package; multiImgController.setImageUrls = package.photoUrls; @@ -69,37 +70,37 @@ class _ProcessingInfoState extends State { iconData: Icons.phone, ); final customerNameBox = DisplayText( - text:_package!=null? _package!.userName:"", + text: _package != null ? _package!.userName : "", labelTextKey: "processing.consignee.name", iconData: Icons.perm_identity, ); var senderFcsIDBox = DisplayText( - text:_package!=null? _package!.senderFCSID:"", + text: _package != null ? _package!.senderFCSID : "", labelTextKey: "processing.fcs.id", icon: FcsIDIcon(), ); final senderPhoneNumberBox = DisplayText( - text: _package!=null?_package!.senderPhoneNumber:"", + text: _package != null ? _package!.senderPhoneNumber : "", labelTextKey: "processing.phone", iconData: Icons.phone, ); final senderNameBox = DisplayText( - text:_package!=null? _package!.senderName:"", + text: _package != null ? _package!.senderName : "", labelTextKey: "processing.shipper.name", iconData: Icons.perm_identity, ); final marketBox = DisplayText( - text:_package!=null? _package!.market : "-", + text: _package != null ? _package!.market : "-", labelTextKey: "processing.market", iconData: Icons.store, ); final descBox = DisplayText( - text:_package!=null? _package!.desc : "-", + text: _package != null ? _package!.desc : "-", labelTextKey: "processing.desc", iconData: MaterialCommunityIcons.message_text_outline, ); final remarkBox = DisplayText( - text:_package!=null? _package!.remark : "-", + text: _package != null ? _package!.remark : "-", labelTextKey: "processing.remark", iconData: Entypo.new_message, ); @@ -175,7 +176,7 @@ class _ProcessingInfoState extends State { _package!.photoUrls.length == 0 ? Container() : img, StatusTree( shipmentHistory: _package!.shipmentHistory, - currentStatus: _package!.status??""), + currentStatus: _package!.status ?? ""), SizedBox( height: 20, ) @@ -223,7 +224,7 @@ class _ProcessingInfoState extends State { PackageModel packageModel = Provider.of(context, listen: false); Package? p = await packageModel.getPackage(_package!.id!); - initPackage(p!); + initPackage(p); } } } diff --git a/lib/pages/receiving/receiving_info.dart b/lib/pages/receiving/receiving_info.dart index d029bf8..eba05cb 100644 --- a/lib/pages/receiving/receiving_info.dart +++ b/lib/pages/receiving/receiving_info.dart @@ -40,7 +40,8 @@ class _ReceivingInfoState extends State { initPackage(widget.package!); } - initPackage(Package package) { + initPackage(Package? package) { + if (package == null) return; multiImgController.setImageUrls = package.photoUrls; setState(() { _package = package; @@ -150,7 +151,7 @@ class _ReceivingInfoState extends State { PackageModel packageModel = Provider.of(context, listen: false); var pkg = await packageModel.getPackage(widget.package!.id!); - initPackage(pkg!); + initPackage(pkg); } _delete() { diff --git a/pubspec.lock b/pubspec.lock index c317df9..5054151 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "22.0.0" + version: "25.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "1.7.1" + version: "2.2.0" args: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.1" barcode_scan2: dependency: "direct main" description: @@ -91,7 +91,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" cli_util: dependency: transitive description: @@ -434,6 +434,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "9.1.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" glob: dependency: transitive description: @@ -531,7 +538,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" mime: dependency: transitive description: @@ -893,21 +900,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.8" + version: "1.17.10" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.2" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.19" + version: "0.4.0" timeline_list: dependency: "direct main" description: