Skip to content
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

Partial refund for products #12164

Draft
wants to merge 8 commits into
base: trunk
Choose a base branch
from
Draft

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Jul 29, 2024

Closes: https://github.com/woocommerce/woomobile-private/issues/285

Description

This PR adds partial refund support for products. Before, the user could only select the products' quantity, and the amount was calculated as a full refund.

Warning

wordpress-mobile/WordPress-FluxC-Android#3069 must be merged before this.

Now, we are shooting a custom amount dialog when the product refund text is tapped. This dialog was already implemented with #1633 but removed later.

before after after-dialog

Steps to reproduce

  1. Open the Orders tab.
  2. Tap + button to create a new order.
  3. Add products, custom amount and shipping and create an order.
  4. Navigate back.
  5. Tap the order item you just created.
  6. Tap the "Issue refund" button.
  7. Make a partial refund.

Testing information

Please test different order types that include products, custom amounts, and shipping. Test full and partial refund.

  • Only products
  • Products and custom amount
  • Products and shipping
  • Products, shipping and custom amount

Images/gif

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@irfano irfano added type: enhancement A request for an enhancement. status: do not merge Dependent on another PR, ready for review but not ready for merge. feature: refunds Related to order refunds. labels Jul 29, 2024
@irfano irfano added this to the 19.8 milestone Jul 29, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 29, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit541fa01
Direct Downloadwoocommerce-wear-prototype-build-pr12164-541fa01.apk

@dangermattic
Copy link
Collaborator

dangermattic commented Jul 29, 2024

1 Error
🚫 This PR is tagged with status: do not merge label(s).
1 Warning
⚠️ This PR is assigned to the milestone 19.8. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

Found 1 violations:

The PR caused the following dependency changes:

expand

-+--- org.wordpress:fluxc:trunk-cc6b2f85546a844b13d99bc0ad6ceabd1af131d3
-|    +--- org.jetbrains.kotlin:kotlin-parcelize-runtime:1.9.25
-|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
-|    |    \--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.9.25
-|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
-|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
-|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.2 (*)
-|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6
-|    |    \--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
-|    +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
-|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.7.0 (*)
-|    |    +--- com.google.crypto.tink:tink-android:1.5.0
-|    |    \--- androidx.collection:collection:1.1.0 -> 1.4.0 (*)
-|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
-|    |    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
-|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.9.10 (*)
-|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-|    +--- org.apache.commons:commons-text:1.10.0 (*)
-|    +--- androidx.room:room-runtime:2.6.1 (*)
-|    +--- androidx.room:room-ktx:2.6.1
-|    |    +--- androidx.room:room-common:2.6.1 (*)
-|    |    +--- androidx.room:room-runtime:2.6.1 (*)
-|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 1.9.25 (*)
-|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1 -> 1.8.1 (*)
-|    |    +--- androidx.room:room-common:2.6.1 (c)
-|    |    \--- androidx.room:room-runtime:2.6.1 (c)
-|    +--- com.google.dagger:dagger:2.51.1
-|    |    \--- javax.inject:javax.inject:1
-|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1 (*)
-|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1 (*)
-|    +--- org.wordpress:wellsql:2.0.0
-|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
-|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
-|    +--- org.wordpress.fluxc:fluxc-annotations:trunk-cc6b2f85546a844b13d99bc0ad6ceabd1af131d3
-|    +--- org.greenrobot:eventbus:3.3.1 (*)
-|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
-|    +--- com.android.volley:volley:1.1.1 -> 1.2.0
-|    +--- androidx.paging:paging-runtime:2.1.2
-|    |    +--- androidx.paging:paging-common:2.1.2
-|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.7.0 (*)
-|    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.2.0 (*)
-|    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.2.0 (*)
-|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.6.2 (*)
-|    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2 (*)
-|    |    \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.2 (*)
-|    +--- com.goterl:lazysodium-android:5.0.2
-|    +--- net.java.dev.jna:jna:5.5.0
-|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
++--- org.wordpress:fluxc:3069-7afd7e6be72dd202b98897527c5878d7c1a4aeff
+|    +--- org.jetbrains.kotlin:kotlin-parcelize-runtime:1.9.25
+|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
+|    |    \--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.9.25
+|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
+|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
+|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.2 (*)
+|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6
+|    |    \--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
+|    +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
+|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.7.0 (*)
+|    |    +--- com.google.crypto.tink:tink-android:1.5.0
+|    |    \--- androidx.collection:collection:1.1.0 -> 1.4.0 (*)
+|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
+|    |    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
+|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.9.10 (*)
+|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
+|    +--- org.apache.commons:commons-text:1.10.0 (*)
+|    +--- androidx.room:room-runtime:2.6.1 (*)
+|    +--- androidx.room:room-ktx:2.6.1
+|    |    +--- androidx.room:room-common:2.6.1 (*)
+|    |    +--- androidx.room:room-runtime:2.6.1 (*)
+|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 1.9.25 (*)
+|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1 -> 1.8.1 (*)
+|    |    +--- androidx.room:room-common:2.6.1 (c)
+|    |    \--- androidx.room:room-runtime:2.6.1 (c)
+|    +--- com.google.dagger:dagger:2.51.1
+|    |    \--- javax.inject:javax.inject:1
+|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1 (*)
+|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1 (*)
+|    +--- org.wordpress:wellsql:2.0.0
+|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
+|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
+|    +--- org.wordpress.fluxc:fluxc-annotations:3069-7afd7e6be72dd202b98897527c5878d7c1a4aeff
+|    +--- org.greenrobot:eventbus:3.3.1 (*)
+|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
+|    +--- com.android.volley:volley:1.1.1 -> 1.2.0
+|    +--- androidx.paging:paging-runtime:2.1.2
+|    |    +--- androidx.paging:paging-common:2.1.2
+|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.7.0 (*)
+|    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.2.0 (*)
+|    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.2.0 (*)
+|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.6.2 (*)
+|    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2 (*)
+|    |    \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.2 (*)
+|    +--- com.goterl:lazysodium-android:5.0.2
+|    +--- net.java.dev.jna:jna:5.5.0
+|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
-\--- org.wordpress.fluxc.plugins:woocommerce:trunk-cc6b2f85546a844b13d99bc0ad6ceabd1af131d3
-     +--- org.wordpress:fluxc:trunk-cc6b2f85546a844b13d99bc0ad6ceabd1af131d3 (*)
-     +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-     +--- com.google.dagger:dagger:2.51.1 (*)
-     +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1 (*)
-     +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1 (*)
-     +--- androidx.room:room-runtime:2.6.1 (*)
-     +--- org.wordpress:wellsql:2.0.0 (*)
-     +--- org.wordpress.fluxc:fluxc-annotations:trunk-cc6b2f85546a844b13d99bc0ad6ceabd1af131d3
-     +--- androidx.room:room-ktx:2.6.1 (*)
-     \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)
+\--- org.wordpress.fluxc.plugins:woocommerce:3069-7afd7e6be72dd202b98897527c5878d7c1a4aeff
+     +--- org.wordpress:fluxc:3069-7afd7e6be72dd202b98897527c5878d7c1a4aeff (*)
+     +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
+     +--- com.google.dagger:dagger:2.51.1 (*)
+     +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1 (*)
+     +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1 (*)
+     +--- androidx.room:room-runtime:2.6.1 (*)
+     +--- org.wordpress:wellsql:2.0.0 (*)
+     +--- org.wordpress.fluxc:fluxc-annotations:3069-7afd7e6be72dd202b98897527c5878d7c1a4aeff
+     +--- androidx.room:room-ktx:2.6.1 (*)
+     \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (*)

