This repository has been archived by the owner on Jul 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
NewInvoice.php
54 lines (40 loc) · 1.59 KB
/
NewInvoice.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
#!/usr/bin/php -f
<?php
/**
* FlexiPeeHP - Example how to create Invoice
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright (G) 2018 Vitex Software
*/
namespace Example\FlexiPeeHP;
use DateTime;
use Ease\Sand;
use FlexiPeeHP\FakturaVydana;
use FlexiPeeHP\FlexiBeeRO;
include_once './config.php';
include_once '../vendor/autoload.php';
$invoice = new FakturaVydana();
$invoice->logBanner('Create New Invoice Example');
//Set due date by DateTime object
$nextMonth = new DateTime();
$nextMonth->modify('+1 month');
$invoice->setDataValue('datSplat', $nextMonth);
$invoice->setDataValue('datVyst', (new \DateTime())->modify('-1 day') );
$invoice->takeData([
'varSym' => Sand::randomNumber(1111, 9999),
'specSym' => Sand::randomNumber(111, 999),
'popis' => 'FlexiPeeHP Example invoice',
'typDokl' => FlexiBeeRO::code('FAKTURA')
]);
$invoice->addArrayToBranch(['nazev' => 'Example Item 1', 'cenaMj' => 100]);
/**
* You need an existing pricelist item here:
* (new \FlexiPeeHP\Cenik())->insertToFlexiBee(['kod'=>'EXAMPLE' ,'nazev'=>'New Example Product','cenaMj'=>100]);
*/
$invoice->addArrayToBranch(['nazev' => 'Example Item 2', 'cenik' => 'code:EXAMPLE',
'mnozMj' => 2]);
if ($invoice->sync()) {
$invoice->addStatusMessage($invoice->getApiURL().' '.FlexiBeeRO::uncode($invoice->getDataValue('typDokl')).' '.FlexiBeeRO::uncode($invoice->getRecordIdent()).' '.FlexiBeeRO::uncode($invoice->getDataValue('sumCelkem')).' '.FlexiBeeRO::uncode($invoice->getDataValue('mena')),
'success');
}
echo $invoice->getJsonizedData($invoice->getData(),JSON_PRETTY_PRINT);