Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UML-3622 rework trust corporations #2854

Merged
merged 24 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f134454
UML-3619 wip
allenannom Sep 30, 2024
4fc3d74
UML-3619 wip
allenannom Sep 30, 2024
69c1773
UML-3619 wip
allenannom Oct 2, 2024
0d63ae0
UML-3619 Convert incoming LPAs to combined format (repository layer)
allenannom Oct 3, 2024
a3e77ca
Merge branch 'UML-3619-Convert-incoming-LPAs-to-combined-format-repos…
allenannom Oct 3, 2024
e2e6232
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 3, 2024
e81c347
UML-3619 updated tests and added donotserialize on func
allenannom Oct 3, 2024
141efe2
UML-3619 updated tests
allenannom Oct 3, 2024
310dada
UML-3619 updated tests for codecoverage
allenannom Oct 3, 2024
39d3576
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 3, 2024
fcb451f
Merge branch 'main' into UML-3619-Convert-incoming-LPAs-to-combined-f…
allenannom Oct 3, 2024
3baa4a1
UML-3619 updated lint
allenannom Oct 3, 2024
1ca16d3
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 3, 2024
73c34f9
Merge branch 'main' into UML-3619-Convert-incoming-LPAs-to-combined-f…
allenannom Oct 3, 2024
527cdeb
UML-3619 updated tests and added test case on hydrating sirius & lpa …
allenannom Oct 4, 2024
720d97a
UML-3619 updated tests and added test case on serialising sirius & lp…
allenannom Oct 4, 2024
a4d1e41
implement the interface
nickdavis2001 Oct 7, 2024
1af0e70
trust corporations, tests
nickdavis2001 Oct 8, 2024
20dc98c
Merge branch 'main' into UML-3622-trust-corp-status
nickdavis2001 Oct 8, 2024
15295fa
fixes
nickdavis2001 Oct 8, 2024
1515855
fixes
nickdavis2001 Oct 8, 2024
2c2faec
Merge branch 'main' into UML-3622-trust-corp-status
nickdavis2001 Oct 8, 2024
30a3c1f
Merge branch 'main' into UML-3622-trust-corp-status
nickdavis2001 Oct 8, 2024
4f19eaf
Merge branch 'main' into UML-3622-trust-corp-status
nickdavis2001 Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
use App\Entity\Casters\ExtractCountryFromLpaStore;
use App\Entity\Casters\ExtractTownFromLpaStore;
use App\Entity\Person;
use App\Service\Lpa\GetTrustCorporationStatus\TrustCorporationStatusInterface;
use DateTimeImmutable;
use EventSauce\ObjectHydrator\DoNotSerialize;
use EventSauce\ObjectHydrator\MapFrom;