Please review and act accordingly

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 29, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit541fa01
Direct Downloadwoocommerce-prototype-build-pr12164-541fa01.apk

@irfano irfano force-pushed the feature/partial-product-refund branch from 4474d7b to c43c6a6 Compare July 29, 2024 18:13
@@ -867,6 +891,8 @@ class IssueRefundViewModel @Inject constructor(
return availableFeeLines
}

private fun calculateProductTotal(order: Order) = order.items.sumByBigDecimal { it.subtotal + it.totalTax }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this logic to ensure nothing is missed here.

Removed the `textAlignment` property as it was unnecessary.
@irfano
Copy link
Contributor Author

irfano commented Jul 31, 2024

@JorgeMucientes, I found an issue with this implementation. After selecting all products and manually changing the products refund amount, from 126 to 100, the subtotal and taxes still display 126. I think it would be better to make the subtotal and taxes fields editable instead of products refund field, similar to how it is done on the web. WDYT?

If you agree, I can update this PR.

@irfano irfano removed the request for review from JorgeMucientes July 31, 2024 16:35
@irfano irfano added the needs: feedback Needs a response from any of the parties involved in the issue. label Jul 31, 2024
@JorgeMucientes
Copy link
Contributor

I think it would be better to make the subtotal and taxes fields editable instead of products refund field, similar to how it is done on the web. WDYT?

Good catch, @irfano. Yeah, I think that makes sense, and enabling it allows for more flexibility when editing the values.

@irfano irfano removed the needs: feedback Needs a response from any of the parties involved in the issue. label Jul 31, 2024
@irfano irfano marked this pull request as draft July 31, 2024 17:00
@irfano irfano removed this from the 19.8 milestone Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: refunds Related to order refunds. status: do not merge Dependent on another PR, ready for review but not ready for merge. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants