fix number formatting
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
class CargoType {
|
class CargoType {
|
||||||
String id;
|
String id;
|
||||||
String name;
|
String name;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Invoice {
|
|||||||
CargoType existing = cargoTypes.firstWhere((wc) => wc.id == tc.id);
|
CargoType existing = cargoTypes.firstWhere((wc) => wc.id == tc.id);
|
||||||
existing.weight += tc.weight;
|
existing.weight += tc.weight;
|
||||||
} else {
|
} else {
|
||||||
cargoTypes.add(tc);
|
cargoTypes.add(tc.clone());
|
||||||
}
|
}
|
||||||
actualWeight += tc.weight;
|
actualWeight += tc.weight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import 'package:fcs/pages/main/util.dart';
|
|||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
typedef OnDiscountSelected(Discount discount);
|
typedef OnDiscountSelected(Discount discount);
|
||||||
typedef OnDeliveryFeeSelected(bool selected);
|
typedef OnDeliveryFeeSelected(bool selected);
|
||||||
|
final formatter = new NumberFormat("#,###.00");
|
||||||
|
|
||||||
class InvoiceCargoTable extends StatelessWidget {
|
class InvoiceCargoTable extends StatelessWidget {
|
||||||
final Invoice invoice;
|
final Invoice invoice;
|
||||||
@@ -46,10 +48,11 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
Expanded(flex: 2, child: Text('${cargo.name}')),
|
Expanded(flex: 2, child: Text('${cargo.name}')),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text('${cargo.calWeight} x ${cargo.calRate}',
|
child: Text(
|
||||||
|
'${cargo.calWeight.toStringAsFixed(2)} x ${cargo.calRate.toStringAsFixed(2)}',
|
||||||
textAlign: TextAlign.center)),
|
textAlign: TextAlign.center)),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ $amount',
|
child: Text('\$ ${amount.toStringAsFixed(2)}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
@@ -118,7 +121,7 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
SizedBox(width: 40),
|
SizedBox(width: 40),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'\$ $total',
|
'\$ ${total.toStringAsFixed(2)}',
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
))
|
))
|
||||||
@@ -155,12 +158,13 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ ( ${invoice.getDiscount()} )',
|
child:
|
||||||
textAlign: TextAlign.end,
|
Text('\$ ( ${invoice.getDiscount().toStringAsFixed(2)} )',
|
||||||
style: TextStyle(
|
textAlign: TextAlign.end,
|
||||||
fontSize: 15,
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontSize: 15,
|
||||||
)))
|
fontWeight: FontWeight.bold,
|
||||||
|
)))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
@@ -185,7 +189,7 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 40),
|
SizedBox(width: 40),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ ${invoice.getCustomFee()}',
|
child: Text('\$ ${invoice.getCustomFee().toStringAsFixed(2)}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
@@ -215,7 +219,8 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 50),
|
SizedBox(width: 50),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ ${invoice.handlingFee?.toString() ?? ""}',
|
child: Text(
|
||||||
|
'\$ ${invoice.getHandlingFee().toStringAsFixed(2) ?? ""}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
@@ -253,12 +258,13 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ ${invoice.getDeliveryFee()}',
|
child:
|
||||||
textAlign: TextAlign.end,
|
Text('\$ ${invoice.getDeliveryFee().toStringAsFixed(2)}',
|
||||||
style: TextStyle(
|
textAlign: TextAlign.end,
|
||||||
fontSize: 15,
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontSize: 15,
|
||||||
)))
|
fontWeight: FontWeight.bold,
|
||||||
|
)))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
@@ -297,7 +303,8 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ ${invoice.getNetAmount(rate)}',
|
child: Text(
|
||||||
|
'\$ ${invoice.getNetAmount(rate).toStringAsFixed(2)}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -327,7 +334,8 @@ class InvoiceCargoTable extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ ${invoice.getTotalBalance(rate)}',
|
child: Text(
|
||||||
|
'\$ ${invoice.getTotalBalance(rate).toStringAsFixed(2)}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_title.dart';
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
@@ -11,8 +12,9 @@ typedef OnSelect = Function(Carton carton, bool checked);
|
|||||||
class InvoiceCartonTable extends StatelessWidget {
|
class InvoiceCartonTable extends StatelessWidget {
|
||||||
final List<Carton> cartons;
|
final List<Carton> cartons;
|
||||||
final OnSelect onSelect;
|
final OnSelect onSelect;
|
||||||
|
final Rate rate;
|
||||||
|
|
||||||
const InvoiceCartonTable({Key key, this.cartons, this.onSelect})
|
const InvoiceCartonTable({Key key, this.cartons, this.onSelect, this.rate})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -88,6 +90,14 @@ class InvoiceCartonTable extends StatelessWidget {
|
|||||||
"${p.value?.length ?? ""} x ${p.value?.width ?? ""} x ${p.value?.height ?? ""}",
|
"${p.value?.length ?? ""} x ${p.value?.width ?? ""} x ${p.value?.height ?? ""}",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
|
new Text(
|
||||||
|
"${p.value?.getShipmentWeight(rate.volumetricRatio)?.toStringAsFixed(2) ?? "0"} lb",
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
|
new Text(
|
||||||
|
"${p.value?.actualWeight?.toStringAsFixed(2) ?? "0"} lb (Actual)",
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
);
|
);
|
||||||
final cartonTable = InvoiceCartonTable(
|
final cartonTable = InvoiceCartonTable(
|
||||||
cartons: _cartons,
|
cartons: _cartons,
|
||||||
|
rate: rate,
|
||||||
onSelect: (c, checked) {
|
onSelect: (c, checked) {
|
||||||
setState(() {
|
setState(() {
|
||||||
c.isChecked = checked;
|
c.isChecked = checked;
|
||||||
|
|||||||
Reference in New Issue
Block a user