magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Creditmemo not possible if Total Amount was 0 #34294

Closed chequille closed 2 years ago

chequille commented 2 years ago

Preconditions (*)

  1. Magento Version 2.4.3

Steps to reproduce (*)

  1. Create a discount rule with 100%
  2. Enable free shipping
  3. Place an order with the discount and choose free shipping
  4. Total amount is 0
  5. Create Shipping and Invoice
  6. Order is going to status closed
  7. Creditmemo is not possible

Expected result (*)

  1. Even if there was a 100% discount on the order, it should be possible to create a creditmemo, as the customer does have the right to give back to product. It must be possible to get back the product and having the creditmemo on the invoice

Actual result (*)

  1. Order is going to status closed and creditmemo is not possibe anymore

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 2 years ago

Hi @chequille. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @ajijshekh123. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

ajijshekh123 commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @ajijshekh123. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @ajijshekh123, here is your Magento Instance: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-develop.instances.magento-community.engineering Admin access: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-develop.instances.magento-community.engineering/admin_b98f Login: c4a7c4bc Password: 96627e5bc50d

ajijshekh123 commented 2 years ago

Hi @chequille, I have verified this issue on the latest Magento version. Once I have place an order and generate the Invoice and Shipment the order status is showing "Complete" instead of "Close". After generating the Invoice and Shipment, Admin can generate the Credit memo.

The issue is not getting and it's working as expected.

See attached the screenshot:

image

image

image

image

image

Thanks

chequille commented 2 years ago

@ajijshekh123 Sorry, my steps to reproduce were not correct:

  1. My products are with tax, do not see tax in your example
  2. The coupon rule is a fixed value, f.e. 100$ not the 100% as I mentioned before, means under Action choose "Fixed amount discount for whole cart"
  3. In Configuration Sales -> Tax: Apply Customer Tax must be set to "After Discount"
  4. In Configuration Sales -> Tax: Apply Discount On Prices must be set to "Including Tax"

Of course, the cart total value must be less than the fixed discount amount to get "No Payment required"

If you try it like this, after creating the invoice status is going to closed and no credit memo is possible.

Try it Best regards, Chequille

chequille commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @chequille. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @chequille, here is your Magento Instance: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-develop.instances.magento-community.engineering Admin access: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-develop.instances.magento-community.engineering/admin_d073 Login: 07d41432 Password: 197db42565be

ajijshekh123 commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @ajijshekh123. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @ajijshekh123, here is your Magento Instance: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-develop.instances.magento-community.engineering Admin access: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-develop.instances.magento-community.engineering/admin_ad78 Login: 90fc3efc Password: e223441b4980

chequille commented 2 years ago

@ajijshekh123 morning I tried to reproduce it, but the settings of the standard instance differ at so many points compared with my shop which is set to use in Germany. As well, there are some modules installed taking care of German and EU law, which are not installed here in the instance. Maybe the only way for my shop would be to know, where Magento decides to disable the credit memo button and setting status to closed. If I would know this, I may develop a plugin for it to handle it as I need it. But I have no idea where this is done. Maybe you can help me. Best regards, Jürgen

ajijshekh123 commented 2 years ago

Hi @chequille,

Thanks for the information. But as a Magneto Maintainer, I can verify the issue on default Magento Instance and if an issue is present I can verify it else I can close it OR assign it to another maintainer. As per your above comment, You are installing other plugins so it will definitely affect to default Magento functionality. I have advised you can you please verify this issue on the default Magento instance and if it is found let me know so I will verify it and create the ticket on the Magento Jira board else you can be fixed your way.

Thanks.

chequille commented 2 years ago

Hi @ajijshekh123, please try it with my information above and using tax for all products and all countries and zip zones. I believe, that it is not related to my third party modules as they only add some new tax classes and some frontend views. Regards, Chequille

ajijshekh123 commented 2 years ago

Okay @chequille, I will verify this issue ASAP and Update it here.

chequille commented 2 years ago

@magento give me 2.4.3 instance

magento-deployment-service[bot] commented 2 years ago

