Working on tax all settings

This commit is contained in:
David Bomba 2023-03-31 15:25:30 +11:00
parent 90e1d8d228
commit fec69f98e2
6 changed files with 106 additions and 11 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -20,7 +20,7 @@ interface RuleInterface
public function tax();
public function taxByType(?int $type);
public function taxByType($type);
public function taxExempt();

View File

@ -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;

View File

@ -44,11 +44,6 @@ class EuTaxTest extends TestCase
$this->makeTestData();
}
public function testInvoiceWithCustomTaxIdTax()
{
}
public function testInvoiceTaxCalcDetoBeNoVat()
{
$settings = CompanySettings::defaults();

View File

@ -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');