mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Tests for taxes
This commit is contained in:
parent
bba25f1033
commit
49b3182639
@ -58,40 +58,49 @@ class Response
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public string $geoPostalCode = "92582";
|
public string $geoPostalCode = "";
|
||||||
public string $geoCity = "SAN JACINTO";
|
public string $geoCity = "";
|
||||||
public string $geoCounty = "RIVERSIDE";
|
public string $geoCounty = "";
|
||||||
public string $geoState = "CA";
|
public string $geoState = "";
|
||||||
public float $taxSales = 0.0875;
|
public float $taxSales = 0;
|
||||||
public float $taxUse = 0.0875;
|
public float $taxUse = 0;
|
||||||
public string $txbService = "N";
|
public string $txbService = "";
|
||||||
public string $txbFreight = "N";
|
public string $txbFreight = "";
|
||||||
public float $stateSalesTax = 0.06;
|
public float $stateSalesTax = 0;
|
||||||
public float $stateUseTax = 0.06;
|
public float $stateUseTax = 0;
|
||||||
public float $citySalesTax = 0.01;
|
public float $citySalesTax = 0;
|
||||||
public float $cityUseTax = 0.01;
|
public float $cityUseTax = 0;
|
||||||
public string $cityTaxCode = "874";
|
public string $cityTaxCode = "";
|
||||||
public float $countySalesTax = 0.0025;
|
public float $countySalesTax = 0;
|
||||||
public float $countyUseTax = 0.0025;
|
public float $countyUseTax = 0;
|
||||||
public string $countyTaxCode = "";
|
public string $countyTaxCode = "";
|
||||||
public float $districtSalesTax = 0.015;
|
public float $districtSalesTax = 0;
|
||||||
public float $districtUseTax = 0.015;
|
public float $districtUseTax = 0;
|
||||||
public string $district1Code = "26";
|
public string $district1Code = "";
|
||||||
public float $district1SalesTax = 0;
|
public float $district1SalesTax = 0;
|
||||||
public float $district1UseTax = 0;
|
public float $district1UseTax = 0;
|
||||||
public string $district2Code = "26";
|
public string $district2Code = "";
|
||||||
public float $district2SalesTax = 0.005;
|
public float $district2SalesTax = 0;
|
||||||
public float $district2UseTax = 0.005;
|
public float $district2UseTax = 0;
|
||||||
public string $district3Code = "";
|
public string $district3Code = "";
|
||||||
public float $district3SalesTax = 0;
|
public float $district3SalesTax = 0;
|
||||||
public float $district3UseTax = 0;
|
public float $district3UseTax = 0;
|
||||||
public string $district4Code = "33";
|
public string $district4Code = "";
|
||||||
public float $district4SalesTax = 0.01;
|
public float $district4SalesTax = 0;
|
||||||
public float $district4UseTax = 0.01;
|
public float $district4UseTax = 0;
|
||||||
public string $district5Code = "";
|
public string $district5Code = "";
|
||||||
public float $district5SalesTax = 0;
|
public float $district5SalesTax = 0;
|
||||||
public float $district5UseTax = 0;
|
public float $district5UseTax = 0;
|
||||||
public string $originDestination = "D";
|
public string $originDestination = "";
|
||||||
|
|
||||||
|
public function __construct(?array $data)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach($data as $key => $value){
|
||||||
|
$this->{$key} = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,12 @@ namespace Tests\Unit\Tax;
|
|||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Invoice;
|
||||||
use Tests\MockAccountData;
|
use Tests\MockAccountData;
|
||||||
|
use App\DataMapper\Tax\ClientTaxData;
|
||||||
|
use App\DataMapper\Tax\CompanyTaxData;
|
||||||
|
use App\DataMapper\Tax\InvoiceTaxData;
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
@ -25,7 +30,9 @@ class SumTaxTest extends TestCase
|
|||||||
use MockAccountData;
|
use MockAccountData;
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
||||||
public array $response = [
|
public Response $response;
|
||||||
|
|
||||||
|
public array $resp = [
|
||||||
"geoPostalCode" => "92582",
|
"geoPostalCode" => "92582",
|
||||||
"geoCity" => "SAN JACINTO",
|
"geoCity" => "SAN JACINTO",
|
||||||
"geoCounty" => "RIVERSIDE",
|
"geoCounty" => "RIVERSIDE",
|
||||||
@ -74,39 +81,79 @@ class SumTaxTest extends TestCase
|
|||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
|
|
||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
|
|
||||||
|
$this->response = new Response($this->resp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTaxOnInvoice()
|
public function testTaxOnCompany()
|
||||||
|
{
|
||||||
|
|
||||||
|
$tax_class = new CompanyTaxData($this->response);
|
||||||
|
|
||||||
|
$this->company->tax_data = $tax_class;
|
||||||
|
$this->company->save();
|
||||||
|
|
||||||
|
$this->assertEquals("92582", $this->company->tax_data->origin->geoPostalCode);
|
||||||
|
$this->assertEquals(0.0875, $this->company->tax_data->origin->taxSales);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTaxOnClient()
|
||||||
{
|
{
|
||||||
$c = Client::factory()->create([
|
$c = Client::factory()->create([
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$c->tax_data = $this->response;
|
$tax_class = new ClientTaxData($this->response, $this->response);
|
||||||
|
|
||||||
|
$c->tax_data = $tax_class;
|
||||||
$c->save();
|
$c->save();
|
||||||
|
|
||||||
$this->assertEquals("92582", $c->tax_data->geoPostalCode);
|
$this->assertEquals("92582", $c->tax_data->origin->geoPostalCode);
|
||||||
$this->assertEquals(0.0875, $c->tax_data->taxSales);
|
$this->assertEquals(0.0875, $c->tax_data->origin->taxSales);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTaxOnInvoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
$i = Invoice::factory()->create([
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'client_id' => $this->client->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tax_class = new InvoiceTaxData($this->response);
|
||||||
|
|
||||||
|
$i->tax_data = $tax_class;
|
||||||
|
$i->save();
|
||||||
|
|
||||||
|
|
||||||
|
$this->assertEquals("92582", $i->tax_data->origin->geoPostalCode);
|
||||||
|
$this->assertEquals(0.0875, $i->tax_data->origin->taxSales);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSumOfInvoice()
|
public function testSumOfInvoice()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->assertEquals("CA", $this->response['geoState']);
|
$this->assertEquals("CA", $this->response->geoState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSumOfTaxes()
|
public function testSumOfTaxes()
|
||||||
{
|
{
|
||||||
$sum =
|
$sum =
|
||||||
$this->response['stateSalesTax'] +
|
$this->response->stateSalesTax +
|
||||||
// $this->response['stateUseTax'] +
|
// $this->response['stateUseTax'] +
|
||||||
$this->response['citySalesTax'] +
|
$this->response->citySalesTax +
|
||||||
// $this->response['cityUseTax'] +
|
// $this->response['cityUseTax'] +
|
||||||
$this->response['countySalesTax'] +
|
$this->response->countySalesTax +
|
||||||
// $this->response['countyUseTax'] +
|
// $this->response['countyUseTax'] +
|
||||||
$this->response['districtSalesTax'];
|
$this->response->districtSalesTax;
|
||||||
// // $this->response['districtUseTax'] +
|
// // $this->response['districtUseTax'] +
|
||||||
// $this->response['district1SalesTax'] +
|
// $this->response['district1SalesTax'] +
|
||||||
// // $this->response['district1UseTax'] +
|
// // $this->response['district1UseTax'] +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user