diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 4cda526ee49e..26d01eb57f7d 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -104,7 +104,7 @@ class BaseRule implements RuleInterface return $this; } - public function taxByType(?int $product_tax_type): self + public function taxByType($product_tax_type): self { return $this; } diff --git a/app/DataMapper/Tax/DE/Rule.php b/app/DataMapper/Tax/DE/Rule.php index 3b9a2d54fe6c..50d2c0d48a57 100644 --- a/app/DataMapper/Tax/DE/Rule.php +++ b/app/DataMapper/Tax/DE/Rule.php @@ -93,7 +93,7 @@ class Rule extends BaseRule implements RuleInterface } - public function taxByType(?int $product_tax_type): self + public function taxByType($product_tax_type): self { if ($this->client->is_tax_exempt) { diff --git a/app/DataMapper/Tax/RuleInterface.php b/app/DataMapper/Tax/RuleInterface.php index 91c5f6ed113a..3ed6f8d06e4f 100644 --- a/app/DataMapper/Tax/RuleInterface.php +++ b/app/DataMapper/Tax/RuleInterface.php @@ -20,7 +20,7 @@ interface RuleInterface public function tax(); - public function taxByType(?int $type); + public function taxByType($type); public function taxExempt(); diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index d6dde1a5e835..5be5aab6ddda 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -67,7 +67,7 @@ class Rule implements RuleInterface } - public function taxByType(?int $product_tax_type): self + public function taxByType($product_tax_type): self { if(!$product_tax_type) return $this; diff --git a/tests/Unit/Tax/EuTaxTest.php b/tests/Unit/Tax/EuTaxTest.php index 1559ae3c8d7d..52ac72ac8c8e 100644 --- a/tests/Unit/Tax/EuTaxTest.php +++ b/tests/Unit/Tax/EuTaxTest.php @@ -44,11 +44,6 @@ class EuTaxTest extends TestCase $this->makeTestData(); } - public function testInvoiceWithCustomTaxIdTax() - { - - } - public function testInvoiceTaxCalcDetoBeNoVat() { $settings = CompanySettings::defaults(); diff --git a/tests/Unit/Tax/UsTaxTest.php b/tests/Unit/Tax/UsTaxTest.php index 75551b316630..e5791ef9fdab 100644 --- a/tests/Unit/Tax/UsTaxTest.php +++ b/tests/Unit/Tax/UsTaxTest.php @@ -146,6 +146,107 @@ class UsTaxTest extends TestCase return $invoice; } + // public function testCompanyTaxAllOffTaxExemptProduct() + // { + + // $invoice = $this->invoiceStub('92582'); + // $client = $invoice->client; + // $client->is_tax_exempt = false; + // $client->save(); + + // $company = $invoice->company; + // $tax_data = $company->tax_data; + + // $tax_data->regions->US->has_sales_above_threshold = true; + // $tax_data->regions->US->tax_all = false; + + // $company->tax_data = $tax_data; + // $company->save(); + + // $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + + // $this->assertEquals(0, $invoice->line_items[0]->tax_rate1); + // $this->assertEquals(100, $invoice->amount); + + // } + + public function testCompanyTaxAllOffButTaxUSRegion() + { + + $invoice = $this->invoiceStub('92582'); + $client = $invoice->client; + $client->is_tax_exempt = false; + $client->save(); + + $company = $invoice->company; + $company->tax_all_products = false; + $tax_data = $company->tax_data; + + $tax_data->regions->US->has_sales_above_threshold = true; + $tax_data->regions->US->tax_all = true; + + $company->tax_data = $tax_data; + $company->save(); + + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + + $this->assertEquals(8.75, $invoice->line_items[0]->tax_rate1); + $this->assertEquals(108.75, $invoice->amount); + + } + + public function testCompanyTaxAllOff() + { + + $invoice = $this->invoiceStub('92582'); + $client = $invoice->client; + $client->is_tax_exempt = false; + $client->save(); + + $company = $invoice->company; + $company->tax_all_products = false; + $tax_data = $company->tax_data; + + $tax_data->regions->US->has_sales_above_threshold = true; + $tax_data->regions->US->tax_all = false; + + $company->tax_data = $tax_data; + $company->save(); + + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + + $this->assertEquals(0, $invoice->line_items[0]->tax_rate1); + $this->assertEquals(100, $invoice->amount); + + } + + + public function testThresholdLevelsAreMet() + { + + $invoice = $this->invoiceStub('92582'); + $client = $invoice->client; + $client->is_tax_exempt = true; + $client->save(); + + + $company = $invoice->company; + $tax_data = $company->tax_data; + + $tax_data->regions->US->has_sales_above_threshold = false; + $tax_data->regions->US->tax_all = true; + + $company->tax_data = $tax_data; + $company->save(); + + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + + $this->assertEquals(0, $invoice->line_items[0]->tax_rate1); + $this->assertEquals(100, $invoice->amount); + + + } + public function testHasValidVatMakesNoDifferenceToTaxCalc() { @@ -158,10 +259,9 @@ class UsTaxTest extends TestCase $this->assertEquals(8.75, $invoice->line_items[0]->tax_rate1); $this->assertEquals(108.75, $invoice->amount); - - } + public function testTaxExemption() { $invoice = $this->invoiceStub('92582');