Skip to content

Commit

Permalink
Persist additional client details ingested from the LayDeputyReport csv
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgoodby committed Dec 11, 2024
1 parent d0ad3ab commit c70c44b
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 6 deletions.
11 changes: 10 additions & 1 deletion api/app/src/DataFixtures/LayUserFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,14 @@ private function addUser(array $data, ObjectManager $manager, int $iteration)

$preRegistrationData = [
'Case' => substr_replace($data['caseNumber'], $iteration, -$offset),
'ClientSurname' => 'Client '.$iteration,
'ClientFirstname' => 'Client 1',
'ClientSurname' => 'Clientsurname',
'ClientAddress1' => 'Client Road',
'ClientAddress2' => null,
'ClientAddress3' => null,
'ClientAddress4' => null,
'ClientAddress5' => null,
'ClientPostcode' => 'CL1 3NT',
'DeputyUid' => $deputyUid,
'DeputyFirstname' => $data['id'].'-User-'.$iteration,
'DeputySurname' => 'User',
Expand All @@ -248,6 +255,7 @@ private function addUser(array $data, ObjectManager $manager, int $iteration)
if ($data['multi-client']) {
$preRegistration2 = clone $preRegistration;
$preRegistration2->setCaseNumber(substr_replace($data['caseNumber'], $iteration, $offset, $offset));
$preRegistration2->setClientFirstname('Client 2');
$manager->persist($preRegistration2);
}

Expand All @@ -272,6 +280,7 @@ private function addUser(array $data, ObjectManager $manager, int $iteration)
$client2 = clone $client;
$client2->setCaseNumber(substr_replace($data['caseNumber'], $iteration, $offset, $offset));
$client2->setLastname('Client '.$iteration.'-'.$iteration);
$client2->setFirstname('Client '.$iteration.'-'.$iteration);
$client2->setEmail(strtolower($data['id']).'-client-'.$iteration.'-'.$iteration.'@example.com');

$manager->persist($client2);
Expand Down
149 changes: 147 additions & 2 deletions api/app/src/Entity/PreRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ class PreRegistration
public function __construct(array $row)
{
$this->caseNumber = $row['Case'] ?? '';
$this->clientFirstname = $row['ClientFirstname'] ?? '';
$this->clientLastname = $row['ClientSurname'] ?? '';
$this->deputyUid = $row['DeputyUid'] ?? '';
$this->clientAddress1 = $row['ClientAddress1'] ?? null;
$this->clientAddress2 = $row['ClientAddress2'] ?? null;
$this->clientAddress3 = $row['ClientAddress3'] ?? null;
$this->clientAddress4 = $row['ClientAddress4'] ?? null;
$this->clientAddress5 = $row['ClientAddress5'] ?? null;
$this->clientPostcode = $row['ClientPostcode'] ?? null;
$this->deputyUid = $row['DeputyUid'] ?? '';
$this->deputyFirstname = $row['DeputyFirstname'] ?? '';
$this->deputySurname = $row['DeputySurname'] ?? '';
$this->deputyAddress1 = $row['DeputyAddress1'] ?? null;
Expand Down Expand Up @@ -73,6 +80,15 @@ public function __construct(array $row)
*/
private string $caseNumber;

/**
* @JMS\Type("string")
*
* @Assert\NotBlank()
*
* @ORM\Column(name="client_firstname", type="string", length=50, nullable=false)
*/
private string $clientFirstname;

/**
* @JMS\Type("string")
*
Expand All @@ -82,6 +98,51 @@ public function __construct(array $row)
*/
private string $clientLastname;

/**
* @JMS\Type("string")
*
* @ORM\Column(name="client_address_1", type="string", nullable=true)
*/
private ?string $clientAddress1;

/**
* @JMS\Type("string")
*
* @ORM\Column(name="client_address_2", type="string", nullable=true)
*/
private ?string $clientAddress2;

/**
* @JMS\Type("string")
*
* @ORM\Column(name="client_address_3", type="string", nullable=true)
*/
private ?string $clientAddress3;

/**
* @JMS\Type("string")
*
* @ORM\Column(name="client_address_4", type="string", nullable=true)
*/
private ?string $clientAddress4;

/**
* @JMS\Type("string")
*
* @ORM\Column(name="client_address_5", type="string", nullable=true)
*/
private ?string $clientAddress5;

/**
* @JMS\Type("string")
*
* @ORM\Column(name="client_postcode", type="string", length=10, nullable=true)
*
* @Assert\Length(min=2, max=10, minMessage="postcode too short", maxMessage="postcode too long" )
*
*/
private ?string $clientPostcode;

/**
* @JMS\Type("string")
*
Expand Down Expand Up @@ -231,6 +292,90 @@ public function getClientLastname()
return $this->clientLastname;
}

public function getClientFirstname(): string
{
return $this->clientFirstname;
}

public function setClientFirstname(string $clientFirstname): self
{
$this->clientFirstname = $clientFirstname;

return $this;
}

public function getClientPostcode(): ?string
{
return $this->clientPostcode;
}

public function setClientPostcode(?string $clientPostcode): self
{
$this->clientPostcode = $clientPostcode;

return $this;
}

public function getClientAddress1(): ?string
{
return $this->clientAddress2;
}

public function setClientAddress1(?string $clientAddress1): self
{
$this->clientAddress2 = $clientAddress1;

return $this;
}

public function getClientAddress2(): ?string
{
return $this->clientAddress2;
}

public function setClientAddress2(?string $clientAddress2): self
{
$this->clientAddress2 = $clientAddress2;

return $this;
}

public function getClientAddress3(): ?string
{
return $this->clientAddress3;
}

public function setClientAddress3(?string $clientAddress3): self
{
$this->clientAddress3 = $clientAddress3;

return $this;
}

public function getClientAddress4(): ?string
{
return $this->clientAddress4;
}

public function setClientAddress4(?string $clientAddress4): self
{
$this->clientAddress4 = $clientAddress4;

return $this;
}

public function getClientAddress5(): ?string
{
return $this->clientAddress5;
}

public function setClientAddress5(?string $clientAddress5): self
{
$this->clientAddress5 = $clientAddress5;

return $this;
}

public function getDeputyUid()
{
return $this->deputyUid;
Expand Down Expand Up @@ -268,7 +413,7 @@ public function getOrderDate(): ?\DateTime
return $this->orderDate;
}

public function setOrderDate(\DateTime $orderDate)
public function setOrderDate(\DateTime $orderDate): self
{
$this->orderDate = $orderDate;

Expand Down
10 changes: 7 additions & 3 deletions api/app/src/FixtureFactory/PreRegistrationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public function __construct(private PreRegistrationDTOFactory $preRegistrationFa
{
}

/**
* @return Client
*/
public function create(array $data): PreRegistration
{
$caseNumber = str_pad((string) rand(1, 99999999), 8, '0', STR_PAD_LEFT);
Expand All @@ -26,8 +23,15 @@ public function create(array $data): PreRegistration

$dto = (new LayDeputyshipDto())
->setCaseNumber($data['caseNumber'] ?? $caseNumber)
->setClientFirstname($data['clientFirstName'] ?? 'John')
->setClientSurname($data['clientLastName'] ?? 'Smith')
->setDeputyUid($deputyUid)
->setClientAddress1($data['clientAddress1'] ?? 'Client Street')
->setClientAddress2($data['clientAddress2'] ?? 'Clientville')
->setClientAddress3($data['clientAddress3'] ?? 'ClientTon')
->setClientAddress4($data['clientAddress4'] ?? null)
->setClientAddress5($data['clientAddress5'] ?? null)
->setClientPostcode($data['clientPostCode'] ?? 'DY8')
->setDeputyAddress1($data['deputyAddress1'] ?? 'Victoria Park')
->setDeputyAddress2($data['deputyAddress2'] ?? 'Fakeville')
->setDeputyAddress3($data['deputyAddress3'] ?? 'Pretendham')
Expand Down
43 changes: 43 additions & 0 deletions api/app/src/Migrations/Version285.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version285 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds columns to store the new client data from the daily import';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE pre_registration ADD client_firstname VARCHAR(50) NOT NULL');
$this->addSql('ALTER TABLE pre_registration ADD client_address_1 VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE pre_registration ADD client_address_2 VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE pre_registration ADD client_address_3 VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE pre_registration ADD client_address_4 VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE pre_registration ADD client_address_5 VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE pre_registration ADD client_postcode VARCHAR(255) DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE pre_registration DROP client_firstname');
$this->addSql('ALTER TABLE pre_registration DROP client_address_1');
$this->addSql('ALTER TABLE pre_registration DROP client_address_2');
$this->addSql('ALTER TABLE pre_registration DROP client_address_3');
$this->addSql('ALTER TABLE pre_registration DROP client_address_4');
$this->addSql('ALTER TABLE pre_registration DROP client_address_5');
$this->addSql('ALTER TABLE pre_registration DROP client_postcode');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SiriusToLayDeputyshipDtoAssembler implements LayDeputyshipDtoAssemblerInte
{
private array $requiredData = [
'Case',
'ClientFirstname',
'ClientSurname',
'DeputyUid',
'DeputyFirstname',
Expand Down Expand Up @@ -46,7 +47,14 @@ private function buildDto(array $data): LayDeputyshipDto
return
(new LayDeputyshipDto())
->setCaseNumber($data['Case'])
->setClientFirstname($data['ClientFirstname'])
->setClientSurname($data['ClientSurname'])
->setClientAddress1($data['ClientAddress1'] ?: null)
->setClientAddress2($data['ClientAddress2'] ?: null)
->setClientAddress3($data['ClientAddress3'] ?: null)
->setClientAddress4($data['ClientAddress4'] ?: null)
->setClientAddress5($data['ClientAddress5'] ?: null)
->setClientPostcode($data['ClientPostcode'] ?: null)
->setDeputyUid($data['DeputyUid'])
->setDeputyFirstname($data['DeputyFirstname'])
->setDeputySurname($data['DeputySurname'])
Expand Down
Loading

0 comments on commit c70c44b

Please sign in to comment.