driesvints / vat-calculator

Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.
MIT License
1.2k stars 88 forks source link

Calculate net from gross amount? #38

Closed ragulka closed 7 years ago

ragulka commented 7 years ago

We'd like to make sure that all of our customers are billed a fixed amount, regardless of their country. This means we'd need to take the gross subscription cost and calculate the net amount from it. Is there any way to do it or plans to support it? AFAIK, this should be a fairly standard practice in EU - you always display the price with VAT.

Let's say I have a subscription plan that's priced at gross 15€/month, and my business is located in Germany. Since VAT rate in Germany is 19%, the net price would be 15€ - 2,39€ = 12,61€.

1) Customer is from Germany - price is 15€ (including 19% or 2,39€ VAT) 2) Customer is from Finland, does not have a VAT number - price is 15€ (including 24% or 2,9€ VAT) 3) Customer is from outside of EU - price is 12,61€ (VAT is always 0% when exporting) 4) Customer is from any EU country (except from Germany), and has a valid VAT number - price is 12,61€ (VAT is always 0% in this case)

The above calculations are based on the input we've had from our accountant. They are basically the same as your library already does, with one exception - the base price is a gross price, not a net price. This does, admittedly, make the calculation a bit trickier, but then again is fair and easier to understand for customers.

mpociot commented 7 years ago

Hi,

can you tell me how you would want to use this new method?

Something like this? VatCalculator::calculateNet( 15.00, 'DE') => 12.61

ragulka commented 7 years ago

Hi @mpociot - yes, something like that would work very well. However, you would need to know the base country in order to deduct the correct VAT rate in case the customer is outside of EU or has a valid VAT number.

// signature
function calculateNet( $gross, $customerCountry, $sellerCountry, $isCompany ) {
}

// we don't need to set sellerCounrty here, because Finnish VAT will be applied
VatCalculator::calculateNet( 15.00, 'FI' ); // => 12.1

// we need to set sellerCountry here, because german VAT will be deducted from the gross amount
VatCalculator::calculateNet( 15.00, 'FI', 'DE', $isCompany = true ); // => 12.61

// we need to set sellerCountry here, because german VAT will be deducted from the gross amount
VatCalculator::calculateNet( 15.00, 'US', 'DE' ); // => 12.61
mpociot commented 7 years ago

This sounds good to me!

Do you have time for a pull request? Otherwise, I can probably add the code + tests in the next few days.

ragulka commented 7 years ago

@mpociot I don't at the moment, sorry :/ I also realized that my suggestion does not include the postal code exceptions, but those should be easy to add in.

mherrmann commented 7 years ago

I would also be interested in this. Is it difficult to add?

(Thanks for the great library @mpociot by the way!)

mpociot commented 7 years ago

This is now fixed, thanks to @mrk-j and released in version 2.2.0