mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Tax Tests
This commit is contained in:
parent
a6af7b7a20
commit
71719e38ab
@ -374,4 +374,10 @@ class BaseRule implements RuleInterface
|
|||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function regionWithNoTaxCoverage(string $iso_3166_2): bool
|
||||||
|
{
|
||||||
|
return ! in_array($iso_3166_2, array_merge($this->eu_country_codes, array_keys($this->region_codes)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,10 @@ class InvoiceItemSum
|
|||||||
$class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule";
|
$class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule";
|
||||||
|
|
||||||
$this->rule = new $class();
|
$this->rule = new $class();
|
||||||
|
|
||||||
|
if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2))
|
||||||
|
return $this;
|
||||||
|
|
||||||
$this->rule
|
$this->rule
|
||||||
->setEntity($this->invoice)
|
->setEntity($this->invoice)
|
||||||
->init();
|
->init();
|
||||||
|
@ -122,6 +122,80 @@ class EuTaxTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEuToBrazilTaxCalculations()
|
||||||
|
{
|
||||||
|
|
||||||
|
$settings = CompanySettings::defaults();
|
||||||
|
$settings->country_id = '276'; // germany
|
||||||
|
|
||||||
|
$tax_data = new TaxModel();
|
||||||
|
$tax_data->seller_subregion = 'DE';
|
||||||
|
$tax_data->regions->EU->has_sales_above_threshold = false;
|
||||||
|
$tax_data->regions->EU->tax_all_subregions = true;
|
||||||
|
$tax_data->regions->AU->tax_all_subregions = true;
|
||||||
|
$tax_data->regions->AU->has_sales_above_threshold = true;
|
||||||
|
|
||||||
|
$company = Company::factory()->create([
|
||||||
|
'account_id' => $this->account->id,
|
||||||
|
'settings' => $settings,
|
||||||
|
'tax_data' => $tax_data,
|
||||||
|
'calculate_taxes' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$client = Client::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'company_id' => $company->id,
|
||||||
|
'country_id' => 76,
|
||||||
|
'shipping_country_id' => 76,
|
||||||
|
'has_valid_vat_number' => false,
|
||||||
|
'is_tax_exempt' => false,
|
||||||
|
// 'tax_data' => new Response([
|
||||||
|
// 'geoState' => 'CA',
|
||||||
|
// 'taxSales' => 0.07,
|
||||||
|
// ]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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([
|
||||||
|
// 'geoState' => 'CA',
|
||||||
|
// 'taxSales' => 0.07,
|
||||||
|
// ]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$invoice = $invoice->calc()->getInvoice()->service()->markSent()->save();
|
||||||
|
|
||||||
|
$this->assertEquals(100, $invoice->amount);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testEuToAuTaxCalculationExemptProduct()
|
public function testEuToAuTaxCalculationExemptProduct()
|
||||||
{
|
{
|
||||||
@ -981,6 +1055,8 @@ class EuTaxTest extends TestCase
|
|||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'country_id' => 840,
|
'country_id' => 840,
|
||||||
|
'state' => 'CA',
|
||||||
|
'postal_code' => '90210',
|
||||||
'shipping_country_id' => 840,
|
'shipping_country_id' => 840,
|
||||||
'has_valid_vat_number' => true,
|
'has_valid_vat_number' => true,
|
||||||
'is_tax_exempt' => true,
|
'is_tax_exempt' => true,
|
||||||
@ -992,7 +1068,7 @@ class EuTaxTest extends TestCase
|
|||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'status_id' => Invoice::STATUS_SENT,
|
'status_id' => Invoice::STATUS_SENT,
|
||||||
'tax_data' => new Response([
|
'tax_data' => new Response([
|
||||||
'geoState' => 'CA',
|
'geoState' => 'CA',
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user