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

Multiple Cancellations on a same line item not allowed from admin UI #2608

Closed
shaheerrs opened this issue Dec 29, 2023 · 2 comments
Closed
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@shaheerrs
Copy link

shaheerrs commented Dec 29, 2023

** Multiple Cancellations on a same line item not allowed from admin UI **

To Reproduce

  1. Go to 'https://demo.vendure.io/'
  2. Create and order with 2 items of 3 quantity each
  3. Add payment to order
  4. Use Refund or cancel 2 quantity from 1st item and 1 quantity from second item.
  5. Trigger refund
  6. Now try to use Refund or cancel option to cancel the one quantity remaining in the first item. (you can see the option is disabled)

Expected behavior
The Customer support should be able to cancel multiple times on line item until it reaches 0.

Environment (please complete the following information):

  • @vendure/core version: Vendure2.1.0
  • Nodejs version - Node 18
  • Database (mysql/postgres etc): Postgres

Additional context
In the above mentioned scenario see the item where I cannot select refund / cancel to proceed with full item cancellation from Admin UI
Screenshot 2023-12-29 at 7 45 23 AM

@shaheerrs shaheerrs added the type: bug 🐛 Something isn't working label Dec 29, 2023
@shaheerrs shaheerrs changed the title Cancellation Issue Multiple Cancellations on a same line item not allowed from admin UI Dec 29, 2023
@michaelbromley michaelbromley moved this to 📋 Backlog in Vendure OS Roadmap Jan 2, 2024
@shaheerrs
Copy link
Author

@michaelbromley I was debugging the code and it seems the following code is the root cause of the issue
lineCanBeRefundedOrCancelled(line) { const refundedCount = this.order.payments ?.reduce((all, payment) => [...all, ...payment.refunds], []) .filter(refund => refund.state !== 'Failed') .reduce((all, refund) => [...all, ...refund.lines], []) .filter(refundLine => refundLine.orderLineId === line.id) .reduce((sum, refundLine) => sum + refundLine.quantity, 0) ?? 0; return refundedCount < **line.quantity**;

Here the line.quantity will always get reduced with cancellation, so the check is always against the remaning quantity in the order than the order placed quantity.

@michaelbromley
Copy link
Member

Thanks for the report & the advice on the location of the bug. You are correct! This will be fixed in the next patch.

@michaelbromley michaelbromley moved this from 📋 Backlog to 🏗 In progress in Vendure OS Roadmap Jan 12, 2024
@michaelbromley michaelbromley moved this from 🏗 In progress to ✅ Done in Vendure OS Roadmap Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
Status: 🚀 Shipped
Development

No branches or pull requests

2 participants