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-3136: Update viewer journey templates to support combined LPAs #2903

Merged
merged 34 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3f1ef42
update types to display viewer journey
acsauk Nov 4, 2024
75a3063
update casters and templates for remaining combined lpa format
acsauk Nov 5, 2024
16bc0de
add code-sniffer-pre-commit
acsauk Nov 5, 2024
f53c933
fix brackets
acsauk Nov 5, 2024
8bd7ff9
include pre-commit origins
acsauk Nov 5, 2024
d8a96de
feature flag by separate templates
acsauk Nov 6, 2024
539f6cc
drop unused template
acsauk Nov 6, 2024
56afc5e
cover new enums and entities
acsauk Nov 8, 2024
c3cb566
drop sniffer hook, share mock data, cover feature enabled injection
acsauk Nov 8, 2024
44ee9a1
cover ParseLpaData
acsauk Nov 8, 2024
3f04a3d
cover serialisation
acsauk Nov 8, 2024
fdc3114
return HowAttorneysAct and WhenCanLpaBeUsed from API, fix templates, …
acsauk Nov 8, 2024
3118f8d
Merge branch 'main' into UML-3136-update-viewer-templates-combined-lpa
acsauk Nov 8, 2024
83bfbe2
format
acsauk Nov 8, 2024
1107064
add missing strict_types
acsauk Nov 8, 2024
1959621
more test fixes
acsauk Nov 8, 2024
4b168fb
test fixes
acsauk Nov 8, 2024
2680bd1
cover getters
acsauk Nov 8, 2024
0dfcb7f
revert api changes (to be extracted to new branch)
acsauk Nov 12, 2024
d86e4bf
more api revert
acsauk Nov 12, 2024
ef7393b
ensure LpaType is accessible, fix addresses, make mock combined data …
acsauk Nov 12, 2024
8255062
reinstate mocked values
acsauk Nov 12, 2024
6bc4f20
bump cov
acsauk Nov 12, 2024
dfdb72f
revert api
acsauk Nov 12, 2024
686a0f6
Merge branch 'main' into UML-3136-update-viewer-templates-combined-lpa
acsauk Nov 12, 2024
7b99d77
fix sniffs
acsauk Nov 12, 2024
9f1b6a6
fix sniffs
acsauk Nov 12, 2024
0e694bd
Merge branch 'main' into UML-3136-update-viewer-templates-combined-lpa
allenannom Nov 20, 2024
9da1d27
Remove Serialisation code and revert field name change.
cooperaj Nov 27, 2024
5778f39
Fix unit tests and remove tests we don't need
cooperaj Nov 27, 2024
65d2e99
Merge branch 'main' into UML-3136-update-viewer-templates-combined-lpa
cooperaj Nov 27, 2024
0f88d46
Remove JsonSerializable definitions
cooperaj Nov 27, 2024
bc1fd1e
Further test cleanup
cooperaj Nov 27, 2024
eaa64f1
Use correct 'uid' field name
cooperaj Nov 27, 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
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ services:
XDEBUG_MODE: develop,debug,coverage
SESSION_EXPIRES: 30 # session expiry length to support timeout message.
COOKIE_EXPIRES: 1440 # cookie expiry for complete logout - initial value to be 24 hours.
SUPPORT_DATASTORE_LPAS: "false"
depends_on:
- api-web

Expand Down
31 changes: 20 additions & 11 deletions service-front/app/src/Common/src/Entity/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Address
{
protected int $id;
protected ?int $id = null;
protected ?string $town = null;
protected ?string $county = null;
protected ?string $postcode = null;
Expand All @@ -16,93 +16,102 @@
protected ?string $addressLine2 = null;
protected ?string $addressLine3 = null;

public function getId(): int
public function getId(): ?int

Check warning on line 19 in service-front/app/src/Common/src/Entity/Address.php

View check run for this annotation

Codecov / codecov/patch

service-front/app/src/Common/src/Entity/Address.php#L19

Added line #L19 was not covered by tests
{
return $this->id;
}

public function setId(int $id): void
public function setId(int $id): self
{
$this->id = $id;
return $this;
}

public function getTown(): ?string
{
return $this->town;
}

public function setTown(string $town): void
public function setTown(string $town): self
{
$this->town = $town;
return $this;
}

public function getCounty(): ?string
{
return $this->county;
}

public function setCounty(string $county): void
public function setCounty(?string $county): self
{
$this->county = $county;
return $this;
}

public function getPostcode(): ?string
{
return $this->postcode;
}

public function setPostcode(string $postcode): void
public function setPostcode(string $postcode): self
{
$this->postcode = $postcode;
return $this;
}

public function getCountry(): ?string
{
return $this->country;
}

public function setCountry(string $country): void
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}

