|
1
|
|
|
#!/usr/bin/php -f |
|
2
|
|
|
<?php |
|
3
|
|
|
/** |
|
4
|
|
|
* FlexiPeeHP - Example how to create Invoice |
|
5
|
|
|
* |
|
6
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
|
7
|
|
|
* @copyright (G) 2018 Vitex Software |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Example\FlexiPeeHP; |
|
11
|
|
|
|
|
12
|
|
|
use \FlexiPeeHP\FlexiBeeRO; |
|
13
|
|
|
use \FlexiPeeHP\FakturaVydana; |
|
14
|
|
|
|
|
15
|
|
|
define('EASE_LOGGER', 'syslog|console'); |
|
16
|
|
|
include_once './config.php'; |
|
17
|
|
|
include_once '../vendor/autoload.php'; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Prepare Testing Invoice |
|
21
|
|
|
* |
|
22
|
|
|
* @param array $initialData |
|
23
|
|
|
* |
|
24
|
|
|
* @return FakturaVydana |
|
25
|
|
|
*/ |
|
26
|
|
|
function makeInvoice($initialData = [], $dayBack = 1, $evidence = 'vydana') |
|
27
|
|
|
{ |
|
28
|
|
|
$yesterday = new \DateTime(); |
|
29
|
|
|
$yesterday->modify('-'.$dayBack.' day'); |
|
30
|
|
|
$testCode = 'INV_'.\Ease\Sand::randomString(); |
|
|
|
|
|
|
31
|
|
|
$invoice = new FakturaVydana(null, ['evidence' => 'faktura-'.$evidence]); |
|
32
|
|
|
$invoice->takeData(array_merge([ |
|
33
|
|
|
'kod' => $testCode, |
|
34
|
|
|
'varSym' => \Ease\Sand::randomNumber(1111, 9999), |
|
|
|
|
|
|
35
|
|
|
'specSym' => \Ease\Sand::randomNumber(111, 999), |
|
36
|
|
|
'bezPolozek' => true, |
|
37
|
|
|
'popis' => 'php-flexibee-matcher Test invoice', |
|
38
|
|
|
'datVyst' => FlexiBeeRO::dateToFlexiDate($yesterday), |
|
39
|
|
|
'typDokl' => FlexiBeeRO::code('FAKTURA') |
|
40
|
|
|
], $initialData)); |
|
41
|
|
|
if ($invoice->sync()) { |
|
42
|
|
|
$invoice->addStatusMessage($invoice->getApiURL().' '. |
|
43
|
|
|
FlexiBeeRO::uncode($invoice->getDataValue('typDokl')).' '. |
|
44
|
|
|
FlexiBeeRO::uncode($invoice->getRecordIdent()).' '. |
|
45
|
|
|
FlexiBeeRO::uncode($invoice->getDataValue('sumCelkem')).' '. |
|
46
|
|
|
FlexiBeeRO::uncode($invoice->getDataValue('mena')), 'success'); |
|
47
|
|
|
} else { |
|
48
|
|
|
$invoice->addStatusMessage(json_encode($invoice->getData()), 'debug'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $invoice; |
|
52
|
|
|
} |
|
53
|
|
|
$invoice = makeInvoice(['id' => 'ext:example:1']); |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
//Set due date by DateTime object |
|
57
|
|
|
$nextMonth = new \DateTime(); |
|
58
|
|
|
$nextMonth->modify('+1 month'); |
|
59
|
|
|
$invoice->setDataValue('datSplat', $nextMonth); |
|
60
|
|
|
|
|
61
|
|
|
$invoice->addStatusMessage(_('Invoice').': '.$invoice->getRecordIdent().' '.$invoice->getRecordCode(), |
|
62
|
|
|
$invoice->sync() ? 'success' : 'error' ); |
|
63
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.