1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* FlexiPeeHP - Objekt vydané faktury. |
4
|
|
|
* |
5
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
6
|
|
|
* @copyright (C) 2015-2017 Spoje.Net |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace FlexiPeeHP; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Faktura vydaná |
13
|
|
|
* |
14
|
|
|
* @link https://demo.flexibee.eu/c/demo/faktura-vydana/properties položky evidence |
15
|
|
|
*/ |
16
|
|
|
class FakturaVydana extends FlexiBeeRW |
17
|
|
|
{ |
18
|
|
|
use Stitky; |
19
|
|
|
use Firma; |
20
|
|
|
/** |
21
|
|
|
* Evidence užitá objektem. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public $evidence = 'faktura-vydana'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Provede spárování platby s dokladem |
29
|
|
|
* |
30
|
|
|
* @link https://demo.flexibee.eu/devdoc/parovani-plateb Párování plateb |
31
|
|
|
* |
32
|
|
|
* @param $doklad Banka|PokladniPohyb|InterniDoklad S jakým dokladem spárovat ? |
|
|
|
|
33
|
|
|
* @param $zbytek string ne|zauctovat|ignorovat|castecnaUhrada|castecnaUhradaNeboZauctovat|castecnaUhradaNeboIgnorovat |
34
|
|
|
* |
35
|
|
|
* @return boolean success |
36
|
|
|
*/ |
37
|
|
|
public function sparujPlatbu($doklad, $zbytek = 'ignorovat') |
38
|
|
|
{ |
39
|
|
|
$sparovani = ['uhrazovanaFak' => $this]; |
40
|
|
|
$sparovani['uhrazovanaFak@type'] = $this->evidence; |
41
|
|
|
$sparovani['zbytek'] = $zbytek; |
42
|
|
|
$doklad->insertToFlexiBee(['id' => $doklad, 'sparovani' => $sparovani]); |
43
|
|
|
return $doklad->lastResponseCode == 201; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Hotovostní platba faktury. |
48
|
|
|
* |
49
|
|
|
* @link https://demo.flexibee.eu/devdoc/hotovostni-uhrada/ Hotovostní úhrada |
50
|
|
|
* @link https://demo.flexibee.eu/c/demo/pokladna Pokladny |
51
|
|
|
* @link https://demo.flexibee.eu/c/demo/typ-pokladni-pohyb Typy dokladů |
52
|
|
|
* @param float $value částka k úhradě |
53
|
|
|
* @param array $uhrada pole nepoviných vlastností úhrady s těmito možnými položkami: |
54
|
|
|
* string|Pokladna 'pokladna' identifikátor pokladny |
55
|
|
|
* string 'typDokl' kod typu pokladniho dokladu |
56
|
|
|
* boolean 'kurzKDatuUhrady' |
57
|
|
|
* string 'uhrazujiciDokl' Pokud uvedeno není, vždy se vytvoří nový |
58
|
|
|
* pokladní doklad. |
59
|
|
|
* string 'rada' dokladová řada pro vytvářený pokladní doklad. |
60
|
|
|
* Např.:code:POKLADNA+ |
61
|
|
|
* string 'datumUhrady' sql formát. Výchozí: dnes |
62
|
1 |
|
* |
63
|
|
|
* @return boolean výsledek pokusu o provedení úhrady |
64
|
1 |
|
*/ |
65
|
1 |
|
public function hotovostniUhrada($value, $uhrada = []) |
66
|
1 |
|
{ |
67
|
1 |
|
if (!isset($uhrada['pokladna'])) { |
68
|
1 |
|
$uhrada['pokladna'] = 'code:POKLADNA KČ'; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if (!isset($uhrada['typDokl'])) { |
72
|
|
|
$uhrada['typDokl'] = 'code:STANDARD'; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
if (!isset($uhrada['kurzKDatuUhrady'])) { |
76
|
|
|
$uhrada['kurzKDatuUhrady'] = false; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
if (!isset($uhrada['datumUhrady'])) { |
80
|
|
|
$uhrada['datumUhrady'] = date('Y-m-d'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
$uhrada['castka'] = $value; |
84
|
|
|
|
85
|
|
|
$this->setDataValue('hotovostni-uhrada', $uhrada); |
86
|
|
|
$this->insertToFlexiBee(); |
87
|
|
|
return $this->lastResponseCode == 201; |
88
|
|
|
} |
89
|
1 |
|
|
90
|
|
|
/** |
91
|
1 |
|
* Odpočet zálohy (vystavení daňového dokladu k platbě) |
92
|
1 |
|
* |
93
|
1 |
|
* @link https://demo.flexibee.eu/devdoc/odpocet-zaloh Odpočet záloh a ZDD |
94
|
|
|
* @param FakturaVydana $invoice zálohová faktura |
95
|
1 |
|
* @param array $odpocet Vlastnosti odpočtu |
96
|
1 |
|
* |
97
|
1 |
|
* @return boolean success |
98
|
|
|
*/ |
99
|
1 |
|
public function odpocetZalohy($invoice, $odpocet = []) |
100
|
1 |
|
{ |
101
|
1 |
|
if (!isset($odpocet['castkaMen'])) { |
102
|
|
|
$odpocet['castkaMen'] = $invoice->getDataValue('sumCelkem'); |
103
|
1 |
|
} |
104
|
1 |
|
$odpocet['doklad'] = $invoice; |
105
|
1 |
|
|
106
|
|
|
$this->setDataValue('odpocty-zaloh', ['odpocet' => $odpocet]); |
107
|
1 |
|
$this->insertToFlexiBee(); |
108
|
|
|
return $this->lastResponseCode == 201; |
109
|
1 |
|
} |
110
|
1 |
|
|
111
|
|
|
/** |
112
|
|
|
* Odpočet ZDD |
113
|
|
|
* |
114
|
|
|
* @link https://demo.flexibee.eu/devdoc/odpocet-zaloh Odpočet záloh a ZDD |
115
|
|
|
* @param FakturaVydana $invoice zálohová faktura |
116
|
|
|
* @param array $odpocet Vlastnosti odpočtu |
117
|
|
|
* |
118
|
|
|
* @return boolean success |
119
|
|
|
*/ |
120
|
|
|
public function odpocetZDD($invoice, $odpocet = []) |
121
|
|
|
{ |
122
|
|
|
if (!isset($odpocet['castkaZaklMen'])) { |
123
|
|
|
$odpocet['castkaZaklMen'] = $invoice->getDataValue('sumZklZakl'); |
124
|
|
|
} |
125
|
|
|
if (!isset($odpocet['castkaSnizMen'])) { |
126
|
|
|
$odpocet['castkaSnizMen'] = $invoice->getDataValue('sumZklSniz'); |
127
|
|
|
} |
128
|
|
|
if (!isset($odpocet['castkaSniz2Men'])) { |
129
|
|
|
$odpocet['castkaSniz2Men'] = $invoice->getDataValue('sumZklSniz2'); |
130
|
|
|
} |
131
|
|
|
if (!isset($odpocet['castkaOsvMen'])) { |
132
|
|
|
$odpocet['castkaOsvMen'] = $invoice->getDataValue('sumOsv'); |
133
|
|
|
} |
134
|
|
|
if (!isset($odpocet['id'])) { |
135
|
|
|
$odpocet['id'] = 'ext:odpocet1'; |
136
|
|
|
} |
137
|
|
|
$odpocet['doklad'] = $invoice; |
138
|
|
|
|
139
|
|
|
$this->setDataValue('odpocty-zaloh', ['odpocet' => $odpocet]); |
140
|
|
|
$this->insertToFlexiBee(); |
141
|
|
|
return $this->lastResponseCode == 201; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* add link to advance tax document |
146
|
|
|
* |
147
|
|
|
* @param Banka|PokladniPohyb $income Income payment document |
148
|
|
|
* |
149
|
|
|
* @return boolean success |
150
|
|
|
* |
151
|
|
|
* @throws Exception |
152
|
|
|
*/ |
153
|
|
|
public function vytvorVazbuZDD($income) |
154
|
|
|
{ |
155
|
|
|
switch (get_class($income)) { |
156
|
|
|
case 'FlexiPeeHP\\Banka': |
157
|
|
|
$modul = 'banka'; |
158
|
|
|
break; |
159
|
|
|
case 'FlexiPeeHP\\PokladniPohyb': |
160
|
|
|
$modul = 'pokladna'; |
161
|
|
|
break; |
162
|
|
|
default : |
|
|
|
|
163
|
|
|
throw new \Ease\Exception(_('Unsupported $income parameter type')); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
$incomeId = $income->getRecordID(); |
167
|
|
|
$myId = $this->getRecordID(); |
168
|
|
|
|
169
|
|
|
$headersBackup = $this->defaultHttpHeaders; |
170
|
|
|
|
171
|
|
|
$this->defaultHttpHeaders['Accept'] = 'text/html'; |
172
|
|
|
$this->setPostFields(http_build_query(['modul' => $modul, |
173
|
|
|
'submit' => 'OK'])); |
174
|
|
|
$this->performRequest($myId.'/vytvor-vazbu-zdd/'.$incomeId, 'GET', |
175
|
|
|
'json'); |
176
|
|
|
|
177
|
|
|
$responseArr = explode("\n", $this->lastCurlResponse); |
178
|
|
|
$result = true; |
179
|
|
|
$message = ''; |
180
|
|
|
foreach ($responseArr as $lineNo => $responseLine) { |
181
|
|
|
if (strstr($responseLine, '<ul class = "flexibee-errors">')) { |
182
|
|
|
$message = trim($responseArr[$lineNo + 1]); |
183
|
|
|
$result = false; |
184
|
|
|
} |
185
|
|
|
if (strstr($responseLine, '<div class = "alert alert-success">')) { |
186
|
|
|
$message = strip_tags(html_entity_decode(trim($responseArr[$lineNo |
187
|
|
|
+ 1]))); |
188
|
|
|
$result = true; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
if ($result === true) { |
193
|
|
|
$this->addStatusMessage(empty($message) ? $this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$income->getRecordCode() |
194
|
|
|
: $message, 'success'); |
195
|
|
|
} else { |
196
|
|
|
$this->addStatusMessage($this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$incomeId, |
197
|
|
|
'warning'); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
$this->defaultHttpHeaders = $headersBackup; |
201
|
|
|
|
202
|
|
|
return $result; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* |
207
|
|
|
* @param int $size requested of image |
208
|
|
|
* |
209
|
|
|
* @return type |
|
|
|
|
210
|
|
|
*/ |
211
|
|
|
public function getQrCodeImage($size = 140) |
212
|
|
|
{ |
213
|
|
|
$this->performRequest($this->getRecordID().'/qrcode.png?size='.$size, |
214
|
|
|
'GET', 'png'); |
215
|
|
|
if ($this->lastResponseCode == 200) { |
216
|
|
|
return $this->lastCurlResponse; |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Get base64 encoded QrCode image |
222
|
|
|
* |
223
|
|
|
* @param int $size requested of image |
224
|
|
|
* |
225
|
|
|
* @return string IMG SRC code |
226
|
|
|
*/ |
227
|
|
|
public function getQrCodeBase64($size = 140) |
228
|
|
|
{ |
229
|
|
|
return 'data: image/png;base64,'.base64_encode($this->getQrCodeImage($size)); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Get Number of days overdue |
234
|
|
|
* |
235
|
|
|
* @param string $dueDate FlexiBee date |
236
|
|
|
* |
237
|
|
|
* @return int |
238
|
|
|
*/ |
239
|
|
|
static public function overdueDays($dueDate) |
|
|
|
|
240
|
|
|
{ |
241
|
|
|
$dateDiff = date_diff(is_object($dueDate) ? $dueDate : FlexiBeeRO::flexiDateToDateTime($dueDate), |
|
|
|
|
242
|
|
|
new \DateTime()); |
243
|
|
|
if ($dateDiff->invert == 1) { |
244
|
|
|
$ddif = $dateDiff->days * -1; |
245
|
|
|
} else { |
246
|
|
|
$ddif = $dateDiff->days; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
return $ddif; |
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths