Skip to content

Commit

Permalink
Merge pull request #26 from boekuwzending/fix/vat-eori-number
Browse files Browse the repository at this point in the history
Eori nummer en vatnumber zijn toegevoegd
  • Loading branch information
darylholling authored Sep 22, 2022
2 parents ff81334 + 9511f19 commit 2521f85
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Resource/DispatchInstruction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
class DispatchInstruction extends Instruction
{
/**
* @var DateTimeInterface
* @var DateTimeInterface|null
*/
protected $date;

/**
* @return DateTimeInterface
* @return ?DateTimeInterface
*/
public function getDate(): DateTimeInterface
public function getDate(): ?DateTimeInterface
{
return $this->date;
}

/**
* @param DateTimeInterface $date
* @param DateTimeInterface|null $date
*/
public function setDate(DateTimeInterface $date): void
public function setDate(?DateTimeInterface $date): void
{
$this->date = $date;
}
Expand Down
30 changes: 30 additions & 0 deletions src/Resource/Instruction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ abstract class Instruction
*/
protected $timeWindowEnd;

/**
* @var string|null
*/
protected $vatNumber;

/**
* @var string|null
*/
protected $eoriNumber;

/**
* @return string|null
*/
Expand Down Expand Up @@ -95,4 +105,24 @@ public function setTimeWindowEnd(?DateTimeInterface $timeWindowEnd): void
{
$this->timeWindowEnd = $timeWindowEnd;
}

public function getVatNumber(): ?string
{
return $this->vatNumber;
}

public function setVatNumber(?string $vatNumber): void
{
$this->vatNumber = $vatNumber;
}

public function getEoriNumber(): ?string
{
return $this->eoriNumber;
}

public function setEoriNumber(?string $eoriNumber): void
{
$this->eoriNumber = $eoriNumber;
}
}
4 changes: 4 additions & 0 deletions src/Serializer/InstructionSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function serialize($data): array
'begin' => $data->getTimeWindowBegin(),
'end' => $data->getTimeWindowEnd(),
],
'vatNumber' => $data->getVatNumber(),
'eoriNumber' => $data->getEoriNumber(),
];

if (null !== $data->getDate()) {
Expand All @@ -49,6 +51,8 @@ public function deserialize(array $data, string $dataType)
$object->setReference($data['reference']);
$object->setTimeWindowBegin($data['timeWindow']['begin']);
$object->setTimeWindowEnd($data['timeWindow']['end']);
$object->setVatNumber($data['vatNumber']);
$object->setEoriNumber($data['eoriNumber']);

if (!empty($data['date'])) {
$object->setDate((new DateTime($data['date'])));
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/ShipmentSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function deserialize(array $data, string $dataType)
$shipment->setInvoiceReference($data['invoiceReference']);
$shipment->setSequence($data['sequence']);
$shipment->setStatus($data['status']);
$shipment->setRelated($data['related']);
$shipment->setRelated($data['related'] ?? null);

$items = [];
foreach ($data['items'] as $item) {
Expand Down
6 changes: 5 additions & 1 deletion tests/Serializer/ShipmentSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public function testShipment()
$addressTo->setCountryCode($this->getFaker()->countryCode);
$shipment->setShipToAddress($addressTo);

// Set Dispactch
// Set Dispatch
$dispatch = new DispatchInstruction();
$dispatch->setDate($this->getFaker()->dateTime());
$dispatch->setEoriNumber($this->getFaker()->randomNumber(9));
$dispatch->setVatNumber($this->getFaker()->randomNumber(9));
$shipment->setDispatch($dispatch);

$serializedShipment = (new ShipmentSerializer())->serialize($shipment);
Expand All @@ -57,6 +59,8 @@ public function testShipment()

self::assertArrayHasKey('dispatch', $serializedShipment);
self::assertArrayHasKey('date', $serializedShipment['dispatch']);
self::assertArrayHasKey('eoriNumber', $serializedShipment['dispatch']);
self::assertArrayHasKey('vatNumber', $serializedShipment['dispatch']);

self::assertArrayHasKey('shipTo', $serializedShipment);
self::assertArrayHasKey('contact', $serializedShipment['shipTo']);
Expand Down

0 comments on commit 2521f85

Please sign in to comment.