2020-06-04 01:36:49 +06:30
|
|
|
import 'package:fcs/model/main_model.dart';
|
2020-06-02 14:56:51 +06:30
|
|
|
import 'package:fcs/pages/invoice/package_addition.dart';
|
|
|
|
|
import 'package:fcs/theme/theme.dart';
|
|
|
|
|
import 'package:fcs/vo/invoice.dart';
|
|
|
|
|
import 'package:fcs/vo/package.dart';
|
|
|
|
|
import 'package:fcs/widget/bottom_up_page_route.dart';
|
|
|
|
|
import 'package:fcs/widget/local_text.dart';
|
|
|
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
|
|
|
import 'package:fcs/widget/multi_img_controller.dart';
|
|
|
|
|
import 'package:fcs/widget/multi_img_file.dart';
|
|
|
|
|
import 'package:fcs/widget/my_data_table.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
|
import '../util.dart';
|
|
|
|
|
|
|
|
|
|
class InvoiceEditor extends StatefulWidget {
|
|
|
|
|
final Invoice invoice;
|
|
|
|
|
InvoiceEditor({this.invoice});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_InvoiceEditorState createState() => _InvoiceEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InvoiceEditorState extends State<InvoiceEditor> {
|
|
|
|
|
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();
|
|
|
|
|
MultiImgController multiImgController = MultiImgController();
|
|
|
|
|
|
|
|
|
|
Invoice _invoice;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
List<Package> _packages = [];
|
|
|
|
|
|
|
|
|
|
@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-03 00:42:31 +06:30
|
|
|
_amountController.text = _invoice.getAmount.toString();
|
2020-06-02 14:56:51 +06:30
|
|
|
_statusController.text = _invoice.status.toString();
|
|
|
|
|
_packages = _invoice.packages;
|
|
|
|
|
} else {
|
|
|
|
|
_packages = [
|
|
|
|
|
Package(
|
|
|
|
|
shipmentNumber: "A202",
|
|
|
|
|
receiverNumber: "3",
|
|
|
|
|
boxNumber: "1",
|
|
|
|
|
rate: 7,
|
|
|
|
|
packageType: "General",
|
|
|
|
|
weight: 25,
|
|
|
|
|
status: "Received",
|
|
|
|
|
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
|
|
|
|
arrivedDate: DateTime(2020, 6, 1),
|
|
|
|
|
),
|
|
|
|
|
Package(
|
|
|
|
|
shipmentNumber: "A202",
|
|
|
|
|
receiverNumber: "3",
|
|
|
|
|
boxNumber: "2",
|
|
|
|
|
rate: 7,
|
|
|
|
|
packageType: "General",
|
|
|
|
|
weight: 20,
|
|
|
|
|
status: "Received",
|
|
|
|
|
arrivedDate: DateTime(2020, 6, 1),
|
|
|
|
|
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon'),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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-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>[
|
|
|
|
|
fcsInput('Invoice Date', Icons.date_range,
|
|
|
|
|
controller: _dateController),
|
|
|
|
|
widget.invoice == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _invoiceNumberController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Invoice Number',
|
|
|
|
|
labelStyle:
|
|
|
|
|
TextStyle(fontSize: 16, color: Colors.grey),
|
|
|
|
|
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',
|
|
|
|
|
labelStyle:
|
|
|
|
|
TextStyle(fontSize: 16, color: Colors.grey),
|
|
|
|
|
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',
|
|
|
|
|
labelStyle:
|
2020-06-03 00:42:31 +06:30
|
|
|
TextStyle(fontSize: 16, color: primaryColor),
|
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-02 14:56:51 +06:30
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 0),
|
|
|
|
|
child: fcsInput('Amount', FontAwesomeIcons.moneyBill,
|
|
|
|
|
controller: _amountController),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: fcsInput('Discount', FontAwesomeIcons.tag,
|
|
|
|
|
controller: _discountController),
|
|
|
|
|
),
|
|
|
|
|
widget.invoice == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _statusController,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Status',
|
|
|
|
|
filled: true,
|
2020-06-03 00:42:31 +06:30
|
|
|
icon: Icon(Icons.av_timer,color: primaryColor,),
|
2020-06-02 14:56:51 +06:30
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
ExpansionTile(
|
|
|
|
|
title: Text('Payment Attachment'),
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 20),
|
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
|
LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"invoice.payment",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
MultiImageFile(
|
|
|
|
|
enabled: true,
|
|
|
|
|
controller: multiImgController,
|
|
|
|
|
title: "Receipt File",
|
|
|
|
|
)
|
|
|
|
|
])),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 25,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
ExpansionTile(
|
2020-06-04 01:36:49 +06:30
|
|
|
title: Text('Box Information'),
|
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,
|
|
|
|
|
"package.number",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"package.rate",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"package.weight",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"package.amount",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
rows: getPackageRow(context),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-06-04 01:36:49 +06:30
|
|
|
mainModel.isOwner()?Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 20),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
|
child: FloatingActionButton.extended(
|
|
|
|
|
icon: Icon(Icons.add),
|
|
|
|
|
label: Text(AppTranslations.of(context)
|
2020-06-04 01:36:49 +06:30
|
|
|
.text("invoice.add_box")),
|
2020-06-02 14:56:51 +06:30
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(BottomUpPageRoute(PackageAddition()));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-06-04 01:36:49 +06:30
|
|
|
):Container(),
|
2020-06-02 14:56:51 +06:30
|
|
|
SizedBox(height: 25),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
)),
|
|
|
|
|
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-04 01:36:49 +06:30
|
|
|
:mainModel.isCustomer()?Container():Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
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
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MyDataRow> getPackageRow(BuildContext context) {
|
|
|
|
|
return _packages.map((p) {
|
|
|
|
|
return MyDataRow(
|
|
|
|
|
onSelectChanged: (bool selected) {},
|
|
|
|
|
cells: [
|
|
|
|
|
MyDataCell(new Text(
|
|
|
|
|
p.packageNumber == null ? "" : p.packageNumber,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
MyDataCell(
|
|
|
|
|
new Text(p.rate.toString(), style: textStyle),
|
|
|
|
|
),
|
|
|
|
|
MyDataCell(
|
|
|
|
|
new Text("${p.weight.toString()} lb", style: textStyle),
|
|
|
|
|
),
|
|
|
|
|
MyDataCell(
|
|
|
|
|
new Text(p.price == null ? "" : "\$ " + p.price.toString(),
|
|
|
|
|
style: textStyle),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
}
|