Tests for taxes

This commit is contained in:
David Bomba 2023-03-19 20:30:28 +11:00
parent 0cd0a42d9a
commit c9fab675c8
3 changed files with 48 additions and 20 deletions

View File

@ -31,7 +31,7 @@ class ClientPresenter extends EntityPresenter
$contact_name = 'No Contact Set'; $contact_name = 'No Contact Set';
if ($contact && (strlen($contact->first_name) >= 1 || strlen($contact->last_name) >= 1)) { if ($contact && ((is_string($contact->first_name) && strlen($contact->first_name) >= 1) || (is_string($contact->last_name) && strlen($contact->last_name) >= 1))) {
$contact_name = $contact->first_name.' '.$contact->last_name; $contact_name = $contact->first_name.' '.$contact->last_name;
} elseif ($contact && (strlen($contact->email))) { } elseif ($contact && (strlen($contact->email))) {
$contact_name = $contact->email; $contact_name = $contact->email;

View File

@ -93,7 +93,7 @@ trait PdfMakerUtilities
if ($child['element'] !== 'script') { if ($child['element'] !== 'script') {
if (array_key_exists('process_markdown', $this->data) && array_key_exists('content', $child) && $this->data['process_markdown']) { if (array_key_exists('process_markdown', $this->data) && array_key_exists('content', $child) && $this->data['process_markdown']) {
$child['content'] = str_replace('<br>', "\r", $child['content']); $child['content'] = str_replace('<br>', "\r", ($child['content'] ?? ''));
$child['content'] = $this->commonmark->convert($child['content'] ?? ''); $child['content'] = $this->commonmark->convert($child['content'] ?? '');
} }
} }

View File

@ -24,23 +24,7 @@ class SumTaxTest extends TestCase
use MockAccountData; use MockAccountData;
use DatabaseTransactions; use DatabaseTransactions;
protected function setUp() :void public array $response =
{
parent::setUp();
$this->withoutMiddleware(
ThrottleRequests::class
);
$this->withoutExceptionHandling();
// $this->makeTestData();
}
public function testSumOfInvoice()
{
$response =
["results" => [ ["results" => [
[ [
"geoPostalCode" => "92582", "geoPostalCode" => "92582",
@ -81,6 +65,50 @@ class SumTaxTest extends TestCase
] ]
]; ];
nlog($response);
protected function setUp() :void
{
parent::setUp();
$this->withoutMiddleware(
ThrottleRequests::class
);
$this->withoutExceptionHandling();
// $this->makeTestData();
} }
public function testSumOfInvoice()
{
$this->assertEquals("CA", $this->response['results'][0]['geoState']);
}
public function testSumOfTaxes()
{
$sum =
$this->response['results'][0]['stateSalesTax'] +
// $this->response['results'][0]['stateUseTax'] +
$this->response['results'][0]['citySalesTax'] +
// $this->response['results'][0]['cityUseTax'] +
$this->response['results'][0]['countySalesTax'] +
// $this->response['results'][0]['countyUseTax'] +
$this->response['results'][0]['districtSalesTax'];
// // $this->response['results'][0]['districtUseTax'] +
// $this->response['results'][0]['district1SalesTax'] +
// // $this->response['results'][0]['district1UseTax'] +
// $this->response['results'][0]['district2SalesTax'] +
// // $this->response['results'][0]['district2UseTax'] +
// $this->response['results'][0]['district3SalesTax'] +
// // $this->response['results'][0]['district3UseTax'] +
// $this->response['results'][0]['district4SalesTax'] +
// // $this->response['results'][0]['district4UseTax'] +
// $this->response['results'][0]['district5SalesTax'];
// $this->response['results'][0]['district5UseTax'];
$this->assertEquals(0.0875, $sum);
}
} }