Round totals on dashboard

This commit is contained in:
Hillel Coren 2020-08-14 12:51:17 +03:00
parent e7375b07d3
commit ca553df99f
3 changed files with 12 additions and 5 deletions

View File

@ -67,9 +67,11 @@ class _EntityListTileState extends State<EntityListTile> {
includeEdit: true, includeEdit: true,
client: entityClient), client: entityClient),
isSaving: false, isSaving: false,
color: state.prefState.enableDarkMode color: isFilteredBy
? (state.prefState.enableDarkMode
? Colors.white ? Colors.white
: Theme.of(context).accentColor, : Theme.of(context).accentColor)
: null,
entity: widget.entity, entity: widget.entity,
onSelected: (context, action) => widget.onEntityActionSelected != null onSelected: (context, action) => widget.onEntityActionSelected != null
? widget.onEntityActionSelected(context, widget.entity, action) ? widget.onEntityActionSelected(context, widget.entity, action)

View File

@ -17,8 +17,8 @@ class InvoiceItemListTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String cost = final String cost = formatNumber(invoiceItem.cost, context,
formatNumber(invoiceItem.cost, context, clientId: invoice.clientId); clientId: invoice.clientId, roundToPrecision: false);
final String qty = formatNumber(invoiceItem.quantity, context, final String qty = formatNumber(invoiceItem.quantity, context,
clientId: invoice.clientId, formatNumberType: FormatNumberType.double); clientId: invoice.clientId, formatNumberType: FormatNumberType.double);
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);

View File

@ -61,6 +61,7 @@ String formatNumber(
FormatNumberType formatNumberType = FormatNumberType.money, FormatNumberType formatNumberType = FormatNumberType.money,
bool showCurrencyCode, bool showCurrencyCode,
bool zeroIsNull = false, bool zeroIsNull = false,
bool roundToPrecision = true,
}) { }) {
if ((zeroIsNull || formatNumberType == FormatNumberType.input) && if ((zeroIsNull || formatNumberType == FormatNumberType.input) &&
value == 0) { value == 0) {
@ -106,6 +107,10 @@ String formatNumber(
return ''; return '';
} }
if (formatNumberType == FormatNumberType.money) {
value = round(value, currency.precision);
}
String thousandSeparator = currency.thousandSeparator; String thousandSeparator = currency.thousandSeparator;
String decimalSeparator = currency.decimalSeparator; String decimalSeparator = currency.decimalSeparator;
bool swapCurrencySymbol = currency.swapCurrencySymbol; bool swapCurrencySymbol = currency.swapCurrencySymbol;