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

Creditmemo when using discount and partial refund does not return the full amount #4396

Open
CalvinMcGee opened this issue Nov 28, 2024 · 6 comments
Labels

Comments

@CalvinMcGee
Copy link

Preconditions (*)

Version: 20.0.20

Steps to reproduce (*)

  1. Create price cart rule
    Skärmdump 2024-11-28, 15 40 29
  2. Enable a payment provider that has _canRefundInvoicePartial = true.
  3. Place an order with payment provider and use the coupon code.
  4. Fulfill the order so it has status complete
    Screenshot 2024-11-28 at 16-05-19 #T-554883 _ Orders _ Sales _ OpenMage Admin
  5. Create a creditmemo.

Expected result (*)

The whole paid amount should be returned.

Actual result (*)

Order lines does not correlate to grand total and there is a difference.

Skärmdump 2024-11-28, 15 50 10

Paid amount in this case is SEK318, but Magento only wants to refund SEK255.50

@Hanmac
Copy link
Contributor

Hanmac commented Nov 28, 2024

@theroch this was one of our problems too, right?

@theroch
Copy link
Contributor

theroch commented Dec 2, 2024

@Hanmac yes, it belongs to ticket #5380 in our system:

Precondition:

  • System -> Configuration -> Sales -> Tax -> Orders, Invoices, Credit Memos Display Settings -> Display of shipping amount: excl. Tax
  • 10% discount

Without discount:

Shipping amount (base_shipping_amount)(Netto): 8,29 €
Total shipping costs (base_shipping_incl_tax)(Brutto): 9,87 €
Input field for refund shipping costs: 9,87 €

{
  "coupon_code": null,
  "base_discount_amount": 0.0000,
  "base_grand_total": 19.8700,
  "base_shipping_amount": 8.2900,
  "base_shipping_tax_amount": 1.5800,
  "base_subtotal": 8.4000,
  "base_tax_amount": 3.1800,
  "discount_amount": 0.0000,
  "grand_total": 19.8700,
  "shipping_amount": 8.2900,
  "shipping_tax_amount": 1.5800,
  "subtotal": 8.4000,
  "tax_amount": 3.1800,
  "base_shipping_discount_amount": 0.0000,
  "base_subtotal_incl_tax": 10.0000,
  "shipping_discount_amount": 0.0000,
  "subtotal_incl_tax": 10.0000,
  "hidden_tax_amount": 0.0000,
  "base_hidden_tax_amount": 0.0000,
  "shipping_hidden_tax_amount": 0.0000,
  "base_shipping_hidden_tax_amnt": 0.0000,
  "hidden_tax_invoiced": null,
  "base_hidden_tax_invoiced": null,
  "shipping_incl_tax": 9.8700,
  "base_shipping_incl_tax": 9.8700
}
$allowedAmount = $order->getShippingAmount() - $order>getShippingRefunded();
//$allowedAmount = 8.29€ - 0€;
$allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded();
//$allowedTaxAmount = 1.58€ - 0€;
$shippingInclTax = $allowedAmount + $allowedTaxAmount;
//9.87€ = 8.29€ + 1.58€

With discount:

Shipping amount (base_shipping_amount)(Netto): 8,29 €
Total shipping costs (base_shipping_incl_tax)(Brutto): 9,87 €
Input field for refund shipping costs: 9,73€ (Difference is 0.14€, due to hidden tax amount)

{
  "coupon_code": "N6KX5L497VK2",
  "base_discount_amount": -1.6700,
  "base_grand_total": 18.2000,
  "base_shipping_amount": 8.2900,
  "base_shipping_tax_amount": 1.4400,
  "base_subtotal": 8.4000,
  "base_tax_amount": 2.9000,
  "discount_amount": -1.6700,
  "grand_total": 18.2000,
  "shipping_amount": 8.2900,
  "shipping_tax_amount": 1.4400,
  "subtotal": 8.4000,
  "tax_amount": 2.9000,
  "base_shipping_discount_amount": 0.8290,
  "base_subtotal_incl_tax": 10.0000,
  "shipping_discount_amount": 0.8290,
  "subtotal_incl_tax": 10.0000,
  "hidden_tax_amount": 0.1400,
  "base_hidden_tax_amount": 0.1400,
  "shipping_hidden_tax_amount": 0.1400,
  "base_shipping_hidden_tax_amnt": 0.1400,
  "hidden_tax_invoiced": 0.28,
  "base_hidden_tax_invoiced": 0.28,
  "shipping_incl_tax": 9.8700,
  "base_shipping_incl_tax": 9.8700
}
$allowedAmount = $order->getShippingAmount() - $order>getShippingRefunded();
//$allowedAmount = 8.29€ - 0€;
$allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded();
//$allowedTaxAmount = 1.44€ - 0€;
$shippingInclTax = $allowedAmount + $allowedTaxAmount;
//9.73€ = 8.29€ + 1.44€

