1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Fenerum\API; |
6
|
|
|
|
7
|
|
|
class DraftInvoiceLines extends Base |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @return array|null |
11
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
12
|
|
|
*/ |
13
|
|
|
public function listDraftInvoiceLines(): ?array |
14
|
|
|
{ |
15
|
|
|
return $this->client->get('draftinvoicelines/'); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param string $uuid |
20
|
|
|
* @return array|null |
21
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
22
|
|
|
*/ |
23
|
|
|
public function getDraftInvoiceLine(string $uuid): ?array |
24
|
|
|
{ |
25
|
|
|
return $this->client->get('draftinvoicelines/'.$uuid.'/'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param array $data |
30
|
|
|
* @return array|null |
31
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
32
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumValidationException |
33
|
|
|
*/ |
34
|
|
|
public function createDraftInvoiceLine(array $data): ?array |
35
|
|
|
{ |
36
|
|
|
$validated = $this->validate($data, [ |
37
|
|
|
'account' => 'required|string', |
38
|
|
|
'description' => 'required|string', |
39
|
|
|
'vat_type' => 'required|string', |
40
|
|
|
'collect_vat' => 'boolean', |
41
|
|
|
'date_from' => 'date', |
42
|
|
|
'date_to' => 'date', |
43
|
|
|
'price' => 'string', |
44
|
|
|
'quantity' => 'string', |
45
|
|
|
'currency' => 'string', |
46
|
|
|
'include_in_next_renewal_invoice' => 'boolean', |
47
|
|
|
'revenue_group' => 'string', |
48
|
|
|
]); |
49
|
|
|
|
50
|
|
|
return $this->client->post('draftinvoicelines/', $validated); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param array $data |
55
|
|
|
* @param string $uuid |
56
|
|
|
* @return array|null |
57
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
58
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumValidationException |
59
|
|
|
*/ |
60
|
|
|
public function updateDraftInvoiceLine(array $data, string $uuid): ?array |
61
|
|
|
{ |
62
|
|
|
$validated = $this->validate($data, [ |
63
|
|
|
'account' => 'required|string', |
64
|
|
|
'description' => 'required|string', |
65
|
|
|
'vat_type' => 'required|string', |
66
|
|
|
'collect_vat' => 'boolean', |
67
|
|
|
'date_from' => 'date', |
68
|
|
|
'date_to' => 'date', |
69
|
|
|
'price' => 'string', |
70
|
|
|
'quantity' => 'string', |
71
|
|
|
'currency' => 'string', |
72
|
|
|
'include_in_next_renewal_invoice' => 'boolean', |
73
|
|
|
'revenue_group' => 'string', |
74
|
|
|
]); |
75
|
|
|
|
76
|
|
|
return $this->client->put('draftinvoicelines/'.$uuid.'/', $validated); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string $uuid |
81
|
|
|
* @return array|null |
82
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
83
|
|
|
*/ |
84
|
|
|
public function deleteDraftInvoiceLine(string $uuid): ?array |
85
|
|
|
{ |
86
|
|
|
return $this->client->delete('draftinvoicelines/'.$uuid.'/'); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|