2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/box.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/cargo.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/invoice.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/payment_method.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/localization/app_translations.dart';
|
|
|
|
|
import 'package:fcs/pages/discount/model/discount_model.dart';
|
|
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
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-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;
|
|
|
|
|
InvoiceEditor({this.invoice});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_InvoiceEditorState createState() => _InvoiceEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InvoiceEditorState extends State<InvoiceEditor> {
|
2020-10-07 02:33:06 +06:30
|
|
|
List<PaymentMethod> get paymentMethods {
|
|
|
|
|
List<PaymentMethod> methods = [
|
|
|
|
|
PaymentMethod(
|
|
|
|
|
name: 'AYA Bank',
|
|
|
|
|
accountName: 'FCS',
|
|
|
|
|
account: '100 23404320548398',
|
|
|
|
|
phone: '+959123456789',
|
|
|
|
|
),
|
|
|
|
|
PaymentMethod(
|
|
|
|
|
name: 'KBZ Bank',
|
|
|
|
|
accountName: 'FCS',
|
|
|
|
|
account: '100 23404320548398',
|
|
|
|
|
phone: '+959123456789',
|
|
|
|
|
),
|
|
|
|
|
PaymentMethod(
|
|
|
|
|
name: 'PayPal',
|
|
|
|
|
accountName: 'FCS',
|
|
|
|
|
link: 'https://www.paypal.com/donate/buttons',
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
return methods;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
String deliveryfee = '\$0';
|
2020-06-29 16:03:41 +06:30
|
|
|
List<Cargo> _cargoTypes = [
|
|
|
|
|
Cargo(type: 'General Cargo', weight: 33, price: 6),
|
|
|
|
|
Cargo(type: 'Medicine', weight: 33, price: 7),
|
|
|
|
|
Cargo(type: 'Dangerous Cargo', weight: 33, price: 8)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
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-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: [
|
|
|
|
|
Cargo(type: 'General Cargo', weight: 25),
|
|
|
|
|
Cargo(type: 'Medicine', weight: 20),
|
|
|
|
|
Cargo(type: 'Dangerous Cargo', weight: 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: [
|
|
|
|
|
Cargo(type: 'General Cargo', weight: 25),
|
|
|
|
|
Cargo(type: 'Medicine', weight: 20),
|
|
|
|
|
Cargo(type: 'Dangerous Cargo', weight: 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-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(
|
|
|
|
|
icon: new Icon(Icons.close),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: LocalText(context, 'invoice.form.title',
|
|
|
|
|
color: Colors.white, fontSize: 20),
|
|
|
|
|
),
|
|
|
|
|
body: Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: ListView(children: <Widget>[
|
2020-06-29 16:03:41 +06:30
|
|
|
TextFormField(
|
|
|
|
|
controller: _dateController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Invoice Date',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.date_range,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
)),
|
2020-06-02 14:56:51 +06:30
|
|
|
widget.invoice == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _invoiceNumberController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Invoice Number',
|
2020-06-29 16:03:41 +06:30
|
|
|
labelStyle: TextStyle(
|
2020-08-30 21:26:37 +06:30
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
2020-06-03 00:42:31 +06:30
|
|
|
FontAwesomeIcons.fileInvoice,
|
|
|
|
|
color: primaryColor,
|
2020-06-02 14:56:51 +06:30
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
widget.invoice == null
|
|
|
|
|
? Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
2020-06-03 00:42:31 +06:30
|
|
|
initialValue: "Ko Myo Min",
|
2020-06-02 14:56:51 +06:30
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Customer Name',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
filled: true,
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(
|
|
|
|
|
color: Colors.grey, width: 1.0)),
|
|
|
|
|
icon: Icon(
|
2020-06-03 00:42:31 +06:30
|
|
|
FontAwesomeIcons.fileInvoice,
|
|
|
|
|
color: primaryColor,
|
2020-06-02 14:56:51 +06:30
|
|
|
),
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.search,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {})),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
widget.invoice == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 0),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _nameController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Customer Name',
|
2020-06-26 16:04:40 +06:30
|
|
|
labelStyle: TextStyle(
|
2020-08-30 21:26:37 +06:30
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
2020-06-03 00:42:31 +06:30
|
|
|
Feather.user,
|
|
|
|
|
color: primaryColor,
|
2020-06-02 14:56:51 +06:30
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
2020-06-03 00:42:31 +06:30
|
|
|
// widget.invoice == null
|
|
|
|
|
// ? Container()
|
|
|
|
|
// : TextFormField(
|
|
|
|
|
// controller: _phoneController,
|
|
|
|
|
// readOnly: true,
|
|
|
|
|
// decoration: InputDecoration(
|
|
|
|
|
// fillColor: Colors.white,
|
|
|
|
|
// labelText: 'Customer Phone Number',
|
|
|
|
|
// labelStyle:
|
|
|
|
|
// TextStyle(fontSize: 16, color: Colors.grey),
|
|
|
|
|
// filled: true,
|
|
|
|
|
// enabledBorder: InputBorder.none,
|
|
|
|
|
// focusedBorder: InputBorder.none,
|
|
|
|
|
// icon: Icon(
|
|
|
|
|
// Icons.phone,
|
|
|
|
|
// color: Colors.grey,
|
|
|
|
|
// ),
|
|
|
|
|
// )),
|
2020-06-26 16:04:40 +06:30
|
|
|
// Container(
|
|
|
|
|
// padding: EdgeInsets.only(top: 0),
|
|
|
|
|
// child: fcsInput('Amount', FontAwesomeIcons.moneyBill,
|
|
|
|
|
// controller: _amountController),
|
|
|
|
|
// ),
|
|
|
|
|
|
2020-06-02 14:56:51 +06:30
|
|
|
widget.invoice == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _statusController,
|
2020-06-26 16:04:40 +06:30
|
|
|
readOnly: true,
|
2020-06-02 14:56:51 +06:30
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Status',
|
2020-06-26 16:04:40 +06:30
|
|
|
labelStyle: TextStyle(
|
2020-08-30 21:26:37 +06:30
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
filled: true,
|
2020-06-26 16:04:40 +06:30
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.av_timer,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
)),
|
|
|
|
|
),
|
2020-06-26 16:04:40 +06:30
|
|
|
|
2020-06-29 16:03:41 +06:30
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 0),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _amountController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Amount',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
FontAwesomeIcons.moneyBill,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _balanceController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Balance',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
FontAwesomeIcons.moneyBill,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _handlingFeeController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Handling Fee',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
FontAwesomeIcons.moneyBill,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _customFeeController,
|
|
|
|
|
readOnly: false,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Customs Fee',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
filled: true,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
FontAwesomeIcons.moneyBill,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide:
|
|
|
|
|
BorderSide(color: Colors.grey, width: 1.0)),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _descriptionController,
|
|
|
|
|
readOnly: false,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Customs Fee Description',
|
2020-08-30 21:26:37 +06:30
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
filled: true,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.comment,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide:
|
|
|
|
|
BorderSide(color: Colors.grey, width: 1.0)),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
|
2020-06-26 16:04:40 +06:30
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 20, left: 18),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
2020-06-29 16:03:41 +06:30
|
|
|
child: Text(
|
|
|
|
|
'Discounts',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
)),
|
2020-06-26 16:04:40 +06:30
|
|
|
Container(
|
|
|
|
|
width: 150.0,
|
|
|
|
|
child: DropdownButtonFormField(
|
|
|
|
|
items: discountModel.discounts
|
|
|
|
|
.map((e) => DropdownMenuItem(
|
|
|
|
|
child: Text(e.code), value: e.code))
|
|
|
|
|
.toList(),
|
|
|
|
|
onChanged: (selected) => {},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5, left: 18),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
2020-06-29 16:03:41 +06:30
|
|
|
child: Text(
|
|
|
|
|
'Payment Method',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
)),
|
2020-06-26 16:04:40 +06:30
|
|
|
Container(
|
|
|
|
|
width: 150.0,
|
|
|
|
|
child: DropdownButtonFormField(
|
2020-10-07 02:33:06 +06:30
|
|
|
items: paymentMethods
|
2020-06-26 16:04:40 +06:30
|
|
|
.map((e) => DropdownMenuItem(
|
|
|
|
|
child: Text(e.name), value: e.name))
|
|
|
|
|
.toList(),
|
|
|
|
|
onChanged: (selected) => {},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 18.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
'Delivery fee:',
|
2020-06-29 16:03:41 +06:30
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
2020-06-26 16:04:40 +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,
|
|
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
Text(
|
|
|
|
|
'(Delivery fee : $deliveryfee)',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
2020-06-26 16:04:40 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
SizedBox(
|
2020-06-26 16:04:40 +06:30
|
|
|
height: 10,
|
2020-06-02 14:56:51 +06:30
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
|
2020-06-02 14:56:51 +06:30
|
|
|
ExpansionTile(
|
2020-06-29 16:03:41 +06:30
|
|
|
title: Text(
|
|
|
|
|
'Payment Attachment',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
children: <Widget>[
|
2020-06-29 16:03:41 +06:30
|
|
|
widget.invoice != null
|
|
|
|
|
? Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
|
child: Text(
|
|
|
|
|
'${dateFormatter.format(_invoice.receipts[0].date)} ',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black, fontSize: 16),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 10),
|
|
|
|
|
child: MultiImageFile(
|
|
|
|
|
enabled: false,
|
|
|
|
|
controller: multiImgController,
|
|
|
|
|
title: "Receipt",
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 10, left: 10),
|
|
|
|
|
child: Text(
|
|
|
|
|
'\$${_invoice.receipts[0].amount} ',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black, fontSize: 16),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
)
|
2020-06-29 16:03:41 +06:30
|
|
|
: Container(),
|
2020-06-02 14:56:51 +06:30
|
|
|
SizedBox(
|
|
|
|
|
height: 25,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
ExpansionTile(
|
2020-06-29 16:03:41 +06:30
|
|
|
title: Text(
|
|
|
|
|
'Box Information',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
2020-06-02 14:56:51 +06:30
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
child: MyDataTable(
|
|
|
|
|
headingRowHeight: 40,
|
|
|
|
|
columnSpacing: 20,
|
|
|
|
|
columns: [
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
2020-06-26 16:04:40 +06:30
|
|
|
"box.number",
|
2020-06-02 14:56:51 +06:30
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
2020-06-26 16:04:40 +06:30
|
|
|
"box.length",
|
2020-06-02 14:56:51 +06:30
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
2020-06-26 16:04:40 +06:30
|
|
|
"box.width",
|
2020-06-02 14:56:51 +06:30
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
2020-06-26 16:04:40 +06:30
|
|
|
"box.height",
|
2020-06-02 14:56:51 +06:30
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2020-06-26 16:04:40 +06:30
|
|
|
rows: getBoxRow(context),
|
2020-06-02 14:56:51 +06:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-10-07 02:33:06 +06:30
|
|
|
true
|
2020-06-26 16:04:40 +06:30
|
|
|
? Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 20),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
|
child: FloatingActionButton.extended(
|
|
|
|
|
icon: Icon(Icons.add),
|
|
|
|
|
label: Text(AppTranslations.of(context)
|
|
|
|
|
.text("invoice.add_box")),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(BottomUpPageRoute(BoxAddition()));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
2020-06-02 14:56:51 +06:30
|
|
|
SizedBox(height: 25),
|
|
|
|
|
],
|
|
|
|
|
),
|
2020-06-26 16:04:40 +06:30
|
|
|
|
|
|
|
|
//Cargo Table
|
|
|
|
|
ExpansionTile(
|
2020-06-29 16:03:41 +06:30
|
|
|
title: Text(
|
|
|
|
|
'Cargo Table',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
child: MyDataTable(
|
|
|
|
|
headingRowHeight: 40,
|
|
|
|
|
columnSpacing: 20,
|
|
|
|
|
columns: [
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.type",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.weight",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.rate",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.amount",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
rows: getCargoDataRow(context)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
]),
|
2020-06-02 14:56:51 +06:30
|
|
|
]),
|
|
|
|
|
)),
|
|
|
|
|
widget.invoice == null
|
|
|
|
|
? Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
|
|
|
|
child: Text('Create invoice'),
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)))
|
2020-06-26 16:04:40 +06:30
|
|
|
: mainModel.isCustomer()
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
|
|
|
|
child: Text('Save invoice'),
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
],
|
|
|
|
|
)),
|
2020-06-02 15:30:11 +06:30
|
|
|
widget.invoice == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
2020-06-04 01:36:49 +06:30
|
|
|
child: Text('Attach Payment Receipt'),
|
2020-06-02 15:30:11 +06:30
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)))
|
2020-06-02 14:56:51 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 16:04:40 +06:30
|
|
|
getCargoTableByBox(BuildContext context) {
|
2020-06-29 16:03:41 +06:30
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.all(5.0),
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: Colors.grey[100],
|
|
|
|
|
width: 1,
|
2020-06-26 16:04:40 +06:30
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
child: MyDataTable(
|
2020-06-26 16:04:40 +06:30
|
|
|
headingRowHeight: 40,
|
|
|
|
|
columnSpacing: 20,
|
|
|
|
|
columns: [
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.type",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.weight",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.rate",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.amount",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2020-06-29 16:03:41 +06:30
|
|
|
rows: getCargoDataRow(context)),
|
2020-06-26 16:04:40 +06:30
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
2020-06-26 16:04:40 +06:30
|
|
|
),
|
2020-06-29 16:03:41 +06:30
|
|
|
),
|
|
|
|
|
);
|
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) {
|
|
|
|
|
print('cargo => $cargo');
|
|
|
|
|
_cargoTypes.asMap().map((index, _cargo) {
|
|
|
|
|
if (_cargo.type == cargo.type) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_cargoTypes[index].weight += cargo.weight;
|
|
|
|
|
});
|
|
|
|
|
print('${_cargoTypes[index].type} =>${_cargoTypes[index]}');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2020-06-02 14:56:51 +06:30
|
|
|
return MyDataRow(
|
|
|
|
|
onSelectChanged: (bool selected) {},
|
|
|
|
|
cells: [
|
|
|
|
|
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(
|
|
|
|
|
p.length == null ? "" : p.length.toString(),
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
MyDataCell(new Text(
|
|
|
|
|
p.width == null ? "" : p.width.toString(),
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
MyDataCell(new Text(
|
|
|
|
|
p.height == null ? "" : p.height.toString(),
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-29 16:03:41 +06:30
|
|
|
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
|
|
|
|
return _cargoTypes.map((cargo) {
|
|
|
|
|
var amt = cargo.weight * cargo.price;
|
2020-06-26 16:04:40 +06:30
|
|
|
return MyDataRow(
|
|
|
|
|
onSelectChanged: (bool selected) {},
|
|
|
|
|
cells: [
|
|
|
|
|
MyDataCell(new Text(
|
2020-06-29 16:03:41 +06:30
|
|
|
cargo.type,
|
2020-06-26 16:04:40 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
MyDataCell(new Text(
|
2020-06-29 16:03:41 +06:30
|
|
|
cargo.weight.toString(),
|
2020-06-26 16:04:40 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
MyDataCell(new Text(
|
2020-06-29 16:03:41 +06:30
|
|
|
'\$${cargo.price}',
|
2020-06-26 16:04:40 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
MyDataCell(new Text(
|
|
|
|
|
"\$$amt",
|
2020-06-02 14:56:51 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
}
|