Files
fcs/lib/pages/invoice/invoice_editor.dart

896 lines
29 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/box.dart';
2020-10-15 03:06:13 +06:30
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/custom_duty.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/domain/entities/discount.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/invoice.dart';
import 'package:fcs/domain/entities/payment_method.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/domain/entities/user.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
2020-10-14 20:56:46 +06:30
import 'package:fcs/pages/discount/discount_list.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/discount/model/discount_model.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/pages/main/model/language_model.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/main/model/main_model.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/pages/main/util.dart';
2020-10-13 18:38:00 +06:30
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
2020-10-14 20:56:46 +06:30
import 'package:fcs/pages/rates/custom_list.dart';
2020-10-15 03:06:13 +06:30
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/pages/user_search/user_serach.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
2020-10-13 18:38:00 +06:30
import 'package:fcs/pages/widgets/discount_dropdown.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/pages/widgets/display_text.dart';
2020-10-14 20:56:46 +06:30
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
2020-10-09 19:00:39 +06:30
import 'package:fcs/pages/widgets/input_text.dart';
2020-10-13 18:38:00 +06:30
import 'package:fcs/pages/widgets/local_dropdown.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/local_text.dart';
2020-10-14 10:33:14 +06:30
import 'package:fcs/pages/widgets/local_title.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
2020-10-14 13:54:42 +06:30
import 'package:flutter/cupertino.dart';
2020-06-02 14:56:51 +06:30
import 'package:flutter/material.dart';
2020-06-03 00:42:31 +06:30
import 'package:flutter_icons/flutter_icons.dart';
2020-06-02 14:56:51 +06:30
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
2020-06-26 16:04:40 +06:30
import 'box_addition.dart';
2020-06-02 14:56:51 +06:30
class InvoiceEditor extends StatefulWidget {
final Invoice invoice;
2020-10-14 20:56:46 +06:30
final User customer;
InvoiceEditor({this.invoice, this.customer});
2020-06-02 14:56:51 +06:30
@override
_InvoiceEditorState createState() => _InvoiceEditorState();
}
class _InvoiceEditorState extends State<InvoiceEditor> {
2020-10-09 19:00:39 +06:30
User user;
2020-06-02 14:56:51 +06:30
var dateFormatter = new DateFormat('dd MMM yyyy');
TextEditingController _invoiceNumberController = new TextEditingController();
TextEditingController _dateController = new TextEditingController();
TextEditingController _nameController = new TextEditingController();
TextEditingController _phoneController = new TextEditingController();
TextEditingController _discountController = new TextEditingController();
TextEditingController _amountController = new TextEditingController();
TextEditingController _statusController = new TextEditingController();
2020-06-29 16:03:41 +06:30
TextEditingController _handlingFeeController = new TextEditingController();
TextEditingController _customFeeController = new TextEditingController();
2020-06-02 14:56:51 +06:30
MultiImgController multiImgController = MultiImgController();
2020-06-29 16:03:41 +06:30
TextEditingController _descriptionController = new TextEditingController();
TextEditingController _balanceController = new TextEditingController();
2020-06-02 14:56:51 +06:30
Invoice _invoice;
bool _isLoading = false;
2020-06-26 16:04:40 +06:30
List<Box> _boxes = [];
bool isSwitched = false;
2020-10-09 19:00:39 +06:30
int deliveryfee = 0;
2020-10-15 03:06:13 +06:30
double customFee = 10;
2020-10-14 20:56:46 +06:30
int handlingFee = 0;
2020-10-09 19:00:39 +06:30
double total = 0;
Discount _discount;
2020-10-13 11:49:35 +06:30
bool isNew = false;
2020-10-13 18:38:00 +06:30
Discount selectedDiscount;
int selectedDiscountAmt;
PaymentMethod paymentMethod;
2020-10-14 20:56:46 +06:30
double volumetricRatio = 0;
2020-10-09 19:00:39 +06:30
List<Box> selectedBoxes = [];
2020-10-15 03:06:13 +06:30
List<CustomDuty> customs = [];
2020-10-09 19:00:39 +06:30
2020-10-15 03:06:13 +06:30
List<CargoType> _cargoTypes = [
CargoType(name: 'General Cargo', weight: 33, rate: 6),
CargoType(name: 'Medicine', weight: 33, rate: 7),
CargoType(name: 'Dangerous Cargo', weight: 33, rate: 8)
2020-06-29 16:03:41 +06:30
];
List<String> _receipts = [
2020-10-07 02:33:06 +06:30
"assets/buying_online_with_first_last_name.png",
2020-06-29 16:03:41 +06:30
];
2020-06-02 14:56:51 +06:30
@override
void initState() {
super.initState();
2020-10-14 20:56:46 +06:30
2020-10-15 03:06:13 +06:30
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
.rate
.volumetricRatio;
2020-10-14 20:56:46 +06:30
2020-06-02 14:56:51 +06:30
if (widget.invoice != null) {
_invoice = widget.invoice;
_invoiceNumberController.text = _invoice.invoiceNumber;
_dateController.text = dateFormatter.format(_invoice.invoiceDate);
_nameController.text = _invoice.customerName;
_phoneController.text = _invoice.customerPhoneNumber;
2020-06-29 16:03:41 +06:30
// _amountController.text = _invoice.getAmount.toString();
_amountController.text = _invoice.amount.toString();
2020-06-02 14:56:51 +06:30
_statusController.text = _invoice.status.toString();
2020-06-29 16:03:41 +06:30
_handlingFeeController.text = '0';
_customFeeController.text = '0';
2020-10-07 02:33:06 +06:30
// multiImgController.setImageUrls = _receipts;
2020-06-29 16:03:41 +06:30
_descriptionController.text = 'For Electronics goods';
_balanceController.text =
(_invoice.amount - _invoice.receipts[0].amount).toString();
2020-06-26 16:04:40 +06:30
// _boxes = _invoice.packages;
2020-06-29 16:03:41 +06:30
} else {
_dateController.text = dateFormatter.format(DateTime.now());
_amountController.text = '0';
_handlingFeeController.text = '0';
_customFeeController.text = '0';
_descriptionController.text = '';
_balanceController.text = '0';
2020-10-14 20:56:46 +06:30
}
if (widget.customer != null) {
user = widget.customer;
2020-10-13 11:49:35 +06:30
setState(() {
isNew = true;
});
2020-06-29 16:03:41 +06:30
}
2020-06-26 16:04:40 +06:30
_boxes = [
Box(
2020-06-02 14:56:51 +06:30
shipmentNumber: "A202",
receiverNumber: "3",
2020-06-26 16:04:40 +06:30
receiverName: "Ko Myo Min",
2020-06-02 14:56:51 +06:30
boxNumber: "1",
rate: 7,
packageType: "General",
2020-06-26 16:04:40 +06:30
weight: 75,
status: "Packed",
2020-06-02 14:56:51 +06:30
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
2020-06-26 16:04:40 +06:30
cargoDesc: "Clothes",
2020-06-02 14:56:51 +06:30
arrivedDate: DateTime(2020, 6, 1),
2020-06-26 16:04:40 +06:30
width: 10,
height: 10,
length: 10,
// packages: packages,
// statusHistory: statusHistory,
cargoTypes: [
2020-10-15 03:06:13 +06:30
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
2020-06-26 16:04:40 +06:30
]),
Box(
shipmentNumber: "A202",
receiverNumber: "3",
receiverName: "Ko Myo Min",
boxNumber: "2",
rate: 7,
packageType: "General",
weight: 75,
status: "Packed",
cargoDesc: "Clothes",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
// statusHistory: statusHistory,
// packages: packages,
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
cargoTypes: [
2020-10-15 03:06:13 +06:30
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
2020-06-26 16:04:40 +06:30
])
];
2020-06-02 14:56:51 +06:30
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
2020-06-04 01:36:49 +06:30
var mainModel = Provider.of<MainModel>(context);
2020-06-26 16:04:40 +06:30
var discountModel = Provider.of<DiscountModel>(context);
2020-10-13 18:38:00 +06:30
var paymentMethodModel = Provider.of<PaymentMethodModel>(context);
2020-10-14 20:56:46 +06:30
final nameBox = DisplayText(
iconData: Feather.user,
labelTextKey: 'invoice.customer_name',
text: user != null ? user.name : '');
final statusBox = DisplayText(
text: _statusController.text,
iconData: Icons.av_timer,
labelTextKey: 'invoice.status');
final fcsIDBox = Row(
children: <Widget>[
Expanded(
child: DisplayText(
text: user != null ? user.fcsID : "",
labelTextKey: "box.fcs.id",
icon: FcsIDIcon(),
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () => searchUser(context, callbackUserSelect: (u) {
setState(() {
this.user = u;
});
})),
],
);
2020-06-04 01:36:49 +06:30
2020-06-02 14:56:51 +06:30
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
2020-10-14 13:54:42 +06:30
icon: new Icon(CupertinoIcons.back, color: primaryColor),
2020-06-02 14:56:51 +06:30
onPressed: () => Navigator.of(context).pop(),
),
2020-10-09 19:00:39 +06:30
backgroundColor: Colors.white,
shadowColor: Colors.transparent,
2020-06-02 14:56:51 +06:30
title: LocalText(context, 'invoice.form.title',
2020-10-09 19:00:39 +06:30
color: primaryColor, fontSize: 20),
2020-06-02 14:56:51 +06:30
),
2020-10-14 10:33:14 +06:30
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
2020-06-02 14:56:51 +06:30
children: <Widget>[
2020-10-14 20:56:46 +06:30
LocalTitle(textKey: "invoice.customer_info"),
2020-10-14 10:33:14 +06:30
DisplayText(
labelTextKey: 'invoice.date',
iconData: Icons.date_range,
text: _dateController.text),
widget.invoice == null
? Container()
: DisplayText(
labelTextKey: 'invoice.number',
iconData: FontAwesomeIcons.fileInvoice,
text: _invoiceNumberController.text),
2020-10-14 20:56:46 +06:30
fcsIDBox,
nameBox,
isNew ? statusBox : Container(),
SizedBox(height: 20),
2020-10-14 10:33:14 +06:30
LocalTitle(textKey: "invoice.box_info"),
2020-10-14 20:56:46 +06:30
Center(child: Column(children: getCartonRows(context))),
SizedBox(height: 20),
LocalTitle(
textKey: "invoice.custom_fee",
trailing: IconButton(
icon: Icon(Icons.add_circle, color: primaryColor),
onPressed: () async {
2020-10-15 03:06:13 +06:30
CustomDuty custom = await Navigator.of(context).push(
2020-10-14 20:56:46 +06:30
CupertinoPageRoute(
builder: (context) => CustomList()));
setState(() {
if (custom != null) customs.add(custom);
});
})),
Column(children: getCustomFeeRows(context)),
SizedBox(height: 20),
2020-10-14 10:33:14 +06:30
LocalTitle(textKey: "invoice.cargo_type"),
Column(children: getCargoTableByBox(context)),
SizedBox(height: 20),
Container(
padding: EdgeInsets.only(top: 5, left: 18),
child: Row(
children: <Widget>[
Expanded(
child: LocalText(context, 'invoice.payment_method',
fontSize: 16,
2020-10-13 18:38:00 +06:30
color: Colors.grey,
2020-10-14 10:33:14 +06:30
fontWeight: FontWeight.bold),
2020-10-13 18:38:00 +06:30
),
2020-10-14 10:33:14 +06:30
Container(
width: 150.0,
child: DropdownButtonFormField(
2020-10-14 20:56:46 +06:30
icon: Icon(
Icons.edit,
color: primaryColor,
),
2020-10-14 10:33:14 +06:30
value: paymentMethod,
items: paymentMethodModel.paymentMethods
.map((e) => DropdownMenuItem(
child: Text(e.name), value: e.name))
.toList(),
onChanged: (selected) => {},
),
),
],
),
),
2020-10-14 20:56:46 +06:30
SizedBox(height: 20),
LocalTitle(
textKey: "invoice.payment_attachment",
trailing: IconButton(
icon: Icon(Icons.add_circle, color: primaryColor),
onPressed: () async {})),
2020-06-02 14:56:51 +06:30
widget.invoice == null
2020-10-09 19:00:39 +06:30
? fcsButton(
context, getLocalString(context, 'invoice.btn_create'))
2020-06-26 16:04:40 +06:30
: mainModel.isCustomer()
? Container()
: Container(
child: Column(
children: <Widget>[
2020-10-09 19:00:39 +06:30
fcsButton(context,
getLocalString(context, 'invoice.btn_save'))
2020-06-26 16:04:40 +06:30
],
)),
2020-10-13 18:38:00 +06:30
isNew
2020-06-02 15:30:11 +06:30
? Container()
2020-10-09 19:00:39 +06:30
: fcsButton(context,
getLocalString(context, 'invoice.btn_payment_receipt'))
2020-06-02 14:56:51 +06:30
],
),
),
),
);
}
2020-10-14 20:56:46 +06:30
getCartonRows(BuildContext context) {
List<Widget> dataRow = [];
dataRow = _boxes.map((box) {
return Container(
height: 50,
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
padding:
const EdgeInsets.only(left: 5.0, right: 5.0, top: 5.0, bottom: 5.0),
child: Row(
children: [
Container(
width: 33,
child: Checkbox(
value: true, onChanged: (v) {}, activeColor: primaryColor),
),
Expanded(flex: 1, child: Text(box.packageNumber)),
Expanded(
flex: 1,
child: Text(
box.length == null
? ""
: box.length.toString() +
' x ' +
box.length.toString() +
' x ' +
box.height.toString(),
textAlign: TextAlign.center)),
Expanded(
flex: 2,
child: Center(
child: Text(
box.getShipmentWeight(volumetricRatio).toString()))),
],
),
);
}).toList();
dataRow.insert(
0,
Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 5.0, bottom: 15.0),
child: Row(
children: [
Container(width: 33),
Expanded(
flex: 1,
child: Center(
child: LocalText(
context,
"invoice.box.number",
color: Colors.grey,
),
)),
Expanded(
flex: 1,
child: Center(
child: Text('L x W x H',
style: TextStyle(color: Colors.grey)))),
Expanded(
flex: 2,
child: Center(
child: LocalText(
context,
"invoice.shipment_weight",
color: Colors.grey,
),
)),
],
),
));
return dataRow;
}
getCustomFeeRows(BuildContext context) {
customFee = 0;
List<Widget> dataRow = [];
dataRow = customs.map((custom) {
customFee += custom.fee;
return Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
padding:
const EdgeInsets.only(left: 5.0, right: 5.0, top: 5.0, bottom: 5.0),
child: Row(
children: [
Expanded(flex: 2, child: Text('${custom.productType}')),
Expanded(
flex: 1,
child: Text('\$ ${custom.fee}', textAlign: TextAlign.center)),
Expanded(
child: IconButton(
icon: Icon(Icons.remove_circle, color: primaryColor),
onPressed: () {
customs.remove(custom);
}))
],
),
);
}).toList();
dataRow.insert(
0,
Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
child: Row(
children: [
Expanded(
flex: 2,
child: Text('Product', style: TextStyle(color: Colors.grey))),
Expanded(
flex: 1,
child: Text('Fee',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey))),
Expanded(flex: 1, child: Container())
],
),
));
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
child: Row(
children: [
Expanded(
flex: 2,
child: Center(
child: LocalText(
context,
'invoice.total_custom_fee',
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
Expanded(
flex: 1,
child: Center(
child: Text('\$ $customFee',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold)))),
Expanded(
child: Container(),
)
],
),
));
return dataRow;
}
2020-06-26 16:04:40 +06:30
getCargoTableByBox(BuildContext context) {
2020-10-09 19:00:39 +06:30
var discountModel = Provider.of<DiscountModel>(context);
2020-10-13 18:38:00 +06:30
total = 0;
2020-10-09 19:00:39 +06:30
List<Widget> dataRow = _cargoTypes.map((cargo) {
2020-10-15 03:06:13 +06:30
var amount = cargo.weight * cargo.rate;
2020-10-09 19:00:39 +06:30
total += amount;
return Container(
2020-10-13 18:38:00 +06:30
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
2020-10-09 19:00:39 +06:30
padding: const EdgeInsets.only(
2020-10-13 18:38:00 +06:30
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
2020-06-29 16:03:41 +06:30
child: Row(
2020-10-09 19:00:39 +06:30
children: [
2020-10-15 03:06:13 +06:30
Expanded(flex: 2, child: Text('${cargo.name}')),
2020-06-29 16:03:41 +06:30
Expanded(
2020-10-09 19:00:39 +06:30
flex: 2,
2020-10-15 03:06:13 +06:30
child: Text('${cargo.weight} x ${cargo.rate}',
2020-10-09 19:00:39 +06:30
textAlign: TextAlign.center)),
Expanded(
child: Text('\$ $amount',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
)))
],
),
);
}).toList();
dataRow.insert(
0,
Container(
2020-10-13 18:38:00 +06:30
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
2020-10-09 19:00:39 +06:30
child: Row(
children: [
Expanded(
flex: 2,
2020-10-13 18:38:00 +06:30
child: Text(getLocalString(context, 'invoice.box.cargo_type'),
2020-10-09 19:00:39 +06:30
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
2020-10-13 18:38:00 +06:30
color: Colors.grey))),
2020-10-09 19:00:39 +06:30
Expanded(
flex: 2,
child: Text(
getLocalString(context, 'cargo.weight') +
' x ' +
getLocalString(context, 'cargo.rate'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
2020-10-13 18:38:00 +06:30
color: Colors.grey))),
2020-10-09 19:00:39 +06:30
Expanded(
child: Text(getLocalString(context, 'invoice.amount'),
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
2020-10-13 18:38:00 +06:30
color: Colors.grey)))
2020-10-09 19:00:39 +06:30
],
),
));
2020-10-13 18:38:00 +06:30
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
child: Row(
children: [
Expanded(
2020-10-14 20:56:46 +06:30
flex: 1,
child: Container(
alignment: Alignment.centerRight,
2020-10-13 18:38:00 +06:30
child: LocalText(
context,
'invoice.total',
color: Colors.black,
),
),
),
2020-10-14 20:56:46 +06:30
SizedBox(width: 40),
2020-10-13 18:38:00 +06:30
Expanded(
child: Text(
'\$ $total',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
textAlign: TextAlign.end,
))
],
),
));
2020-10-09 19:00:39 +06:30
dataRow.insert(
dataRow.length,
Container(
2020-10-14 20:56:46 +06:30
padding: const EdgeInsets.only(left: 5.0, right: 5.0, top: 0),
2020-10-09 19:00:39 +06:30
child: Row(
children: [
Expanded(
2020-10-14 20:56:46 +06:30
flex: 1,
child: Container(
alignment: Alignment.centerRight,
2020-10-13 18:38:00 +06:30
child: LocalText(
context,
'invoice.discount_value',
color: Colors.black,
2020-10-09 19:00:39 +06:30
),
2020-06-26 16:04:40 +06:30
),
2020-06-29 16:03:41 +06:30
),
2020-10-14 20:56:46 +06:30
new IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () async {
Discount discount = await Navigator.of(context).push(
CupertinoPageRoute(
builder: (context) =>
DiscountList(selected: true)));
setState(() {
if (discount != null) _discount = discount;
});
}),
2020-10-09 19:00:39 +06:30
Expanded(
child: Text(
2020-10-14 20:56:46 +06:30
'\$ ( ${_discount != null ? _discount.amount.toInt() : 0} )',
2020-10-09 19:00:39 +06:30
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
)))
],
),
));
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
2020-10-14 20:56:46 +06:30
left: 5.0, right: 5.0, top: 10.0, bottom: 0.0),
2020-10-09 19:00:39 +06:30
child: Row(
children: [
Expanded(
2020-10-14 20:56:46 +06:30
flex: 1,
child: Container(
alignment: Alignment.centerRight,
child: LocalText(
context,
'invoice.custom_fee',
color: Colors.black,
),
),
),
SizedBox(width: 40),
2020-10-09 19:00:39 +06:30
Expanded(
child: Text('\$ ${customFee}',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
)),
),
],
),
));
2020-10-14 20:56:46 +06:30
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(left: 5.0, right: 5.0, top: 20.0),
child: Row(
children: [
Expanded(
flex: 1,
child: Container(
alignment: Alignment.centerRight,
child: LocalText(
context,
'invoice.handling_fee',
color: Colors.black,
),
),
),
new IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: () async {}),
Expanded(
child: Text('\$ $handlingFee',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
)))
],
),
));
2020-10-09 19:00:39 +06:30
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
2020-10-13 18:38:00 +06:30
left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
2020-10-09 19:00:39 +06:30
child: Row(
children: [
Expanded(
2020-10-13 18:38:00 +06:30
flex: 1,
child: Container(
alignment: Alignment.centerRight,
child: LocalText(
context,
'invoice.delivery_fee',
color: Colors.black,
),
)),
2020-10-09 19:00:39 +06:30
Switch(
value: isSwitched,
onChanged: (value) {
setState(() {
isSwitched = value;
if (value) {
deliveryfee = 5;
} else {
deliveryfee = 0;
}
print(isSwitched);
});
},
activeTrackColor: primaryColor.withOpacity(0.8),
activeColor: primaryColor,
),
Expanded(
child: Text('\$ $deliveryfee',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
)))
],
),
));
2020-10-13 18:38:00 +06:30
2020-10-09 19:00:39 +06:30
dataRow.insert(
dataRow.length,
Container(
child: Row(
children: [
Expanded(child: Text('')),
Expanded(
flex: 2,
child: Divider(
thickness: 3,
)),
2020-06-29 16:03:41 +06:30
],
2020-10-09 19:00:39 +06:30
)));
2020-10-13 18:38:00 +06:30
2020-10-09 19:00:39 +06:30
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
child: Row(
children: [
Expanded(
flex: 2,
2020-10-13 18:38:00 +06:30
child: Center(
child: LocalText(
context,
'invoice.net_amount',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
2020-10-09 19:00:39 +06:30
),
),
Expanded(
2020-10-13 18:38:00 +06:30
child: Text('\$ ${getTotalBalance(total)}',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: primaryColor)))
2020-10-09 19:00:39 +06:30
],
),
));
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
child: Row(
children: [
Expanded(
flex: 2,
2020-10-13 18:38:00 +06:30
child: Center(
child: LocalText(
context,
'invoice.balance',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
2020-10-09 19:00:39 +06:30
),
),
Expanded(
child: Text('\$ ${getTotalBalance(total)}',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: primaryColor)))
],
),
));
return dataRow;
}
getTotalBalance(total) {
double balance = 0;
double custom = customFee != 0 ? customFee.toDouble() : 0;
2020-10-14 20:56:46 +06:30
double discount = _discount != null ? _discount.amount.toDouble() : 0;
2020-10-09 19:00:39 +06:30
double deliveryFee = deliveryfee != 0 ? deliveryfee.toDouble() : 0;
2020-10-14 20:56:46 +06:30
balance = (total + custom + deliveryFee) - discount;
2020-10-09 19:00:39 +06:30
return balance;
2020-06-26 16:04:40 +06:30
}
List<MyDataRow> getBoxRow(BuildContext context) {
return _boxes.map((p) {
2020-06-29 16:03:41 +06:30
p.cargoTypes.map((cargo) {
_cargoTypes.asMap().map((index, _cargo) {
2020-10-15 03:06:13 +06:30
if (_cargo.id == cargo.id) {
2020-06-29 16:03:41 +06:30
setState(() {
_cargoTypes[index].weight += cargo.weight;
});
}
});
});
2020-06-02 14:56:51 +06:30
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
2020-10-09 19:00:39 +06:30
MyDataCell(Checkbox(
value: true,
onChanged: (value) {
selectedBoxes.add(p);
},
)),
2020-06-02 14:56:51 +06:30
MyDataCell(new Text(
2020-06-26 16:04:40 +06:30
p.boxNumber == null
? ""
: '${p.shipmentNumber}-${p.receiverNumber} #${p.boxNumber}',
style: textStyle,
)),
MyDataCell(new Text(
2020-10-09 19:00:39 +06:30
p.length == null
? ""
: p.length.toString() +
' x ' +
p.length.toString() +
' x ' +
p.height.toString(),
2020-06-26 16:04:40 +06:30
style: textStyle,
)),
],
);
}).toList();
}
2020-06-29 16:03:41 +06:30
List<MyDataRow> getCargoDataRow(BuildContext context) {
2020-10-09 19:00:39 +06:30
return _cargoTypes.asMap().entries.map((c) {
var cargo = c.value;
2020-10-15 03:06:13 +06:30
var amt = cargo.weight * cargo.rate;
2020-06-26 16:04:40 +06:30
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
2020-10-15 03:06:13 +06:30
cargo.name,
2020-06-26 16:04:40 +06:30
style: textStyle,
)),
MyDataCell(new Text(
2020-10-15 03:06:13 +06:30
cargo.weight.toString() + ' x ' + cargo.rate.toString(),
2020-06-26 16:04:40 +06:30
style: textStyle,
)),
MyDataCell(new Text(
"\$$amt",
2020-06-02 14:56:51 +06:30
style: textStyle,
)),
],
);
2020-10-09 19:00:39 +06:30
}).toList()
// .insert(_cargoTypes.length,MyDataRow(cells: [
// MyDataCell(new Text('')),
// MyDataCell(new Text('Total')),
// MyDataCell(new Text(
// "\$5000",
// style: textStyle,
// )),
// ])
// )
;
2020-06-02 14:56:51 +06:30
}
}