diff --git a/app/DataMapper/ClientSettings.php b/app/DataMapper/ClientSettings.php index 4e299fb9e7..14fcd8e1b1 100644 --- a/app/DataMapper/ClientSettings.php +++ b/app/DataMapper/ClientSettings.php @@ -60,6 +60,8 @@ class ClientSettings extends BaseSettings public $auto_bill; public $auto_archive_invoice; + public $groups; + /** * Counter Variables * diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index cbf86fb348..e56d95eb23 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -84,6 +84,8 @@ class CompanySettings extends BaseSettings public $inclusive_taxes; public $translations; + public $group_selectors; + public $groups; /** * Counter Variables @@ -170,6 +172,34 @@ class CompanySettings extends BaseSettings 'design' => 'views/pdf/design1.blade.php', 'translations' => (object) [], + 'group_selectors' => self::groupSelectors(), + 'groups' => self::groupObjects(), + ]; + } + + /** + * Implements App\DataMapper\Group objects + * in order to customise grouped option behaviour + * @return object Settings objects + */ + private static function groupObjects() + { + return (object)[ + 'company_gateways' => NULL, + 'invoice_designs' => NULL + ]; + } + + + /** + * Storage point for ALL Group options + * @return object Settings objects + */ + private static function groupSelectors() + { + return (object)[ + 'company_gateways' => NULL, + 'invoice_designs' => NULL ]; } } diff --git a/app/DataMapper/Group.php b/app/DataMapper/Group.php new file mode 100644 index 0000000000..8e347c772d --- /dev/null +++ b/app/DataMapper/Group.php @@ -0,0 +1,43 @@ +payment_gateways) - $gateways = $this->company->company_gateways->whereIn('id', $settings->payment_gateways); + $gateways = $this->company->company_gateways->whereIn('id', $settings->payment_gateways); else $gateways = $this->company->company_gateways; diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 6c953940da..e7abb2218a 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -173,7 +173,6 @@ class CompanyGateway extends BaseModel if ($this->fee_tax_rate1) $fee += $pre_tax_fee * $this->fee_tax_rate1 / 100; - if ($this->fee_tax_rate2) $fee += $pre_tax_fee * $this->fee_tax_rate2 / 100; diff --git a/app/Utils/Traits/CompanyGatewaySettings.php b/app/Utils/Traits/CompanyGatewaySettings.php new file mode 100644 index 0000000000..7544e37cf1 --- /dev/null +++ b/app/Utils/Traits/CompanyGatewaySettings.php @@ -0,0 +1,31 @@ +getMergedSettings(); + + if(isset($settings->groups->company_gateways)) + { + + } + } + +} \ No newline at end of file diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index ffaf03e234..0f25cbf203 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -211,7 +211,7 @@ trait MakesInvoiceValues $data['$company_city'] = $this->company->city; $data['$company_state'] = $this->company->state; $data['$company_postal_code'] = $this->company->postal_code; - $data['$company_country'] = $this->company->country->name; + $data['$company_country'] = $this->company->country ? $this->company->country->name : ''; $data['$company_phone'] = $this->company->work_phone; $data['$company_email'] = $this->company->work_email; $data['$company_vat_number'] = $this->company->vat_number; diff --git a/routes/client.php b/routes/client.php index 2438d5bde2..275565d985 100644 --- a/routes/client.php +++ b/routes/client.php @@ -24,7 +24,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index'); Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index'); - Route::get('payments/{company_gateway_id}/{payment_method_id}/{}')->name('payments.process')->signed(); + Route::get('payments/{company_gateway_id}/{payment_method_id}', 'PaymentController@process')->name('payments.process')->middleware('signed'); Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit'); Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update'); diff --git a/tests/Unit/GroupTest.php b/tests/Unit/GroupTest.php new file mode 100644 index 0000000000..0d898f3c8e --- /dev/null +++ b/tests/Unit/GroupTest.php @@ -0,0 +1,54 @@ +settings = new ClientSettings(ClientSettings::defaults()); + $this->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults())); + + } + + public function testGroupsPropertiesExistsResponses() + { + //$this->assertEquals(print_r($this->settings)); + + $this->assertTrue(property_exists($this->settings->groups, 'company_gateways')); + + $this->assertTrue(property_exists($this->settings, 'groups')); + } + + public function testPropertyValueAccessors() + { + + $this->settings->groups->company_gateways = 'slug'; + + $this->assertEquals('slug', $this->settings->groups->company_gateways); + + } + + public function testPropertyIsSet() + { + $this->assertFalse(isset($this->settings->groups->company_gateways)); + + $this->settings->groups->company_gateways = 'slug'; + + $this->assertTrue(isset($this->settings->groups->company_gateways)); + } + +} \ No newline at end of file