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;
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
$this->rule = new $class();
|
||||
|
||||
if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2))
|
||||
return $this;
|
||||
|
||||
$this->rule
|
||||
->setEntity($this->invoice)
|
||||
->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()
|
||||
{
|
||||
@ -981,6 +1055,8 @@ class EuTaxTest extends TestCase
|
||||
'user_id' => $this->user->id,
|
||||
'company_id' => $company->id,
|
||||
'country_id' => 840,
|
||||
'state' => 'CA',
|
||||
'postal_code' => '90210',
|
||||
'shipping_country_id' => 840,
|
||||
'has_valid_vat_number' => true,
|
||||
'is_tax_exempt' => true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user