class LpaStoreTrustCorporations extends Person
class LpaStoreTrustCorporations extends Person implements TrustCorporationStatusInterface
{
public function __construct(
#[MapFrom('address')]
Expand Down Expand Up @@ -68,4 +70,22 @@ public function companyName(): ?string
{
return $this->companyName;
}

#[DoNotSerialize]
public function getCompanyName(): string
{
return $this->companyName();
}

#[DoNotSerialize]
public function getSystemStatus(): bool|string
{
return $this->systemStatus;
}

#[DoNotSerialize]
public function getUid(): string
{
return $this->uId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Entity\Sirius;

use App\Entity\Person;
use App\Service\Lpa\GetTrustCorporationStatus\TrustCorporationStatusInterface;
use EventSauce\ObjectHydrator\DoNotSerialize;
use App\Entity\Sirius\Casters\{
ExtractAddressLine1FromSiriusLpa,
Expand All @@ -21,7 +22,7 @@
use DateTimeImmutable;
use JsonSerializable;

class SiriusLpaTrustCorporations extends Person implements JsonSerializable
class SiriusLpaTrustCorporations extends Person implements JsonSerializable , TrustCorporationStatusInterface
{
public function __construct(
#[MapFrom('addresses')]
Expand Down Expand Up @@ -95,4 +96,22 @@ public function jsonSerialize(): mixed

return $data;
}

#[DoNotSerialize]
public function getCompanyName(): ?string
{
return $this->name;
}

#[DoNotSerialize]
public function getSystemStatus(): bool|string
{
return $this->systemStatus;
}

#[DoNotSerialize]
public function getUid(): string
{
return $this->uId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function __invoke(TrustCorporationStatusInterface $trustCorporation): int
return TrustCorporationStatuses::GHOST_TC->value;
}

if (!$trustCorporation->getSystemStatus()) {
$systemStatus = $trustCorporation->getSystemStatus();
if (!$systemStatus || $systemStatus === 'false') {
$this->logger->debug('Looked up attorney {id} but is inactive', ['id' => $trustCorporation->getUid()]);
return TrustCorporationStatuses::INACTIVE_TC->value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

interface TrustCorporationStatusInterface
{
public function getCompanyName(): string;
public function getCompanyName(): ?string;

public function getSystemStatus(): bool;
public function getSystemStatus(): bool|string;

public function getUid(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace AppTest\Service\Lpa;

use App\Entity\LpaStore\LpaStoreTrustCorporations;
use App\Entity\Sirius\SiriusLpaTrustCorporations;
use App\Service\Lpa\GetTrustCorporationStatus;
use App\Service\Lpa\SiriusPerson;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -26,6 +28,7 @@ public function setUp(): void
#[Test]
public function returns_0_if_trustCorporation_is_active(): void
{

$trustCorporation = new SiriusPerson(
[
'uId' => 7,
Expand All @@ -41,6 +44,36 @@ public function returns_0_if_trustCorporation_is_active(): void
$this->assertEquals(0, ($status)($trustCorporation));
}

#[Test]
public function returns_0_if_trustCorporation_is_active_combined_format_lpastore(): void
{
$trustCorporation = new LpaStoreTrustCorporations(
$addressLine1 = '103 Line 1',
$addressLine2 = null,
$addressLine3 = null,
$countryName = 'UK',
$country = 'GB',
$county = null,
$dob = null,
$email = null,
$firstname = null,
$firstnames = null,
$name = 'ABC Ltd',
$otherNames = null,
$postcode = null,
$surname = null,
$systemStatus = 'active',
$town = 'Town',
$type = null,
$uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(0, ($status)($trustCorporation));
}
#[Test]
public function returns_1_if_trustCorporation_is_a_ghost(): void
{
Expand All @@ -58,6 +91,36 @@ public function returns_1_if_trustCorporation_is_a_ghost(): void

$this->assertEquals(1, ($status)($trustCorporation));
}
#[Test]
public function returns_1_if_trustCorporation_is_a_ghost_combined_format_lpastore(): void
{
$trustCorporation = new LpaStoreTrustCorporations(
$addressLine1 = '103 Line 1',
$addressLine2 = null,
$addressLine3 = null,
$companyName = '',
$country = 'GB',
$county = null,
$dob = null,
$email = null,
$firstname = null,
$firstnames = null,
$name = '',
$otherNames = null,
$postcode = null,
$surname = null,
$systemStatus = 'active',
$town = 'Town',
$type = null,
$uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(1, ($status)($trustCorporation));
}

#[Test]
public function returns_2_if_trustCorporation_is_inactive(): void
Expand All @@ -74,6 +137,65 @@ public function returns_2_if_trustCorporation_is_inactive(): void
$this->loggerProphecy->reveal()
);

$this->assertEquals(2, ($status)($trustCorporation));
}
#[Test]
public function returns_2_if_trustCorporation_is_inactive_combined_format_lpastore(): void
{
$trustCorporation = new LpaStoreTrustCorporations(
$addressLine1 = '103 Line 1',
$addressLine2 = null,
$addressLine3 = null,
$country = 'GB',
$county = null,
$companyName = 'XYZ Ltd',
$dob = null,
$email = null,
$firstname = null,
$firstnames = null,
$name = '',
$otherNames = null,
$postcode = null,
$surname = null,
$systemStatus = 'false',
$town = 'Town',
$type = null,
$uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(2, ($status)($trustCorporation));
}
#[Test]
public function returns_2_if_trustCorporation_is_inactive_combined_format_sirius(): void
{
$trustCorporation = new SiriusLpaTrustCorporations(
$addressLine1 = 'Street 1',
$addressLine2 = 'Street 2',
$addressLine3 = 'Street 3',
$country = 'GB',
$county = 'County',
$dob = null,
$email = null,
$firstname = 'trust',
$firstnames = null,
$name = 'XYZ Ltd',
$otherNames = null,
$postcode = 'ABC 123',
$surname = 'test',
$systemStatus = 'false',
$town = 'Town',
$type = 'Primary',
$uId = '7000-0015-1998',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(2, ($status)($trustCorporation));
}
}
Loading