update carton

This commit is contained in:
Thinzar Win
2021-01-12 16:59:52 +06:30
parent 9dee2c55f3
commit fddcc91515
11 changed files with 91 additions and 139 deletions

View File

@@ -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 ================================================================":"",

View File

@@ -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 ================================================================":"",

View File

@@ -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

View File

@@ -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,

View File

@@ -84,7 +84,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
final saveBtn = fcsButton(
context,
getLocalString(context, 'box.cargo.save.btn'),
getLocalString(context, 'box.cargo.select.btn'),
callack: () {
List<CargoType> _cargos =
this.cargos.where((c) => c.isChecked).toList();

View File

@@ -74,7 +74,7 @@ class _CartonEditorState extends State<CartonEditor> {
//for carton from cargos
User consignee;
User sender;
List<Carton> _cartonsForCargos = [];
List<Carton> _cartonsFromCartons = [];
@override
void initState() {
@@ -95,17 +95,17 @@ class _CartonEditorState extends State<CartonEditor> {
_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<CartonEditor> {
));
final fcsIDBox = Container(
padding: EdgeInsets.only(top: 10),
padding: EdgeInsets.only(top: 15),
child: Row(
children: <Widget>[
Expanded(
@@ -389,6 +389,7 @@ class _CartonEditorState extends State<CartonEditor> {
color: primaryColor,
),
onPressed: () async {
boxModel.selectedIndexFilter = 1;
searchCarton(context, callbackCartonSelect: (c) {
_addMixCarton(c);
});
@@ -451,7 +452,7 @@ class _CartonEditorState extends State<CartonEditor> {
);
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<CartonEditor> {
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<CartonEditor> {
context,
isFromPackages
? this._cartons
: this._cartonsForCargos))
: this._cartonsFromCartons))
: Container(),
_isNew ? Container() : cargoTableTitleBox,
_isNew ? Container() : cargoTableBox,
@@ -635,14 +628,9 @@ class _CartonEditorState extends State<CartonEditor> {
builder: (context) =>
DeliveryAddressSelection(
deliveryAddress: _deliveryAddress,
user: isFromPackages
? User(
user: User(
id: _carton.userID,
name: _carton.userName)
: User(
id: _carton.receiverID,
name: _carton
.receiverName))),
name: _carton.userName))),
);
if (d == null) return;
setState(() {
@@ -845,9 +833,9 @@ class _CartonEditorState extends State<CartonEditor> {
}
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<CartonEditor> {
}
if (isFromCartons) {
_cartonsForCargos.add(_carton);
_cartonsFromCartons.add(_carton);
}
setState(() {});
@@ -938,19 +926,19 @@ class _CartonEditorState extends State<CartonEditor> {
_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<CartonEditor> {
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<CartonEditor> {
});
}
}
isDataChanged() {
if (_isNew) {
return false;
// return _fcsShipment != null || _user != null;
} else {
return false;
}
}
}

View File

@@ -63,8 +63,6 @@ class _CartonInfoState extends State<CartonInfo> {
void initState() {
super.initState();
_box = widget.box;
// _box.cartonType = carton_from_cargos;
// _box.cartonType = carton_mix_box;
//for shipment weight
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
.rate
@@ -188,13 +186,13 @@ class _CartonInfoState extends State<CartonInfo> {
);
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,

View File

@@ -34,32 +34,32 @@ class CartonModel extends BaseModel {
status: "Delivered", date: DateTime(2020, 6, 15), done: false)
];
List<Carton> get completed {
return boxes.where((e) => e.status == "Delivered").toList()
..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber);
});
}
// List<Carton> get completed {
// return boxes.where((e) => e.status == "Delivered").toList()
// ..sort((e1, e2) {
// return e2.packageNumber.compareTo(e1.packageNumber);
// });
// }
List<Carton> get processed {
return boxes.where((e) => e.status == "Packed").toList()
..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber);
});
}
// List<Carton> get processed {
// return boxes.where((e) => e.status == "Packed").toList()
// ..sort((e1, e2) {
// return e2.packageNumber.compareTo(e1.packageNumber);
// });
// }
List<Carton> 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<Carton> 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<String> 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")

View File

@@ -67,7 +67,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
_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();
@@ -162,8 +162,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
CupertinoIcons.back,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
onPressed: () => Navigator.of(context).pop()),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
@@ -192,13 +191,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
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<PackageCartonEditor> {
}
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;

View File

@@ -59,12 +59,13 @@ class _BoxAdditionState extends State<BoxAddition> {
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) => {},
),
]),

View File

@@ -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