1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for taxes

This commit is contained in:
David Bomba 2023-05-17 14:39:59 +10:00
parent 8908bc318c
commit 7b91911c24
3 changed files with 111 additions and 3 deletions

View File

@ -174,7 +174,7 @@ class BaseRule implements RuleInterface
*/
$tax_data = new Response([]);
if($this->seller_region == 'US'){
if($this->seller_region == 'US' && $this->client_region == 'US'){
$company = $this->invoice->company;

View File

@ -29,6 +29,36 @@ class InvoiceItemSum
use Discounter;
use Taxer;
private array $eu_tax_jurisdictions = [
'AT', // Austria
'BE', // Belgium
'BG', // Bulgaria
'CY', // Cyprus
'CZ', // Czech Republic
'DE', // Germany
'DK', // Denmark
'EE', // Estonia
'ES', // Spain
'FI', // Finland
'FR', // France
'GR', // Greece
'HR', // Croatia
'HU', // Hungary
'IE', // Ireland
'IT', // Italy
'LT', // Lithuania
'LU', // Luxembourg
'LV', // Latvia
'MT', // Malta
'NL', // Netherlands
'PL', // Poland
'PT', // Portugal
'RO', // Romania
'SE', // Sweden
'SI', // Slovenia
'SK', // Slovakia
];
private array $tax_jurisdictions = [
// 'AT', // Austria
// 'BE', // Belgium
@ -144,7 +174,7 @@ class InvoiceItemSum
return $this;
}
if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions) && in_array($this->client->country->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions
if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions) ) { //only calculate for supported tax jurisdictions
$class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule";

View File

@ -98,6 +98,8 @@ class UsTaxTest extends TestCase
'settings' => $settings,
'tax_data' => $tax_data,
'calculate_taxes' => true,
'origin_tax_data' => new Response($this->mock_response),
]);
$client = Client::factory()->create([
@ -147,6 +149,78 @@ class UsTaxTest extends TestCase
return $invoice;
}
public function testInterstateWithNoTax()
{
$settings = CompanySettings::defaults();
$settings->country_id = '840'; // germany
$tax_data = new TaxModel();
$tax_data->seller_subregion = 'CA';
$tax_data->regions->US->has_sales_above_threshold = true;
$tax_data->regions->US->tax_all_subregions = false;
$company = Company::factory()->create([
'account_id' => $this->account->id,
'settings' => $settings,
'tax_data' => $tax_data,
'calculate_taxes' => true,
'origin_tax_data' => new Response($this->mock_response),
]);
$client = Client::factory()->create([
'user_id' => $this->user->id,
'company_id' => $company->id,
'country_id' => 840,
'postal_code' => '30002',
'shipping_country_id' => 840,
'shipping_postal_code' => '30002',
'shipping_state' => '30002',
'has_valid_vat_number' => false,
'is_tax_exempt' => false,
'state' => 'GA'
]);
$invoice = Invoice::factory()->create([
'company_id' => $company->id,
'client_id' => $client->id,
'status_id' => 1,
'user_id' => $this->user->id,
'uses_inclusive_taxes' => false,
'discount' => 0,
'line_items' => [
[
'product_key' => 'Test',
'notes' => 'Test',
'cost' => 100,
'quantity' => 1,
'tax_name1' => '',
'tax_rate1' => 0,
'tax_name2' => '',
'tax_rate2' => 0,
'tax_name3' => '',
'tax_rate3' => 0,
'type_id' => '1',
'tax_id' => Product::PRODUCT_TYPE_PHYSICAL,
],
],
'tax_rate1' => 0,
'tax_rate2' => 0,
'tax_rate3' => 0,
'tax_name1' => '',
'tax_name2' => '',
'tax_name3' => '',
'tax_data' => new Response($this->mock_response),
]);
$invoice = $invoice->calc()->getInvoice()->service()->markSent()->save();
$this->assertEquals(100, $invoice->amount);
}
public function testSameSubregionAndExemptProduct()
{
@ -166,6 +240,7 @@ class UsTaxTest extends TestCase
'settings' => $settings,
'tax_data' => $tax_data,
'calculate_taxes' => true,
'origin_tax_data' => new Response($this->mock_response),
]);
$client = Client::factory()->create([
@ -236,6 +311,7 @@ class UsTaxTest extends TestCase
'settings' => $settings,
'tax_data' => $tax_data,
'calculate_taxes' => true,
'origin_tax_data' => new Response($this->mock_response),
]);
$client = Client::factory()->create([
@ -305,6 +381,7 @@ class UsTaxTest extends TestCase
'settings' => $settings,
'tax_data' => $tax_data,
'calculate_taxes' => true,
'origin_tax_data' => new Response($this->mock_response),
]);
$client = Client::factory()->create([
@ -373,6 +450,7 @@ class UsTaxTest extends TestCase
'settings' => $settings,
'tax_data' => $tax_data,
'calculate_taxes' => true,
'origin_tax_data' => new Response($this->mock_response),
]);
$client = Client::factory()->create([