update invoice page
This commit is contained in:
@@ -1,350 +0,0 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/discount/discount_list.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
typedef OnDiscountSelected(Discount discount);
|
||||
typedef OnDeliveryFeeSelected(bool selected);
|
||||
final formatter = new NumberFormat("#,###.00");
|
||||
|
||||
class InvoiceCargoTable extends StatelessWidget {
|
||||
final Invoice invoice;
|
||||
final Rate rate;
|
||||
final OnDiscountSelected discountSelected;
|
||||
final OnDeliveryFeeSelected deliveryFeeSelected;
|
||||
|
||||
const InvoiceCargoTable(
|
||||
{Key key,
|
||||
this.invoice,
|
||||
this.discountSelected,
|
||||
this.deliveryFeeSelected,
|
||||
this.rate})
|
||||
: super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: getRows(context));
|
||||
}
|
||||
|
||||
getRows(BuildContext context) {
|
||||
List<CargoType> _cargoTypes = invoice.getCargoTypes(rate);
|
||||
double total = 0;
|
||||
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
||||
var amount = cargo.calWeight * cargo.calRate;
|
||||
total += amount;
|
||||
return 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('${cargo.name}')),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
'${cargo.calWeight.toStringAsFixed(2)} x ${cargo.calRate.toStringAsFixed(2)}',
|
||||
textAlign: TextAlign.center)),
|
||||
Expanded(
|
||||
child: Text('\$ ${amount.toStringAsFixed(2)}',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
)))
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
dataRow.insert(
|
||||
0,
|
||||
Container(
|
||||
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))),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(getLocalString(context, 'invoice.box.cargo_type'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey))),
|
||||
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: Colors.grey))),
|
||||
Expanded(
|
||||
child: Text(getLocalString(context, 'invoice.amount'),
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey)))
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
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: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.total',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 40),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'\$ ${total.toStringAsFixed(2)}',
|
||||
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: 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.discount_value',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
new IconButton(
|
||||
icon: Icon(Icons.search, color: primaryColor),
|
||||
onPressed: () async {
|
||||
Discount discount = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
DiscountList(selectionMode: true)));
|
||||
if (discountSelected != null) {
|
||||
discountSelected(discount);
|
||||
}
|
||||
}),
|
||||
Expanded(
|
||||
child:
|
||||
Text('\$ ( ${invoice.getDiscount().toStringAsFixed(2)} )',
|
||||
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: 0.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.custom_fee',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 40),
|
||||
Expanded(
|
||||
child: Text('\$ ${invoice.getCustomFee().toStringAsFixed(2)}',
|
||||
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: 20.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.handling_fee',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 50),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'\$ ${invoice.getHandlingFee().toStringAsFixed(2) ?? ""}',
|
||||
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: 1,
|
||||
child: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.delivery_fee',
|
||||
color: Colors.black,
|
||||
),
|
||||
)),
|
||||
Switch(
|
||||
value: (invoice.deliveryFee ?? 0) > 0,
|
||||
onChanged: (value) {
|
||||
if (deliveryFeeSelected != null) {
|
||||
deliveryFeeSelected(value);
|
||||
}
|
||||
},
|
||||
activeTrackColor: primaryColor.withOpacity(0.8),
|
||||
activeColor: primaryColor,
|
||||
),
|
||||
Expanded(
|
||||
child:
|
||||
Text('\$ ${invoice.getDeliveryFee().toStringAsFixed(2)}',
|
||||
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: 2,
|
||||
child: Center(
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.net_amount',
|
||||
color: Colors.black,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'\$ ${invoice.getNetAmount(rate).toStringAsFixed(2)}',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
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: Center(
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.balance',
|
||||
color: Colors.black,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'\$ ${invoice.getTotalBalance(rate).toStringAsFixed(2)}',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: primaryColor)))
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
return dataRow;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
@@ -20,7 +19,7 @@ class InvoiceCartonTable extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tableTitle = Container(
|
||||
padding: EdgeInsets.only(right: 10.0, top: 20),
|
||||
padding: EdgeInsets.only(right: 10.0, top: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
@@ -76,10 +75,6 @@ class InvoiceCartonTable extends StatelessWidget {
|
||||
p.value.cartonNumber,
|
||||
style: textStyle,
|
||||
),
|
||||
Text(
|
||||
p.value.shipmentNumber ?? "",
|
||||
style: textStyle,
|
||||
),
|
||||
],
|
||||
)),
|
||||
Flexible(
|
||||
|
||||
88
lib/pages/invoice/invoice_discount_table.dart
Normal file
88
lib/pages/invoice/invoice_discount_table.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class InvoiceDiscountTable extends StatelessWidget {
|
||||
final List<Discount> discounts;
|
||||
|
||||
const InvoiceDiscountTable({
|
||||
Key key,
|
||||
this.discounts,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"invoice.shipment.discount.title",
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: table(context),
|
||||
));
|
||||
}
|
||||
|
||||
Widget table(BuildContext context) {
|
||||
return MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"discount.code",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"discount.amount",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getRows(context),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getRows(BuildContext context) {
|
||||
if (discounts == null) {
|
||||
return [];
|
||||
}
|
||||
var rows = discounts.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (value) => Navigator.pop(context, c),
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
c.code ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(c.amount?.toStringAsFixed(2) ?? "0", style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,33 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton/model/carton_model.dart';
|
||||
import 'package:fcs/pages/discount/discount_list.dart';
|
||||
import 'package:fcs/pages/discount/model/discount_model.dart';
|
||||
import 'package:fcs/pages/invoice/invoice_cargo_table.dart';
|
||||
import 'package:fcs/pages/invoice/invoice_discount_table.dart';
|
||||
import 'package:fcs/pages/invoice/invoice_shipment_table.dart';
|
||||
import 'package:fcs/pages/invoice/invoice_table.dart';
|
||||
import 'package:fcs/pages/invoice/invoice_carton_table.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
||||
import 'package:fcs/pages/rates/custom_list.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_icons.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_popupmenu.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -44,99 +49,84 @@ class InvoiceEditor extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
User user;
|
||||
User _user;
|
||||
|
||||
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();
|
||||
TextEditingController _handlingFeeController = new TextEditingController();
|
||||
TextEditingController _customFeeController = new TextEditingController();
|
||||
MultiImgController multiImgController = MultiImgController();
|
||||
TextEditingController _descriptionController = new TextEditingController();
|
||||
TextEditingController _balanceController = new TextEditingController();
|
||||
|
||||
Invoice _invoice;
|
||||
bool _isLoading = false;
|
||||
List<Carton> _cartons = [];
|
||||
bool isSwitched = false;
|
||||
int deliveryfee = 0;
|
||||
double customFee = 10.0;
|
||||
double handlingFee = 10.0; // it will get from shipment
|
||||
double total = 0;
|
||||
Discount _discount;
|
||||
bool _isNew = false;
|
||||
Discount selectedDiscount;
|
||||
int selectedDiscountAmt;
|
||||
PaymentMethod _paymentMethod;
|
||||
double volumetricRatio = 0;
|
||||
|
||||
List<Carton> selectedBoxes = [];
|
||||
List<CustomDuty> customs = [];
|
||||
|
||||
// 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)
|
||||
// ];
|
||||
bool _isNew;
|
||||
|
||||
List<bool> isSelected = [false];
|
||||
bool _showCartons = false;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
.rate
|
||||
.volumetricRatio;
|
||||
_isNew = widget.invoice == null;
|
||||
|
||||
if (widget.invoice != null) {
|
||||
_isNew = false;
|
||||
_invoice = widget.invoice;
|
||||
_invoiceNumberController.text = _invoice.invoiceNumber;
|
||||
_dateController.text = dateFormatter.format(_invoice.invoiceDate);
|
||||
_nameController.text = _invoice.customerName;
|
||||
_phoneController.text = _invoice.customerPhoneNumber;
|
||||
// _amountController.text = _invoice.getAmount.toString();
|
||||
_amountController.text = _invoice.amount.toString();
|
||||
_statusController.text = _invoice.status.toString();
|
||||
_handlingFeeController.text = '0';
|
||||
_customFeeController.text = '0';
|
||||
// multiImgController.setImageUrls = _receipts;
|
||||
_descriptionController.text = 'For Electronics goods';
|
||||
_balanceController.text =
|
||||
(_invoice.amount - _invoice.receipts[0].amount).toString();
|
||||
// _boxes = _invoice.packages;
|
||||
} else {
|
||||
_isNew = true;
|
||||
_dateController.text = dateFormatter.format(DateTime.now());
|
||||
_amountController.text = '0';
|
||||
_handlingFeeController.text = '0';
|
||||
_customFeeController.text = '0';
|
||||
_descriptionController.text = '';
|
||||
_balanceController.text = '0';
|
||||
_invoice = Invoice(customDuties: [], cartons: []);
|
||||
_invoice = Invoice(
|
||||
customDuties: [],
|
||||
cartons: [],
|
||||
shipments: [],
|
||||
invoiceDate: DateTime.now());
|
||||
}
|
||||
_user = widget.customer;
|
||||
_loadAll();
|
||||
}
|
||||
|
||||
if (widget.customer != null && widget.invoice == null) {
|
||||
user = widget.customer;
|
||||
_loadAll() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
await _loadCartons();
|
||||
await _loadShipments();
|
||||
await _loadDiscount();
|
||||
} catch (e) {} finally {
|
||||
setState(() {
|
||||
_isNew = true;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
_loadCartons();
|
||||
}
|
||||
|
||||
_loadCartons() async {
|
||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
List<Carton> cartons = await cartonModel.getCartonsForInvoice(
|
||||
widget.fcsShipment.id, widget.customer.id);
|
||||
setState(() {
|
||||
_cartons = cartons;
|
||||
cartons.forEach((c) {
|
||||
c.isChecked = true;
|
||||
});
|
||||
setState(() {
|
||||
_invoice.cartons = cartons;
|
||||
});
|
||||
}
|
||||
|
||||
_loadShipments() async {
|
||||
ShipmentModel shipmentModel =
|
||||
Provider.of<ShipmentModel>(context, listen: false);
|
||||
List<Shipment> shipments = await shipmentModel.getShipmentWithHandlingFee(
|
||||
widget.fcsShipment.id, widget.customer.id);
|
||||
shipments.forEach((s) {
|
||||
s.isSelected = true;
|
||||
});
|
||||
setState(() {
|
||||
_invoice.shipments = shipments;
|
||||
});
|
||||
}
|
||||
|
||||
List<Discount> discounts = [];
|
||||
_loadDiscount() async {
|
||||
DiscountModel discountModel =
|
||||
Provider.of<DiscountModel>(context, listen: false);
|
||||
discounts = await discountModel.getDiscount(widget.customer.id);
|
||||
if (discounts != null && discounts.length > 0) {
|
||||
setState(() {
|
||||
_invoice.discount = discounts.first;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -147,38 +137,22 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var mainModel = Provider.of<MainModel>(context);
|
||||
var discountModel = Provider.of<DiscountModel>(context);
|
||||
var paymentMethodModel = Provider.of<PaymentMethodModel>(context);
|
||||
var rateModel = Provider.of<ShipmentRateModel>(context);
|
||||
var rate = rateModel.rate;
|
||||
|
||||
final nameBox = DisplayText(
|
||||
iconData: Feather.user,
|
||||
labelTextKey: 'invoice.customer_name',
|
||||
text: user != null ? user.name : 'Ko Nyi');
|
||||
|
||||
final statusBox = DisplayText(
|
||||
text: _statusController.text,
|
||||
text: _invoice?.status ?? "",
|
||||
iconData: Icons.av_timer,
|
||||
labelTextKey: 'invoice.status');
|
||||
|
||||
final fcsIDBox = DisplayText(
|
||||
text: user != null ? user.fcsID : "FCS-KRUTUG",
|
||||
labelTextKey: "box.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
final cartonTable = InvoiceCartonTable(
|
||||
cartons: _cartons,
|
||||
cartons: _invoice.cartons,
|
||||
rate: rate,
|
||||
onSelect: (c, checked) {
|
||||
setState(() {
|
||||
c.isChecked = checked;
|
||||
});
|
||||
if (checked) {
|
||||
_invoice.cartons.add(c);
|
||||
} else {
|
||||
_invoice.cartons.remove(c);
|
||||
}
|
||||
},
|
||||
);
|
||||
final customTableHeaderBox = LocalTitle(
|
||||
@@ -196,19 +170,19 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
onAdd: (c) => _addCustom(c),
|
||||
onRemove: (c) => _removeCustom(c),
|
||||
);
|
||||
var paymentTypesBox = LocalDropdown<PaymentMethod>(
|
||||
final paymentTypesBox = LocalDropdown<PaymentMethod>(
|
||||
callback: (v) {
|
||||
setState(() {
|
||||
_paymentMethod = v;
|
||||
_invoice.paymentMethod = v;
|
||||
});
|
||||
},
|
||||
labelKey: "invoice.payment_method",
|
||||
iconData: FontAwesome.money,
|
||||
display: (u) => u.name,
|
||||
selectedValue: _paymentMethod,
|
||||
selectedValue: _invoice.paymentMethod,
|
||||
values: paymentMethodModel.paymentMethods,
|
||||
);
|
||||
final cargoTypeTableBox = InvoiceCargoTable(
|
||||
final invoiceTableBox = InvoiceTable(
|
||||
invoice: _invoice,
|
||||
rate: rate,
|
||||
deliveryFeeSelected: (selected) {
|
||||
@@ -225,6 +199,97 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
_invoice.discount = discount;
|
||||
});
|
||||
},
|
||||
onRemove: (i) {
|
||||
if (i.invoiceDataType == InvoiceDataType.CustomFeeDataType) {
|
||||
_removeCustom(i.data);
|
||||
}
|
||||
if (i.invoiceDataType == InvoiceDataType.DiscountDataType) {
|
||||
setState(() {
|
||||
_invoice.discount = null;
|
||||
});
|
||||
}
|
||||
if (i.invoiceDataType == InvoiceDataType.DeliveryFeeType) {
|
||||
setState(() {
|
||||
_invoice.deliveryFee = 0;
|
||||
});
|
||||
}
|
||||
if (i.invoiceDataType == InvoiceDataType.HandlingFeeType) {
|
||||
setState(() {
|
||||
_removeShipment(i.data);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
final toggleButtonsBox = ToggleButtons(
|
||||
color: Colors.black45,
|
||||
selectedColor: Colors.black45,
|
||||
disabledColor: Colors.grey,
|
||||
selectedBorderColor: primaryColor,
|
||||
borderColor: Colors.transparent,
|
||||
fillColor: Colors.transparent,
|
||||
highlightColor: Colors.black45,
|
||||
children: <Widget>[
|
||||
Icon(cartonIconData),
|
||||
],
|
||||
onPressed: (int index) {
|
||||
setState(() {
|
||||
_showCartons = !_showCartons;
|
||||
});
|
||||
},
|
||||
isSelected: [_showCartons],
|
||||
);
|
||||
|
||||
final popupMenu = LocalPopupMenuButton(
|
||||
buttonIcon: Icons.add_circle,
|
||||
selectable: false,
|
||||
buttonColor: Colors.black45,
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1,
|
||||
textKey: "invoice.add.custom.fee.menu",
|
||||
),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "invoice.add.handling.fee.menu",
|
||||
),
|
||||
LocalPopupMenu(
|
||||
id: 3,
|
||||
textKey: "invoice.add.discount.menu",
|
||||
),
|
||||
LocalPopupMenu(
|
||||
id: 4,
|
||||
textKey: "invoice.delivery_fee",
|
||||
)
|
||||
],
|
||||
popupMenuCallback: (p) async {
|
||||
if (p.id == 1) {
|
||||
CustomDuty customDuty = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CustomList(selected: true)));
|
||||
_addCustom(customDuty);
|
||||
} else if (p.id == 2) {
|
||||
Shipment shipment = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
InvoiceShipmentTable(shipments: _invoice.shipments)));
|
||||
_addShipment(shipment);
|
||||
} else if (p.id == 3) {
|
||||
Discount discount =
|
||||
await Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => InvoiceDiscountTable(
|
||||
discounts: discounts,
|
||||
)));
|
||||
if (discount != null) {
|
||||
setState(() {
|
||||
_invoice.discount = discount;
|
||||
});
|
||||
}
|
||||
} else if (p.id == 4) {
|
||||
setState(() {
|
||||
_invoice.deliveryFee = rate.deliveryFee;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
@@ -245,31 +310,55 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
LocalTitle(textKey: "invoice.customer_info"),
|
||||
DisplayText(
|
||||
labelTextKey: 'invoice.date',
|
||||
iconData: Icons.date_range,
|
||||
text: _dateController.text),
|
||||
widget.invoice == null
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(dateFormatter.format(_invoice.invoiceDate)),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(_user?.name ?? ""),
|
||||
Text(
|
||||
_user?.fcsID ?? "",
|
||||
style: TextStyle(fontSize: 12),
|
||||
)
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
toggleButtonsBox,
|
||||
popupMenu,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
_isNew
|
||||
? Container()
|
||||
: DisplayText(
|
||||
labelTextKey: 'invoice.number',
|
||||
iconData: FontAwesomeIcons.fileInvoice,
|
||||
text: _invoiceNumberController.text),
|
||||
fcsIDBox,
|
||||
nameBox,
|
||||
text: _invoice?.invoiceNumber ?? ""),
|
||||
_isNew ? Container() : statusBox,
|
||||
SizedBox(height: 20),
|
||||
customTableHeaderBox,
|
||||
customTableBox,
|
||||
SizedBox(height: 20),
|
||||
cartonTable,
|
||||
LocalTitle(textKey: "invoice.cargo_type"),
|
||||
cargoTypeTableBox,
|
||||
// Column(children: getCargoTableByBox(context)),
|
||||
SizedBox(height: 20),
|
||||
_showCartons ? cartonTable : Container(),
|
||||
_showCartons
|
||||
? Divider(
|
||||
color: primaryColor,
|
||||
thickness: 2,
|
||||
)
|
||||
: Container(),
|
||||
invoiceTableBox,
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
paymentTypesBox,
|
||||
SizedBox(height: 20),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
_isNew
|
||||
? Container()
|
||||
: LocalTitle(
|
||||
@@ -277,7 +366,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.add_circle, color: primaryColor),
|
||||
onPressed: () async {})),
|
||||
widget.invoice == null
|
||||
_isNew
|
||||
? fcsButton(
|
||||
context, getLocalString(context, 'invoice.btn_create'))
|
||||
: mainModel.isCustomer()
|
||||
@@ -300,15 +389,6 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
);
|
||||
}
|
||||
|
||||
getTotalBalance(total) {
|
||||
double balance = 0;
|
||||
double custom = customFee != 0 ? customFee.toDouble() : 0;
|
||||
double discount = _discount != null ? _discount.amount.toDouble() : 0;
|
||||
double deliveryFee = deliveryfee != 0 ? deliveryfee.toDouble() : 0;
|
||||
balance = (total + custom + deliveryFee) - discount;
|
||||
return balance;
|
||||
}
|
||||
|
||||
_addCustom(CustomDuty customDuty) {
|
||||
if (customDuty == null) return;
|
||||
setState(() {
|
||||
@@ -317,6 +397,24 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
});
|
||||
}
|
||||
|
||||
_addShipment(Shipment shipment) {
|
||||
if (shipment == null) return;
|
||||
shipment.isSelected = true;
|
||||
setState(() {
|
||||
_invoice.shipments.remove(shipment);
|
||||
_invoice.shipments.add(shipment);
|
||||
});
|
||||
}
|
||||
|
||||
_removeShipment(Shipment shipment) {
|
||||
if (shipment == null) return;
|
||||
shipment.isSelected = false;
|
||||
setState(() {
|
||||
_invoice.shipments.remove(shipment);
|
||||
_invoice.shipments.add(shipment);
|
||||
});
|
||||
}
|
||||
|
||||
_removeCustom(CustomDuty customDuty) {
|
||||
setState(() {
|
||||
_invoice.customDuties.remove(customDuty);
|
||||
|
||||
@@ -99,16 +99,14 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
_invoice = widget.invoice;
|
||||
_invoiceNumberController.text = _invoice.invoiceNumber;
|
||||
_dateController.text = dateFormatter.format(_invoice.invoiceDate);
|
||||
_nameController.text = _invoice.customerName;
|
||||
_phoneController.text = _invoice.customerPhoneNumber;
|
||||
_nameController.text = _invoice.userName;
|
||||
_phoneController.text = _invoice.phoneNumber;
|
||||
// _amountController.text = _invoice.getAmount.toString();
|
||||
_amountController.text = _invoice.amount.toString();
|
||||
_statusController.text = _invoice.status.toString();
|
||||
_customFeeController.text = '0';
|
||||
// multiImgController.setImageUrls = _receipts;
|
||||
_descriptionController.text = 'For Electronics goods';
|
||||
_balanceController.text =
|
||||
(_invoice.amount - _invoice.receipts[0].amount).toString();
|
||||
// _boxes = _invoice.packages;
|
||||
} else {
|
||||
_dateController.text = dateFormatter.format(DateTime.now());
|
||||
|
||||
105
lib/pages/invoice/invoice_shipment_table.dart
Normal file
105
lib/pages/invoice/invoice_shipment_table.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnAdd(Shipment shipment);
|
||||
typedef OnRemove(Shipment shipment);
|
||||
|
||||
class InvoiceShipmentTable extends StatelessWidget {
|
||||
final List<Shipment> shipments;
|
||||
final OnAdd onAdd;
|
||||
final OnRemove onRemove;
|
||||
|
||||
const InvoiceShipmentTable(
|
||||
{Key key, this.shipments, this.onAdd, this.onRemove})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"invoice.shipment.handling.fee.title",
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: table(context),
|
||||
));
|
||||
}
|
||||
|
||||
Widget table(BuildContext context) {
|
||||
return MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"invoice.shipment.number",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"invoice.add.handling.fee.menu",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getRows(context),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getRows(BuildContext context) {
|
||||
if (shipments == null) {
|
||||
return [];
|
||||
}
|
||||
var rows = shipments.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (value) => Navigator.pop(context, c),
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
c.shipmentNumber ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(c.handlingFee?.toStringAsFixed(2) ?? "0",
|
||||
style: textStyle),
|
||||
onRemove == null
|
||||
? SizedBox(
|
||||
width: 50,
|
||||
)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.remove_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
if (onRemove != null) onRemove(c);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
377
lib/pages/invoice/invoice_table.dart
Normal file
377
lib/pages/invoice/invoice_table.dart
Normal file
@@ -0,0 +1,377 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/discount/discount_list.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
typedef OnDiscountSelected(Discount discount);
|
||||
typedef OnDeliveryFeeSelected(bool selected);
|
||||
typedef OnRemove(InvoiceTableRow row);
|
||||
final formatter = new NumberFormat("#,###.00");
|
||||
|
||||
enum InvoiceDataType {
|
||||
CargoDataType,
|
||||
DiscountDataType,
|
||||
CustomFeeDataType,
|
||||
HandlingFeeType,
|
||||
DeliveryFeeType,
|
||||
}
|
||||
|
||||
class InvoiceTableRow {
|
||||
final dynamic data;
|
||||
final String id;
|
||||
final InvoiceDataType invoiceDataType;
|
||||
final String desc;
|
||||
final String rate;
|
||||
final String amount;
|
||||
|
||||
InvoiceTableRow(
|
||||
{this.id,
|
||||
this.data,
|
||||
this.invoiceDataType,
|
||||
this.desc,
|
||||
this.rate,
|
||||
this.amount});
|
||||
}
|
||||
|
||||
class InvoiceTable extends StatelessWidget {
|
||||
final Invoice invoice;
|
||||
final Rate rate;
|
||||
final OnDiscountSelected discountSelected;
|
||||
final OnDeliveryFeeSelected deliveryFeeSelected;
|
||||
final OnRemove onRemove;
|
||||
|
||||
const InvoiceTable(
|
||||
{Key key,
|
||||
this.invoice,
|
||||
this.discountSelected,
|
||||
this.deliveryFeeSelected,
|
||||
this.onRemove,
|
||||
this.rate})
|
||||
: super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: getRows(context));
|
||||
}
|
||||
|
||||
List<InvoiceTableRow> getTableRows() {
|
||||
List<InvoiceTableRow> tableRows = [];
|
||||
// add cargo types
|
||||
List<CargoType> _cargoTypes = invoice.getCargoTypes(rate);
|
||||
_cargoTypes.forEach((c) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
invoiceDataType: InvoiceDataType.CargoDataType,
|
||||
desc: c.name,
|
||||
rate:
|
||||
"${c.calWeight.toStringAsFixed(2)} x ${c.calRate.toStringAsFixed(2)}",
|
||||
amount: "${c.amount.toStringAsFixed(2)}"));
|
||||
});
|
||||
invoice.shipments.where((ss) => (ss.isSelected ?? false)).forEach((s) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: s,
|
||||
invoiceDataType: InvoiceDataType.HandlingFeeType,
|
||||
desc: "Handling fee\n${s.shipmentNumber}",
|
||||
rate: "",
|
||||
amount: "${s.handlingFee.toStringAsFixed(2)}"));
|
||||
});
|
||||
// add custom fee
|
||||
invoice.customDuties.forEach((c) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: c,
|
||||
invoiceDataType: InvoiceDataType.CustomFeeDataType,
|
||||
desc: "${c.productType} custom fee",
|
||||
rate: "",
|
||||
amount: "${c.fee.toStringAsFixed(2)}"));
|
||||
});
|
||||
// add delivery fee
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: invoice.deliveryFee == null || invoice.deliveryFee == 0
|
||||
? null
|
||||
: invoice.deliveryFee,
|
||||
invoiceDataType: InvoiceDataType.DeliveryFeeType,
|
||||
desc: "Delivery fee",
|
||||
rate: "",
|
||||
amount: "${invoice?.deliveryFee?.toStringAsFixed(2) ?? '0'}"));
|
||||
|
||||
// add discounts
|
||||
if (invoice.discount != null) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: invoice.discount,
|
||||
invoiceDataType: InvoiceDataType.DiscountDataType,
|
||||
desc: "Discount\n${invoice?.discount?.code ?? ""}",
|
||||
rate: "",
|
||||
amount: "(${invoice?.discount?.amount?.toStringAsFixed(2) ?? ''})"));
|
||||
}
|
||||
|
||||
return tableRows;
|
||||
}
|
||||
|
||||
getRows(BuildContext context) {
|
||||
List<InvoiceTableRow> tableRows = getTableRows();
|
||||
|
||||
List<Widget> dataRow = tableRows.map((r) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(child: Text('${r.desc}')),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
r.data == null || onRemove == null
|
||||
? Container()
|
||||
: InkWell(
|
||||
onTap: () => onRemove(r),
|
||||
child: Icon(
|
||||
Icons.remove_circle,
|
||||
color: Colors.black45,
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
'${r.rate}',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(fontSize: 12),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text('\$ ${r.amount}',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
)))
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
dataRow.insert(
|
||||
0,
|
||||
Container(
|
||||
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))),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(getLocalString(context, 'invoice.box.desc'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey))),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
getLocalString(context, 'invoice.weight') +
|
||||
' x ' +
|
||||
getLocalString(context, 'invoice.rate'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey))),
|
||||
Expanded(
|
||||
child: Text(getLocalString(context, 'invoice.amount'),
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey)))
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
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: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
'invoice.total',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
Text(
|
||||
'\$ ${invoice.getNetAmount(rate).toStringAsFixed(2)}',
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.end,
|
||||
)
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
// 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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(width: 50),
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// '\$ ${invoice.getHandlingFee().toStringAsFixed(2) ?? ""}',
|
||||
// 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: 1,
|
||||
// child: Container(
|
||||
// alignment: Alignment.centerRight,
|
||||
// child: LocalText(
|
||||
// context,
|
||||
// 'invoice.delivery_fee',
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// )),
|
||||
// Switch(
|
||||
// value: (invoice.deliveryFee ?? 0) > 0,
|
||||
// onChanged: (value) {
|
||||
// if (deliveryFeeSelected != null) {
|
||||
// deliveryFeeSelected(value);
|
||||
// }
|
||||
// },
|
||||
// activeTrackColor: primaryColor.withOpacity(0.8),
|
||||
// activeColor: primaryColor,
|
||||
// ),
|
||||
// Expanded(
|
||||
// child:
|
||||
// Text('\$ ${invoice.getDeliveryFee().toStringAsFixed(2)}',
|
||||
// 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: 2,
|
||||
// child: Center(
|
||||
// child: LocalText(
|
||||
// context,
|
||||
// 'invoice.net_amount',
|
||||
// color: Colors.black,
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// '\$ ${invoice.getNetAmount(rate).toStringAsFixed(2)}',
|
||||
// textAlign: TextAlign.end,
|
||||
// style: TextStyle(
|
||||
// fontSize: 18,
|
||||
// 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: Center(
|
||||
// child: LocalText(
|
||||
// context,
|
||||
// 'invoice.balance',
|
||||
// color: Colors.black,
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// '\$ ${invoice.getTotalBalance(rate).toStringAsFixed(2)}',
|
||||
// textAlign: TextAlign.end,
|
||||
// style: TextStyle(
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: primaryColor)))
|
||||
// ],
|
||||
// ),
|
||||
// ));
|
||||
|
||||
return dataRow;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/data/services/services.dart';
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/receipt.dart';
|
||||
import 'package:fcs/domain/vo/message.dart';
|
||||
import 'package:fcs/helpers/paginator.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
|
||||
class InvoiceModel extends BaseModel {
|
||||
final log = Logger('InvoiceModel');
|
||||
@@ -18,37 +15,13 @@ class InvoiceModel extends BaseModel {
|
||||
|
||||
List<Invoice> _invoices = [
|
||||
Invoice(
|
||||
invoiceNumber: 'A092(A)-33',
|
||||
invoiceDate: DateTime(2020, 4, 6, 12, 15),
|
||||
customerName: 'Ko Myo Min',
|
||||
customerPhoneNumber: '+959 555555555',
|
||||
amount: 300,
|
||||
status: 'Pending',
|
||||
receipts: [
|
||||
Receipt(amount: 200, date: '1 Jun 2020'),
|
||||
],
|
||||
packages: [
|
||||
Package(
|
||||
shipmentNumber: "A201",
|
||||
receiverNumber: "1",
|
||||
boxNumber: "1",
|
||||
rate: 9,
|
||||
packageType: "Dangerous",
|
||||
weight: 25,
|
||||
status: "Delivered",
|
||||
arrivedDate: DateTime(2020, 5, 21),
|
||||
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'),
|
||||
Package(
|
||||
shipmentNumber: "A201",
|
||||
receiverNumber: "1",
|
||||
boxNumber: "2",
|
||||
rate: 7,
|
||||
packageType: "General",
|
||||
weight: 5,
|
||||
status: "Delivered",
|
||||
arrivedDate: DateTime(2020, 5, 21),
|
||||
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'),
|
||||
])
|
||||
invoiceNumber: 'A092(A)-33',
|
||||
invoiceDate: DateTime(2020, 4, 6, 12, 15),
|
||||
userName: 'Ko Myo Min',
|
||||
phoneNumber: '+959 555555555',
|
||||
amount: 300,
|
||||
status: 'Pending',
|
||||
)
|
||||
];
|
||||
|
||||
List<Invoice> get invoices =>
|
||||
|
||||
@@ -121,7 +121,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
getCustomFeeRows(BuildContext context) {
|
||||
List<Widget> dataRow = [];
|
||||
|
||||
dataRow = _invoice.receipts.asMap().entries.map((receipt) {
|
||||
dataRow = [].asMap().entries.map((receipt) {
|
||||
var r = receipt.value;
|
||||
var k = receipt.key + 1;
|
||||
return Container(
|
||||
|
||||
Reference in New Issue
Block a user