update carton from packages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
@@ -12,7 +12,7 @@ import 'package:provider/provider.dart';
|
||||
import 'model/shipment_rate_model.dart';
|
||||
|
||||
class CustomEditor extends StatefulWidget {
|
||||
final CustomDuty custom;
|
||||
final CargoType custom;
|
||||
CustomEditor({this.custom});
|
||||
|
||||
@override
|
||||
@@ -25,7 +25,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
TextEditingController _shipmentRateController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
CustomDuty _custom = new CustomDuty();
|
||||
CargoType _custom = new CargoType();
|
||||
bool _isNew = false;
|
||||
|
||||
@override
|
||||
@@ -33,11 +33,10 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
super.initState();
|
||||
if (widget.custom != null) {
|
||||
_custom = widget.custom;
|
||||
_productController.text = _custom.productType;
|
||||
_feeController.text = _custom.fee.toStringAsFixed(2);
|
||||
_shipmentRateController.text = _custom.shipmentRate == null
|
||||
? ""
|
||||
: _custom.shipmentRate.toStringAsFixed(2);
|
||||
_productController.text = _custom.name;
|
||||
_feeController.text = _custom.customDutyFee.toStringAsFixed(2);
|
||||
_shipmentRateController.text =
|
||||
_custom.rate == null ? "" : _custom.rate.toStringAsFixed(2);
|
||||
} else {
|
||||
_isNew = true;
|
||||
}
|
||||
@@ -123,11 +122,10 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
try {
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
CustomDuty _customduty = CustomDuty(
|
||||
productType: _productController.text,
|
||||
fee: double.parse(_feeController.text),
|
||||
shipmentRate: double.parse(_shipmentRateController.text));
|
||||
print('_customduty => $_customduty');
|
||||
CargoType _customduty = CargoType(
|
||||
name: _productController.text,
|
||||
customDutyFee: double.parse(_feeController.text),
|
||||
rate: double.parse(_shipmentRateController.text));
|
||||
if (_isNew) {
|
||||
await shipmentRateModel.addCustomDuty(_customduty);
|
||||
} else {
|
||||
@@ -173,12 +171,11 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
_feeController.text != "" ||
|
||||
_shipmentRateController.text != "";
|
||||
} else {
|
||||
CustomDuty _customduty = CustomDuty(
|
||||
productType: _productController.text,
|
||||
fee: double.parse(_feeController.text),
|
||||
// shipmentRate: double.parse(_shipmentRateController.text)
|
||||
);
|
||||
return widget.custom.isChangedForEdit(_customduty);
|
||||
CargoType _customduty = CargoType(
|
||||
name: _productController.text,
|
||||
customDutyFee: double.parse(_feeController.text),
|
||||
rate: double.parse(_shipmentRateController.text));
|
||||
return widget.custom.isChangedForEditCustomDuty(_customduty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
@@ -74,8 +75,7 @@ class _CustomListState extends State<CustomList> {
|
||||
),
|
||||
itemCount: shipmentRateModel.rate.customDuties.length,
|
||||
itemBuilder: (context, index) {
|
||||
CustomDuty custom =
|
||||
shipmentRateModel.rate.customDuties[index];
|
||||
CargoType custom = shipmentRateModel.rate.customDuties[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
_selected
|
||||
@@ -86,11 +86,11 @@ class _CustomListState extends State<CustomList> {
|
||||
},
|
||||
child: Container(
|
||||
child: _row(
|
||||
custom.productType,
|
||||
"\$ " + custom.fee.toStringAsFixed(2),
|
||||
custom.shipmentRate == null
|
||||
custom.name,
|
||||
"Custom Fee \$ " + custom.customDutyFee.toStringAsFixed(2),
|
||||
custom.rate == null
|
||||
? ""
|
||||
: "\$ " + custom.shipmentRate.toStringAsFixed(2)),
|
||||
: "Shipment rate \$ " + custom.rate.toStringAsFixed(2)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
@@ -120,7 +120,7 @@ class _CustomListState extends State<CustomList> {
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 3.0),
|
||||
child: Text(
|
||||
"\$ " + "$shipmentRate",
|
||||
"$shipmentRate",
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -50,16 +50,18 @@ class ShipmentRateModel extends BaseModel {
|
||||
|
||||
//CustomDuty
|
||||
|
||||
Future<void> addCustomDuty(CustomDuty customDuty) {
|
||||
return Services.instance.rateService.createCustomDuty(customDuty);
|
||||
Future<void> addCustomDuty(CargoType customDuty) {
|
||||
customDuty.isCutomDuty=true;
|
||||
return Services.instance.rateService.createCargoType(customDuty);
|
||||
}
|
||||
|
||||
Future<void> updateCustomDuty(CustomDuty customDuty) {
|
||||
return Services.instance.rateService.updateCustomDuty(customDuty);
|
||||
Future<void> updateCustomDuty(CargoType customDuty) {
|
||||
customDuty.isCutomDuty=true;
|
||||
return Services.instance.rateService.updateCargoType(customDuty);
|
||||
}
|
||||
|
||||
Future<void> deleteCustomDuty(String id) {
|
||||
return Services.instance.rateService.deleteCustomDuty(id);
|
||||
return Services.instance.rateService.deleteCargoType(id);
|
||||
}
|
||||
|
||||
//Discount by weight
|
||||
|
||||
@@ -145,14 +145,10 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
"Volumetric Ratio",
|
||||
"${rate.volumetricRatio.toStringAsFixed(2)}",
|
||||
"in3 per pound"),
|
||||
_row(
|
||||
"Weight difference discount",
|
||||
"${rate.diffDiscountWeight.toStringAsFixed(2)}",
|
||||
"pounds"),
|
||||
_row(
|
||||
"Weight difference rate",
|
||||
"\$ ${rate.diffWeightRate.toStringAsFixed(2)}",
|
||||
""),
|
||||
_row("Weight difference discount",
|
||||
"${rate.diffDiscountWeight.toStringAsFixed(2)}", "pounds"),
|
||||
_row("Weight difference rate",
|
||||
"\$ ${rate.diffWeightRate.toStringAsFixed(2)}", ""),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
@@ -195,10 +191,10 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<Widget> getCustonWidget(List<CustomDuty> customs) {
|
||||
List<Widget> getCustonWidget(List<CargoType> customs) {
|
||||
return customs.map((c) {
|
||||
return Container(
|
||||
child: _row(c.productType, "\$ " + c.fee.toStringAsFixed(2), ''),
|
||||
child: _row(c.name, "\$ " + c.customDutyFee.toStringAsFixed(2), ''),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
_minWeight.text = rate.freeDeliveryWeight?.toStringAsFixed(2) ?? "";
|
||||
_deliveryFee.text = rate.deliveryFee?.toStringAsFixed(2) ?? "";
|
||||
_volumetricRatio.text = rate.volumetricRatio?.toStringAsFixed(2) ?? "";
|
||||
_diffDiscountWeight.text = rate.diffDiscountWeight?.toStringAsFixed(2) ?? "";
|
||||
_diffDiscountWeight.text =
|
||||
rate.diffDiscountWeight?.toStringAsFixed(2) ?? "";
|
||||
_diffWeightRate.text = rate.diffWeightRate?.toStringAsFixed(2) ?? "";
|
||||
}
|
||||
|
||||
@@ -162,120 +163,4 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
);
|
||||
return rate.isChangedForEdit(_rate);
|
||||
}
|
||||
|
||||
List<MyDataRow> getCargoRows(List<CargoType> cargos) {
|
||||
return cargos.map((r) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (selected) {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CargoEditor(cargo: r)),
|
||||
);
|
||||
},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(
|
||||
r.name,
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
new Text(
|
||||
r.rate.toString(),
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<MyDataRow> getCustomsRows(List<CustomDuty> customs) {
|
||||
return customs.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (selected) {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CustomEditor(custom: c)),
|
||||
);
|
||||
},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(
|
||||
c.productType,
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
new Text(
|
||||
c.fee.toString(),
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<MyDataRow> getDiscounts(List<DiscountByWeight> discounts) {
|
||||
return discounts.map((d) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (selected) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(builder: (context) => CargoEditor(rate: r)),
|
||||
// );
|
||||
},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(
|
||||
"${d.weight} lb",
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
Center(
|
||||
child: new Text(
|
||||
d.discount.toString(),
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_row(String desc, String price, String unit) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('$desc ', style: TextStyle(fontSize: 15)),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 3.0),
|
||||
child: Text(
|
||||
'$price',
|
||||
style: TextStyle(color: primaryColor, fontSize: 14),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$unit',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 50,
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user