-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathInvoice.php
205 lines (178 loc) · 5.47 KB
/
Invoice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php declare(strict_types=1);
namespace MpApiClient\Financial\Entity\Invoice;
use DateTimeInterface;
use Exception;
use JsonSerializable;
use MpApiClient\Common\Util\InputDataUtil;
use MpApiClient\Common\Util\JsonSerializeEntityTrait;
use MpApiClient\Financial\Entity\Common\Customer;
final class Invoice implements JsonSerializable
{
use JsonSerializeEntityTrait;
private int $invoiceNumber;
private string $partner;
private ?DateTimeInterface $createdAt;
private ?DateTimeInterface $deliveryAt;
private ?DateTimeInterface $dueDate;
private ?string $originDocumentId;
private string $currency;
private Supplier $supplier;
private Customer $customer;
private ItemIterator $items;
private string $filePath;
private float $total;
private TaxRecap $taxRecap;
private string $note;
private string $purchNoC;
private string $invoiceType;
private string $invoiceIndicator;
private string $documentType;
private string $invoiceTypeTag;
private function __construct(
int $invoiceNumber,
string $partner,
?DateTimeInterface $createdAt,
?DateTimeInterface $deliveryAt,
?DateTimeInterface $dueDate,
?string $originDocumentId,
string $currency,
Supplier $supplier,
Customer $customer,
ItemIterator $items,
string $filePath,
float $total,
TaxRecap $taxRecap,
string $note,
string $purchNoC,
string $invoiceType,
string $invoiceIndicator,
string $documentType,
string $invoiceTypeTag
) {
$this->invoiceNumber = $invoiceNumber;
$this->partner = $partner;
$this->createdAt = $createdAt;
$this->deliveryAt = $deliveryAt;
$this->dueDate = $dueDate;
$this->originDocumentId = $originDocumentId;
$this->currency = $currency;
$this->supplier = $supplier;
$this->customer = $customer;
$this->items = $items;
$this->filePath = $filePath;
$this->total = $total;
$this->taxRecap = $taxRecap;
$this->note = $note;
$this->purchNoC = $purchNoC;
$this->invoiceType = $invoiceType;
$this->invoiceIndicator = $invoiceIndicator;
$this->documentType = $documentType;
$this->invoiceTypeTag = $invoiceTypeTag;
}
/**
* @param array<string, mixed> $data
*
* @throws Exception
* @internal
*/
public static function createFromApi(array $data): self
{
return new self(
(int) $data['invoiceNumber'],
(string) $data['partner'],
InputDataUtil::getNullableDate($data, 'createdAt'),
InputDataUtil::getNullableDate($data, 'deliveryAt'),
InputDataUtil::getNullableDate($data, 'dueDate'),
InputDataUtil::getNullableString($data, 'originDocumentId'),
(string) $data['currency'],
Supplier::createFromApi($data['supplier']),
Customer::createFromApi($data['customer']),
ItemIterator::createFromApi($data['items']),
(string) $data['filePath'],
(float) $data['total'],
TaxRecap::createFromApi($data['taxRecap']),
(string) $data['note'],
(string) $data['purchNoC'],
(string) $data['invoiceType'],
(string) $data['invoiceIndicator'],
(string) $data['documentType'],
(string) $data['invoiceTypeTag'],
);
}
public function getInvoiceNumber(): int
{
return $this->invoiceNumber;
}
public function getPartner(): string
{
return $this->partner;
}
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function getDeliveryAt(): ?DateTimeInterface
{
return $this->deliveryAt;
}
public function getDueDate(): ?DateTimeInterface
{
return $this->dueDate;
}
public function getOriginDocumentId(): ?string
{
return $this->originDocumentId;
}
public function getCurrency(): string
{
return $this->currency;
}
public function getSupplier(): Supplier
{
return $this->supplier;
}
public function getCustomer(): Customer
{
return $this->customer;
}
public function getItems(): ItemIterator
{
return $this->items;
}
public function getFilePath(): string
{
return $this->filePath;
}
public function getTotal(): float
{
return $this->total;
}
public function getTaxRecap(): TaxRecap
{
return $this->taxRecap;
}
public function getNote(): string
{
return $this->note;
}
public function getPurchNoC(): string
{
return $this->purchNoC;
}
public function getInvoiceType(): string
{
return $this->invoiceType;
}
public function getInvoiceIndicator(): string
{
return $this->invoiceIndicator;
}
public function getDocumentType(): string
{
return $this->documentType;
}
public function getInvoiceTypeTag(): string
{
return $this->invoiceTypeTag;
}
}