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

avoid sql error with refunded product #58

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

NicolasCador
Copy link

@NicolasCador NicolasCador commented Jan 19, 2024

Questions Answers
Description? There is a SQL error when there is at least a refunded product in a validated order:
> SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in '(((dbs9731789.od.product_quantity - dbs9731789.od.product_quantity_refunded) - dbs9731789.od.product_quantity_return) - dbs9731789.od.product_quantity_reinjected)'
due to the fact that columns product_quantity, product_quantity_refunded, product_quantity_return, and product_quantity_reinjected are unsigned so the sum is unsigned. But there is a refunded/return product in an order, it could be automatically reinjected. So quantity - refunded/return quantity - reinjected quantity is negative. so it gives a SQL error.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#35107. & PrestaShop/PrestaShop#28431
How to test? 1. Create a validated order (payment by credit card)
2. go to BO and in the order
3. Create a refunding
4. go to dashboard
5. see there IS data in dashproducts hook

Copy link
Member

@boherm boherm left a comment

Choose a reason for hiding this comment

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

Hi @NicolasCador, thanks for your contribution ;)

@AureRita AureRita self-assigned this Jan 29, 2024
@AureRita
Copy link

Hi @NicolasCador

Thank you for your PR, I tested it and it seems to works on develop as you can see :

recording.77.webm

Unfortunately, when I test on 8.1.x, I keep the "Recents Orders" but I can't have the "best sellers" before and after the partial refund as you can see :

recording.78.webm

Did you know how we can improve your modification ?

Thank you for your first PR which was clear enough for me to test it easily !

Waiting for your feedback

@NicolasCador
Copy link
Author

Hi @AureRita ,

ok, thank you for your feedback.

I'm sorry, I have 8.1.x and I can see the "best sellers" before and after the partial refund.

And it seems the videos are photos: when I click on play, it doesn't move. Could you plea&se check?

Thanks

PS:
you're using Firefox, if you right click on the page then on Inspect, then on Network ; then you refresh the "best sellers" by clicking on the double arrows, then check the answer of the last index.php in Network: what is the response?
image

@NicolasCador
Copy link
Author

Hello, I answered

@NicolasCador
Copy link
Author

Hello @AureRita, how to remove waiting for author?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for review
Development

Successfully merging this pull request may close these issues.

dashproducts module - SQL error with refunded product in validated order
5 participants