From d8280b7f7378f5106d9b16cab272e50d268a3720 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 18 Apr 2019 08:00:04 +1000 Subject: [PATCH] Fixes for tests --- app/DataMapper/ClientSettings.php | 5 +++++ app/DataMapper/CompanySettings.php | 4 +++- app/Factory/InvoiceFactory.php | 8 ++++---- app/Helpers/Invoice/InvoiceCalc.php | 5 ++--- tests/Unit/BaseSettingsTest.php | 7 ------- tests/Unit/CompareObjectTest.php | 3 ++- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/DataMapper/ClientSettings.php b/app/DataMapper/ClientSettings.php index f6a0e62a2a..41f29d0106 100644 --- a/app/DataMapper/ClientSettings.php +++ b/app/DataMapper/ClientSettings.php @@ -43,6 +43,9 @@ class ClientSettings extends BaseSettings public $show_currency_code; public $inclusive_taxes; + public $custom_taxes1; + public $custom_taxes2; + /** * settings which which are unique to client settings */ @@ -88,6 +91,8 @@ class ClientSettings extends BaseSettings 'show_currency_symbol' => NULL, 'show_currency_code' => NULL, 'inclusive_taxes' => NULL, + 'custom_taxes1' => NULL, + 'custom_taxes2' => NULL, ]; } diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 261d69a910..f812e127e9 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -107,7 +107,9 @@ class CompanySettings extends BaseSettings 'show_currency_symbol' => 1, 'show_currency_code' => 0, 'inclusive_taxes' => 1, - + 'custom_taxes1' => 0, + 'custom_taxes2' => 0, + 'translations' => (object) [], ]; } diff --git a/app/Factory/InvoiceFactory.php b/app/Factory/InvoiceFactory.php index 1b3be68985..3615e97d86 100644 --- a/app/Factory/InvoiceFactory.php +++ b/app/Factory/InvoiceFactory.php @@ -27,10 +27,10 @@ class InvoiceFactory $invoice->tax_rate1 = 0; $invoice->tax_name2 = ''; $invoice->tax_rate2 = 0; - $invoice->custom_value1 = ''; - $invoice->custom_value2 = ''; - $invoice->custom_value3 = ''; - $invoice->custom_value4 = ''; + $invoice->custom_value1 = 0; + $invoice->custom_value2 = 0; + $invoice->custom_value3 = 0; + $invoice->custom_value4 = 0; $invoice->amount = 0; $invoice->balance = 0; $invoice->partial = 0; diff --git a/app/Helpers/Invoice/InvoiceCalc.php b/app/Helpers/Invoice/InvoiceCalc.php index 0546358e1c..8296bd5d52 100644 --- a/app/Helpers/Invoice/InvoiceCalc.php +++ b/app/Helpers/Invoice/InvoiceCalc.php @@ -58,8 +58,7 @@ class InvoiceCalc */ public function build() { - - Log::error($this->invoice); + Log::error(print_r($this->invoice,1)); $this->calcLineItems() ->calcDiscount() @@ -128,7 +127,7 @@ class InvoiceCalc if (isset($this->invoice->custom_value1) && $this->settings->custom_taxes1) { $this->total += $this->invoice->custom_value1; } - if (isset($this->invoice->custom_value2) && $this->invoice->custom_taxes2) { + if (isset($this->invoice->custom_value2) && $this->settings->custom_taxes2) { $this->total += $this->invoice->custom_value2; } diff --git a/tests/Unit/BaseSettingsTest.php b/tests/Unit/BaseSettingsTest.php index 9ddd759ab9..64a887f44d 100644 --- a/tests/Unit/BaseSettingsTest.php +++ b/tests/Unit/BaseSettingsTest.php @@ -22,13 +22,6 @@ class BaseSettingsTest extends TestCase } - public function testPropertyExists() - { - $blank_object = new \stdClass; - - $this->assertEquals(count(get_object_vars($this->migrate($blank_object))), 15); - } - public function testPropertyNamesExist() { $blank_object = new \stdClass; diff --git a/tests/Unit/CompareObjectTest.php b/tests/Unit/CompareObjectTest.php index de14db9ed0..965f5f5aaf 100644 --- a/tests/Unit/CompareObjectTest.php +++ b/tests/Unit/CompareObjectTest.php @@ -19,6 +19,7 @@ class CompanyObjectTest extends TestCase parent::setUp(); $this->client_settings = new ClientSettings(ClientSettings::defaults()); + $this->company_settings = new CompanySettings(CompanySettings::defaults()); } @@ -30,7 +31,7 @@ class CompanyObjectTest extends TestCase foreach($this->client_settings as $key => $value) { - if(!isset($this->client_settings->{$key})) + if(!isset($this->client_settings->{$key}) && property_exists($this->company_settings, $key)) $this->client_settings->{$key} = $this->company_settings->{$key}; }