1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of datamolino client. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 cwd.at GmbH <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Cwd\Datamolino\Model; |
15
|
|
|
|
16
|
|
|
use Cwd\Datamolino\Model\Document\BankAccount; |
17
|
|
|
use Cwd\Datamolino\Model\Document\Customer; |
18
|
|
|
use Cwd\Datamolino\Model\Document\Data; |
19
|
|
|
use Cwd\Datamolino\Model\Document\Item; |
20
|
|
|
use Cwd\Datamolino\Model\Document\Summary; |
21
|
|
|
use Cwd\Datamolino\Model\Document\Supplier; |
22
|
|
|
use Cwd\Datamolino\Model\Document\TaxLine; |
23
|
|
|
|
24
|
|
|
class Document |
25
|
|
|
{ |
26
|
|
|
const TYPE_INVOICE = 0; |
27
|
|
|
const TYPE_CREDIT_NOTE = 1; |
28
|
|
|
const TYPE_PROFORMA_INVOICE = 2; |
29
|
|
|
const TYPE_RECEIPT = 3; |
30
|
|
|
|
31
|
|
|
const DOCTYPE_PURCHASE = 'PurchaseInvoice'; |
32
|
|
|
const DOCTYPE_SALES = 'SalesInvoice'; |
33
|
|
|
|
34
|
|
|
const STATES = [ |
35
|
|
|
'uploaded', |
36
|
|
|
'extracting', |
37
|
|
|
'templating', |
38
|
|
|
'extracted', |
39
|
|
|
'verifying', |
40
|
|
|
'verifying_individual', |
41
|
|
|
'extracting_items', |
42
|
|
|
'repairing', |
43
|
|
|
'ready', |
44
|
|
|
'not_ready', |
45
|
|
|
'parent', |
46
|
|
|
'trash', |
47
|
|
|
'file_duplicate', |
48
|
|
|
'data_duplicate', |
49
|
|
|
'exporting', |
50
|
|
|
'auto_exporting', |
51
|
|
|
'exported', |
52
|
|
|
'auto_exported', |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
/** @var int */ |
56
|
|
|
private $id; |
57
|
|
|
|
58
|
|
|
/** @var string */ |
59
|
|
|
private $type; |
60
|
|
|
|
61
|
|
|
/** @var \DateTime|null */ |
62
|
|
|
private $created_at; |
63
|
|
|
|
64
|
|
|
/** @var \DateTime|null */ |
65
|
|
|
private $last_modified_at; |
66
|
|
|
|
67
|
|
|
/** @var string */ |
68
|
|
|
private $state; |
69
|
|
|
|
70
|
|
|
/** @var string|null */ |
71
|
|
|
private $verificator_response; |
72
|
|
|
|
73
|
|
|
/** @var string|null */ |
74
|
|
|
private $preview; |
75
|
|
|
|
76
|
|
|
/** @var string|null */ |
77
|
|
|
private $original; |
78
|
|
|
|
79
|
|
|
/** @var string|null */ |
80
|
|
|
private $user_file_name; |
81
|
|
|
|
82
|
|
|
/** @var int|null */ |
83
|
|
|
private $invoice_type; |
84
|
|
|
|
85
|
|
|
/** @var int|null */ |
86
|
|
|
private $parent_document_id; |
87
|
|
|
|
88
|
|
|
/** @var Data */ |
89
|
|
|
private $data; |
90
|
|
|
|
91
|
|
|
/** @var BankAccount */ |
92
|
|
|
private $bank_account; |
93
|
|
|
|
94
|
|
|
/** @var Supplier */ |
95
|
|
|
private $supplier; |
96
|
|
|
|
97
|
|
|
/** @var Customer */ |
98
|
|
|
private $customer; |
99
|
|
|
|
100
|
|
|
/** @var Summary */ |
101
|
|
|
private $summary; |
102
|
|
|
|
103
|
|
|
/** @var TaxLine[] */ |
104
|
|
|
private $tax_lines = []; |
105
|
|
|
|
106
|
|
|
/** @var Item[] */ |
107
|
|
|
private $items = []; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return int |
111
|
|
|
*/ |
112
|
|
|
public function getId(): ?int |
113
|
|
|
{ |
114
|
|
|
return $this->id; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param int $id |
119
|
|
|
* |
120
|
|
|
* @return Document |
121
|
|
|
*/ |
122
|
|
|
public function setId(int $id): Document |
123
|
|
|
{ |
124
|
|
|
$this->id = $id; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getType(): string |
133
|
|
|
{ |
134
|
|
|
return $this->type; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param string $type |
139
|
|
|
* |
140
|
|
|
* @return Document |
141
|
|
|
*/ |
142
|
|
|
public function setType(string $type): Document |
143
|
|
|
{ |
144
|
|
|
$this->type = $type; |
145
|
|
|
|
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return \DateTime|null |
151
|
|
|
*/ |
152
|
|
|
public function getCreatedAt(): ?\DateTime |
153
|
|
|
{ |
154
|
|
|
return $this->created_at; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param \DateTime|null $created_at |
159
|
|
|
* |
160
|
|
|
* @return Document |
161
|
|
|
*/ |
162
|
|
|
public function setCreatedAt(?\DateTime $created_at): Document |
163
|
|
|
{ |
164
|
|
|
$this->created_at = $created_at; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return \DateTime|null |
171
|
|
|
*/ |
172
|
|
|
public function getLastModifiedAt(): ?\DateTime |
173
|
|
|
{ |
174
|
|
|
return $this->last_modified_at; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param \DateTime|null $last_modified_at |
179
|
|
|
* |
180
|
|
|
* @return Document |
181
|
|
|
*/ |
182
|
|
|
public function setLastModifiedAt(?\DateTime $last_modified_at): Document |
183
|
|
|
{ |
184
|
|
|
$this->last_modified_at = $last_modified_at; |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return string |
191
|
|
|
*/ |
192
|
|
|
public function getState(): string |
193
|
|
|
{ |
194
|
|
|
return $this->state; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @param string $state |
199
|
|
|
* |
200
|
|
|
* @return Document |
201
|
|
|
*/ |
202
|
|
|
public function setState(string $state): Document |
203
|
|
|
{ |
204
|
|
|
$this->state = $state; |
205
|
|
|
|
206
|
|
|
return $this; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @return null|string |
211
|
|
|
*/ |
212
|
|
|
public function getVerificatorResponse(): ?string |
213
|
|
|
{ |
214
|
|
|
return $this->verificator_response; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @param null|string $verificator_response |
219
|
|
|
* |
220
|
|
|
* @return Document |
221
|
|
|
*/ |
222
|
|
|
public function setVerificatorResponse(?string $verificator_response): Document |
223
|
|
|
{ |
224
|
|
|
$this->verificator_response = $verificator_response; |
225
|
|
|
|
226
|
|
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @return null|string |
231
|
|
|
*/ |
232
|
|
|
public function getPreview(): ?string |
233
|
|
|
{ |
234
|
|
|
return $this->preview; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @param null|string $preview |
239
|
|
|
* |
240
|
|
|
* @return Document |
241
|
|
|
*/ |
242
|
|
|
public function setPreview(?string $preview): Document |
243
|
|
|
{ |
244
|
|
|
$this->preview = $preview; |
245
|
|
|
|
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return null|string |
251
|
|
|
*/ |
252
|
|
|
public function getOriginal(): ?string |
253
|
|
|
{ |
254
|
|
|
return $this->original; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @param null|string $original |
259
|
|
|
* |
260
|
|
|
* @return Document |
261
|
|
|
*/ |
262
|
|
|
public function setOriginal(?string $original): Document |
263
|
|
|
{ |
264
|
|
|
$this->original = $original; |
265
|
|
|
|
266
|
|
|
return $this; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @return null|string |
271
|
|
|
*/ |
272
|
|
|
public function getUserFileName(): ?string |
273
|
|
|
{ |
274
|
|
|
return $this->user_file_name; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @param null|string $user_file_name |
279
|
|
|
* |
280
|
|
|
* @return Document |
281
|
|
|
*/ |
282
|
|
|
public function setUserFileName(?string $user_file_name): Document |
283
|
|
|
{ |
284
|
|
|
$this->user_file_name = $user_file_name; |
285
|
|
|
|
286
|
|
|
return $this; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @return null|int |
291
|
|
|
*/ |
292
|
|
|
public function getInvoiceType(): ?int |
293
|
|
|
{ |
294
|
|
|
return $this->invoice_type; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @param int|null $invoice_type |
299
|
|
|
* |
300
|
|
|
* @return Document |
301
|
|
|
*/ |
302
|
|
|
public function setInvoiceType(?int $invoice_type): Document |
303
|
|
|
{ |
304
|
|
|
$this->invoice_type = $invoice_type; |
305
|
|
|
|
306
|
|
|
return $this; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @return int|null |
311
|
|
|
*/ |
312
|
|
|
public function getParentDocumentId(): ?int |
313
|
|
|
{ |
314
|
|
|
return $this->parent_document_id; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @param int|null $parent_document_id |
319
|
|
|
* |
320
|
|
|
* @return Document |
321
|
|
|
*/ |
322
|
|
|
public function setParentDocumentId(?int $parent_document_id): Document |
323
|
|
|
{ |
324
|
|
|
$this->parent_document_id = $parent_document_id; |
325
|
|
|
|
326
|
|
|
return $this; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* @return Data |
331
|
|
|
*/ |
332
|
|
|
public function getData(): Data |
333
|
|
|
{ |
334
|
|
|
return $this->data; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* @param Data $data |
339
|
|
|
* |
340
|
|
|
* @return Document |
341
|
|
|
*/ |
342
|
|
|
public function setData(Data $data): Document |
343
|
|
|
{ |
344
|
|
|
$this->data = $data; |
345
|
|
|
|
346
|
|
|
return $this; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* @return BankAccount |
351
|
|
|
*/ |
352
|
|
|
public function getBankAccount(): BankAccount |
353
|
|
|
{ |
354
|
|
|
return $this->bank_account; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* @param BankAccount $bank_account |
359
|
|
|
* |
360
|
|
|
* @return Document |
361
|
|
|
*/ |
362
|
|
|
public function setBankAccount(BankAccount $bank_account): Document |
363
|
|
|
{ |
364
|
|
|
$this->bank_account = $bank_account; |
365
|
|
|
|
366
|
|
|
return $this; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* @return Supplier |
371
|
|
|
*/ |
372
|
|
|
public function getSupplier(): Supplier |
373
|
|
|
{ |
374
|
|
|
return $this->supplier; |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* @param Supplier $supplier |
379
|
|
|
* |
380
|
|
|
* @return Document |
381
|
|
|
*/ |
382
|
|
|
public function setSupplier(Supplier $supplier): Document |
383
|
|
|
{ |
384
|
|
|
$this->supplier = $supplier; |
385
|
|
|
|
386
|
|
|
return $this; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* @return Customer |
391
|
|
|
*/ |
392
|
|
|
public function getCustomer(): Customer |
393
|
|
|
{ |
394
|
|
|
return $this->customer; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* @param Customer $customer |
399
|
|
|
* |
400
|
|
|
* @return Document |
401
|
|
|
*/ |
402
|
|
|
public function setCustomer(Customer $customer): Document |
403
|
|
|
{ |
404
|
|
|
$this->customer = $customer; |
405
|
|
|
|
406
|
|
|
return $this; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* @return Summary |
411
|
|
|
*/ |
412
|
|
|
public function getSummary(): Summary |
413
|
|
|
{ |
414
|
|
|
return $this->summary; |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* @param Summary $summary |
419
|
|
|
* |
420
|
|
|
* @return Document |
421
|
|
|
*/ |
422
|
|
|
public function setSummary(Summary $summary): Document |
423
|
|
|
{ |
424
|
|
|
$this->summary = $summary; |
425
|
|
|
|
426
|
|
|
return $this; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* @return TaxLine[] |
431
|
|
|
*/ |
432
|
|
|
public function getTaxLines(): array |
433
|
|
|
{ |
434
|
|
|
return $this->tax_lines; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* @param TaxLine[] $tax_lines |
439
|
|
|
* |
440
|
|
|
* @return Document |
441
|
|
|
*/ |
442
|
|
|
public function setTaxLines(array $tax_lines): Document |
443
|
|
|
{ |
444
|
|
|
$this->tax_lines = $tax_lines; |
445
|
|
|
|
446
|
|
|
return $this; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* @return Item[] |
451
|
|
|
*/ |
452
|
|
|
public function getItems(): array |
453
|
|
|
{ |
454
|
|
|
return $this->items; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* @param Item[] $items |
459
|
|
|
* |
460
|
|
|
* @return Document |
461
|
|
|
*/ |
462
|
|
|
public function setItems(array $items): Document |
463
|
|
|
{ |
464
|
|
|
$this->items = $items; |
465
|
|
|
|
466
|
|
|
return $this; |
467
|
|
|
} |
468
|
|
|
} |
469
|
|
|
|