mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor for taxes
This commit is contained in:
parent
680277f062
commit
40f53e3dde
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Invoice Ninja (https://invoiceninja.com).
|
|
||||||
*
|
|
||||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
|
||||||
*
|
|
||||||
* @license https://www.elastic.co/licensing/elastic-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\DataMapper\Tax;
|
|
||||||
|
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClientTaxData
|
|
||||||
*
|
|
||||||
* Definition for the client tax data
|
|
||||||
*/
|
|
||||||
class ClientTaxData
|
|
||||||
{
|
|
||||||
public int $updated_at;
|
|
||||||
|
|
||||||
public function __construct(public Response $origin, public Response $destination)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Invoice Ninja (https://invoiceninja.com).
|
|
||||||
*
|
|
||||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
|
||||||
*
|
|
||||||
* @license https://www.elastic.co/licensing/elastic-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\DataMapper\Tax;
|
|
||||||
|
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CompanyTaxData
|
|
||||||
*
|
|
||||||
* Definition for the company tax data structure
|
|
||||||
*/
|
|
||||||
class CompanyTaxData
|
|
||||||
{
|
|
||||||
public int $updated_at;
|
|
||||||
|
|
||||||
public function __construct(public Response $origin)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,7 +18,7 @@ use App\DataMapper\Tax\ZipTax\Response;
|
|||||||
*
|
*
|
||||||
* Definition for the invoice tax data structure
|
* Definition for the invoice tax data structure
|
||||||
*/
|
*/
|
||||||
class InvoiceTaxData
|
class TaxData
|
||||||
{
|
{
|
||||||
public int $updated_at;
|
public int $updated_at;
|
||||||
|
|
@ -17,9 +17,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use Tests\MockAccountData;
|
use Tests\MockAccountData;
|
||||||
use App\DataMapper\InvoiceItem;
|
use App\DataMapper\InvoiceItem;
|
||||||
use App\DataMapper\Tax\ClientTaxData;
|
use App\DataMapper\Tax\TaxData;
|
||||||
use App\DataMapper\Tax\CompanyTaxData;
|
|
||||||
use App\DataMapper\Tax\InvoiceTaxData;
|
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
use App\Factory\InvoiceFactory;
|
use App\Factory\InvoiceFactory;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
@ -89,7 +87,7 @@ class SumTaxTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Proves that we do not charge taxes automatically */
|
||||||
public function testCalcInvoiceNoTax()
|
public function testCalcInvoiceNoTax()
|
||||||
{
|
{
|
||||||
$this->company->calculate_taxes = false;
|
$this->company->calculate_taxes = false;
|
||||||
@ -108,7 +106,7 @@ class SumTaxTest extends TestCase
|
|||||||
|
|
||||||
$line_items = [];
|
$line_items = [];
|
||||||
|
|
||||||
$invoice->tax_data = new InvoiceTaxData($this->response);
|
$invoice->tax_data = new TaxData($this->response);
|
||||||
|
|
||||||
$line_item = new InvoiceItem();
|
$line_item = new InvoiceItem();
|
||||||
$line_item->quantity = 1;
|
$line_item->quantity = 1;
|
||||||
@ -131,7 +129,7 @@ class SumTaxTest extends TestCase
|
|||||||
$this->assertEquals(0, $line_items[0]->tax_rate1);
|
$this->assertEquals(0, $line_items[0]->tax_rate1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Proves that we do calc taxes automatically */
|
||||||
public function testCalcInvoiceTax()
|
public function testCalcInvoiceTax()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -151,7 +149,7 @@ class SumTaxTest extends TestCase
|
|||||||
|
|
||||||
$line_items = [];
|
$line_items = [];
|
||||||
|
|
||||||
$invoice->tax_data = new InvoiceTaxData($this->response);
|
$invoice->tax_data = new TaxData($this->response);
|
||||||
|
|
||||||
$line_item = new InvoiceItem;
|
$line_item = new InvoiceItem;
|
||||||
$line_item->quantity = 1;
|
$line_item->quantity = 1;
|
||||||
@ -177,7 +175,7 @@ class SumTaxTest extends TestCase
|
|||||||
public function testTaxOnCompany()
|
public function testTaxOnCompany()
|
||||||
{
|
{
|
||||||
|
|
||||||
$tax_class = new CompanyTaxData($this->response);
|
$tax_class = new TaxData($this->response);
|
||||||
|
|
||||||
$this->company->tax_data = $tax_class;
|
$this->company->tax_data = $tax_class;
|
||||||
$this->company->save();
|
$this->company->save();
|
||||||
@ -194,7 +192,7 @@ class SumTaxTest extends TestCase
|
|||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tax_class = new ClientTaxData($this->response, $this->response);
|
$tax_class = new TaxData($this->response, $this->response);
|
||||||
|
|
||||||
$c->tax_data = $tax_class;
|
$c->tax_data = $tax_class;
|
||||||
$c->save();
|
$c->save();
|
||||||
@ -213,7 +211,7 @@ class SumTaxTest extends TestCase
|
|||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tax_class = new InvoiceTaxData($this->response);
|
$tax_class = new TaxData($this->response);
|
||||||
|
|
||||||
$i->tax_data = $tax_class;
|
$i->tax_data = $tax_class;
|
||||||
$i->save();
|
$i->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user