Code Monkey home page Code Monkey logo

pmpro-vat-tax's Introduction

License

Welcome to the Paid Memberships Pro - VAT (Value Added Tax) Add On GitHub Repository

Calculate VAT at checkout and allow customers with a VAT Number to avoid the tax. This plugin adds a new section on the Membership Checkout form titled "European Union Residents VAT".

The customer can select their EU country of residence from a drop-down box or enter their VAT number to avoid the tax. The entered VAT number is validated using the SOAP service provided through the European Commission (https://ec.europa.eu/taxation_customs/vies/technicalInformation.html).

For more information please visit paidmembershipspro.com/add-ons/vat-tax/

Installation

For detailed installation steps, visit the documentation page.

  1. Download the current development ZIP file directly: https://github.com/strangerstudios/pmpro-vat-tax/archive/dev.zip

Please ensure that once installing this version of the plugin to remove -dev from the plugin's folder name.

Bugs

If you find an issue/bug, let us know by creating a detailed GitHub issue.

Support

This is a developer's portal for Paid Memberships Pro - VAT (Value Added Tax) Add On. We do not offer support on this channel. Any support related questions should be directed to paidmembershipspro.com/support.

Contributing to Paid Memberships Pro - VAT (Value Added Tax) Add On

We encourage and welcome any contribution to Paid Memberships Pro - VAT (Value Added Tax) Add On. Please read the guidelines for contributing to this repository.

There are various ways to the help development of Paid Memberships Pro - VAT (Value Added Tax) Add On:

  1. Report bugs/issues on GitHub.
  2. Work on any issues by submitting a Pull Request.

Here are some ways for non-developers to contribute to Paid Memberships Pro - VAT (Value Added Tax) Add On:

  1. Translate Paid Memberships Pro - VAT (Value Added Tax) Add On into your own language.
  2. Purchase a paid membership to help fund ongoing development and bug fixes.

pmpro-vat-tax's People

Contributors

00travelgirl00 avatar alvaromartinezmajado avatar andrewlimaza avatar dparker1005 avatar eighty20results avatar github-actions[bot] avatar greathmaster avatar ideadude avatar ipokkel avatar jarrydlong avatar kimcoleman avatar lessthanweb avatar messica avatar michaelbeil avatar mircobabini avatar noeggfriedrice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pmpro-vat-tax's Issues

Internal server error when validating VAT number

I am getting an internal server error when I click ‘apply’ to validate a VAT number.

The error doesn’t stop the payment from working, with or without a VAT number, and if I’ve entered a VAT number, no VAT is added to the total (which is correct). It’s just the VAT number validation which is breaking. Which will most certainly result in user complaints / enquiries from end users.

Portuguese VAT number fails to validate

Entering a valid Portuguese VAT number returns invalid. It seems some VAT validations return true while mostly returning false.

Ticket Reference: #377166

Vat field is not hidden on same country if was visible

To replicate the issues:

  1. Select a country which is NOT the seller_country
  2. Tick the vat box checkbox (it will show the vat_number_validation_tr)
  3. Select the country === seller_country

The vat checkbox will hide, but the vat_number_validation_tr will still be there.

Solution:
Imho, we should add a parent div for #vat_have_number and #vat_number_validation_tr.

Update text domain

Text domain (currently pmprovat) should match plugin slug (pmpro-vat-tax).

VAT amount is not added to the order total

The new .4 VAT plugin is not adding the VAT amount to the order total.

Users can enter VAT details, or not, and the base price (pre-tax) is not changed

This is how the plugin should work, as far as I can see:

  • If the VAT add-on is installed AND I set my EU VAT Seller Country ti ‘United Kingdom’, the default VAT rate should automatically be set to 20%. (ie 20% is added to all the prices)
  • If a member enters their EU country, the VAT rate should change to the country-specific VAT rate percentage (and the order total updated)
  • If a member enters their EU VAT code, then the VAT should be removed from the order total

In its current state, this plugin is not usable.

Detect if the VAT Number Entered Contains the Country ISO Code

There's cases where a member will enter a full VAT number including country code which results in the validation failing as we prepend the country code to the VAT number before validation.

We should rather check if the country code is present, then use it as is, otherwise prepend it to the VAT number where necessary based on the country selected.

not working anymore

Hi,
After the latest updates (either to the core or other addons) the VAT addon stopped working. It used to require the user to select the VAT country and used to check if the selected country is the same as the country in the billing address. Not anymore. If it is left on "choose one" or selecting a different country than the one given in billing address does not stop the registration process.

Show billing address for company

Is your feature request related to a problem? Please describe.
A customer (ticket ID 338442) moderators only sent in a ticket sent in the following request:

Billing Address for Company

There is a way to show billing address for Companies?
I mean now there is Name and Surname, is there also the possibility to include:
– Company Name
– VAT

Describe the solution you'd like
Show billing address for a company.

Additional context
Add a field in the WordPress dashboard that would make this possible to show on the front end.

Make sure the subtotal on recurring orders is the price excluding tax

A user has reported that recurring payments with Stripe have orders created with subtotals that include the VAT price.

From the user:

The order for the initial payment went through as anticipated – £10 subscription + £2 tax = £12. The subtotal field and tax fields were completed correctly.
We did notice that the recurring payment on the Edit User was reported as £10 – the no-VAT figure.
The next payment came through at £12, which is correct. Looking at the order detail, the subtotal is reported as £12 and the tax as £2.40, with a total of £12.

The new order should have a subtotal of £10, a tax value of £2, and total of £12.

Document VAT for recurring orders.

Currently, only the initial order shows the tax, subtotal, and total correctly. For recurring orders, the tax is 0. The subtotal for the recurring order seems to show the original price + tax.

Request for Enhancement #1

From the members support forum:

One thing that I am sure will be really confusing for customers is the part where only EU customers need to select a country from the drop-down box. I am quite sure that customers outside of the EU won’t really understand and will look for their country in the list – and if they can’t find it this will cause confusion and loss of sales.

Would it be possible to have a country list of ALL countries in the world? Then, any EU counties selected will have VAT added, and non-EU selections will not have the added VAT. I think this will make it much more user-friendly.

Enhancement: Better handling of VAT number

As per this topic: https://www.paidmembershipspro.com/forums/topic/vat-number-on-checkout-and-also-wrong-on-invoices/

An EU VAT number consists of a country prefix such as NL or DE and then a 8 digit number — like: DE12345678

On the checkout page, only the 8 digit code is accepted without the country prefix. – 12345678. We also only validate the number, without the prefix.

Therefore, PMPRO prints a wrong VAT number of the client on the invoice as the country prefix is missing.

Fatal error: Uncaught Error: Call to a member function checkVat()

Describe the bug
As reported in ticket 414552 (moderators only), there is an error after purchasing a membership.

To Reproduce
Steps to reproduce the behavior:

  1. Make a purchase with the VAT Add On activated, select a country, and pay by check.
  2. See error: Fatal error: Uncaught Error: Call to a member function checkVat() on null in /test/app/public/wp-content/plugins/pmpro-vat-tax/includes/vatValidation.class.php on line 30

Screenshots
image
Expected behavior
There should not be an error shown.

Isolating the problem:

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

WordPress Environment

``` Paid Memberships Pro 2.7.5, Pay by Check Add On 0.10, VAT Add On 0.7.1, Twenty Twenty-One 1.4, WordPress 5.9.3, and PHP 7.4.1. ```

Bug: Undefined Variable

Notice: Undefined variable: bstate in C:\wamp64\www\pmpro\wp-content\plugins\pmpro-vat-tax\pmpro-vat-tax.php on line 471

Error occurs after proceeding through checkout.

Tested On:
WordPress 5.4
PMPro 2.3.1
VAT Tax Add-on .5.2
Memberlite 4.3

VAT should not be exempt when seller and customer country are the same

I have just realised there is another major problem with this VAT add-on

  • For sales where seller and customer country are the same, VAT should always be added (so the transaction can’t be VAT exempt)

So, VAT exemption upon the presentation of a valid VAT number is only relevant for non-matching countries that are both in the EU area, as the reverse charge applies between those countries.

I have just checked the above with our VAT consultant, and this is correct

However, the VAT add-on wrongly allows transactions to be VAT exempt when the seller and customer countries are the same. I have UK set as the seller country and was able to make a VAT-exempt membership purchase with a UK billing address. This should not be allowed. VAT should have been added at 20%.

This needs to be fixed urgently

Small issues

  1. Stripe work only if user enable/set "Show Billing Address Fields:YES" , and it dont work if user set that field as "No" ... This isnt required by Stripe...
  2. Croatia need to be inside "EU" countries - $pmpro_european_union = array().. missing "HR"...
  3. $pmpro_european_union = array()... I18n - right now not usable/translatable via WPML or others...
  4. Need to fix "Greece" - first array is "GR" and in second one is "EL" -> "Greece"
    so its not working right now...

Show order total inc VAT on checkout

On the checkout page, and using the VAT add-on, a customer does not see the accurate order total (inc VAT) until after the payment has been made.

Example: Site owner is based in UK. Membership is £10. Customer is based in the UK, where VAT rate is 20%. Customer is not Vat-registered. Amount payable is £12. Currently, the customer sees the price as £10, then pays and only then sees that they have paid £12. The £2 VAT charge was not explicitly displayed to the customer. This is not acceptable.

I can't think of a single other e-commerce checkout process where this happens. I would also expect this is against UK / EU law, though I can't say for certain.

It is standard practice to show the below details, on a checkout page, prior to making payment:

  • Individual order line amounts
  • Subtotal before tax
  • Tax total
  • Grand total (inc tax)

I believe this info should be presented on the checkout page, so that the customer is aware of the total charge, before submitting payment.

(I've also added this on the forum here )

SoapFault Exceptions

This row can throw a number of exceptions

$rs = $this->_client->checkVat( array('countryCode' => $countryCode, 'vatNumber' => $vatNumber) );

Should be try-catched. Examples:

  • PHP Fatal error: Uncaught SoapFault exception: [soap:Server] MS_UNAVAILABLE
  • PHP Fatal error: Uncaught SoapFault exception: [soap:Server] MS_MAX_CONCURRENT_REQ

Enhancement: integration with PMPro Register Helper

When PMPro Register Helper is active, the field should be added using that addon.

This way, it will also add the value to the user metas for future auto-completion.
In my case I also have the Company Name working the same way.

Fix for the recurring orders total/subtotal bug

The current VAT Tax plugin version won't calculate the tax for recurring orders.

Here is a fix: This code snippet will check new recurring orders for specific total sums you have to define. Then, it will divide this total by a tax rate defined by you and uses it to calculate a subtotal and tax. These sums are added to the orders database entries.

function my_pmpro_email_template($type, $email){
	global $wpdb;
	
	if($type == 'invoice'){

		$data = $email->data;
		$code = $data['invoice_id'];
		$total = $data['invoice_total'];
		$toCheck = [36,48,72,3.5, 4.8,7]; /* check for specific total sums in orders to detect which orders to change */
		$total = number_format(floatval($total),1);
	
		if(in_array($total, $toCheck)) {
			// get order by unique code
			$sql = $wpdb->prepare( "SELECT id, subtotal, tax, total FROM $wpdb->pmpro_membership_orders WHERE code = '%s' LIMIT 1", $code);
			$results = $wpdb->get_results( $sql );
			$morder = [];

			if ( !empty( $results ) ) {
				foreach ( $results as $r ) {
					$morder['id'] = $r->id;
					$morder['subtotal'] = $r->subtotal;
					$morder['tax'] = $r->tax;
					$morder['total'] = $r->total;
				}

				$tax = intval($morder['tax']);
				if($tax == 0){
					$divisor = 1.1; /* enter tax rate here to calculate subtotal and tax */ 
					$y = date('Y');
					$m = date('m');
	
					$no = (float)($total / $divisor);
					$no = pmpro_round_price($no);
					$morder['subtotal'] = $no;
					$tax = pmpro_round_price((float)($total - $no));
					$id = $morder['id'];
				
					$sqlQuery = "UPDATE $wpdb->pmpro_membership_orders
							SET 
							`subtotal` = '" . $no . "',
							`tax` = '" . $tax . "'
							WHERE id = '" . $id . "'
							LIMIT 1";
					$wpdb->query($sqlQuery);
				}

			}
			
		}
	}
	return $type;
}
add_filter('pmpro_email_template', 'my_pmpro_email_template',10,2);

VAT number formats not clear

Customers are reporting issues with "VAT number not validated" because the input format for the VAT number either isn't described, or (ideally) we're not stripping out extra whitespace/dashes/etc when we process the VAT number.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.