-
Notifications
You must be signed in to change notification settings - Fork 3
/
ConvertIncomeToZdd.php
56 lines (44 loc) · 1.9 KB
/
ConvertIncomeToZdd.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
<?php
/**
* AbraFlexi - Example how to convert Bank Income into ZDD
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright (G) 2020-2022 Vitex Software
*/
namespace AbraFlexi\Bricks;
include_once './config.php';
include_once '../vendor/autoload.php';
include_once './common.php';
$payment = \Test\AbraFlexi\Banka::makeTestPayment();
$copyer = new \AbraFlexi\Bricks\Convertor($payment,
new \AbraFlexi\FakturaVydana(
['typDokl' => 'code:ZDD',
'nazev' => 'XXXX',
'stavMailK' => 'stavMail.neodesilat'
]));
/**
* @var FakturaVydana ZDD
*/
$zdd = $copyer->conversion();
$zdd->defaultUrlParams['relations'] = 'vazby';
if ($zdd->sync()) {
$zdd->addStatusMessage(sprintf(_('New advance tax document was created: %s '), \AbraFlexi\Functions::uncode((string)$zdd)), 'success');
if ($zdd->getDataValue('sumCelkem') == $payment->getDataValue('sumCelkem')) {
if ($zdd->vytvorVazbuZDD($payment)) {
$zdd->addStatusMessage(sprintf(_('ZDD %s bond to payment %s '),
\AbraFlexi\Functions::uncode((string)$zdd), \AbraFlexi\Functions::uncode((string)$payment)), 'success');
$zdd->sync(['id' => $zdd, 'stavMailK' => 'stavMail.odeslat']);
$bonds = $zdd->getDataValue('vazby');
if (empty($bonds)) {
$zdd->addStatusMessage(sprintf(_('Error creating ZDD %s bond to payment %s '),
fb::uncode($zdd), fb::uncode($payment)), 'error');
}
}
} else {
$zdd->addStatusMessage(sprintf(_('ZDD %s value %d does not match payment %s value %s'),
\AbraFlexi\Functions::uncode((string)$zdd), $zdd->getDataValue('sumCelkem'), $payment,
$payment->getDataValue('sumCelkem')), 'error');
}
} else {
$zdd->addStatusMessage(sprintf(_('Error creating ZZD for %s'), \AbraFlexi\Functions::uncode((string)$payment)), 'error');
}