From fddcc91515bed3a0bad895f9a9d81ba3e4f46aa2 Mon Sep 17 00:00:00 2001 From: Thinzar Win Date: Tue, 12 Jan 2021 16:59:52 +0630 Subject: [PATCH] update carton --- assets/local/localization_en.json | 4 +- assets/local/localization_mu.json | 4 +- lib/domain/entities/carton.dart | 26 ++------ lib/domain/entities/package.dart | 10 --- lib/pages/carton/cargo_type_addtion.dart | 2 +- lib/pages/carton/carton_editor.dart | 73 ++++++++------------- lib/pages/carton/carton_info.dart | 6 +- lib/pages/carton/model/carton_model.dart | 56 ++++++++-------- lib/pages/carton/package_carton_editor.dart | 28 ++++---- lib/pages/invoice/box_addition.dart | 13 ++-- pubspec.yaml | 8 ++- 11 files changed, 91 insertions(+), 139 deletions(-) diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index 211c051..7401f60 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -275,7 +275,7 @@ "box.packages":"Packages", "box.tracking.id":"Tracking ID", "box.market":"Market", - "box.cargo.save.btn":"Select", + "box.cargo.save.btn":"Update Carton", "box.type.title":"Carton types", "box.shipment.boxes":"Cartons", "box.shipment_number":"Shipment number", @@ -302,6 +302,8 @@ "box.mix_type":"Mix Box Types", "box.selection":"Carton Selection", "box.weight":"Weight", + "box.mix_carton.update.btn":"Update mix carton", + "box.cargo.select.btn":"Select", "Boxes End ================================================================":"", "Delivery Start ================================================================":"", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index ed43d1e..f4e7c89 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -275,7 +275,7 @@ "box.packages":"အထုပ်များ", "box.tracking.id":"Tracking ID", "box.market":"အွန်လိုင်စျေးဆိုင်", - "box.cargo.save.btn":"ရွေးမည်", + "box.cargo.save.btn":"သေတ္တာ ပြုပြင်မည်", "box.type.title":"သေတ္တာအမျိုးအစားများ", "box.shipment.boxes":"သေတ္တာများ", "box.shipment_number":"ပို့ဆောင်နံပါတ်", @@ -302,6 +302,8 @@ "box.mix_type":"Mix Box Types", "box.selection":"သေတ္တာ ရွေးချယ်ခြင်း", "box.weight":"အလေးချိန်", + "box.mix_carton.update.btn":"Update mix carton", + "box.cargo.select.btn":"ရွေးချယ်မည်", "Boxes End ================================================================":"", "Delivery Start ================================================================":"", diff --git a/lib/domain/entities/carton.dart b/lib/domain/entities/carton.dart index 85ded1d..831adf2 100644 --- a/lib/domain/entities/carton.dart +++ b/lib/domain/entities/carton.dart @@ -15,11 +15,7 @@ class Carton { String senderID; String senderFCSID; String senderName; - String receiverID; - String receiverFCSID; - String receiverName; - String receiverAddress; - String receiverNumber; + String boxNumber; String status; String cargoDesc; @@ -65,8 +61,8 @@ class Carton { int get amount => rate != null && weight != null ? rate * weight : 0; - String get packageNumber => - shipmentNumber + "-" + receiverNumber + " #" + boxNumber; + // String get packageNumber => + // shipmentNumber + "-" + receiverNumber + " #" + boxNumber; double get price => rate.toDouble() * weight; double get actualWeight => @@ -136,11 +132,6 @@ class Carton { this.senderID, this.senderFCSID, this.senderName, - this.receiverID, - this.receiverFCSID, - this.receiverName, - this.receiverNumber, - this.receiverAddress, this.boxNumber, this.desc, this.width, @@ -196,9 +187,6 @@ class Carton { 'mix_carton_id': mixCartonID, 'mix_box_type': mixBoxType, 'mix_cartons': _mixCartons, - 'receiver_id': receiverID, - 'receiver_fcs_id': receiverFCSID, - 'receiver_name': receiverName, 'sender_id': senderID, 'sender_fcs_id': senderFCSID, 'sender_name': senderName @@ -223,7 +211,7 @@ class Carton { arrivedDate: _arrivedDate != null ? _arrivedDate.toDate() : null, shipmentID: map['shipment_id'], shipmentNumber: map['shipment_number'], - receiverNumber: map['receiver_number'], + // receiverNumber: map['receiver_number'], boxNumber: map['box_number'], length: double.tryParse(map['length']?.toString()), width: double.tryParse(map['width']?.toString()), @@ -244,9 +232,6 @@ class Carton { cargoTypes: cargoTypes, mixBoxType: map['mix_box_type'], mixCartons: _mixCartons, - receiverID: map['receiver_id'], - receiverFCSID: map['receiver_fcs_id'], - receiverName: map['receiver_name'], senderID: map['sender_id'], senderFCSID: map['sender_fcs_id'], senderName: map['sender_name'], @@ -273,9 +258,6 @@ class Carton { 'mix_carton_id': mixCartonID, 'mix_box_type': mixBoxType, 'mix_cartons': _mixCartons, - 'receiver_id': receiverID, - 'receiver_fcs_id': receiverFCSID, - 'receiver_name': receiverName, 'sender_id': senderID, 'sender_fcs_id': senderFCSID, 'sender_name': senderName diff --git a/lib/domain/entities/package.dart b/lib/domain/entities/package.dart index 114e787..e63a9b5 100644 --- a/lib/domain/entities/package.dart +++ b/lib/domain/entities/package.dart @@ -20,10 +20,6 @@ class Package { String shipmentNumber; String senderFCSID; String senderName; - String receiverFCSID; - String receiverName; - String receiverAddress; - String receiverNumber; String boxNumber; String cargoDesc; String market; @@ -43,8 +39,6 @@ class Package { int get amount => rate != null && weight != null ? rate * weight : 0; - String get packageNumber => - shipmentNumber + "-" + receiverNumber + " #" + boxNumber; double get price => rate.toDouble() * weight; Package({ @@ -57,10 +51,6 @@ class Package { this.shipmentNumber, this.senderFCSID, this.senderName, - this.receiverFCSID, - this.receiverName, - this.receiverNumber, - this.receiverAddress, this.boxNumber, this.rate, this.weight, diff --git a/lib/pages/carton/cargo_type_addtion.dart b/lib/pages/carton/cargo_type_addtion.dart index 1c1e5a4..8aec5b4 100644 --- a/lib/pages/carton/cargo_type_addtion.dart +++ b/lib/pages/carton/cargo_type_addtion.dart @@ -84,7 +84,7 @@ class _CargoTypeAdditionState extends State { final saveBtn = fcsButton( context, - getLocalString(context, 'box.cargo.save.btn'), + getLocalString(context, 'box.cargo.select.btn'), callack: () { List _cargos = this.cargos.where((c) => c.isChecked).toList(); diff --git a/lib/pages/carton/carton_editor.dart b/lib/pages/carton/carton_editor.dart index b0ae520..6a6c481 100644 --- a/lib/pages/carton/carton_editor.dart +++ b/lib/pages/carton/carton_editor.dart @@ -74,7 +74,7 @@ class _CartonEditorState extends State { //for carton from cargos User consignee; User sender; - List _cartonsForCargos = []; + List _cartonsFromCartons = []; @override void initState() { @@ -95,17 +95,17 @@ class _CartonEditorState extends State { _heightController.text = _carton.height.toString(); _lengthController.text = _carton.length.toString(); _selectedCartonType = _carton.cartonType; - _cargoTypes = List.from(_carton.cargoTypes); + + _cargoTypes = _carton.cargoTypes.map((e) => e.clone()).toList(); + _isNew = false; _user = User( id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName); consignee = User( - id: _carton.receiverID, - fcsID: _carton.receiverFCSID, - name: _carton.receiverName); + id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName); sender = User( id: _carton.senderID, - fcsID: _carton.senderID, + fcsID: _carton.senderFCSID, name: _carton.senderName); _selectedMixBoxType = _carton.mixBoxType ?? ""; this._mixCartons = @@ -251,7 +251,7 @@ class _CartonEditorState extends State { )); final fcsIDBox = Container( - padding: EdgeInsets.only(top: 10), + padding: EdgeInsets.only(top: 15), child: Row( children: [ Expanded( @@ -389,6 +389,7 @@ class _CartonEditorState extends State { color: primaryColor, ), onPressed: () async { + boxModel.selectedIndexFilter = 1; searchCarton(context, callbackCartonSelect: (c) { _addMixCarton(c); }); @@ -451,7 +452,7 @@ class _CartonEditorState extends State { ); final createMixCarton = LocalButton( - textKey: _isNew ? "box.mix_carton_btn" : "btn.save", + textKey: _isNew ? "box.mix_carton_btn" : "box.mix_carton.update.btn", callBack: _creatMixCarton, ); @@ -529,17 +530,9 @@ class _CartonEditorState extends State { appBar: AppBar( centerTitle: true, leading: new IconButton( - icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30), - onPressed: () { - if (isDataChanged()) { - showConfirmDialog(context, "back.button_confirm", () { - Navigator.of(context).pop(); - }); - } else { - Navigator.of(context).pop(); - } - }, - ), + icon: + new Icon(CupertinoIcons.back, color: primaryColor, size: 30), + onPressed: () => Navigator.of(context).pop()), shadowColor: Colors.transparent, backgroundColor: Colors.white, title: LocalText( @@ -610,7 +603,7 @@ class _CartonEditorState extends State { context, isFromPackages ? this._cartons - : this._cartonsForCargos)) + : this._cartonsFromCartons)) : Container(), _isNew ? Container() : cargoTableTitleBox, _isNew ? Container() : cargoTableBox, @@ -635,14 +628,9 @@ class _CartonEditorState extends State { builder: (context) => DeliveryAddressSelection( deliveryAddress: _deliveryAddress, - user: isFromPackages - ? User( - id: _carton.userID, - name: _carton.userName) - : User( - id: _carton.receiverID, - name: _carton - .receiverName))), + user: User( + id: _carton.userID, + name: _carton.userName))), ); if (d == null) return; setState(() { @@ -845,9 +833,9 @@ class _CartonEditorState extends State { } if (isFromCartons) { - carton.receiverID = consignee?.id; - carton.receiverFCSID = consignee?.fcsID; - carton.receiverName = consignee?.name; + carton.userID = consignee?.id; + carton.fcsID = consignee?.fcsID; + carton.userName = consignee?.name; carton.senderID = sender?.id; carton.senderFCSID = sender?.fcsID; carton.senderName = sender?.name; @@ -877,7 +865,7 @@ class _CartonEditorState extends State { } if (isFromCartons) { - _cartonsForCargos.add(_carton); + _cartonsFromCartons.add(_carton); } setState(() {}); @@ -938,19 +926,19 @@ class _CartonEditorState extends State { _save() async { bool isFromPackages = _selectedCartonType == carton_from_packages; - bool isFromCargos = _selectedCartonType == carton_from_cartons; - if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCargos)) { + bool isFromCartons = _selectedCartonType == carton_from_cartons; + if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCartons)) { showMsgDialog(context, "Error", "Expect at least one cargo type"); return; } double l = double.parse(_lengthController.text, (s) => 0); double w = double.parse(_widthController.text, (s) => 0); double h = double.parse(_heightController.text, (s) => 0); - if ((l <= 0 || w <= 0 || h <= 0) && (isFromPackages || isFromCargos)) { + if ((l <= 0 || w <= 0 || h <= 0) && (isFromPackages || isFromCartons)) { showMsgDialog(context, "Error", "Invalid dimension"); return; } - if (_deliveryAddress == null && (isFromPackages || isFromCargos)) { + if (_deliveryAddress == null && (isFromPackages || isFromCartons)) { showMsgDialog(context, "Error", "Invalid delivery address"); return; } @@ -963,8 +951,8 @@ class _CartonEditorState extends State { carton.userID = _user?.id; carton.packages = _carton.packages.where((e) => e.isChecked).toList(); } - if (isFromCargos) { - carton.receiverID = consignee?.id; + if (isFromCartons) { + carton.userID = consignee?.id; carton.senderID = sender?.id; } @@ -990,13 +978,4 @@ class _CartonEditorState extends State { }); } } - - isDataChanged() { - if (_isNew) { - return false; - // return _fcsShipment != null || _user != null; - } else { - return false; - } - } } diff --git a/lib/pages/carton/carton_info.dart b/lib/pages/carton/carton_info.dart index 7592357..16cebf7 100644 --- a/lib/pages/carton/carton_info.dart +++ b/lib/pages/carton/carton_info.dart @@ -63,8 +63,6 @@ class _CartonInfoState extends State { void initState() { super.initState(); _box = widget.box; - // _box.cartonType = carton_from_cargos; - // _box.cartonType = carton_mix_box; //for shipment weight volumetricRatio = Provider.of(context, listen: false) .rate @@ -188,13 +186,13 @@ class _CartonInfoState extends State { ); final consigneefcsIDBox = DisplayText( - text: _box.receiverFCSID != null ? _box.receiverFCSID : "", + text: _box.fcsID != null ? _box.fcsID : "", labelTextKey: "processing.fcs.id", icon: FcsIDIcon(), ); final consigneeNameBox = DisplayText( - text: _box.receiverName != null ? _box.receiverName : "", + text: _box.userName != null ? _box.userName : "", labelTextKey: "processing.consignee.name", maxLines: 2, iconData: Icons.person, diff --git a/lib/pages/carton/model/carton_model.dart b/lib/pages/carton/model/carton_model.dart index aa1e8dd..24d3aeb 100644 --- a/lib/pages/carton/model/carton_model.dart +++ b/lib/pages/carton/model/carton_model.dart @@ -34,32 +34,32 @@ class CartonModel extends BaseModel { status: "Delivered", date: DateTime(2020, 6, 15), done: false) ]; - List get completed { - return boxes.where((e) => e.status == "Delivered").toList() - ..sort((e1, e2) { - return e2.packageNumber.compareTo(e1.packageNumber); - }); - } + // List get completed { + // return boxes.where((e) => e.status == "Delivered").toList() + // ..sort((e1, e2) { + // return e2.packageNumber.compareTo(e1.packageNumber); + // }); + // } - List get processed { - return boxes.where((e) => e.status == "Packed").toList() - ..sort((e1, e2) { - return e2.packageNumber.compareTo(e1.packageNumber); - }); - } + // List get processed { + // return boxes.where((e) => e.status == "Packed").toList() + // ..sort((e1, e2) { + // return e2.packageNumber.compareTo(e1.packageNumber); + // }); + // } - List get upcoming { - return boxes - .where((e) => - e.status == "Packed" || - // e.status == "Received" || - e.status == "Shipped" || - e.status == "Arrived") - .toList() - ..sort((e1, e2) { - return e2.packageNumber.compareTo(e1.packageNumber); - }); - } + // List get upcoming { + // return boxes + // .where((e) => + // e.status == "Packed" || + // // e.status == "Received" || + // e.status == "Shipped" || + // e.status == "Arrived") + // .toList() + // ..sort((e1, e2) { + // return e2.packageNumber.compareTo(e1.packageNumber); + // }); + // } List cartonTypes = [ carton_from_packages, @@ -153,10 +153,10 @@ class CartonModel extends BaseModel { try { Query listenerQuery = Firestore.instance .collection("$path") - .where("carton_type", - whereIn: [carton_from_packages, carton_from_cartons]) - .where("status", isEqualTo: carton_packed_status) - .orderBy(orderName, descending: true); + .where("carton_type", whereIn: [ + carton_from_packages, + carton_from_cartons + ]).where("status", isEqualTo: carton_packed_status); Query pageQuery = Firestore.instance .collection("$path") diff --git a/lib/pages/carton/package_carton_editor.dart b/lib/pages/carton/package_carton_editor.dart index a6d78a1..458bc96 100644 --- a/lib/pages/carton/package_carton_editor.dart +++ b/lib/pages/carton/package_carton_editor.dart @@ -67,7 +67,7 @@ class _PackageCartonEditorState extends State { _widthCtl.text = "0"; _heightCtl.text = "0"; } else { - _cargoTypes = List.from(widget.carton.cargoTypes); + _cargoTypes = widget.carton.cargoTypes.map((e) => e.clone()).toList(); _lengthCtl.text = _carton.length.toString(); _widthCtl.text = _carton.width.toString(); _heightCtl.text = _carton.height.toString(); @@ -158,12 +158,11 @@ class _PackageCartonEditorState extends State { appBar: AppBar( centerTitle: true, leading: new IconButton( - icon: new Icon( - CupertinoIcons.back, - color: primaryColor, - ), - onPressed: () => Navigator.of(context).pop(), - ), + icon: new Icon( + CupertinoIcons.back, + color: primaryColor, + ), + onPressed: () => Navigator.of(context).pop()), shadowColor: Colors.transparent, backgroundColor: Colors.white, title: LocalText( @@ -192,13 +191,8 @@ class _PackageCartonEditorState extends State { CupertinoPageRoute( builder: (context) => DeliveryAddressSelection( deliveryAddress: _deliveryAddress, - user: isFromPackages - ? User( - id: _carton.userID, - name: _carton.userName) - : User( - id: _carton.receiverID, - name: _carton.receiverName), + user: User( + id: _carton.userID, name: _carton.userName), )), ); if (d == null) return; @@ -334,9 +328,9 @@ class _PackageCartonEditorState extends State { } if (isFromCartons) { - carton.receiverID = _carton.receiverID; - carton.receiverFCSID = _carton.receiverFCSID; - carton.receiverName = _carton.receiverName; + carton.userID = _carton.userID; + carton.fcsID = _carton.fcsID; + carton.userName = _carton.userName; carton.senderID = _carton.senderID; carton.senderFCSID = _carton.senderFCSID; carton.senderName = _carton.senderName; diff --git a/lib/pages/invoice/box_addition.dart b/lib/pages/invoice/box_addition.dart index 882529d..5429589 100644 --- a/lib/pages/invoice/box_addition.dart +++ b/lib/pages/invoice/box_addition.dart @@ -59,12 +59,13 @@ class _BoxAdditionState extends State { fillColor: Colors.white, labelText: 'Box Number', icon: Icon(Icons.pages)), - items: boxModel.processed - .map((e) => DropdownMenuItem( - child: Text( - '${e.shipmentNumber}-${e.receiverNumber} #${e.boxNumber}'), - value: e)) - .toList(), + items: [], + // boxModel.processed + // .map((e) => DropdownMenuItem( + // child: Text( + // '${e.shipmentNumber}-${e.receiverNumber} #${e.boxNumber}'), + // value: e)) + // .toList(), onChanged: (map) => {}, ), ]), diff --git a/pubspec.yaml b/pubspec.yaml index 088449f..3b0e893 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,8 +24,12 @@ dependencies: image_picker: ^0.6.0+9 shared_preferences: ^0.5.7+3 progress: - path: - ../flutter/packages/progress + git: + url: https://git.mokkon.com/tzw/mokkon-flutter.git + ref: v1.0.0 + path: packages/progress + # path: + # ../flutter/packages/progress flutter_datetime_picker: ^1.3.8 dio: ^3.0.9 package_info: ^0.4.0+6