Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
magohamote committed Oct 16, 2023
1 parent 13e8a80 commit 18b0e8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libraries/PaymentsUI/Sources/Extensions/PriceFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import Foundation

enum PriceFormatter {
static func formatPlanPrice(price: Double, locale: Locale = Locale.current, currency: String? = nil, maximumFractionDigits: Int = 2) -> String {
static func formatPlanPrice(price: Double, locale: Locale = Locale.current, currencyCode: String? = nil, maximumFractionDigits: Int = 2) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = locale
if let currency {
formatter.currencyCode = currency
if let currencyCode {
formatter.currencyCode = currencyCode
}
formatter.maximumFractionDigits = maximumFractionDigits
let priceString = formatter.string(from: NSNumber(value: price)) ?? ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ struct CurrentPlanDetailsV5 {
}

var price: String
if let amount = details.amount {
price = PriceFormatter.formatPlanPrice(price: Double(amount) / 100, currency: details.currency)
if let amount = details.amount, amount != 0 {
price = PriceFormatter.formatPlanPrice(price: Double(amount) / 100, currencyCode: details.currency)
} else {
price = PUITranslations.plan_details_free_price.l10n
}
Expand Down

0 comments on commit 18b0e8f

Please sign in to comment.