diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index 537ccb5..abba310 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -308,6 +308,26 @@ "invoice.payment":"Payment Receipt", "invoice.add_box":"Add Box", "invoice.add_package":"Add Package", + "invoice.date":"Invoice Date", + "invoice.number":"Invoice Number", + "invoice.customer_name":"Customer Name", + "invoice.status":"Status", + "invoice.amount":"Amount", + "invoice.total":"Total Amount", + "invoice.balance":"Balance", + "invoice.handling_fee":"Handling Fee", + "invoice.custom_fee":"Custom Fee", + "invoice.custom_fee_desc":"Custom Fee Description", + "invoice.discount":"Discounts", + "invoice.payment_method":"Payment Method", + "invoice.delivery_fee":"Delivery Fee : ", + "invoice.payment_attachment":"Payment Attachment", + "invoice.box_info":"Box Information", + "invoice.cargo_table":"Cargo Table", + "invoice.btn_create":"Create Invoice", + "invoice.btn_save":"Save Invoice", + "invoice.btn_payment_receipt":"Attachment Payment Receipt", + "invoice.description": "Description", "Invoices End ================================================================":"", "Discount Start ================================================================":"", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 7b64f6f..401b018 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -230,10 +230,10 @@ "box.package.desc":"Description", "box.package.market":"Market", "box.add_package":"Add Package", - "box.number":"Box Number", - "box.length":"Length", - "box.width":"Width", - "box.height":"Height", + "box.number":"Box နံပါတ်", + "box.length":"အလျား", + "box.width":"အနံ", + "box.height":"အမြင့်", "Boxes End ================================================================":"", "Delivery Start ================================================================":"", @@ -307,7 +307,27 @@ "invoice.form.title":"ငွေတောင်းခံလွှာ", "invoice.payment":"လက်ခံဖြတ်ပိုင်း", "invoice.add_package":"Add Package", - "invoice.add_box":"Add Box", + "invoice.add_box":"Box အသစ်", + "invoice.date":"ငွေတောင်းခံလွှာ ရက်စွဲ", + "invoice.number":"ငွေတောင်းခံလွှာ နံပါတ်", + "invoice.customer_name":"ဝယ်ယူသူနာမည်", + "invoice.status":"အခြေအနေ", + "invoice.amount":"ပမာဏ", + "invoice.total":"စုစုပေါင်းပမာဏ", + "invoice.balance":"ပေးချေရန်ကျန်ရှိငွေ", + "invoice.handling_fee":"ထိန်းသိမ်းခ", + "invoice.custom_fee":"ကုန်သွယ်ခွန်", + "invoice.custom_fee_desc":"ကုန်သွယ်ခွန်အကြောင်းအရာ", + "invoice.discount":"လျှော့စျေး : ", + "invoice.payment_method":"ငွေပေးချေစနစ်", + "invoice.delivery_fee":"ပို့ဆောင်ခ", + "invoice.payment_attachment":"ပေးချေပြီးဖိုင်များ", + "invoice.box_info":"Box အချက်အလက်", + "invoice.cargo_table":"ကုန်ပစ္စည်းဇယား", + "invoice.btn_create":"ငွေတောင်းခံလွှာ ပြုလုပ်ရန်", + "invoice.btn_save":"ငွေတောင်းခံလွှာ သိမ်းရန်", + "invoice.btn_payment_receipt":"ငွေလက်ခံဖြတ်ပိုင်း ထည့်ရန်", + "invoice.description": "အကြောင်းအရာ", "Invoices End ================================================================":"", "Discount Start ================================================================":"", diff --git a/lib/pages/invoice/invoce_list.dart b/lib/pages/invoice/invoce_list.dart index 6fd64d0..0133dfc 100644 --- a/lib/pages/invoice/invoce_list.dart +++ b/lib/pages/invoice/invoce_list.dart @@ -1,6 +1,10 @@ +import 'package:fcs/domain/entities/package.dart'; +import 'package:fcs/domain/entities/user.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/localization/app_translations.dart'; import 'package:fcs/pages/invoice/model/invoice_model.dart'; +import 'package:fcs/pages/package_search/package_serach.dart'; +import 'package:fcs/pages/user_search/user_serach.dart'; import 'package:fcs/pages/widgets/bottom_up_page_route.dart'; import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/progress.dart'; @@ -31,6 +35,7 @@ class _InvoiceListState extends State { @override Widget build(BuildContext context) { var owner = true; + var invoiceModel = Provider.of(context); return LocalProgress( inAsyncCall: _isLoading, @@ -48,21 +53,9 @@ class _InvoiceListState extends State { color: Colors.white, fontSize: 20), actions: [ IconButton( - icon: Icon( - Icons.search, - color: Colors.white, - ), - iconSize: 30, - // onPressed: () => showPlacesSearch(context), - ), + icon: Icon(Icons.search, color: Colors.white), + onPressed: () {}), ], - bottom: TabBar( - unselectedLabelColor: Colors.grey, - tabs: [ - Tab(text: "Pending"), - Tab(text: "Paid"), - ], - ), ), floatingActionButton: owner ? FloatingActionButton.extended( @@ -71,12 +64,27 @@ class _InvoiceListState extends State { }, icon: Icon(Icons.add), label: - Text(AppTranslations.of(context).text("invoices.add")), + LocalText(context, 'invoices.add', color: Colors.white), backgroundColor: primaryColor, ) : null, - body: TabBarView( - children: [_pending(), _paided()], + body: Column( + children: [ + Expanded( + child: new ListView.separated( + separatorBuilder: (context, index) => Divider( + color: Colors.black, + ), + scrollDirection: Axis.vertical, + padding: EdgeInsets.only(top: 15), + shrinkWrap: true, + itemCount: invoiceModel.invoices.length, + itemBuilder: (BuildContext context, int index) { + return InvoiceListRow( + invoice: invoiceModel.invoices[index]); + }), + ), + ], )), ), ); diff --git a/lib/pages/invoice/invoice_editor.dart b/lib/pages/invoice/invoice_editor.dart index abf7415..63aa5dc 100644 --- a/lib/pages/invoice/invoice_editor.dart +++ b/lib/pages/invoice/invoice_editor.dart @@ -1,12 +1,19 @@ import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/cargo.dart'; +import 'package:fcs/domain/entities/discount.dart'; import 'package:fcs/domain/entities/invoice.dart'; import 'package:fcs/domain/entities/payment_method.dart'; +import 'package:fcs/domain/entities/user.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/language_model.dart'; import 'package:fcs/pages/main/model/main_model.dart'; +import 'package:fcs/pages/main/util.dart'; +import 'package:fcs/pages/user_search/user_serach.dart'; import 'package:fcs/pages/widgets/bottom_up_page_route.dart'; +import 'package:fcs/pages/widgets/display_text.dart'; +import 'package:fcs/pages/widgets/input_text.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'; @@ -29,6 +36,8 @@ class InvoiceEditor extends StatefulWidget { } class _InvoiceEditorState extends State { + User user; + List get paymentMethods { List methods = [ PaymentMethod( @@ -70,7 +79,13 @@ class _InvoiceEditorState extends State { bool _isLoading = false; List _boxes = []; bool isSwitched = false; - String deliveryfee = '\$0'; + int deliveryfee = 0; + int customFee = 10; + double total = 0; + Discount _discount; + + List selectedBoxes = []; + List _cargoTypes = [ Cargo(type: 'General Cargo', weight: 33, price: 6), Cargo(type: 'Medicine', weight: 33, price: 7), @@ -166,6 +181,7 @@ class _InvoiceEditorState extends State { Widget build(BuildContext context) { var mainModel = Provider.of(context); var discountModel = Provider.of(context); + var languageModel = Provider.of(context); return LocalProgress( inAsyncCall: _isLoading, @@ -173,12 +189,13 @@ class _InvoiceEditorState extends State { appBar: AppBar( centerTitle: true, leading: new IconButton( - icon: new Icon(Icons.close), + icon: new Icon(Icons.close, color: primaryColor), onPressed: () => Navigator.of(context).pop(), ), - backgroundColor: primaryColor, + backgroundColor: Colors.white, + shadowColor: Colors.transparent, title: LocalText(context, 'invoice.form.title', - color: Colors.white, fontSize: 20), + color: primaryColor, fontSize: 20), ), body: Card( child: Column( @@ -187,288 +204,112 @@ class _InvoiceEditorState extends State { child: Padding( padding: const EdgeInsets.all(10.0), child: ListView(children: [ - TextFormField( - controller: _dateController, - readOnly: true, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Invoice Date', - labelStyle: TextStyle( - fontSize: 16, - ), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - Icons.date_range, - color: primaryColor, - ), - )), + DisplayText( + labelTextKey: 'invoice.date', + iconData: Icons.date_range, + text: _dateController.text), 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, - ), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - FontAwesomeIcons.fileInvoice, - color: primaryColor, - ), - )), - ), + : DisplayText( + labelTextKey: 'invoice.number', + iconData: FontAwesomeIcons.fileInvoice, + text: _invoiceNumberController.text), + widget.invoice == null - ? Container( - padding: EdgeInsets.only(top: 5), - child: TextFormField( - initialValue: "Ko Myo Min", - cursorColor: primaryColor, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Customer Name', - labelStyle: TextStyle( - fontSize: 16, - ), - filled: true, - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Colors.grey, width: 1.0)), - icon: Icon( - FontAwesomeIcons.fileInvoice, - color: primaryColor, - ), - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.grey, - ), - onPressed: () {})), - ), + ? Row( + children: [ + Expanded( + child: DisplayText( + text: user != null ? user.name : "Myo Min", + labelTextKey: "invoice.customer_name", + iconData: Feather.user, + )), + IconButton( + icon: Icon(Icons.search, color: primaryColor), + onPressed: () => searchUser(context, + callbackUserSelect: (u) { + setState(() { + this.user = u; + }); + })), + ], ) - : 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: TextStyle( - fontSize: 16, - ), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - Feather.user, - color: primaryColor, - ), - )), - ), - // 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, - // ), - // )), - // Container( - // padding: EdgeInsets.only(top: 0), - // child: fcsInput('Amount', FontAwesomeIcons.moneyBill, - // controller: _amountController), - // ), + : DisplayText( + text: _nameController.text, + iconData: Feather.user, + labelTextKey: 'invoice.customer_name'), widget.invoice == null ? Container() - : Container( - padding: EdgeInsets.only(top: 5), - child: TextFormField( - controller: _statusController, - readOnly: true, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Status', - labelStyle: TextStyle( - fontSize: 16, - ), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - Icons.av_timer, - color: primaryColor, - ), - )), - ), + : DisplayText( + text: _statusController.text, + iconData: Icons.av_timer, + labelTextKey: 'invoice.status'), - Container( - padding: EdgeInsets.only(top: 0), - child: TextFormField( - controller: _amountController, - readOnly: true, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Amount', - labelStyle: TextStyle( - fontSize: 16, - ), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - FontAwesomeIcons.moneyBill, - color: primaryColor, - ), - )), - ), + SizedBox(height: 15), + LocalText(context, 'invoice.box_info', + color: primaryColor, + fontWeight: FontWeight.bold, + fontSize: 16.0), Container( - padding: EdgeInsets.only(top: 5), - child: TextFormField( - controller: _balanceController, - readOnly: true, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Balance', - labelStyle: TextStyle( - fontSize: 16, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: MyDataTable( + headingRowHeight: 40, + columnSpacing: 20, + columns: [ + MyDataColumn( + label: Text(''), ), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - FontAwesomeIcons.moneyBill, - color: primaryColor, + MyDataColumn( + label: LocalText( + context, + "box.number", + color: Colors.grey, + ), ), - )), - ), - - Container( - padding: EdgeInsets.only(top: 5), - child: TextFormField( - controller: _handlingFeeController, - readOnly: true, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Handling Fee', - labelStyle: TextStyle( - fontSize: 16, + MyDataColumn( + label: Text( + getLocalString(context, "box.length") + + ' x ' + + getLocalString(context, "box.width") + + ' x ' + + getLocalString(context, "box.height"), + ), ), - 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', - labelStyle: TextStyle( - fontSize: 16, - ), - 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', - labelStyle: TextStyle( - fontSize: 16, - ), - filled: true, - icon: Icon( - Icons.comment, - color: primaryColor, - ), - focusedBorder: UnderlineInputBorder( - borderSide: - BorderSide(color: Colors.grey, width: 1.0)), - )), - ), - - Container( - padding: EdgeInsets.only(top: 20, left: 18), - child: Row( - children: [ - Expanded( - child: Text( - 'Discounts', - style: TextStyle( - fontSize: 16, - color: primaryColor, - fontWeight: FontWeight.bold), - )), - Container( - width: 150.0, - child: DropdownButtonFormField( - items: discountModel.discounts - .map((e) => DropdownMenuItem( - child: Text(e.code), value: e.code)) - .toList(), - onChanged: (selected) => {}, - ), - ), - ], + ], + rows: getBoxRow(context), + ), ), ), + SizedBox(height: 25), + + Divider(thickness: 1), + + SizedBox(height: 15), + + Container( + child: Column(children: getCargoTableByBox(context)), + ), + + Divider(thickness: 1), + + // InputText( + // controller: _handlingFeeController, + // iconData: FontAwesomeIcons.moneyBill, + // labelTextKey: 'invoice.handling_fee'), + Container( padding: EdgeInsets.only(top: 5, left: 18), child: Row( children: [ Expanded( - child: Text( - 'Payment Method', - style: TextStyle( - fontSize: 16, - color: primaryColor, - fontWeight: FontWeight.bold), - )), + child: LocalText(context, 'invoice.payment_method', + fontSize: 16, + color: primaryColor, + fontWeight: FontWeight.bold)), Container( width: 150.0, child: DropdownButtonFormField( @@ -482,266 +323,115 @@ class _InvoiceEditorState extends State { ], ), ), - Container( - padding: EdgeInsets.only(top: 5), - child: Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 18.0), - child: Text( - 'Delivery fee:', - style: TextStyle( - fontSize: 16, - color: primaryColor, - fontWeight: FontWeight.bold), - ), - )), - Switch( - value: isSwitched, - onChanged: (value) { - setState(() { - isSwitched = value; - if (value) { - deliveryfee = '\$5'; - } else { - deliveryfee = '\$0'; - } - print(isSwitched); - }); - }, - activeTrackColor: primaryColor.withOpacity(0.8), - activeColor: primaryColor, - ), - Text( - '(Delivery fee : $deliveryfee)', - style: TextStyle( - color: primaryColor, fontWeight: FontWeight.bold), - ), - ], - ), - ), - SizedBox( - height: 10, - ), + // Container( + // padding: EdgeInsets.only(top: 5), + // child: Row( + // children: [ + // Expanded( + // child: Padding( + // padding: const EdgeInsets.only(left: 18.0), + // child: LocalText(context, 'invoice.delivery_fee', + // fontSize: 16, + // color: primaryColor, + // fontWeight: FontWeight.bold), + // )), + // Switch( + // value: isSwitched, + // onChanged: (value) { + // setState(() { + // isSwitched = value; + // if (value) { + // deliveryfee = 5; + // } else { + // deliveryfee = 0; + // } + // print(isSwitched); + // }); + // }, + // activeTrackColor: primaryColor.withOpacity(0.8), + // activeColor: primaryColor, + // ), + // Text( + // '(' + + // getLocalString(context, 'invoice.delivery_fee') + + // ' $deliveryfee)', + // style: TextStyle( + // color: primaryColor, + // fontWeight: FontWeight.bold, + // fontSize: 12), + // ), + // ], + // ), + // ), + // SizedBox( + // height: 10, + // ), - ExpansionTile( - title: Text( - 'Payment Attachment', - style: TextStyle( - color: primaryColor, fontWeight: FontWeight.bold), - ), - children: [ - widget.invoice != null - ? Padding( - padding: EdgeInsets.only(left: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 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), - ), - ), - ], - ), - ) - : Container(), - SizedBox( - height: 25, - ), - ], - ), - ExpansionTile( - title: Text( - 'Box Information', - style: TextStyle( - color: primaryColor, fontWeight: FontWeight.bold), - ), - children: [ - Container( - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: MyDataTable( - headingRowHeight: 40, - columnSpacing: 20, - columns: [ - MyDataColumn( - label: LocalText( - context, - "box.number", - color: Colors.grey, - ), - ), - MyDataColumn( - label: LocalText( - context, - "box.length", - color: Colors.grey, - ), - ), - MyDataColumn( - label: LocalText( - context, - "box.width", - color: Colors.grey, - ), - ), - MyDataColumn( - label: LocalText( - context, - "box.height", - color: Colors.grey, - ), - ), - ], - rows: getBoxRow(context), - ), - ), - ), - true - ? 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(), - SizedBox(height: 25), - ], - ), - - //Cargo Table - ExpansionTile( - title: Text( - 'Cargo Table', - style: TextStyle( - color: primaryColor, fontWeight: FontWeight.bold), - ), - children: [ - 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)), - ), - ), - ]), + // ExpansionTile( + // title: LocalText(context, 'invoice.payment_attachment', + // color: primaryColor, + // fontWeight: FontWeight.bold, + // fontSize: 16.0), + // children: [ + // widget.invoice != null + // ? Padding( + // padding: EdgeInsets.only(left: 20), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Container( + // padding: EdgeInsets.only(top: 10), + // child: Text( + // '${dateFormatter.format(_invoice.receipts[0].date)} ', + // style: TextStyle( + // color: Colors.black, fontSize: 16), + // ), + // ), + // Expanded( + // child: 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), + // ), + // ), + // ], + // ), + // ) + // : Container(), + // 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); - }, - ), - ))) + ? fcsButton( + context, getLocalString(context, 'invoice.btn_create')) : mainModel.isCustomer() ? Container() : Container( child: Column( children: [ - 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); - }, - ), - ))), + fcsButton(context, + getLocalString(context, 'invoice.btn_save')) ], )), widget.invoice == null ? Container() - : Align( - alignment: Alignment.bottomCenter, - child: Center( - child: Container( - width: 250, - child: FlatButton( - child: Text('Attach Payment Receipt'), - color: primaryColor, - textColor: Colors.white, - onPressed: () { - Navigator.pop(context); - }, - ), - ))) + : fcsButton(context, + getLocalString(context, 'invoice.btn_payment_receipt')) ], ), ), @@ -750,62 +440,251 @@ class _InvoiceEditorState extends State { } getCargoTableByBox(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(5.0), - child: Container( - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey[100], - width: 1, - ), - ), + var discountModel = Provider.of(context); + + List dataRow = _cargoTypes.map((cargo) { + var amount = cargo.weight * cargo.price; + total += amount; + return Container( + padding: const EdgeInsets.only( + left: 5.0, right: 5.0, top: 10.0, bottom: 10.0), child: Row( - children: [ + children: [ + Expanded(flex: 2, child: Text('${cargo.type}')), Expanded( - child: 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)), - ), - ), - ) + flex: 2, + child: Text('${cargo.weight} x ${cargo.price}', + textAlign: TextAlign.center)), + Expanded( + child: Text('\$ $amount', + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ))) ], ), - ), - ); + ); + }).toList(); + dataRow.insert( + 0, + Container( + padding: const EdgeInsets.all(5.0), + child: Row( + children: [ + Expanded( + flex: 2, + child: Text(getLocalString(context, 'invoice.description'), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: primaryColor))), + Expanded( + flex: 2, + child: Text( + getLocalString(context, 'cargo.weight') + + ' x ' + + getLocalString(context, 'cargo.rate'), + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: primaryColor))), + Expanded( + child: Text(getLocalString(context, 'invoice.amount'), + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: primaryColor))) + ], + ), + )); + 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, + child: Text(getLocalString(context, 'invoice.discount'))), + Expanded( + child: Container( + width: 80.0, + child: DropdownButtonFormField( + items: discountModel.discounts + .map((e) => DropdownMenuItem( + child: Text(e.code, style: TextStyle(fontSize: 13)), + value: e.code)) + .toList(), + onChanged: (selected) { + var d = discountModel.discounts + .firstWhere((d) => d.code == selected); + setState(() { + _discount = d; + }); + }, + ), + ), + ), + Expanded( + child: Text( + '\$ ${_discount != null ? _discount.amount.toInt() : 0}', + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ))) + ], + ), + )); + + 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, + child: Text(getLocalString(context, 'invoice.custom_fee'))), + // Expanded( + // child: Text( + // '', + // )), + // Container( + // width: 100, + // child: InputText( + // controller: _customFeeController, + // iconData: null, + // labelTextKey: 'invoice.custom_fee'), + // ), + Expanded( + child: Text('\$ ${customFee}', + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + )), + ), + ], + ), + )); + + 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, + child: Text(getLocalString(context, 'invoice.delivery_fee'))), + 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, + ))) + ], + ), + )); + dataRow.insert( + dataRow.length, + Container( + child: Row( + children: [ + Expanded(child: Text('')), + Expanded( + flex: 2, + child: Divider( + thickness: 3, + )), + ], + ))); + 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: 1, child: Text('')), + Expanded( + flex: 2, + child: LocalText( + context, + 'invoice.total', + color: Colors.black, + ), + ), + Expanded( + child: Text( + '\$ $total', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + textAlign: TextAlign.end, + )) + ], + ), + )); + + 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: 1, child: Text('')), + Expanded( + flex: 2, + child: LocalText( + context, + 'invoice.balance', + color: Colors.black, + ), + ), + 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; + double deliveryFee = deliveryfee != 0 ? deliveryfee.toDouble() : 0; + balance = (total + custom + deliveryFee) - 100.0; + return balance; } List getBoxRow(BuildContext context) { @@ -824,6 +703,12 @@ class _InvoiceEditorState extends State { return MyDataRow( onSelectChanged: (bool selected) {}, cells: [ + MyDataCell(Checkbox( + value: true, + onChanged: (value) { + selectedBoxes.add(p); + }, + )), MyDataCell(new Text( p.boxNumber == null ? "" @@ -831,15 +716,13 @@ class _InvoiceEditorState extends State { 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(), + p.length == null + ? "" + : p.length.toString() + + ' x ' + + p.length.toString() + + ' x ' + + p.height.toString(), style: textStyle, )), ], @@ -848,7 +731,8 @@ class _InvoiceEditorState extends State { } List getCargoDataRow(BuildContext context) { - return _cargoTypes.map((cargo) { + return _cargoTypes.asMap().entries.map((c) { + var cargo = c.value; var amt = cargo.weight * cargo.price; return MyDataRow( onSelectChanged: (bool selected) {}, @@ -858,11 +742,7 @@ class _InvoiceEditorState extends State { style: textStyle, )), MyDataCell(new Text( - cargo.weight.toString(), - style: textStyle, - )), - MyDataCell(new Text( - '\$${cargo.price}', + cargo.weight.toString() + ' x ' + cargo.price.toString(), style: textStyle, )), MyDataCell(new Text( @@ -871,6 +751,16 @@ class _InvoiceEditorState extends State { )), ], ); - }).toList(); + }).toList() + // .insert(_cargoTypes.length,MyDataRow(cells: [ + // MyDataCell(new Text('')), + // MyDataCell(new Text('Total')), + // MyDataCell(new Text( + // "\$5000", + // style: textStyle, + // )), + // ]) + // ) + ; } } diff --git a/lib/pages/invoice/payment_page.dart b/lib/pages/invoice/payment_page.dart index 6c3b993..89f3867 100644 --- a/lib/pages/invoice/payment_page.dart +++ b/lib/pages/invoice/payment_page.dart @@ -1,6 +1,7 @@ import 'package:fcs/domain/entities/invoice.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/localization/app_translations.dart'; +import 'package:fcs/pages/main/util.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'; @@ -57,7 +58,8 @@ class _PaymentPageState extends State { @override Widget build(BuildContext context) { - // var images = isNew ? [] : _images; + final saveBox = fcsButton(context, getLocalString(context, 'btn.save')); + return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( @@ -128,13 +130,15 @@ class _PaymentPageState extends State { color: Colors.black, fontSize: 16), ), ), - Container( - padding: EdgeInsets.only(left: 10), - child: MultiImageFile( - enabled: true, - controller: multiImgController, - title: "Receipt File", - )), + Expanded( + child: Container( + padding: EdgeInsets.only(left: 10), + child: MultiImageFile( + enabled: true, + controller: multiImgController, + title: "Receipt File", + )), + ), ], ), ), @@ -179,6 +183,8 @@ class _PaymentPageState extends State { ], ), ), + saveBox, + SizedBox(height: 10), ], ), ), diff --git a/lib/pages/main/home_page.dart b/lib/pages/main/home_page.dart index bb45104..39fd1ae 100644 --- a/lib/pages/main/home_page.dart +++ b/lib/pages/main/home_page.dart @@ -298,7 +298,7 @@ class _HomePageState extends State { true ? widgets.add(boxesBtn) : ""; true ? widgets.add(deliveryBtn) : ""; user.hasCustomers() ? widgets.add(customersBtn) : ""; - // true ? widgets.add(invoicesBtn) : ""; + true ? widgets.add(invoicesBtn) : ""; // true ? widgets.add(discountBtn) : ""; } widgets.add(faqBtn);