From 85d4675d053346e93f7282e89bb4422ddca02e10 Mon Sep 17 00:00:00 2001 From: Allen Annom <49309320+allenannom@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:10:12 +0000 Subject: [PATCH] UML-3570 refactor templates to work with combined format summary (#2904) * UML-3619 Convert incoming LPAs to combined format (repository layer) * feature flag by separate templates * drop unused template * UML-3570 fixed relevant test cases, added more tests, added new enum and cast, updated fixtures * UML-3570 updated tests, added verbose to ui test * revert api changes (to be extracted to new branch) * more api revert * ensure LpaType is accessible, fix addresses, make mock combined data dynamic * UML-3570 removed original, inactive and active attoryneys * reinstate mocked values * bump cov * revert api * fix sniffs * fix sniffs * UML-3570 updated tests * UML-3570 updated WhenTheLpaCanBeUsed.php lint * UML-3570 added more test cases and updated templates with feature flags * UML-3570 added new combined lpa templates depending on if the feature flag is enabled address test cases * UML-3570 added more tests for code coverage * UML-3570 reverted change * UML-3570 removed final references to original, inactive, and active attorneys * UML-3570 updated tests updated references to addressline1,2,3 added getters * UML-3570 fixed - referenced incorrect key for attoryneys --------- Co-authored-by: Alex Saunders Co-authored-by: SeemaMenon --- .../context/Integration/LpaContext.php | 27 +-- .../Service/ActorCodes/ActorCodeService.php | 1 - .../app/src/App/src/Service/Lpa/SiriusLpa.php | 3 - .../App/src/Service/Lpa/SiriusLpaManager.php | 15 +- .../Service/Lpa/SiriusLpaManagerTest.php | 17 -- service-front/app/composer.json | 2 +- .../app/features/actor-view-lpa.feature | 42 ++++- .../app/features/bootstrap/behat.config.php | 8 +- .../features/context/BaseUiContextTrait.php | 28 +++ .../app/features/context/UI/LpaContext.php | 59 ++++++ .../src/Handler/CheckAccessCodesHandler.php | 12 +- .../src/Handler/CreateViewerCodeHandler.php | 9 +- .../src/Handler/ViewLpaSummaryHandler.php | 7 +- .../check-access-codes-combined-lpa.html.twig | 101 ++++++++++ ...a-create-viewercode-combined-lpa.html.twig | 79 ++++++++ .../view-lpa-summary-combined-lpa.html.twig | 176 ++++++++++++++++++ .../app/src/Common/src/Entity/CombinedLpa.php | 5 + .../src/Entity/LpaStore/LpaStoreAttorney.php | 12 +- .../src/Entity/LpaStore/LpaStoreDonor.php | 12 +- .../LpaStore/LpaStoreTrustCorporations.php | 12 +- .../app/src/Common/src/Entity/Person.php | 13 ++ .../Sirius/SiriusLpaTrustCorporations.php | 1 + .../Common/src/Service/Lpa/ParseLpaData.php | 1 + .../full-lpa-display-combined-lpa.html.twig | 2 +- ...pa-attorney-details-combined-lpa.html.twig | 2 +- .../lpa-attorney-details.html.twig | 4 +- .../lpa-donor-details-combined-lpa.html.twig | 23 +++ .../CommonTest/Entity/CombinedLpaTest.php | 2 + ...CanHydrateLpaStoreToCombinedFormatTest.php | 18 +- .../app/test/CommonTest/Entity/PersonTest.php | 15 +- .../CanHydrateSiriusToCombinedFormatTest.php | 2 +- .../CommonTest/View/Twig/LpaExtensionTest.php | 45 +++++ .../app/test/fixtures/combined_lpa.json | 110 +++++++++++ 33 files changed, 762 insertions(+), 103 deletions(-) create mode 100644 service-front/app/src/Actor/templates/actor/check-access-codes-combined-lpa.html.twig create mode 100644 service-front/app/src/Actor/templates/actor/lpa-create-viewercode-combined-lpa.html.twig create mode 100644 service-front/app/src/Actor/templates/actor/view-lpa-summary-combined-lpa.html.twig create mode 100644 service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-donor-details-combined-lpa.html.twig create mode 100644 service-front/app/test/fixtures/combined_lpa.json diff --git a/service-api/app/features/context/Integration/LpaContext.php b/service-api/app/features/context/Integration/LpaContext.php index 001098e259..3c4780099b 100644 --- a/service-api/app/features/context/Integration/LpaContext.php +++ b/service-api/app/features/context/Integration/LpaContext.php @@ -383,10 +383,7 @@ public function iProvideTheAttorneyDetailsFromAValidPaperLPADocument(): void $lpaMatchResponse = $addOlderLpa->validateRequest($this->userId, $data); $expectedLpaArray = json_decode(json_encode($this->lpa), true); - $expectedLpaArray['original_attorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['activeAttorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['inactiveAttorneys'] = []; - $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); + $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); $expectedResponse = new AccessForAllValidation( new ActorMatch( new SiriusPerson(json_decode(json_encode($this->lpa->attorneys[0]), true)), @@ -1594,10 +1591,7 @@ public function iConfirmDetailsShownToMeOfTheFoundLPAAreCorrect(): void $lpaMatchResponse = $addOlderLpa->validateRequest($this->userId, $data); $expectedLpaArray = json_decode(json_encode($this->lpa), true); - $expectedLpaArray['original_attorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['activeAttorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['inactiveAttorneys'] = []; - $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); + $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); $expectedResponse = new AccessForAllValidation( new ActorMatch( new SiriusPerson(json_decode(json_encode($lpa->donor), true)), @@ -1875,10 +1869,7 @@ public function iProvideDetailsThatMatchAValidPaperDocument($firstnames, $lastna $lpaMatchResponse = $addAccessForAllLpa->validateRequest($this->userId, $data); $expectedLpaArray = json_decode(json_encode($this->lpa), true); - $expectedLpaArray['original_attorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['activeAttorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['inactiveAttorneys'] = []; - $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); + $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); $expectedResponse = new AccessForAllValidation( new ActorMatch( new SiriusPerson(json_decode(json_encode($this->lpa->donor), true)), @@ -1938,10 +1929,7 @@ public function iProvideTheDetailsFromAValidPaperLPADocument(): void $lpaMatchResponse = $addOlderLpa->validateRequest($this->userId, $data); $expectedLpaArray = json_decode(json_encode($this->lpa), true); - $expectedLpaArray['original_attorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['activeAttorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['inactiveAttorneys'] = []; - $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); + $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); $expectedResponse = new AccessForAllValidation( new ActorMatch( new SiriusPerson(json_decode(json_encode($this->lpa->donor), true)), @@ -2739,13 +2727,10 @@ public function iRequestForANewActivationKeyAgain(): void ); $addOlderLpa = $this->container->get(AddAccessForAllLpa::class); - $response = $addOlderLpa->validateRequest($this->userId, $data); + $response = $addOlderLpa->validateRequest($this->userId, $data); $expectedLpaArray = json_decode(json_encode($this->lpa), true); - $expectedLpaArray['original_attorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['activeAttorneys'] = $expectedLpaArray['attorneys']; - $expectedLpaArray['inactiveAttorneys'] = []; - $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); + $expectedLpa = new \App\Service\Lpa\SiriusLpa($expectedLpaArray); $expectedResponse = new AccessForAllValidation( new ActorMatch( new SiriusPerson(json_decode(json_encode($this->lpa->donor), true)), diff --git a/service-api/app/src/App/src/Service/ActorCodes/ActorCodeService.php b/service-api/app/src/App/src/Service/ActorCodes/ActorCodeService.php index e91af0577d..e621d7856e 100644 --- a/service-api/app/src/App/src/Service/ActorCodes/ActorCodeService.php +++ b/service-api/app/src/App/src/Service/ActorCodes/ActorCodeService.php @@ -48,7 +48,6 @@ public function validateDetails(string $code, string $uid, string $dob): ?array $actor = ($this->resolveActor)($lpa->getData(), $actorUid); $lpaData = $lpa->getData(); - unset($lpaData['original_attorneys']); return [ 'actor' => $actor, diff --git a/service-api/app/src/App/src/Service/Lpa/SiriusLpa.php b/service-api/app/src/App/src/Service/Lpa/SiriusLpa.php index 7cbd329ce1..d59961b406 100644 --- a/service-api/app/src/App/src/Service/Lpa/SiriusLpa.php +++ b/service-api/app/src/App/src/Service/Lpa/SiriusLpa.php @@ -37,9 +37,6 @@ public function __construct(private array $lpa) } $this->transformArrayToSiriusPersons('attorneys'); - $this->transformArrayToSiriusPersons('original_attorneys'); - $this->transformArrayToSiriusPersons('inactiveAttorneys'); - $this->transformArrayToSiriusPersons('activeAttorneys'); $this->transformArrayToSiriusPersons('trustCorporations'); } diff --git a/service-api/app/src/App/src/Service/Lpa/SiriusLpaManager.php b/service-api/app/src/App/src/Service/Lpa/SiriusLpaManager.php index 66c9ec4930..9358af140d 100644 --- a/service-api/app/src/App/src/Service/Lpa/SiriusLpaManager.php +++ b/service-api/app/src/App/src/Service/Lpa/SiriusLpaManager.php @@ -48,23 +48,13 @@ public function getByUid(string $uid): ?LpaInterface $lpaData = $lpa->getData(); if ($lpaData['attorneys'] !== null) { - $lpaData['original_attorneys'] = $lpaData['attorneys']; - $lpaData['activeAttorneys'] = array_values( + $lpaData['attorneys'] = array_values( array_filter($lpaData['attorneys'], function ($attorney) { return ($this->getAttorneyStatus)($attorney) === AttorneyStatus::ACTIVE_ATTORNEY; }) ); } - if ($lpaData['attorneys'] !== null) { - $lpaData['original_attorneys'] = $lpaData['attorneys']; - $lpaData['inactiveAttorneys'] = array_values( - array_filter($lpaData['attorneys'], function ($attorney) { - return ($this->getAttorneyStatus)($attorney) === AttorneyStatus::INACTIVE_ATTORNEY; - }) - ); - } - if ($lpaData['trustCorporations'] !== null) { $lpaData['trustCorporations'] = array_values( array_filter($lpaData['trustCorporations'], function ($trustCorporation) { @@ -93,7 +83,6 @@ public function getByUserLpaActorToken(string $token, string $userId): ?array } $lpaData = $lpa->getData(); - unset($lpaData['original_attorneys']); $result = [ 'user-lpa-actor-token' => $map['Id'], @@ -183,7 +172,6 @@ public function getByViewerCode(string $viewerCode, string $donorSurname, ?strin } $lpaData = $lpa->getData(); - unset($lpaData['original_attorneys']); $result = [ 'date' => $lpa->getLookupTime()->format('c'), @@ -241,7 +229,6 @@ private function lookupAndFormatLpas(array $lpaActorMaps): array $actor = ($this->resolveActor)($lpaData, (string) $item['ActorId']); $added = $item['Added']->format('Y-m-d H:i:s'); - unset($lpaData['original_attorneys']); //Extract and return only LPA's where status is Registered or Cancelled if (($this->isValidLpa)($lpaData)) { diff --git a/service-api/app/test/AppTest/Service/Lpa/SiriusLpaManagerTest.php b/service-api/app/test/AppTest/Service/Lpa/SiriusLpaManagerTest.php index 8fc74eb260..43d69873e2 100644 --- a/service-api/app/test/AppTest/Service/Lpa/SiriusLpaManagerTest.php +++ b/service-api/app/test/AppTest/Service/Lpa/SiriusLpaManagerTest.php @@ -115,17 +115,8 @@ public function can_get_by_id(): void [ 'attorneys' => [ ['id' => 1, 'firstname' => 'A', 'surname' => 'B', 'systemStatus' => true], - ['id' => 2, 'firstname' => 'A', 'surname' => 'B', 'systemStatus' => false], - ['id' => 3, 'firstname' => 'A', 'systemStatus' => true], - ['id' => 4, 'surname' => 'B', 'systemStatus' => true], - ['id' => 5, 'systemStatus' => true], - ], - 'original_attorneys' => [ - ['id' => 1, 'firstname' => 'A', 'surname' => 'B', 'systemStatus' => true], - ['id' => 2, 'firstname' => 'A', 'surname' => 'B', 'systemStatus' => false], ['id' => 3, 'firstname' => 'A', 'systemStatus' => true], ['id' => 4, 'surname' => 'B', 'systemStatus' => true], - ['id' => 5, 'systemStatus' => true], ], 'trustCorporations' => [ new SiriusPerson( @@ -135,14 +126,6 @@ public function can_get_by_id(): void 'systemStatus' => true, ]), ], - 'inactiveAttorneys' => [ - ['id' => 2, 'firstname' => 'A', 'surname' => 'B', 'systemStatus' => false], - ], - 'activeAttorneys' => [ - ['id' => 1, 'firstname' => 'A', 'surname' => 'B', 'systemStatus' => true], - ['id' => 3, 'firstname' => 'A', 'systemStatus' => true], - ['id' => 4, 'surname' => 'B', 'systemStatus' => true], - ], ], ), $lpaResponse->getLookupTime() diff --git a/service-front/app/composer.json b/service-front/app/composer.json index bbea09bcb9..a581e97108 100644 --- a/service-front/app/composer.json +++ b/service-front/app/composer.json @@ -143,7 +143,7 @@ "cs-check": "@dc-php /app/vendor/bin/phpcs", "cs-fix": "@dc-php /app/vendor/bin/phpcbf", "unit-test": "@dc-php /app/vendor/bin/phpunit --colors=always", - "ui-test": "@dc-php -dapc.enable_cli=1 /app/vendor/bin/behat -p acceptance --colors", + "ui-test": "@dc-php -dapc.enable_cli=1 /app/vendor/bin/behat -p acceptance --colors -vv", "int-test": "@dc-php /app/vendor/bin/behat -p integration --colors", "extract": "@dc-php console.php translation:update" } diff --git a/service-front/app/features/actor-view-lpa.feature b/service-front/app/features/actor-view-lpa.feature index 4f35ed3134..7eb8cf83ff 100644 --- a/service-front/app/features/actor-view-lpa.feature +++ b/service-front/app/features/actor-view-lpa.feature @@ -55,4 +55,44 @@ Feature: View an LPA that I have added to my account Given I have added an LPA to my account And I am on the dashboard page When I request to view an LPA where all actors do not have an also known by name - Then I will not see the also known as field \ No newline at end of file + Then I will not see the also known as field + + @integration @ui @ff:support_datastore_lpas:true + Scenario Outline: The user can view a Combined LPA added to their account + Given I have added a Combined LPA to my account + And I am on the dashboard page + When I request to view an LPA which status is "" + Then The full LPA is displayed with the correct + Examples: + | status | message | + | Registered | This LPA is registered | + + @integration @ui @ff:support_datastore_lpas:true + Scenario: The user cannot view a Combined LPA added to their account whose status has changed Revoked + Given I have added a Combined LPA to my account + And I am on the dashboard page + And The LPA has been revoked + When I request to view an LPA whose status changed to Revoked + Then I am taken back to the dashboard page + And The Revoked LPA details are not displayed + + @ui @ff:support_datastore_lpas:true + Scenario: The user can view a Combined LPA and see trust corporation details in attorney sections + Given I have added a Combined LPA to my account + And I am on the dashboard page + When I request to view an LPA which has a trust corporation added + Then I can see the trust corporation trust corporation in the list of attorneys + + @ui @ff:support_datastore_lpas:true + Scenario: The user can only see active attorneys in the attorney section of Combined LPA summary + Given I have added a Combined LPA to my account + And I am on the dashboard page + When I request to view an LPA which has an inactive attorney named 'Harold Stallman' + Then I will not see 'Harold Stallman' in the attorney section of LPA summary + + @ui @ff:support_datastore_lpas:true + Scenario: Show also known as when an actor has other names defined of Combined LPA + Given I have added a Combined LPA to my account + And I am on the dashboard page + When I request to view an LPA with a donor who is also known as 'Ezra' + Then I will see Ezra in the also known as field \ No newline at end of file diff --git a/service-front/app/features/bootstrap/behat.config.php b/service-front/app/features/bootstrap/behat.config.php index 7df992906e..6e6b383b95 100644 --- a/service-front/app/features/bootstrap/behat.config.php +++ b/service-front/app/features/bootstrap/behat.config.php @@ -35,10 +35,10 @@ //'debug' => true, ], 'feature_flags' => [ - 'delete_lpa_feature' => true, - 'instructions_and_preferences' => true, - 'allow_gov_one_login' => true, - 'support_datastore_lpas' => false, + 'delete_lpa_feature' => true, + 'instructions_and_preferences' => true, + 'allow_gov_one_login' => true, + 'support_datastore_lpas' => false, ], 'notify' => [ 'api' => [ diff --git a/service-front/app/features/context/BaseUiContextTrait.php b/service-front/app/features/context/BaseUiContextTrait.php index cc91e045e8..85e99233e2 100644 --- a/service-front/app/features/context/BaseUiContextTrait.php +++ b/service-front/app/features/context/BaseUiContextTrait.php @@ -5,12 +5,16 @@ namespace BehatTest\Context; use Aws\MockHandler as AwsMockHandler; +use Behat\Behat\Hook\Scope\AfterScenarioScope; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\MinkExtension\Context\MinkContext; use BehatTest\Context\UI\BaseUiContext; use BehatTest\Context\UI\SharedState; use GuzzleHttp\Client; use GuzzleHttp\Handler\MockHandler; +use Monolog\Handler\TestHandler; +use Monolog\Logger; +use Psr\Log\LoggerInterface; /** * Trait BaseUiContextTrait @@ -37,6 +41,30 @@ public function gatherContexts(BeforeScenarioScope $scope): void $this->awsFixtures = $this->base->awsFixtures; } + /** + * @AfterScenario + */ + public function outputLogsOnFailure(AfterScenarioScope $scope): void + { + $logger = $this->base->container->get(LoggerInterface::class); + + if ($logger instanceof Logger) { + /** @var TestHandler $testHandler */ + $testHandler = array_filter( + $logger->getHandlers(), + fn ($handler) => $handler instanceof TestHandler + )[0]; + + if (!$scope->getTestResult()->isPassed()) { + foreach ($testHandler->getRecords() as $record) { + print_r($record['formatted']); + } + } + + $logger->reset(); + } + } + /** * Checks the response for a particular header being set with a specified value * diff --git a/service-front/app/features/context/UI/LpaContext.php b/service-front/app/features/context/UI/LpaContext.php index a4de7888ba..c540a94bbd 100644 --- a/service-front/app/features/context/UI/LpaContext.php +++ b/service-front/app/features/context/UI/LpaContext.php @@ -3111,6 +3111,7 @@ public function iRequestToViewAnLPAWithADonorWhoIsAlsoKnownAs($name): void { $this->ui->assertPageContainsText('View LPA summary'); $this->lpa->donor->otherNames = $name; + $this->mockApiGetLpaByIdAndGetImagesById(); } @@ -3246,4 +3247,62 @@ public function iReturnToTheDashboard(): void { $this->ui->assertPageAddress('/lpa/dashboard'); } + + /** + * @Given I have added a Combined LPA to my account + */ + public function iHaveAddedACombinedLpaToMyAccount(): void + { + $this->iHaveBeenGivenAccessToUseACombinedLPAViaCredentials(); + + $this->dashboardLPAs = [$this->userLpaActorToken => $this->lpaData]; + } + + /** + * @Given I have been given access to use a Combined LPA via credentials + */ + public function iHaveBeenGivenAccessToUseACombinedLPAViaCredentials(): void + { + $this->lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/combined_lpa.json')); + + $this->userLpaActorToken = '987654321'; + $this->actorId = 9; + + $this->lpaData = [ + 'user-lpa-actor-token' => $this->userLpaActorToken, + 'date' => 'today', + 'actor' => [ + 'type' => 'primary-attorney', + 'details' => [ + 'addresses' => [ + [ + 'addressLine1' => '', + 'addressLine2' => '', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'id' => 0, + 'postcode' => '', + 'town' => '', + 'type' => 'Primary', + ], + ], + 'companyName' => null, + 'dob' => '1975-10-05', + 'email' => 'string', + 'firstname' => 'Ian', + 'id' => 0, + 'middlenames' => null, + 'salutation' => 'Mr', + 'surname' => 'Deputy', + 'systemStatus' => true, + 'uId' => '700000000054', + ], + ], + 'applicationHasRestrictions' => true, + 'applicationHasGuidance' => false, + 'lpa' => $this->lpa, + 'added' => '2021-10-5 12:00:00', + ]; + } } diff --git a/service-front/app/src/Actor/src/Handler/CheckAccessCodesHandler.php b/service-front/app/src/Actor/src/Handler/CheckAccessCodesHandler.php index bff8abb214..78ec78d67a 100644 --- a/service-front/app/src/Actor/src/Handler/CheckAccessCodesHandler.php +++ b/service-front/app/src/Actor/src/Handler/CheckAccessCodesHandler.php @@ -7,8 +7,10 @@ use Actor\Form\CancelCode; use Common\Entity\CaseActor; use Common\Entity\Lpa; +use Common\Entity\Person; use Common\Exception\InvalidRequestException; use Common\Handler\{AbstractHandler, CsrfGuardAware, Traits\CsrfGuard, Traits\Session, Traits\User, UserAware}; +use Common\Service\Features\FeatureEnabled; use Common\Service\Lpa\{LpaService, ViewerCodeService}; use DateTime; use Laminas\Diactoros\Response\HtmlResponse; @@ -36,6 +38,7 @@ public function __construct( private LpaService $lpaService, private ViewerCodeService $viewerCodeService, LoggerInterface $logger, + private FeatureEnabled $featureEnabled, ) { parent::__construct($renderer, $urlHelper, $logger); @@ -159,10 +162,15 @@ public function handle(ServerRequestInterface $request): ResponseInterface ); } + $templateName = 'actor::check-access-codes'; + if (($this->featureEnabled)('support_datastore_lpas')) { + $templateName = 'actor::check-access-codes-combined-lpa'; + } + /** @var FlashMessagesInterface $flash */ $flash = $request->getAttribute(FlashMessageMiddleware::FLASH_ATTRIBUTE); - return new HtmlResponse($this->renderer->render('actor::check-access-codes', [ + return new HtmlResponse($this->renderer->render($templateName, [ 'actorToken' => $actorLpaToken, 'user' => $user, 'lpa' => $lpa, @@ -171,7 +179,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface ])); } - private function idMatch(CaseActor $actor, array $code): bool + private function idMatch(CaseActor|Person $actor, array $code): bool { return $actor->getId() === $code['ActorId'] || intval($actor->getUId()) === $code['ActorId']; diff --git a/service-front/app/src/Actor/src/Handler/CreateViewerCodeHandler.php b/service-front/app/src/Actor/src/Handler/CreateViewerCodeHandler.php index b3d61d9620..657f1a30c0 100644 --- a/service-front/app/src/Actor/src/Handler/CreateViewerCodeHandler.php +++ b/service-front/app/src/Actor/src/Handler/CreateViewerCodeHandler.php @@ -12,6 +12,7 @@ use Common\Handler\Traits\Session; use Common\Handler\Traits\User; use Common\Handler\UserAware; +use Common\Service\Features\FeatureEnabled; use Common\Service\Lpa\LpaService; use Common\Service\Lpa\ViewerCodeService; use DateTimeImmutable; @@ -37,6 +38,7 @@ public function __construct( AuthenticationInterface $authenticator, private LpaService $lpaService, private ViewerCodeService $viewerCodeService, + private FeatureEnabled $featureEnabled, ) { parent::__construct($renderer, $urlHelper); @@ -101,7 +103,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface return $this->redirectToRoute('lpa.dashboard'); } - return new HtmlResponse($this->renderer->render('actor::lpa-create-viewercode', [ + $templateName = 'actor::lpa-create-viewercode'; + if (($this->featureEnabled)('support_datastore_lpas')) { + $templateName = 'actor::lpa-create-viewercode-combined-lpa'; + } + + return new HtmlResponse($this->renderer->render($templateName, [ 'user' => $user, 'lpa' => $lpaData->lpa, 'actorToken' => $form->get('lpa_token')->getValue(), diff --git a/service-front/app/src/Actor/src/Handler/ViewLpaSummaryHandler.php b/service-front/app/src/Actor/src/Handler/ViewLpaSummaryHandler.php index 6fce49c103..32c29ec8b9 100644 --- a/service-front/app/src/Actor/src/Handler/ViewLpaSummaryHandler.php +++ b/service-front/app/src/Actor/src/Handler/ViewLpaSummaryHandler.php @@ -81,9 +81,14 @@ public function handle(ServerRequestInterface $request): ResponseInterface $renderData['iap_images'] = $this->instAndPrefImagesService->getImagesById($identity, $actorLpaToken); } + $templateName = 'actor::view-lpa-summary'; + if (($this->featureEnabled)('support_datastore_lpas')) { + $templateName = 'actor::view-lpa-summary-combined-lpa'; + } + return new HtmlResponse( $this->renderer->render( - 'actor::view-lpa-summary', + $templateName, $renderData, ) ); diff --git a/service-front/app/src/Actor/templates/actor/check-access-codes-combined-lpa.html.twig b/service-front/app/src/Actor/templates/actor/check-access-codes-combined-lpa.html.twig new file mode 100644 index 0000000000..1e2d50ba16 --- /dev/null +++ b/service-front/app/src/Actor/templates/actor/check-access-codes-combined-lpa.html.twig @@ -0,0 +1,101 @@ +{% extends '@actor/layout.html.twig' %} + +{% block html_title %}{% trans %}Access codes for this LPA{% endtrans %} - {{ parent() }} {% endblock %} + +{% block content %} + +
+ + +
+ + {{ include('@actor/partials/flash-message.html.twig', {'flash': flash, 'flash_key':'Actor\\Handler\\CancelCodeHandler::CANCEL_CODE_FLASH_MSG'}) }} + +
+ +
+ {{ actor_name(lpa.donor, false) }}, {{ lpa.caseSubtype.value == 'pfa' ? 'Property and finance' | trans : 'Health and welfare' | trans }} + +

{% trans %}Check access codes{% endtrans %}

+
+ +
+ + {{ include('@actor/partials/lpa-sub-navigation.html.twig') }} + +
+
+ + {% if shareCodes is empty %} +

{% trans %}There are no access codes for this LPA.{% endtrans %}

+

{% trans %}When an organisation has been given access you will be able to see the
+ access codes and details here.{% endtrans %}

+ + + {% trans %}Give an organisation access{% endtrans %} + + {% else %} + {% set containsActive = false %} + {% set containsInactive = false %} + + {% for code in shareCodes %} + + {% if check_if_code_has_expired(code.Expires) %} + {% set containsInactive = true %} + {% elseif check_if_code_is_cancelled(code) %} + {% set containsInactive = true %} + {% else %} + {% set containsActive = true %} + {% endif %} + {% endfor %} + + {% if containsActive %} +

{% trans %}Active codes{% endtrans %}

+ +

{% trans %}Give an organisation their access code so they can view this LPA. They should go to www.gov.uk/view-lpa to use the code.{% endtrans %}

+ + {% if (lpa.applicationHasRestrictions or lpa.applicationHasGuidance) and not feature_enabled("instructions_and_preferences") %} +
+ + + {% trans %}Warning{% endtrans %} + {{ include('@actor/partials/lpa-instructions-preferences-warning-message.html.twig') }} + +
+ {% endif %} + +
+ {% for code in shareCodes %} + {% set id_counter = ( id_counter | default(0) ) + 1 %} + {% if not (check_if_code_has_expired(code.Expires) or check_if_code_is_cancelled(code)) %} + {# show active code even if it belongs to a deleted LPA #} + {{ include('@actor/partials/check-code-details.html.twig', {'id_counter': id_counter }) }} + {% endif %} + {% endfor %} +
+ {% endif %} + + {% if containsInactive %} +

{% trans %}Inactive codes{% endtrans %}

+ +

{% trans %}The following codes will no longer work.{% endtrans %}
+ {%trans with {'%create-code-link%': path('lpa.create-code', {}, {'lpa': actorToken })} %}If an organisation asks to see this LPA again, you can make them a new code.{% endtrans %} +

+ +
+ {% for code in shareCodes %} + {% set id_counter = ( id_counter | default(0) ) + 1 %} + {% if check_if_code_has_expired(code.Expires) or check_if_code_is_cancelled(code) %} + {{ include('@actor/partials/check-code-details.html.twig', {'id_counter': id_counter }) }} + {% endif %} + {% endfor %} +
+ {% endif %} + {% endif %} +
+
+
+
+{% endblock %} diff --git a/service-front/app/src/Actor/templates/actor/lpa-create-viewercode-combined-lpa.html.twig b/service-front/app/src/Actor/templates/actor/lpa-create-viewercode-combined-lpa.html.twig new file mode 100644 index 0000000000..7d3d8c5152 --- /dev/null +++ b/service-front/app/src/Actor/templates/actor/lpa-create-viewercode-combined-lpa.html.twig @@ -0,0 +1,79 @@ +{% extends '@actor/layout.html.twig' %} + +{% block html_title %}{% trans %}Which organisation do you want to give access to{% endtrans %} - {{ parent() }} {% endblock %} + +{% block content %} +
+ + +
+ + {{ govuk_error_summary(form) }} + +
+ +
+ {{ actor_name(lpa.donor, false) }}, {{ lpa.caseSubtype.value == 'pfa' ? 'Property and finance' | trans : 'Health and welfare' | trans }} +

{% trans %}Which organisation do you want to give access to?{% endtrans %}

+
+ +
+ + {{ include('@actor/partials/lpa-sub-navigation.html.twig') }} + +
+ {{ govuk_form_open(form) }} +
+ + {{ govuk_form_element(form.get('__csrf')) }} + {{ govuk_form_element(form.get('lpa_token')) }} + +
+ {% if lpa.caseSubtype.value|lower == 'hw' %} + {% set hint = 'The organisation could be a hospital, care home, or other health care provider. This is for your reference only' | trans %} + {% elseif lpa.caseSubtype.value|lower == 'pfa' %} + {% set hint = 'The organisation could be a bank, energy provider, or another business. This is for your reference only' | trans %} + {% endif %} + + {{ govuk_form_element(form.get('org_name'), { + 'label': 'Organisation name' | trans, + 'hint': hint, + 'attr' : {'class': 'govuk-!-width-three-quarters', 'label_class': 'govuk-label--s govuk-!-margin-bottom-3'} + }) }} +
+ + {% if (lpa.applicationHasRestrictions or lpa.applicationHasGuidance) and not feature_enabled('instructions_and_preferences')%} +
+ + + {% trans %}Warning{% endtrans %} + {{ include('@actor/partials/lpa-instructions-preferences-warning-message.html.twig') }} + +
+ {% endif %} + + {% if not lpa.applicationHasRestrictions and not lpa.applicationHasGuidance %} +
+ + + {% trans %}Warning{% endtrans %} + {% trans %} + Check that the organisation will accept an online summary of the LPA and how they want to receive the access code you make for them. + {% endtrans %} + +
+ {% endif %} + + + +
+ {{ govuk_form_close() }} +
+
+
+{% endblock %} diff --git a/service-front/app/src/Actor/templates/actor/view-lpa-summary-combined-lpa.html.twig b/service-front/app/src/Actor/templates/actor/view-lpa-summary-combined-lpa.html.twig new file mode 100644 index 0000000000..3652a47d78 --- /dev/null +++ b/service-front/app/src/Actor/templates/actor/view-lpa-summary-combined-lpa.html.twig @@ -0,0 +1,176 @@ +{% extends '@actor/layout.html.twig' %} + +{% block html_title %}{% trans %}LPA summary{% endtrans %} - {{ parent() }} {% endblock %} + +{% block content %} + +
+ + +
+
+
+ {{ actor_name(lpa.donor, false) }}, {{ lpa.caseSubtype.propertyAndAffairs ? 'Property and finance' | trans : 'Health and welfare' | trans }} +

+ {% trans %}LPA summary{% endtrans %} +

+
+
+ + {{ include('@actor/partials/lpa-sub-navigation.html.twig') }} + + {% if is_lpa_cancelled(lpa) %} +
+
+

+ {% trans %}This LPA has been cancelled{% endtrans %} +

+
+
+ {% else %} +
+
+ {% if lpa.caseSubtype.propertyAndAffairs and lpa.whenTheLpaCanBeUsed.isWhenHasCapacity %} +

+ {% trans %}This LPA is registered and can be used now{% endtrans %} +

+ {% else %} +

+ {% trans %}This LPA is registered{% endtrans %} +

+ {% endif %} +

+ {% if (lpa.caseSubtype and lpa.caseSubtype.propertyAndAffairs) %} + {% if (lpa.whenTheLpaCanBeUsed.isWhenHasCapacity) %} + {% if actor.type == 'donor' %} + {% trans %}While you have mental capacity, your attorneys must get your permission to use this + LPA.{% endtrans %} + {% else %} + {% trans %}While the donor has mental capacity, you must get their permission to use this + LPA.{% endtrans %} + {% endif %} + {% elseif (lpa.whenTheLpaCanBeUsed.isWhenCapacityLost) %} + {% trans %}This LPA can only be used when the donor has lost capacity.{% endtrans %} + {% elseif lpa.whenTheLpaCanBeUsed == null or lpa.whenTheLpaCanBeUsed.isUnknown %} + {% trans %}This LPA can be used as soon as it's registered unless instructions say otherwise.{% endtrans %} + {% endif %} + {% endif %} + + {% if lpa.lifeSustainingTreatment.OptionA %} + {% trans %}The attorneys have the authority to make decisions about life-sustaining treatment{% endtrans %} + {% elseif lpa.lifeSustainingTreatment.OptionB %} + {% trans %}The attorneys do NOT have the authority to make decisions about life-sustaining treatment{% endtrans %} + {% endif %} +

+ {% if not feature_enabled("instructions_and_preferences") %} +

+ {{ include('@actor/partials/lpa-instructions-preferences-warning-message.html.twig') }} +

+ {% endif %} +
+
+ {% endif %} + +
+
+ {% include '@partials/lpa-summary-details/lpa-donor-details-combined-lpa.html.twig' %} +

+ + {% trans %}Need to change the donor's details?{% endtrans %} + +

+
+
+ + {{ include('@partials/section-break.html.twig') }} + +
+
+ {% include '@partials/lpa-summary-details/lpa-attorney-details.html.twig' %} +

+ + {% trans %}Need to change an attorney's details?{% endtrans %} + +

+
+
+ + {{ include('@partials/section-break.html.twig') }} + +
+
+

+ {% trans %}LPA details{% endtrans %} +

+ + {% if feature_enabled("instructions_and_preferences") %} + {% include '@partials/lpa-summary-details/iap-images-components.html.twig' %} + + + {% endif %} + + {% include '@partials/lpa-summary-details/lpa-details-combined-lpa.html.twig' %} + + {% if feature_enabled("instructions_and_preferences") and iap_images is defined %} + {% if iap_images.status is not constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_ERROR') %} +
+ {% trans %}If any scanned images are not readable, organisations may ask to see the paper LPA so that + they can find out what the instructions or preferences are.{% endtrans %} +
+ {% endif %} + {% endif %} + + {% if feature_enabled("instructions_and_preferences") %} +
+ {% endif %} + +

+ + {% trans %}Seen something incorrect in the LPA details?{% endtrans %} + +

+
+
+ + {{ include('@partials/section-break.html.twig') }} + +
+
+
+
+
{% trans %}Date summary viewed{% endtrans %}
+
{{ lpa_date('today') }}
+
+
+
+
+ + +

+

+ + + {% trans %}Warning{% endtrans %} + {% trans %}You cannot use a download or printout of this LPA summary. Always use the original paper LPA or give someone an access code.{% endtrans %} + +
+

+ +
+
+{% endblock %} diff --git a/service-front/app/src/Common/src/Entity/CombinedLpa.php b/service-front/app/src/Common/src/Entity/CombinedLpa.php index 4ad1069892..48e2e4da50 100644 --- a/service-front/app/src/Common/src/Entity/CombinedLpa.php +++ b/service-front/app/src/Common/src/Entity/CombinedLpa.php @@ -67,6 +67,11 @@ public function getApplicationHasRestrictions(): ?bool return $this->applicationHasRestrictions; } + public function getAttorneys(): ?array + { + return $this->attorneys; + } + public function getDonor(): Person { return $this->donor; diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php index cd0b593ede..def5a8a3f8 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php @@ -17,9 +17,9 @@ class LpaStoreAttorney extends Person public function __construct( #[MapFrom('address')] #[ExtractAddressLine1FromLpaStore] - ?string $line1, - ?string $line2, - ?string $line3, + ?string $addressLine1, + ?string $addressLine2, + ?string $addressLine3, #[MapFrom('address')] #[ExtractCountryFromLpaStore] ?string $country, @@ -48,9 +48,9 @@ public function __construct( ?string $uId, ) { parent::__construct( - $line1, - $line2, - $line3, + $addressLine1, + $addressLine2, + $addressLine3, $country, $county, $dob, diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php index 17be4bd4b3..eb7dff1f4e 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php @@ -17,9 +17,9 @@ class LpaStoreDonor extends Person public function __construct( #[MapFrom('address')] #[ExtractAddressLine1FromLpaStore] - ?string $line1, - ?string $line2, - ?string $line3, + ?string $addressLine1, + ?string $addressLine2, + ?string $addressLine3, #[MapFrom('address')] #[ExtractCountryFromLpaStore] ?string $country, @@ -47,9 +47,9 @@ public function __construct( ?string $uId, ) { parent::__construct( - $line1, - $line2, - $line3, + $addressLine1, + $addressLine2, + $addressLine3, $country, $county, $dob, diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php index 10e83d3a13..8f76c5ba9a 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php @@ -17,9 +17,9 @@ class LpaStoreTrustCorporations extends Person public function __construct( #[MapFrom('address')] #[ExtractAddressLine1FromLpaStore] - ?string $line1, - ?string $line2, - ?string $line3, + ?string $addressLine1, + ?string $addressLine2, + ?string $addressLine3, #[MapFrom('name')] public readonly ?string $companyName, #[MapFrom('address')] @@ -47,9 +47,9 @@ public function __construct( ?string $uId, ) { parent::__construct( - $line1, - $line2, - $line3, + $addressLine1, + $addressLine2, + $addressLine3, $country, $county, $dob, diff --git a/service-front/app/src/Common/src/Entity/Person.php b/service-front/app/src/Common/src/Entity/Person.php index 35f71c6eaa..a90fe38f0b 100644 --- a/service-front/app/src/Common/src/Entity/Person.php +++ b/service-front/app/src/Common/src/Entity/Person.php @@ -109,4 +109,17 @@ public function getAddresses(): array ->setCountry($this->getCountry()), ]; } + + public function getUid(): ?string + { + return $this->uId; + } + + /** + * @return string The id (or uid) of the person + */ + public function getId(): ?string + { + return $this->uId; + } } diff --git a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php index 719dcb221d..c065b5c4e9 100644 --- a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php +++ b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php @@ -43,6 +43,7 @@ public function __construct( ?string $firstname, #[MapFrom('firstNames')] ?string $firstnames, + #[MapFrom('companyName')] ?string $name, ?string $otherNames, #[MapFrom('addresses')] diff --git a/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php b/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php index e72031d7b4..8c26133a8a 100644 --- a/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php +++ b/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php @@ -94,6 +94,7 @@ public static function getMockedCombinedFormat(bool $asLpaStoreLpa): array 'firstname' => 'Rachel', 'middlenames' => 'Emma', 'surname' => 'Sanderson', + 'otherNames' => 'Ezra', 'addresses' => [ [ 'id' => 7, diff --git a/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig b/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig index ba62b47403..72d41ffda6 100644 --- a/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig +++ b/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig @@ -88,7 +88,7 @@
- {% include '@partials/lpa-summary-details/lpa-donor-details.html.twig' %} + {% include '@partials/lpa-summary-details/lpa-donor-details-combined-lpa.html.twig' %}
diff --git a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig index 7295bce707..8ebb693b25 100644 --- a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig +++ b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig @@ -42,7 +42,7 @@ {% endfor %} {% for tc in lpa.trustCorporations %} - {% set i = loop.index + lpa.activeAttorneys | length %} + {% set i = loop.index + lpa.attorneys | length %}

{% trans count i with {'%attorneyOrdinal%': i | ordinal } %}%attorneyOrdinal% attorney|%attorneyOrdinal% attorney{% endtrans %}

diff --git a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig index 9224071ad0..edd598df8e 100644 --- a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig +++ b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig @@ -17,7 +17,7 @@
-{% for attorney in lpa.activeAttorneys %} +{% for attorney in lpa.attorneys %}

{% trans count loop.index with {'%attorneyOrdinal%': loop.index | ordinal} %}%attorneyOrdinal% attorney|%attorneyOrdinal% attorney{% endtrans %}

@@ -42,7 +42,7 @@ {% endfor %} {% for tc in lpa.trustCorporations %} - {% set i = loop.index + lpa.activeAttorneys | length %} + {% set i = loop.index + lpa.attorneys | length %}

{% trans count i with {'%attorneyOrdinal%': i | ordinal } %}%attorneyOrdinal% attorney|%attorneyOrdinal% attorney{% endtrans %}

diff --git a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-donor-details-combined-lpa.html.twig b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-donor-details-combined-lpa.html.twig new file mode 100644 index 0000000000..fe2214744d --- /dev/null +++ b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-donor-details-combined-lpa.html.twig @@ -0,0 +1,23 @@ +

{% trans %}The donor{% endtrans %}

+
+
+
{% trans %}Name{% endtrans %}
+
{{ actor_name(lpa.donor) }}
+
+
{{ lpa.donor.otherNames }}
+ {{ dump(lpa) }} + {% if lpa.donor.otherNames is not empty and lpa.donor.otherNames != 'null' %} +
+
{% trans %}Also known as{% endtrans %}
+
{{ lpa.donor.otherNames }}
+
+ {% endif %} +
+
{% trans %}Date of birth{% endtrans %}
+
{{ lpa_date(lpa.donor.dob) }}
+
+
+
{% trans %}Address{% endtrans %}
+
{{ actor_address(lpa.donor) }}
+
+
\ No newline at end of file diff --git a/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php b/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php index e9ea961064..a44b1ae108 100644 --- a/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php +++ b/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php @@ -76,5 +76,7 @@ public function can_test_getters() $this->assertEquals($trustCorporations, $combinedLpa->getTrustCorporations()); $this->assertEquals('123', $combinedLpa->getUId()); $this->assertEquals(WhenTheLpaCanBeUsed::WHEN_HAS_CAPACITY, $combinedLpa->getWhenTheLpaCanBeUsed()); + $this->assertEquals($attorneys, $combinedLpa->getAttorneys()); + $this->assertEquals(LpaType::PERSONAL_WELFARE, $combinedLpa->getLpaType()); } } diff --git a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php b/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php index 87977109c3..f1d0c45f5e 100644 --- a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php +++ b/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php @@ -30,9 +30,9 @@ public function setUp(): void public function expectedLpaStore(): LpaStore { $donor = new LpaStoreDonor( - line1 : '74 Cloob Close', - line2 : null, - line3 : null, + addressLine1 : '74 Cloob Close', + addressLine2 : null, + addressLine3 : null, country : 'GB', county : null, dob : new DateTimeImmutable('1970-01-24'), @@ -51,9 +51,9 @@ public function expectedLpaStore(): LpaStore $attorneys = [ new LpaStoreAttorney( - line1 : '81 NighOnTimeWeBuiltIt Street', - line2 : null, - line3 : null, + addressLine1 : '81 NighOnTimeWeBuiltIt Street', + addressLine2 : null, + addressLine3 : null, country : 'GB', county : null, dob : new DateTimeImmutable('1982-07-24'), @@ -73,9 +73,9 @@ public function expectedLpaStore(): LpaStore $trustCorporations = [ new LpaStoreTrustCorporations( - line1 : '103 Line 1', - line2 : null, - line3 : null, + addressLine1 : '103 Line 1', + addressLine2 : null, + addressLine3 : null, companyName : 'Trust us Corp.', country : 'GB', county : null, diff --git a/service-front/app/test/CommonTest/Entity/PersonTest.php b/service-front/app/test/CommonTest/Entity/PersonTest.php index e78f4c59ea..46b13726ab 100644 --- a/service-front/app/test/CommonTest/Entity/PersonTest.php +++ b/service-front/app/test/CommonTest/Entity/PersonTest.php @@ -29,17 +29,22 @@ public function can_test_getters() $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/test_lpa.json'), true); $combinedLpa = ($this->lpaDataFormatter)($lpa); - $expectedSalutation = ''; - $expectedFirstname = 'Rachel'; - $expectedMiddlename = ''; - $expectedSurname = 'Sanderson'; - $expectedDob = new DateTimeImmutable('1948-11-01'); + $expectedSalutation = ''; + $expectedFirstname = 'Rachel'; + $expectedMiddlename = ''; + $expectedSurname = 'Sanderson'; + $expectedDob = new DateTimeImmutable('1948-11-01'); + $expectedCompanyName = 'trust corporation'; + $expectedUid = '700000000799'; $this->assertEquals($expectedSalutation, $combinedLpa->getDonor()->getSalutation()); $this->assertEquals($expectedFirstname, $combinedLpa->getDonor()->getFirstname()); $this->assertEquals($expectedMiddlename, $combinedLpa->getDonor()->getMiddlenames()); $this->assertEquals($expectedSurname, $combinedLpa->getDonor()->getSurname()); $this->assertEquals($expectedDob, $combinedLpa->getDonor()->getDob()); + $this->assertEquals($expectedCompanyName, $combinedLpa->trustCorporations[0]->getCompanyName()); + $this->assertEquals($expectedUid, $combinedLpa->getDonor()->getUId()); + $this->assertEquals($expectedUid, $combinedLpa->getDonor()->getId()); } #[Test] diff --git a/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php b/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php index 94174bb910..47f8575902 100644 --- a/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php +++ b/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php @@ -108,7 +108,7 @@ public function expectedSiriusLpa(): SiriusLpa email : null, firstname : 'trust', firstnames : null, - name : null, + name : 'trust corporation', otherNames : null, postcode : 'ABC 123', surname : 'test', diff --git a/service-front/app/test/CommonTest/View/Twig/LpaExtensionTest.php b/service-front/app/test/CommonTest/View/Twig/LpaExtensionTest.php index d40909cf1d..dae4d44543 100644 --- a/service-front/app/test/CommonTest/View/Twig/LpaExtensionTest.php +++ b/service-front/app/test/CommonTest/View/Twig/LpaExtensionTest.php @@ -4,6 +4,7 @@ namespace CommonTest\View\Twig; +use Common\Entity\Person; use Common\Service\Lpa\Factory\LpaDataFormatter; use DateTimeImmutable; use PHPUnit\Framework\Attributes\Test; @@ -96,11 +97,54 @@ public function it_concatenates_an_address_array_into_a_comma_separated_string($ $this->assertEquals($expected, $addressString); } + #[Test] + public function it_concatenates_an_address_array_into_a_comma_separated_string_for_combined_format(): void + { + $extension = new LpaExtension(); + + $actor = new Person( + addressLine1: 'Street 1', + addressLine2: 'Street 2', + addressLine3: 'Street 3', + country: 'Country', + county: 'County', + dob: new DateTimeImmutable('22-12-1997'), + email: 'email@email.com', + firstname: 'John', + firstnames: 'Jonathan', + name: 'name', + otherNames: 'Maverick', + postcode: 'ABC 123', + surname: 'Doe', + systemStatus: 'true', + town: 'Town', + type: 'Primary', + uId: '700000012345', + ); + + $expected = 'Street 1, Street 2, Street 3, Town, County, ABC 123, Country'; + $addressString = $extension->actorAddress($actor); + + $this->assertEquals($expected, $addressString); + } + + #[Test] + public function access_address_key_values(): void + { + $address = new Address(); + $address->setId(1); + $address->setType('Primary'); + + $this->assertEquals(1, $address->getId()); + $this->assertEquals('Primary', $address->getType()); + } + public static function addressDataProvider() { return [ [ [ + 'id' => 1, 'addressLine1' => 'Some House', 'addressLine2' => 'Some Place', 'addressLine3' => 'Somewhere', @@ -108,6 +152,7 @@ public static function addressDataProvider() 'county' => 'Some County', 'postcode' => 'AB1 2CD', 'country' => 'Some country', + 'type' => 'Primary', ], 'Some House, Some Place, Somewhere, Some Town, Some County, AB1 2CD, Some country', ], diff --git a/service-front/app/test/fixtures/combined_lpa.json b/service-front/app/test/fixtures/combined_lpa.json new file mode 100644 index 0000000000..06f46ed9c5 --- /dev/null +++ b/service-front/app/test/fixtures/combined_lpa.json @@ -0,0 +1,110 @@ +{ + "applicationHasGuidance": false, + "applicationHasRestrictions": false, + "applicationType": "Classic", + "attorneyActDecisions": null, + "attorneys": [ + { + "addressLine1": "9 high street", + "addressLine2": "", + "addressLine3": "", + "country": "", + "county": "", + "dob": "1990-05-04 00:00:00.000000+0000", + "email": "", + "firstname": "jean", + "firstnames": null, + "name": null, + "otherNames": null, + "postcode": "DN37 5SH", + "surname": "sanderson", + "systemStatus": "1", + "town": "", + "type": "Primary", + "uId": "700000000815" + }, + { + "addressLine1": "", + "addressLine2": "", + "addressLine3": "", + "country": "", + "county": "", + "dob": "1975-10-05 00:00:00.000000+0000", + "email": "XXXXX", + "firstname": "Ann", + "firstnames": null, + "name": null, + "otherNames": null, + "postcode": "", + "surname": "Summers", + "systemStatus": "1", + "town": "", + "type": "Primary", + "uId": "7000-0000-0849" + } + ], + "caseSubtype": "hw", + "channel": null, + "dispatchDate": null, + "donor": { + "addressLine1": "81 Front Street", + "addressLine2": "LACEBY", + "addressLine3": "", + "country": "", + "county": "", + "dob": "1948-11-01 00:00:00.000000+0000", + "email": "RachelSanderson@opgtest.com", + "firstname": "Rachel", + "firstnames": null, + "name": null, + "otherNames": "Ezra", + "postcode": "DN37 5SH", + "surname": "Sanderson", + "systemStatus": null, + "town": "", + "type": "Primary", + "uId": "700000000799", + "linked": [ + { + "id": 7, + "uId": "700000000799" + } + ] + }, + "hasSeveranceWarning": null, + "invalidDate": null, + "lifeSustainingTreatment": "option-a", + "lpaDonorSignatureDate": "2012-12-12 00:00:00.000000+0000", + "lpaIsCleansed": true, + "onlineLpaId": "A33718377316", + "receiptDate": "2014-09-26 00:00:00.000000+0000", + "registrationDate": "2019-10-10 00:00:00.000000+0000", + "rejectedDate": null, + "replacementAttorneys": [], + "status": "Registered", + "statusDate": null, + "trustCorporations": [ + { + "addressLine1": "Street 1", + "addressLine2": "Street 2", + "addressLine3": "Street 3", + "country": "GB", + "county": "County", + "dob": null, + "email": null, + "firstname": "trust", + "firstnames": null, + "name": "trust corporation", + "otherNames": null, + "postcode": "ABC 123", + "surname": "test", + "systemStatus": "1", + "town": "Town", + "type": "Primary", + "uId": "7000-0015-1998" + } + ], + "uId": "700000000047", + "withdrawnDate": null, + "whenTheLpaCanBeUsed": "when-has-capacity" +} \ No newline at end of file