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,
client: entityClient),
isSaving: false,
color: state.prefState.enableDarkMode
? Colors.white
: Theme.of(context).accentColor,
color: isFilteredBy
? (state.prefState.enableDarkMode
? Colors.white
: Theme.of(context).accentColor)
: null,
entity: widget.entity,
onSelected: (context, action) => widget.onEntityActionSelected != null
? widget.onEntityActionSelected(context, widget.entity, action)

View File

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

View File

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