A temporary workaround could be:

  • System -> Configuration -> Sales -> Tax -> Orders, Invoices, Credit Memos Display Settings -> Display of shipping amount: incl. Tax
    But you have to test it with your configuration.

@CalvinMcGee can give please a detailed description of your tax configuration?
We need the following configuration fields:
grafik

Is it possible to post the DB fields as in our example from sales_flat_order for the corresponding order?

@CalvinMcGee
Copy link
Author

@theroch of course. Here it is:

Skärmdump 2024-12-09, 08 03 15

@sreichel
Copy link
Contributor

sreichel commented Dec 9, 2024

Think this is still present in M2.

Thanks for sharing config. Time to rfefactore all that.

@CalvinMcGee
Copy link
Author

@theroch here is also the row from sales_flat_order in JSON format:

{
  "entity_id": 318337,
  "state": "complete",
  "status": "complete",
  "coupon_code": "JOACHIM",
  "protect_code": "4209c1",
  "shipping_description": "DB Schenker Ombud",
  "is_virtual": 0,
  "store_id": 4,
  "customer_id": null,
  "base_discount_amount": "-250.0000",
  "base_discount_canceled": null,
  "base_discount_invoiced": "-250.0000",
  "base_discount_refunded": null,
  "base_grand_total": "318.0000",
  "base_shipping_amount": "55.2000",
  "base_shipping_canceled": null,
  "base_shipping_invoiced": "55.2000",
  "base_shipping_refunded": null,
  "base_shipping_tax_amount": "13.8000",
  "base_shipping_tax_refunded": null,
  "base_subtotal": "399.2000",
  "base_subtotal_canceled": null,
  "base_subtotal_invoiced": "399.2000",
  "base_subtotal_refunded": null,
  "base_tax_amount": "63.6000",
  "base_tax_canceled": null,
  "base_tax_invoiced": "63.6000",
  "base_tax_refunded": null,
  "base_to_global_rate": "1.0000",
  "base_to_order_rate": "1.0000",
  "base_total_canceled": null,
  "base_total_invoiced": "318.0000",
  "base_total_invoiced_cost": "0.0000",
  "base_total_offline_refunded": null,
  "base_total_online_refunded": null,
  "base_total_paid": "318.0000",
  "base_total_qty_ordered": null,
  "base_total_refunded": null,
  "discount_amount": "-250.0000",
  "discount_canceled": null,
  "discount_invoiced": "-250.0000",
  "discount_refunded": null,
  "grand_total": "318.0000",
  "shipping_amount": "55.2000",
  "shipping_canceled": null,
  "shipping_invoiced": "55.2000",
  "shipping_refunded": null,
  "shipping_tax_amount": "13.8000",
  "shipping_tax_refunded": null,
  "store_to_base_rate": "1.0000",
  "store_to_order_rate": "1.0000",
  "subtotal": "399.2000",
  "subtotal_canceled": null,
  "subtotal_invoiced": "399.2000",
  "subtotal_refunded": null,
  "tax_amount": "63.6000",
  "tax_canceled": null,
  "tax_invoiced": "63.6000",
  "tax_refunded": null,
  "total_canceled": null,
  "total_invoiced": "318.0000",
  "total_offline_refunded": null,
  "total_online_refunded": null,
  "total_paid": "318.0000",
  "total_qty_ordered": "1.0000",
  "total_refunded": null,
  "can_ship_partially": null,
  "can_ship_partially_item": null,
  "customer_is_guest": 0,
  "customer_note_notify": 0,
  "billing_address_id": 577988,
  "customer_group_id": 0,
  "edit_increment": null,
  "email_sent": 1,
  "forced_shipment_with_invoice": null,
  "payment_auth_expiration": null,
  "quote_address_id": null,
  "quote_id": 780686,
  "shipping_address_id": 577989,
  "adjustment_negative": null,
  "adjustment_positive": null,
  "base_adjustment_negative": null,
  "base_adjustment_positive": null,
  "base_shipping_discount_amount": "0.0000",
  "base_subtotal_incl_tax": "499.0000",
  "base_total_due": "0.0000",
  "payment_authorization_amount": null,
  "shipping_discount_amount": "0.0000",
  "subtotal_incl_tax": "499.0000",
  "total_due": "0.0000",
  "weight": "5.0000",
  "customer_dob": null,
  "increment_id": "T-554883",
  "applied_rule_ids": "1760",
  "base_currency_code": "SEK",
  "customer_email": "[email protected]",
  "customer_firstname": null,
  "customer_lastname": null,
  "customer_middlename": null,
  "customer_prefix": null,
  "customer_suffix": null,
  "customer_taxvat": null,
  "discount_description": "JOACHIM",
  "ext_customer_id": null,
  "ext_order_id": null,
  "global_currency_code": "SEK",
  "hold_before_state": null,
  "hold_before_status": null,
  "order_currency_code": "SEK",
  "original_increment_id": null,
  "relation_child_id": null,
  "relation_child_real_id": null,
  "relation_parent_id": null,
  "relation_parent_real_id": null,
  "remote_ip": "10.30.0.11",
  "shipping_method": "tablerate_bestway",
  "store_currency_code": "SEK",
  "store_name": "[REDACTED]",
  "x_forwarded_for": "[REDACTED]",
  "customer_note": null,
  "created_at": "2024-11-28 13:28:45",
  "updated_at": "2024-11-28 13:29:44",
  "total_item_count": 1,
  "customer_gender": null,
  "hidden_tax_amount": "50.0000",
  "base_hidden_tax_amount": "50.0000",
  "shipping_hidden_tax_amount": "0.0000",
  "base_shipping_hidden_tax_amnt": "0.0000",
  "hidden_tax_invoiced": "50.0000",
  "base_hidden_tax_invoiced": "50.0000",
  "hidden_tax_refunded": null,
  "base_hidden_tax_refunded": null,
  "shipping_incl_tax": "69.0000",
  "base_shipping_incl_tax": "69.0000",
  "coupon_rule_name": "Joachim 250 SEK",
  "paypal_ipn_customer_notified": 0,
  "gift_message_id": null,
  "payment_fee_amount": "0.00",
  "payment_fee_amount_invoiced": "0.00",
  "payment_fee_amount_refunded": "0.00",
  "payment_fee_tax_amount": "0.00",
  "base_payment_fee_amount": "0.00",
  "base_payment_fee_amount_invoiced": "0.00",
  "base_payment_fee_amount_refunded": "0.00",
  "base_payment_fee_tax_amount": "0.00",
  "payment_fee_title": null,
  "ebizmarts_abandonedcart_flag": null,
  "ebizmarts_magemonkey_campaign_id": null,
  "mailchimp_campaign_id": null,
  "mailchimp_abandonedcart_flag": 0,
  "mailchimp_landing_page": "",
  "base_retain24_amount": "0.00",
  "base_retain24_amount_invoiced": "0.00",
  "base_retain24_amount_refunded": "0.00",
  "retain24_amount": "0.00",
  "retain24_amount_invoiced": "0.00",
  "retain24_amount_refunded": "0.00",
  "retain24_code": null,
  "retain24_reservation_reference_id": null,
  "retain24_pin": null,
  "external_order_api_reference": null,
  "external_order_api_unique_id": null
}

