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

VAT is not being refunded when using wc_create_refund() #22157

Closed
3 tasks done
YourMark opened this issue Dec 6, 2018 · 4 comments
Closed
3 tasks done

VAT is not being refunded when using wc_create_refund() #22157

YourMark opened this issue Dec 6, 2018 · 4 comments

Comments

@YourMark
Copy link

YourMark commented Dec 6, 2018

Describe the bug
I have created a script (see below) that fetches the orders that are given, goes through them and should refund the entire order.

All lines are refunded, except the VAT unfortunately. This causes the refund amount to be incorrect.

I have tried to follow the args for wc_create_refund() as far as possible and when dumping the $args in the woocommerce_refund_created filter, I see the VAT as I expect it. But it's not showing up on the order.

To Reproduce
I have created this script: https://gist.github.com/YourMark/cc5c02aa624090c453adbdf05aa7e6c5
This runs through WP-CLI.

Screenshots
edit_order_ _patboard_ _wordpress
In the screenshot you can see that the VAT (BTW in Dutch) is not refunded, the amount does not add up.

Expected behavior
I expected the VAT per order line to be refunded.

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment
Note: It says Twenty Seventeen active, but I also tried it with StoreFront and the custom theme for this site. The result is the same in all.

`

WordPress Environment

Home URL: https://dev.patboard
Site URL: https://dev.patboard
WC Version: 3.5.2
Log Directory Writable: ✔
WP Version: 4.9.8
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –

Server Environment

Server Info: Apache
PHP Version: 7.2.8
PHP Post Max Size: 8 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.60.0
OpenSSL/1.0.2o

SUHOSIN Installed: –
MySQL Version: 5.7.23
Max Upload Size: 8 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 3.5.1
WC Database Prefix: wpshop_
Total Database Size: 879.64MB
Database Data Size: 707.75MB
Database Index Size: 171.89MB
wpshop_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB
wpshop_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB
wpshop_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB
wpshop_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.05MB
wpshop_woocommerce_order_items: Data: 3.52MB + Index: 1.52MB
wpshop_woocommerce_order_itemmeta: Data: 26.56MB + Index: 31.11MB
wpshop_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB
wpshop_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.05MB
wpshop_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB
wpshop_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB
wpshop_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB
wpshop_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB
wpshop_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB
wpshop_woocommerce_log: Data: 0.02MB + Index: 0.02MB
wpshop_acm_cron_logs: Data: 0.02MB + Index: 0.00MB
wpshop_ac_abandoned_cart_history_lite: Data: 1.52MB + Index: 0.00MB
wpshop_ac_email_templates_lite: Data: 0.03MB + Index: 0.00MB
wpshop_ac_guest_abandoned_cart_history_lite: Data: 0.13MB + Index: 0.00MB
wpshop_ac_sent_history_lite: Data: 0.09MB + Index: 0.00MB
wpshop_aelia_dismissed_messages: Data: 0.02MB + Index: 0.00MB
wpshop_aelia_exchange_rates_history: Data: 0.02MB + Index: 0.00MB
wpshop_cloudinvoiceclient: Data: 0.02MB + Index: 0.00MB
wpshop_commentmeta: Data: 0.02MB + Index: 0.03MB
wpshop_comments: Data: 10.52MB + Index: 10.09MB
wpshop_cp_feeds: Data: 0.02MB + Index: 0.00MB
wpshop_ewwwio_images: Data: 2.52MB + Index: 2.81MB
wpshop_geot_countries: Data: 0.02MB + Index: 0.02MB
wpshop_grp_google_place: Data: 0.02MB + Index: 0.02MB
wpshop_grp_google_review: Data: 0.02MB + Index: 0.03MB
wpshop_links: Data: 0.02MB + Index: 0.02MB
wpshop_mollie_pending_payment: Data: 0.02MB + Index: 0.00MB
wpshop_options: Data: 3.48MB + Index: 1.14MB
wpshop_pay_options: Data: 0.02MB + Index: 0.00MB
wpshop_pay_option_subs: Data: 0.02MB + Index: 0.00MB
wpshop_pay_transactions: Data: 0.05MB + Index: 0.02MB
wpshop_postmeta: Data: 135.63MB + Index: 69.22MB
wpshop_posts: Data: 11.52MB + Index: 3.70MB
wpshop_redirection_404: Data: 0.02MB + Index: 0.06MB
wpshop_redirection_groups: Data: 0.02MB + Index: 0.03MB
wpshop_redirection_items: Data: 0.02MB + Index: 0.08MB
wpshop_redirection_logs: Data: 0.02MB + Index: 0.08MB
wpshop_sm_sessions: Data: 475.00MB + Index: 39.67MB
wpshop_snippets: Data: 0.02MB + Index: 0.00MB
wpshop_termmeta: Data: 0.05MB + Index: 0.03MB
wpshop_terms: Data: 0.09MB + Index: 0.09MB
wpshop_term_relationships: Data: 0.25MB + Index: 0.14MB
wpshop_term_taxonomy: Data: 0.09MB + Index: 0.13MB
wpshop_usermeta: Data: 9.52MB + Index: 6.03MB
wpshop_users: Data: 0.20MB + Index: 0.20MB
wpshop_wcpdf_credit_note_number: Data: 0.02MB + Index: 0.00MB
wpshop_wcpdf_invoice_number: Data: 0.27MB + Index: 0.00MB
wpshop_wcpdf_packing_slip_number: Data: 0.11MB + Index: 0.00MB
wpshop_wcpdf_proforma_number: Data: 0.02MB + Index: 0.00MB
wpshop_wc_download_log: Data: 0.02MB + Index: 0.03MB
wpshop_wc_webhooks: Data: 0.02MB + Index: 0.02MB
wpshop_wfBadLeechers: Data: 0.02MB + Index: 0.00MB
wpshop_wfBlockedCommentLog: Data: 0.02MB + Index: 0.00MB
wpshop_wfBlockedIPLog: Data: 0.02MB + Index: 0.00MB
wpshop_wfBlocks: Data: 0.02MB + Index: 0.02MB
wpshop_wfBlocks7: Data: 0.02MB + Index: 0.05MB
wpshop_wfBlocksAdv: Data: 0.02MB + Index: 0.00MB
wpshop_wfConfig: Data: 2.42MB + Index: 0.00MB
wpshop_wfCrawlers: Data: 0.02MB + Index: 0.00MB
wpshop_wfFileChanges: Data: 0.02MB + Index: 0.00MB
wpshop_wfFileMods: Data: 4.52MB + Index: 0.00MB
wpshop_wfHits: Data: 1.41MB + Index: 0.22MB
wpshop_wfHoover: Data: 8.52MB + Index: 1.52MB
wpshop_wfIssues: Data: 0.02MB + Index: 0.06MB
wpshop_wfKnownFileList: Data: 2.52MB + Index: 0.00MB
wpshop_wfLeechers: Data: 2.52MB + Index: 0.00MB
wpshop_wfLiveTrafficHuman: Data: 0.02MB + Index: 0.02MB
wpshop_wfLockedOut: Data: 0.02MB + Index: 0.00MB
wpshop_wfLocs: Data: 0.02MB + Index: 0.00MB
wpshop_wfLogins: Data: 0.17MB + Index: 0.06MB
wpshop_wfNet404s: Data: 0.02MB + Index: 0.02MB
wpshop_wfNotifications: Data: 0.02MB + Index: 0.00MB
wpshop_wfPendingIssues: Data: 0.02MB + Index: 0.06MB
wpshop_wfReverseCache: Data: 0.02MB + Index: 0.00MB
wpshop_wfScanners: Data: 0.02MB + Index: 0.00MB
wpshop_wfSNIPCache: Data: 0.02MB + Index: 0.05MB
wpshop_wfStatus: Data: 0.14MB + Index: 0.11MB
wpshop_wfThrottleLog: Data: 0.02MB + Index: 0.02MB
wpshop_wfTrafficRates: Data: 0.02MB + Index: 0.00MB
wpshop_wfVulnScanners: Data: 0.02MB + Index: 0.00MB
wpshop_woocommerce_arr_log: Data: 0.09MB + Index: 0.00MB
wpshop_woocommerce_exported_csv_items: Data: 0.02MB + Index: 0.02MB
wpshop_wsal_metadata: Data: 2.52MB + Index: 2.52MB
wpshop_wsal_occurrences: Data: 0.30MB + Index: 0.38MB
wpshop_wsal_options: Data: 0.02MB + Index: 0.00MB
wpshop_yoast_seo_links: Data: 0.19MB + Index: 0.09MB
wpshop_yoast_seo_meta: Data: 0.14MB + Index: 0.00MB

Post Type Counts

attachment: 1311
blocks: 12
braintree_log: 33
custom_css: 1
customize_changeset: 7
export_template: 5
faqs: 10
mc4wp-form: 2
nav_menu_item: 84
oembed_cache: 10
page: 53
post: 8
postman_sent_mail: 250
product: 378
product_variation: 98
revision: 49
scheduled_export: 5
scheduled-action: 18
shipping_package: 3
shipping_zone: 2
shop_coupon: 31
shop_order: 10787
shop_order_refund: 148
swift-slider: 10
team: 5
testimonials: 3
user_request: 1
was: 12
wc_reminder_email: 5
wpcf7_contact_form: 8

Security

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins (2)

Patboard custom functionality: by YourMark – 1.0
WooCommerce: by Automattic – 3.5.2

Settings

API Enabled: ✔
Force SSL: ✔
Currency: EUR (€)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

WC Pages

Shop base: ❌ Page not set
Cart: #11205 - /cart/
Checkout: #11206 - /checkout/
My account: #11207 - /my-account/
Terms and conditions: #11229 - /terms-and-conditions/

Theme

Name: Twenty Seventeen
Version: 1.7
Author URL: https://wordpress.org/
Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce Support: ✔

Templates

Overrides: –
`

@YourMark
Copy link
Author

YourMark commented Dec 6, 2018

I have found the issue.

Apparently the tax ID had to be passed to the array too. This was not documented unfortunately, but this works now.

@YourMark YourMark closed this as completed Dec 6, 2018
@n9yty
Copy link

n9yty commented Jul 29, 2019

Would you mind documenting the details of what tax ID and where you passed it in? Having it here for those who search (like me) would be helpful. :)

@YourMark
Copy link
Author

Ah yes, right. For those who else need it: This was the solution that worked for me:
https://gist.github.com/YourMark/cc5c02aa624090c453adbdf05aa7e6c5#gistcomment-2984690

@jvdsmonta
Copy link

jvdsmonta commented Nov 15, 2019

@n9yty We found out :) from the WooCommerce REST api the request should look like:

{
"reason": "Line Item refund",
"amount": "15.00",
"line_items": {
"139": {
"qty": 1,
"refund_total": "15.00",
"refund_tax": {
"1": "3.15"
}
}
}
}

Where 1 is the tax_class
And refund_total should not include the tax. (This is incorrect in the example above.)

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

No branches or pull requests

3 participants