From 232a2a7e3720bd0bd02cc8e21e4a7648a9e1c088 Mon Sep 17 00:00:00 2001 From: Paolo Musolino Date: Mon, 11 Oct 2021 16:11:04 +0200 Subject: [PATCH 1/3] feat: display the discounted price `rate` instead of the retail rate `retail_rate`, to align the behavior with Android --- .../ShippingLabelCarrierRowViewModel.swift | 10 +++++----- .../ShippingLabelFormViewModel.swift | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/Carriers and Rates/ShippingLabelCarrierRowViewModel.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/Carriers and Rates/ShippingLabelCarrierRowViewModel.swift index 0c9060b3c22..c338f1a62ac 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/Carriers and Rates/ShippingLabelCarrierRowViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/Carriers and Rates/ShippingLabelCarrierRowViewModel.swift @@ -58,12 +58,12 @@ struct ShippingLabelCarrierRowViewModel: Identifiable { price = { if signatureSelected, let signatureRate = signatureRate { - return currencyFormatter.formatAmount(Decimal(signatureRate.retailRate)) ?? "" + return currencyFormatter.formatAmount(Decimal(signatureRate.rate)) ?? "" } if adultSignatureSelected, let adultSignatureRate = adultSignatureRate { - return currencyFormatter.formatAmount(Decimal(adultSignatureRate.retailRate)) ?? "" + return currencyFormatter.formatAmount(Decimal(adultSignatureRate.rate)) ?? "" } - return currencyFormatter.formatAmount(Decimal(rate.retailRate)) ?? "" + return currencyFormatter.formatAmount(Decimal(rate.rate)) ?? "" }() carrierLogo = CarrierLogo(rawValue: rate.carrierID)?.image() @@ -92,14 +92,14 @@ struct ShippingLabelCarrierRowViewModel: Identifiable { displayAdultSignatureRequired = adultSignatureRate != nil if displaySignatureRequired, let signatureRate = signatureRate { - let amount = currencyFormatter.formatAmount(Decimal(signatureRate.retailRate - rate.retailRate)) ?? "" + let amount = currencyFormatter.formatAmount(Decimal(signatureRate.rate - rate.rate)) ?? "" signatureRequiredText = String(format: Localization.signatureRequired, amount) } else { signatureRequiredText = "" } if displayAdultSignatureRequired, let adultSignatureRate = adultSignatureRate { - let amount = currencyFormatter.formatAmount(Decimal(adultSignatureRate.retailRate - rate.retailRate)) ?? "" + let amount = currencyFormatter.formatAmount(Decimal(adultSignatureRate.rate - rate.rate)) ?? "" adultSignatureRequiredText = String(format: Localization.adultSignatureRequired, amount) } else { diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/ShippingLabelFormViewModel.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/ShippingLabelFormViewModel.swift index becd56d5309..86c908b5716 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/ShippingLabelFormViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/Create Shipping Label Form/ShippingLabelFormViewModel.swift @@ -352,7 +352,7 @@ final class ShippingLabelFormViewModel { if selectedRates.count == 1, let selectedRate = selectedRates.first { let currencyFormatter = CurrencyFormatter(currencySettings: ServiceLocator.currencySettings) - let price = currencyFormatter.formatAmount(Decimal(selectedRate.retailRate)) ?? "" + let price = currencyFormatter.formatAmount(Decimal(selectedRate.totalRate)) ?? "" let formatString = selectedRate.rate.deliveryDays == 1 ? Localization.businessDaySingular : Localization.businessDaysPlural @@ -365,7 +365,7 @@ final class ShippingLabelFormViewModel { } else { let ratesCount = String(format: Localization.selectedRatesCount, selectedRates.count) - let total = selectedRates.reduce(0, { $0 + $1.retailRate }) + let total = selectedRates.reduce(0, { $0 + $1.totalRate }) let currencyFormatter = CurrencyFormatter(currencySettings: ServiceLocator.currencySettings) let price = currencyFormatter.formatAmount(Decimal(total)) ?? "" let totalRate = String(format: Localization.totalRate, price) @@ -395,7 +395,7 @@ final class ShippingLabelFormViewModel { } let currencyFormatter = CurrencyFormatter(currencySettings: ServiceLocator.currencySettings) return selectedRates.map { rate in - currencyFormatter.formatAmount(Decimal(rate.retailRate)) ?? "" + currencyFormatter.formatAmount(Decimal(rate.totalRate)) ?? "" } } From 1d3ce24f0d3311a247e66f18d13b45fc7b8b03f5 Mon Sep 17 00:00:00 2001 From: Paolo Musolino Date: Mon, 11 Oct 2021 16:17:51 +0200 Subject: [PATCH 2/3] update: release-notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 9d2c85db378..5d14b750bb9 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,6 +6,7 @@ - [*] Fix incorrect info banner color and signature option spacing on Carrier and Rates screen. [https://github.com/woocommerce/woocommerce-ios/pull/5144] - [x] Fix an error where merchants were unable to connect to valid stores when they have other stores with corrupted information https://github.com/woocommerce/woocommerce-ios/pull/5161 - [*] Shipping Labels: The shipping address now prefills the phone number from the billing address if a shipping phone number is not available. [https://github.com/woocommerce/woocommerce-ios/pull/5177] +- [*] Shipping Labels: now in Carrier and Rates we always display the discounted rate instead of the retail rate if available. 7.7 ----- From 9735c1743c107d86415e9ee46a2258b2eaeceffb Mon Sep 17 00:00:00 2001 From: Paolo Musolino Date: Mon, 11 Oct 2021 16:21:54 +0200 Subject: [PATCH 3/3] update: release-notes --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 5d14b750bb9..9b7152f6cb1 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,7 +6,7 @@ - [*] Fix incorrect info banner color and signature option spacing on Carrier and Rates screen. [https://github.com/woocommerce/woocommerce-ios/pull/5144] - [x] Fix an error where merchants were unable to connect to valid stores when they have other stores with corrupted information https://github.com/woocommerce/woocommerce-ios/pull/5161 - [*] Shipping Labels: The shipping address now prefills the phone number from the billing address if a shipping phone number is not available. [https://github.com/woocommerce/woocommerce-ios/pull/5177] -- [*] Shipping Labels: now in Carrier and Rates we always display the discounted rate instead of the retail rate if available. +- [*] Shipping Labels: now in Carrier and Rates we always display the discounted rate instead of the retail rate if available. [https://github.com/woocommerce/woocommerce-ios/pull/5188] 7.7 -----