-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Order form] Use order item data for products in order creation/editing #13305
Conversation
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
@rachelmcr I would appreciate it if you could take a look at this 🙇 . I opted to make as simple changes as possible to address the main issue - showing misleading prices in the product section when Yes, I will enter prices inclusive of tax setting is enabled. In your previous PR #11431 you made further improvements around loading states and chose to pass additional properties to the collapsable card rather than using the existing |
0e66a92
to
49e68f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this!
I found two things that behave oddly, but I think both precedes your changes and seem related to displaying the price without taking into account the store settings regarding inclusive/exclusive of taxes:
- When testing custom amounts note how using
Yes, I will enter prices inclusive of tax
still allows us to add additional tax on top of a custom amount, since can be edited by toggling the button.
Custom amount | Toggle taxes |
---|---|
- Having products inclusive/exclusive of taxes seems to be ignored if we "Set new tax rate". In this example prices should already have taxes baked in, but upon setting a new tax it adds it to the current price 🤔
I don't have full context of the custom amounts/set tax features, but as mentioned these exist before your PR, so we should log/address them separately
Yosemite/Yosemite/Model/Orders/OrderItem+PricePreDiscount.swift
Outdated
Show resolved
Hide resolved
@@ -137,7 +137,7 @@ public struct ProductInputTransformer { | |||
product: product, | |||
quantity: quantity, | |||
discount: discount ?? defaultDiscount, | |||
baseSubtotal: baseSubtotal(on: item), | |||
baseSubtotal: item.pricePreDiscount.decimalValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While not part of this PR, the same as above: How about netPrice
or basePrice
for the property? I'd say baseSubtotal
feels off since both base and subtotal should mean the same price-wise ( a base price without any modifiers).
…m price When making order, we need to show a order item price for a single item without discounts and taxes. There's no property to support all of these requirements so we need to calculate it ourselves. This mimics the functionality that Android already has.
…diting/creation flow When we have Tax setting "Yes, I will enter prices inclusive of tax" enabled, using product.price in Order view results in different information shown in Product List and Order Summary within Order View. Order Summary shows product prices without taxes, while Product List shows full price including the tax. Use pre-discount single order item price which mimics the behavior on Android and on the web when displaying products within order.
…tTransformer When calculating prices, Yosemite already uses pricePreDiscount logic within baseSubtotal method.
Thanks for the review, @iamgabrielma!
I think it's fine behavior, no? Regardless of this setting, we still allow users to select whether a tax will be applied to the Custom Amount or not. Even if Your expected behavior would be that if
I see what you mean and that's a very good point. I agree that if the product already includes taxes, then the total shouldn't change, just the I created an issue: #13342 and may file a CUW p1721127325826489-slack-C025A8VV728 Edit: This issue is also reported on the web (woocommerce/woocommerce#30702). Even if it's a bug, it's not an app issue. |
49e68f0
to
402e091
Compare
Nevermind, you can ignore my last comment. I'm not sure what was happening with my testing on this branch earlier, but it's now all working as expected. Looks good! The only issue I've seen is with the "Price after discount" amount when editing a product discount where the product quantity is > 1, but it looks like that is resolved with #13313.
Your solution looks good to me! I can't remember why I approached it the way I did before, and this approach looks clean and easy to follow. |
Thanks for the review @rachelmcr! Appreciate that 🙇
Good to hear! Not sure what happened there as well 🤔
Yes, it was resolved there. I haven't merged this branch with trunk after merging the other PR. |
Closes: #11455
Investigation: pdfdoF-4rm-p2
Description
This PR addresses an issue where iOS uses
Product
price, instead of theOrder Item
price in the Order Creation / Editing view.It results in a couple of issues when Yes, I will enter prices inclusive of tax setting is enabled.
3.1 When discounts are applied, discounted totals in the Product Section are calculated with included taxes, again resulting in different product prices displayed in Order Summary.
3.2. Individually-priced bundle products are shown with full price, rather than an individual price within the bundle, which sums up to a different total that is shown in the Order Summary.
Solution
The simplest solution I found is to pass
a single pre-tax pre-discount order item price
toCollapsibleProductRowCardViewModel
rather thanProduct.price
. This mimics what Android implemented (https://github.com/woocommerce/woocommerce-android/blob/1e2829c413233e7a1a8602137ea8b2858b377386/WooCommerce/src/main/kotlin/com/woocommerce/android/model/Order.kt#L126) with introducingbasePrice
toOrder Item
. This is also could be considered a continuation of another fix #11012 which started using this single order item subtotal price to address order total calculation issues.basePrice
behaves as we would expect because it:Other existing
Order Item
properties do not satisfy these requirements:Other not-addressed issues:
Simple Product
The product price is correctly displayed before tax which matches the "Products" line in the Order Summary
Simple Product + Discount
The product price is correctly displayed before which matches the "Products" line in the Order Summary
Variable Product + Discount
Product Bundle + Child item custom price
Testing information
Checklist borrowed from pdfdoF-4rm-p2:
With the Prices entered with tax setting – Yes, I will enter prices inclusive of tax
1.1 When adding an item to an order –
- The item's total should be equal to the item's price, excluding taxes.
- Taxes total should be calculated based on the item's price excluding taxes.
1.2 When incrementing a quantity of the item –
- The items' total should be updated accordingly, excluding taxes.
- Taxes total should be calculated based on the sum of items' prices excluding taxes.
1.3 When adding a discount to the item –
- The item's total should be reduced according to the discount amount.
- Taxes total for that item should be calculated based on the item's total excluding taxes reduced by the discount amount.
With the Prices entered with tax setting – No, I will enter prices exclusive of tax
2.1 When adding an item to an order –
- The item's total should be equal to the item's price, excluding taxes.
- Taxes total should be calculated based on the item's price excluding taxes.
2.2 When incrementing a quantity of the item –
- The items' total should be updated accordingly, excluding taxes.
- Taxes total should be calculated based on the sum of items' prices excluding taxes.
2.3 When adding a discount to the item –
- The item's total should be reduced according to the discount amount.
- Taxes total for that item should be calculated based on the item's total excluding taxes reduced by the discount amount.
Testing steps (Borrowed from #11431)
+
to create an orderRELEASE-NOTES.txt
if necessary.