Skip to content

Commit a8fb169

Browse files
committed
Add default parameters for currency formatter and code
1 parent 1bb3681 commit a8fb169

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Factories/StatsDataTextFormatter.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ struct StatsDataTextFormatter {
3434

3535
/// Creates the text to display for the net revenue.
3636
///
37-
static func createNetRevenueText(orderStats: OrderStatsV4?, currencyFormatter: CurrencyFormatter?, currencyCode: String) -> String {
37+
static func createNetRevenueText(orderStats: OrderStatsV4?,
38+
currencyFormatter: CurrencyFormatter = CurrencyFormatter(currencySettings: ServiceLocator.currencySettings),
39+
currencyCode: String = ServiceLocator.currencySettings.currencyCode.rawValue) -> String {
3840
guard let revenue = orderStats?.totals.netRevenue else {
3941
return Constants.placeholderText
4042
}
4143

4244
// If revenue is an integer, no decimal points are shown.
4345
let numberOfDecimals: Int? = revenue.isInteger ? 0 : nil
44-
let currencyFormatter = currencyFormatter ?? CurrencyFormatter(currencySettings: ServiceLocator.currencySettings)
4546
return currencyFormatter.formatAmount(revenue, with: currencyCode, numberOfDecimals: numberOfDecimals) ?? String()
4647
}
4748

0 commit comments

Comments
 (0)