1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Working on Groups

This commit is contained in:
David Bomba 2019-09-09 21:24:22 +10:00
parent 5f7a0b96d7
commit db7043abd9
4 changed files with 24 additions and 10 deletions

View File

@ -93,7 +93,7 @@ class ClientSettings extends BaseSettings
public $design;
public $payment_gateways;
public $company_gateways;
/**
* Cast object values and return entire class
* prevents missing properties from not being returned

View File

@ -115,7 +115,7 @@ class CompanySettings extends BaseSettings
public $design;
public $payment_gateways;
public $company_gateways;
/**
* Cast object values and return entire class
* prevents missing properties from not being returned

View File

@ -18,14 +18,30 @@ namespace App\Utils\Traits;
trait CompanyGatewaySettings
{
/**
*
* This method will cascade through a sequence of
* levels and return the first available set of settings
* it hits
*
* @return array A single dimension array of company gateway ids
*/
public function findCompanyGateways()
{
$settings = $this->getMergedSettings();
if(isset($settings->groups->company_gateways))
{
/* Group Level */
if(isset($settings->groups->company_gateways)){
$gateways = $this->company->company_gateways->whereIn('id', $settings->group_selectors->{$settings->group->company_gateways});
}
/* Client Level - Company Level*/
else if(isset($settings->company_gateways)) {
$gateways = $this->company->company_gateways->whereIn('id', $settings->company_gateways);
}
/* DB raw*/
else
return $this->company->company_gateways;
}
}

View File

@ -9,7 +9,7 @@ use Tests\TestCase;
/**
* @test
* @covers App\DataMapper\Group
* @covers App\Utils\Traits\CompanyGatewaySettings
*/
class GroupTest extends TestCase
{
@ -17,17 +17,15 @@ class GroupTest extends TestCase
public function setUp() :void
{
parent::setUp();
parent::setUp();
// $this->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'));