public function getType(): ?string
{
return $this->type;
}

public function setType(string $type): void
public function setType(string $type): self
{
$this->type = $type;
return $this;
}

public function getAddressLine1(): ?string
{
return $this->addressLine1;
}

public function setAddressLine1(string $addressLine1): void
public function setAddressLine1(string $addressLine1): self
{
$this->addressLine1 = $addressLine1;
return $this;
}

public function getAddressLine2(): ?string
{
return $this->addressLine2;
}

public function setAddressLine2(string $addressLine2): void
public function setAddressLine2(?string $addressLine2): self
{
$this->addressLine2 = $addressLine2;
return $this;
}

public function getAddressLine3(): ?string
{
return $this->addressLine3;
}

public function setAddressLine3(string $addressLine3): void
public function setAddressLine3(?string $addressLine3): self
{
$this->addressLine3 = $addressLine3;
return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
#[Attribute(Attribute::TARGET_PARAMETER)]
class CastToCaseSubtype implements PropertyCaster
{
public function cast(mixed $value, ObjectMapper $hydrator): string
public function cast(mixed $value, ObjectMapper $hydrator): ?string
{
return LpaType::fromShortName($value)->value;
if (is_null(LpaType::tryFrom($value))) {
return LpaType::fromShortName($value)->value;
}

return LpaType::from($value)->value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Common\Entity\Casters;

use Attribute;
use Common\Enum\HowAttorneysMakeDecisions;
use Common\Enum\WhenTheLpaCanBeUsed;
use EventSauce\ObjectHydrator\ObjectMapper;
use EventSauce\ObjectHydrator\PropertyCaster;

#[Attribute(Attribute::TARGET_PARAMETER)]
class CastToHowAttorneysMakeDecisions implements PropertyCaster
{
public function cast(mixed $value, ObjectMapper $hydrator): ?string
{
return HowAttorneysMakeDecisions::from($value)->value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Common\Enum\LifeSustainingTreatment;
use Attribute;
use Common\Enum\LpaType;
use EventSauce\ObjectHydrator\ObjectMapper;
use EventSauce\ObjectHydrator\PropertyCaster;

Expand All @@ -14,6 +15,10 @@ class CastToLifeSustainingTreatment implements PropertyCaster
{
public function cast(mixed $value, ObjectMapper $hydrator): mixed
{
if (is_null(LifeSustainingTreatment::tryFrom($value))) {
return LifeSustainingTreatment::fromShortName($value)->value;
}

return LifeSustainingTreatment::from($value)->value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Common\Entity\Casters;

use Common\Enum\HowAttorneysMakeDecisions;
use Attribute;
use Common\Enum\WhenTheLpaCanBeUsed;
use EventSauce\ObjectHydrator\ObjectMapper;
use EventSauce\ObjectHydrator\PropertyCaster;

Expand All @@ -14,6 +14,14 @@ class CastToWhenTheLpaCanBeUsed implements PropertyCaster
{
public function cast(mixed $value, ObjectMapper $hydrator): ?string
{
return HowAttorneysMakeDecisions::from($value)->value;
if (is_null(WhenTheLpaCanBeUsed::tryFrom($value))) {
$value = match ($value) {
'when registered' => WhenTheLpaCanBeUsed::WHEN_HAS_CAPACITY->value,
'loss of capacity' => WhenTheLpaCanBeUsed::WHEN_CAPACITY_LOST->value,
default => '',
};
}

return WhenTheLpaCanBeUsed::from($value)->value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Common\Entity\Casters;

use Attribute;
use EventSauce\ObjectHydrator\ObjectMapper;
use EventSauce\ObjectHydrator\PropertyCaster;

#[Attribute(Attribute::TARGET_PARAMETER)]
class ExtractPostcodeFromLpaStore implements PropertyCaster
{
public function cast(mixed $value, ObjectMapper $hydrator): ?string
{
if (is_array($value) && isset($value['postcode'])) {
return $value['postcode'];

Check warning on line 17 in service-front/app/src/Common/src/Entity/Casters/ExtractPostcodeFromLpaStore.php

View check run for this annotation

Codecov / codecov/patch

service-front/app/src/Common/src/Entity/Casters/ExtractPostcodeFromLpaStore.php#L17

Added line #L17 was not covered by tests
}

return null;
}
}
79 changes: 74 additions & 5 deletions service-front/app/src/Common/src/Entity/CombinedLpa.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Common\Enum\LpaType;
use Common\Service\Lpa\ServiceInterfaces\GroupLpasInterface;
use Common\Service\Lpa\ServiceInterfaces\SortLpasInterface;
use Common\Enum\WhenTheLpaCanBeUsed;
use DateTimeImmutable;
use JsonSerializable;

Expand All @@ -18,13 +19,16 @@
public readonly ?bool $applicationHasGuidance,
public readonly ?bool $applicationHasRestrictions,
public readonly ?string $applicationType,
public readonly ?HowAttorneysMakeDecisions $attorneyActDecisions,
/**
* @var Person[] $attorneys
*/
public readonly ?array $attorneys,
public readonly ?LpaType $caseSubtype,
public readonly ?string $channel,
public readonly ?DateTimeImmutable $dispatchDate,
public readonly ?Person $donor,
public readonly ?bool $hasSeveranceWarning,
public readonly ?HowAttorneysMakeDecisions $howAttorneysMakeDecisions,
public readonly ?DateTimeImmutable $invalidDate,
public readonly ?LifeSustainingTreatment $lifeSustainingTreatment,
public readonly ?DateTimeImmutable $lpaDonorSignatureDate,
Expand All @@ -33,24 +37,34 @@
public readonly ?DateTimeImmutable $receiptDate,
public readonly ?DateTimeImmutable $registrationDate,
public readonly ?DateTimeImmutable $rejectedDate,
/**
* @var Person[] $replacementAttorneys
*/
public readonly ?array $replacementAttorneys,
public readonly ?string $status,
public readonly ?DateTimeImmutable $statusDate,
/**
* @var SiriusLpaTrustCorporations[] $trustCorporations
*/
public readonly ?array $trustCorporations,
public readonly ?string $uId,
public readonly ?DateTimeImmutable $withdrawnDate,
public readonly ?WhenTheLpaCanBeUsed $whenTheLpaCanBeUsed,
) {
}

public function jsonSerialize(): mixed
{
$data = get_object_vars($this);

array_walk($data, function (&$value) {
if ($value instanceof DateTimeImmutable) {
$value = $value->format('Y-m-d H:i:s.uO');
array_walk(
$data,
function (&$value) {
if ($value instanceof DateTimeImmutable) {
$value = $value->format('Y-m-d H:i:s.uO');
}
}
});
);

return $data;
}
Expand Down Expand Up @@ -84,4 +98,59 @@
{
return $this->caseSubtype->value;
}

public function getStatus(): ?string
{
return $this->status;
}

public function getLifeSustainingTreatment(): string
{
return $this->lifeSustainingTreatment->value;
}

public function getHowAttorneysMakeDecisions(): HowAttorneysMakeDecisions
{
return $this->howAttorneysMakeDecisions;
}

public function getCaseAttorneySingular(): bool
{
return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::SINGULAR;
}

public function getCaseAttorneyJointly(): bool
{
return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::JOINTLY;
}

public function getCaseAttorneyJointlyAndSeverally(): bool
{
return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::JOINTLY_AND_SEVERALLY;
}

public function getCaseAttorneyJointlyAndJointlyAndSeverally(): bool
{
return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::JOINTLY_FOR_SOME_SEVERALLY_FOR_OTHERS;
}

public function getActiveAttorneys(): ?array
{
return $this->attorneys;
}

public function getTrustCorporations(): ?array
{
return $this->trustCorporations;
}

public function getWhenTheLpaCanBeUsed(): WhenTheLpaCanBeUsed
{
return $this->whenTheLpaCanBeUsed;
}

public function getLpaType(): LpaType

Check warning on line 152 in service-front/app/src/Common/src/Entity/CombinedLpa.php

View check run for this annotation

Codecov / codecov/patch

service-front/app/src/Common/src/Entity/CombinedLpa.php#L152

Added line #L152 was not covered by tests
{
return LpaType::from($this->getCaseSubtype());

Check warning on line 154 in service-front/app/src/Common/src/Entity/CombinedLpa.php

View check run for this annotation

Codecov / codecov/patch

service-front/app/src/Common/src/Entity/CombinedLpa.php#L154

Added line #L154 was not covered by tests
}
}
Loading
Loading