diff --git a/app/Models/Presenters/ClientPresenter.php b/app/Models/Presenters/ClientPresenter.php index b0c30b107807..53450a587284 100644 --- a/app/Models/Presenters/ClientPresenter.php +++ b/app/Models/Presenters/ClientPresenter.php @@ -31,7 +31,7 @@ class ClientPresenter extends EntityPresenter $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; } elseif ($contact && (strlen($contact->email))) { $contact_name = $contact->email; diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index d38ef430b170..e76aac567061 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -93,7 +93,7 @@ trait PdfMakerUtilities if ($child['element'] !== 'script') { if (array_key_exists('process_markdown', $this->data) && array_key_exists('content', $child) && $this->data['process_markdown']) { - $child['content'] = str_replace('
', "\r", $child['content']); + $child['content'] = str_replace('
', "\r", ($child['content'] ?? '')); $child['content'] = $this->commonmark->convert($child['content'] ?? ''); } } diff --git a/tests/Unit/Tax/SumTaxTest.php b/tests/Unit/Tax/SumTaxTest.php index a68bc13679e5..23bc7bd34450 100644 --- a/tests/Unit/Tax/SumTaxTest.php +++ b/tests/Unit/Tax/SumTaxTest.php @@ -24,23 +24,7 @@ class SumTaxTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void - { - parent::setUp(); - - $this->withoutMiddleware( - ThrottleRequests::class - ); - - $this->withoutExceptionHandling(); - - // $this->makeTestData(); - } - - public function testSumOfInvoice() - { - - $response = + public array $response = ["results" => [ [ "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); + } + } \ No newline at end of file