Skip to content

Commit 2d7429d

Browse files
committed
Update PaymentMandate add PayerFinancialAccount property and remove PayeeFinancialAcount property
1 parent af6cec6 commit 2d7429d

2 files changed

Lines changed: 63 additions & 39 deletions

File tree

src/PayerFinancialAccount.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace NumNum\UBL;
4+
5+
use Sabre\Xml\Reader;
6+
use Sabre\Xml\Writer;
7+
use Sabre\Xml\XmlDeserializable;
8+
use Sabre\Xml\XmlSerializable;
9+
10+
use function Sabre\Xml\Deserializer\keyValue;
11+
12+
class PayerFinancialAccount implements XmlSerializable, XmlDeserializable
13+
{
14+
public $xmlTagName = 'PayerFinancialAccount';
15+
private $id;
16+
17+
public static function xmlDeserialize(Reader $reader)
18+
{
19+
$keyValues = keyValue($reader);
20+
21+
return (new static())
22+
->setId($keyValues[Schema::CBC . 'ID'] ?? null);
23+
}
24+
25+
public function xmlSerialize(Writer $writer): void
26+
{
27+
$writer->write([
28+
Schema::CBC . 'ID' => $this->id,
29+
]);
30+
}
31+
32+
public function getId(): string
33+
{
34+
return $this->id;
35+
}
36+
37+
public function setId(string $id): self
38+
{
39+
$this->id = $id;
40+
41+
return $this;
42+
}
43+
}

src/PaymentMandate.php

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,52 @@
1111

1212
class PaymentMandate implements XmlSerializable, XmlDeserializable
1313
{
14-
public $xmlTagName = 'PaymentMandate';
15-
1614
private $id;
17-
private $payeeFinancialAccount;
15+
private $payerFinancialAccount;
1816

19-
/**
20-
* @return string
21-
*/
2217
public function getId(): ?string
2318
{
2419
return $this->id;
2520
}
2621

27-
/**
28-
* @param string $id
29-
* @return static
30-
*/
31-
public function setId(?string $id)
22+
public function setId(?string $id): self
3223
{
3324
$this->id = $id;
3425
return $this;
3526
}
3627

37-
/**
38-
* @return PayeeFinancialAccount
39-
*/
40-
public function getPayeeFinancialAccount(): ?PayeeFinancialAccount
28+
public function xmlSerialize(Writer $writer): void
4129
{
42-
return $this->payeeFinancialAccount;
30+
if ($this->id !== null) {
31+
$writer->write([
32+
Schema::CBC . 'ID' => $this->id,
33+
]);
34+
}
35+
36+
if ($this->getPayerFinancialAccount() !== null) {
37+
$writer->write([
38+
Schema::CAC . $this->payerFinancialAccount->xmlTagName => $this->getPayerFinancialAccount(),
39+
]);
40+
}
4341
}
4442

45-
/**
46-
* @param PayeeFinancialAccount $payeeFinancialAccount
47-
* @return static
48-
*/
49-
public function setPayeeFinancialAccount(?PayeeFinancialAccount $payeeFinancialAccount)
43+
public function getPayerFinancialAccount(): ?PayerFinancialAccount
5044
{
51-
$this->payeeFinancialAccount = $payeeFinancialAccount;
52-
return $this;
45+
return $this->payerFinancialAccount;
5346
}
5447

55-
public function xmlSerialize(Writer $writer): void
48+
public function setPayerFinancialAccount(?PayerFinancialAccount $payerFinancialAccount): self
5649
{
57-
$writer->write([
58-
Schema::CBC . 'ID' => $this->id
59-
]);
60-
61-
if ($this->getPayeeFinancialAccount() !== null) {
62-
$writer->write([
63-
Schema::CAC . 'PayeeFinancialAccount' => $this->getPayeeFinancialAccount()
64-
]);
65-
}
50+
$this->payerFinancialAccount = $payerFinancialAccount;
51+
return $this;
6652
}
6753

68-
/**
69-
* The xmlDeserialize method is called during xml reading.
70-
* @param Reader $reader
71-
* @return static
72-
*/
7354
public static function xmlDeserialize(Reader $reader)
7455
{
7556
$keyValues = keyValue($reader);
7657

7758
return (new static())
7859
->setId($keyValues[Schema::CBC . 'ID'] ?? null)
79-
->setPayeeFinancialAccount($keyValues[Schema::CAC . 'PayeeFinancialAccount'] ?? null);
60+
->setPayerFinancialAccount($keyValues[Schema::CAC . 'PayerFinancialAccount'] ?? null);
8061
}
8162
}

0 commit comments

Comments
 (0)