Hi @chequille. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @chequille, here is your Magento Instance: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-3.instances.magento-community.engineering Admin access: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-3.instances.magento-community.engineering/admin_7409 Login: c6200a23 Password: 3dc31376001a

chequille commented 2 years ago

Hi @ajijshekh123,

I believe I found the problem. It is alittle bit tricky to setup a new shop to reproduce it, as my shop is a german shop with some special things. But I can describe when it happens and when it is working.

Some explanations: we do have two different tax rates in germany, 19% and 7%. THese rates are valid all over germany and they do not depend on regions or states as it is in the US. There are products with 7% tax and there are products with 19% tax. Below a screenshot from my tax rules grafik

What I found is, if an order does contain only products with 7% tax (the frist entry in the rules list), I can create a creditmemo if doing it like above with discount and free shipping. If the order contains a product with 19% tax, creditmemo is not possible anymore because after invoicing the order state is going to closed.

Because of this, you could not reproduce it because the demo shop of an instance is set to US and all products are non tabable.

Therefore, I would like to know the part of the code which is setting the order state after invoicing. It seems for me, that there will be the error.

Do you know where it is done and could you let me know so I can have a look into it? Regards, Chequille

chequille commented 2 years ago

Additional info: in model Magento\Sales\Model\ResourceModel\Order\Handler\State the state of the order is checked and set. WIthin this check, there is a function canCreditmemo() which is called and in case of this function returning false status is set to Closed This canCreditmemo function is defined in Magento\Sales\Model\Order Why it is returning false in case of an order having a product with the 19% tax I have no idea. It is returning true if the order contains only products with 7% tax. So far my insvestigations. I hope somebody does have an idea why this happens and how to fix it.

Regards Chequille

ajijshekh123 commented 2 years ago

@magento give me 2.4.3 instance

magento-deployment-service[bot] commented 2 years ago

Hi @ajijshekh123. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @ajijshekh123, here is your Magento Instance: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-3.instances.magento-community.engineering Admin access: https://64adcc76e524ad5a6a84ea3f074ec277-2-4-3.instances.magento-community.engineering/admin_3421 Login: 30815ac2 Password: eac8898dd068

ajijshekh123 commented 2 years ago

@ajijshekh123 Sorry, my steps to reproduce were not correct:

  1. My products are with tax, do not see tax in your example
  2. The coupon rule is a fixed value, f.e. 100$ not the 100% as I mentioned before, means under Action choose "Fixed amount discount for whole cart"
  3. In Configuration Sales -> Tax: Apply Customer Tax must be set to "After Discount"
  4. In Configuration Sales -> Tax: Apply Discount On Prices must be set to "Including Tax"

Of course, the cart total value must be less than the fixed discount amount to get "No Payment required"

If you try it like this, after creating the invoice status is going to closed and no credit memo is possible.

Try it Best regards, Chequille

Hi @chequille,

I tried with the above your steps but still, the issue is not reproduced. After placing an order with the "No Payment required" payment method. I can able to generate the Invoice and Credit memo.

See attached the screenshot:

  1. Order Placed image

  2. Invoice: image

  3. Credit Memo image

  4. After Generate the Credit memo, The Order status would be 'Closed" image

Thanks.

chequille commented 2 years ago

Hi @ajijshekh123,

sorry, but I still see no tax in your order and as well you did not read my last comments. Of course you can not reproduce it because all products are without tax. As I found, my reported issue only happens if there are more than one tax classes configured. Please read my comments: https://github.com/magento/magento2/issues/34294#issuecomment-945125218 https://github.com/magento/magento2/issues/34294#issuecomment-945197635

If you don't do it as my shop is configured using products with 7% tax and products with 19% tax, it will not be reproducable.

Best regards, Chequille

ajijshekh123 commented 2 years ago

Okay @chequille, Sorry for that. Let me unassign this task and the Magento QA team can itself verify the issue and update the status and comment.

simonmaass commented 2 years ago

We also have a german magento 2.4.3 shop and i can confirm the same issue

chequille commented 2 years ago

@simonmaass Thank you very much for this. Maybe this helps, we are now two having this issue.

engcom-Hotel commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

engcom-Hotel commented 2 years ago

Hello @chequille @simonmaass,

We have tried to reproduce the issue in Magento 2.4-develop branch but for us, it is not reproducible. Please have a look at our configuration below:

  1. Tax Rule: image

  2. Discount Rule: image

  3. Product: image

  4. Tax Configuration in Stores->Configuration ->Sales->Tax: a. Calculation Settings: image

b. Default Tax Destination Calculation: image

  1. After creating shipment and invoice of order, we can create credit memo for the same: image

Please let us know if we have missed anything. I request you to please run this scenario in Magento 2.4-develop.

Thanks

simonmaass commented 2 years ago

@engcom-Hotel could you please show a screenshot from the order?

you have to admit, that a refund of the grand total of 19€ makes absolutely no sense if the order total was 0€

chequille commented 2 years ago

@engcom-Hotel Question: The product you choosed for the order, which tax does it have? If it has the VAT-Standard, then please try to make the same with a the product having the VAT-Reduced Tax

As I said in my comments before, it only happens with one of the two defined tax classes. grafik

In my shop I can do the credit memo when the product does have the 7% Tax, but not when I am using the second defined tax class 19%

If you do not try this, you cannot reproduce the bug I and Simonmaass are reporting.

Best regards, CHequille

chequille commented 2 years ago

Just saw, that your product was set to use VAT-Standard. Therefore, you have to try it with a product having the VAT-Reduced. You (hopefully) will see, that this order cannot be credited.

As well your refund is not correct as Simonmaas said before.

chequille commented 2 years ago

Hi Everybody, as I made as well a few new tests regarding this issue, I found a new situation and it is strange.

Whether the order is going to closed or completed depends on the price value of the product.

I made an order with a product having a price (incl. 19% tax) of 17,40€ and this order is going to closed after I made the invoice. I made another order with a product having a price (incl. 19% tax) of 9,90€ and this order is going to completed after I made the invoice, which is the correct behaviour.

So, I think that there is somewhere a rounding problem of float vlaues which causes this problem. Unfortunately, I did not find yet the point in the code where the status of the order is set, but I guess within this procedure the fault can be found.

Do you know where status is set after invoice is made?

Best regards, Chequile

engcom-Hotel commented 2 years ago

@chequille

Below I have tried with the product price with 17,40€, please have a look at checkout page:

image

I can create the credit memo for this as well. As you mentioned in the main description, we need to enable free shipping, do we need to follow this here as well.

Thanks

chequille commented 2 years ago

Yes, you must add free shipping and as well a coupon code. Order Total must be 0.00€

engcom-Hotel commented 2 years ago

Hello @chequille,

We have tried to reproduce the issue again but we are unable to get the order total as 0. Maybe we have different tax calculations, below are the screenshots for the same:

Checkout Page image

Tax Calculation Settings image

Do we need to make any changes to it? Please let us know.

Thanks

chequille commented 2 years ago

Hi @engcom-Hotel,

sorry, but this is now a completly different bug. Where is the 3,31€ coming from? Sorry, product is €17,40, discount is €17,40 With my calculator 17,40 -17,40 is ZERO

We do not have to go one if the order is wrong as it is above in your example. But, to answer your question: the settings are the same in my setup.

BR Chequille

engcom-Hotel commented 2 years ago

Hello @chequille,

In that case, can we edit the main description with the bug I have encountered? Because we are not able to reproduce the issue you have mentioned.

Or please tell us if missed anything in order to reproduce the issue.

Thanks

chequille commented 2 years ago

Hello @engcom-Hotel, I do not understand what you are talking about. I said in my last comment, that the order you made is completly wrong. There is already the bug that your order does have a total of 3.35€, because it should have a total of 0€ Therefore it is clear, that you cannot reproduce my issue. In my point of view you have first to find why your order is NOT ZERO !!!!

Best regards, Jürgen

engcom-Hotel commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, here is your Magento Instance: https://4cbacf09b833ea61deb174bd6edf54e4.instances.magento-community.engineering Admin access: https://4cbacf09b833ea61deb174bd6edf54e4.instances.magento-community.engineering/admin_4f14 Login: 48b882d3 Password: 14ca8fe4fb8a

engcom-Hotel commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.