I did try to temporarily switch to Include tax in System -> Configuration -> Sales -> Tax -> Orders, Invoices, Credit Memos Display Settings -> Display of shipping amount, but nothing happened as far as I could see.

Here's our current config:

Skärmbild från 2024-12-09 08-13-21

@Piralein
Copy link

Piralein commented Dec 13, 2024

The description about changing the display settings is about the shipping cost and its discount.

Konfiguration:

Coupon Settings:
coupon

Calculation Settings:
calculation-settings

Order (Exclude Tax Display):
order

Orders, Invoices, Credit Memos Display Settings (All Excluding Tax):

Create Creditmemo:
(Both screenshots are taken with exclude-tax display)

exclude-progress

It displays a different total.
13,69€ instead of 13,41€

Final Overview:
exclude-done

Calculated the refund correctly

Orders, Invoices, Credit Memos Display Settings (All Including Tax):

Create Creditmemo:
(Both screenshots are taken with include-tax display)

including-progress

It displays a different total and the shipping amount of 3€ is refunded with 2.98 (default)

Final Overview:
including-done

0.04€ are missing.

Creditmemo Comparison:

Exclude-Tax Creditmemo:
(Both screenshots are taken with include-tax display)

creditmemo-exclude

Include-Tax Creditmemo:
creditmemo-include

The coupon and shipping amount is different. resulting in 0.04€ less refunded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants