mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Adds support for currency display (#277)
* Adds a helper function for rendering currency data * Update helper functions for StockItem model * Render purchasePrice correctly for stockitem * Use currency_formatter library instead of money_formatter * Add total price display for purchase order * icon fix
This commit is contained in:
parent
221920cbbe
commit
347e80d8e2
9 changed files with 311 additions and 236 deletions
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
import "dart:io";
|
||||
import "package:currency_formatter/currency_formatter.dart";
|
||||
|
||||
import "package:audioplayers/audioplayers.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
|
|
@ -77,3 +78,23 @@ Future<void> playAudioFile(String path) async {
|
|||
final player = AudioPlayer();
|
||||
player.play(AssetSource(path));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper function for rendering a money / currency object as a String
|
||||
*/
|
||||
String renderCurrency(double? amount, String currency, {int decimals = 2}) {
|
||||
|
||||
if (amount == null) return "-";
|
||||
if (amount.isInfinite || amount.isNaN) return "-";
|
||||
|
||||
CurrencyFormatterSettings backupSettings = CurrencyFormatterSettings(
|
||||
symbol: "\$",
|
||||
symbolSide: SymbolSide.left,
|
||||
);
|
||||
|
||||
return CurrencyFormatter.format(
|
||||
amount,
|
||||
CurrencyFormatter.majors[currency.toLowerCase()] ?? backupSettings
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue