├── .gitignore ├── LICENSE ├── README.md ├── callback.php ├── example.php ├── lexoffice-php-api.php └── tests ├── README.md ├── test.php └── tests ├── 001_webhooks.php ├── 002_invoices.php ├── 003_profile.php ├── 004_contacts.php ├── 005_invoice_specific_contact.php ├── 006_files.php ├── 007_quotations.php ├── 008_order_confirmations.php ├── 009_dunnings.php ├── 010_error_handling.php ├── 011_oss_origin.php ├── 012_tax.php ├── 013_contacts_create_big_amount.php ├── 014_get_needed_tax_type.php ├── 015_oss_destination.php ├── 016_delivery_notes.php ├── 017_credit_notes.php ├── 018_contacts_wildcards.php ├── 019_contacts_no_wildcards.php ├── 020_validate_vat_id.php ├── 021_e_invoice_pdf_rendering.php ├── 100_tax_net_company_destinantion.php ├── 100_tax_net_company_origin.php ├── 100_tax_taxfree_company.php ├── 110_vouchers_e_invoices.php ├── 120_invoices_e_invoices.php ├── 301_contact_with_multiple_addresses.php ├── 302_contact_with_empty_mail.php ├── 303_contact_with_empty_phone_number.php ├── 304_contact_with_invalid_phone_number.php ├── 305_contact_with_invalid_mail.php ├── 306_contact_with_strange_mail.php ├── 307_contact_with_umlaut_mail_domain.php ├── 308_contact_with_umlaut_mail_local.php ├── 400_vouchers.php ├── 401_voucher_with_rounding.php ├── 402_vouchers_create_big_amount.php ├── 403_invoice_empty_contact_address.php ├── 404_invoicesMultilineTermLabel.php ├── 500_articles.php ├── 501_articles_all.php ├── 901_http_429_rate_limit.php ├── 999_api_access.php └── files ├── XRechnung-sample.pdf ├── XRechnung-sample.xml ├── cat.jpg ├── cat_5245kb.jpg ├── cat_without_extension ├── dummy.pdf ├── dummy_12_pages.pdf ├── dummy_2.pdf └── libssh2.dll /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | /tests/_local_settings.php 3 | /tests/tests/tmp/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lexware-php-api (ehemals lexoffice-php-api) 2 | PHP Client für [office.lexware.de](https://www.awin1.com/cread.php?awinmid=13787&awinaffid=635216&ued=https%3A%2F%2Foffice.lexware.de) Public API 3 | 4 | PHP Versionen: 5 | * PHP 8.4 (siehe Branch [master-php-8.4](https://github.com/Baebeca-Solutions/lexware-php-api/tree/master-php-8.4) 6 | * PHP 8.3 (legacy, siehe Branch [master-php-8.3](https://github.com/Baebeca-Solutions/lexware-php-api/tree/master-php-8.3) 7 | * PHP 8.0 (legacy, siehe Branch [master-php-8.0](https://github.com/Baebeca-Solutions/lexware-php-api/tree/master-php-8.0) 8 | * PHP 7.4 (legacy, siehe Branch [master-php-7.4](https://github.com/Baebeca-Solutions/lexware-php-api/tree/master-php-7.4) 9 | 10 | Wir lieben Automatisierung und die nahtlose Verzahnung von Systemen! 11 | 12 | [office.lexware.de](https://www.awin1.com/cread.php?awinmid=13787&awinaffid=635216&ued=https%3A%2F%2Foffice.lexware.de) stellt seinen Kunden eine öffentliche API-Schnittstelle zur Verfügung über die 13 | bestehende Systeme integriert und Prozesse automatisiert werden können. Für diesen Ansatz haben 14 | wir einen PHP-Client entwickelt und stellen diesen kostenfrei zur Verfügung. 15 | 16 | Alle weiteren Informationen finden Sie hier: 17 | * Allgemeine Themen auf unserer [Projektseite](https://www.baebeca.de/softwareentwicklung/projekte/lexware-php-client/) 18 | * Eine technische Dokumentation in unserem [Wiki](https://wiki.baebeca.de/index.php?title=lexware-php-api) 19 | 20 | ## Baebeca Solutions bei office.lexware.de 21 | * [Integrationspartner](https://www.awin1.com/cread.php?awinmid=13787&awinaffid=635216&ued=https%3A%2F%2Foffice.lexware.de) 22 | * [Softwarepartner](https://www.awin1.com/cread.php?awinmid=13787&awinaffid=635216&ued=https%3A%2F%2Foffice.lexware.de) 23 | 24 | [![Lexware Office - Technologie Partner](https://www.baebeca.de/wp-content/uploads/2024/09/Lexware-Office_TP_Badge_rgb-1-300x199.png)](https://www.awin1.com/cread.php?awinmid=13787&awinaffid=635216&ued=https%3A%2F%2Foffice.lexware.de) 25 | 26 | ## office.lexware.de API-Dokumentation 27 | Die offizielle Lexware Office API-Dokumentation findest du [hier](https://developers.lexware.io). 28 | 29 | ## lexware-php-api Dokumentation 30 | Die Dokumentation mit allen Informationen findest du in unserem [Wiki](https://wiki.baebeca.de/index.php?title=lexware-php-api) unter https://wiki.baebeca.de/index.php?title=lexware-php-api 31 | 32 | ## Support 33 | An wen kann ich mich wenden, wenn ich Probleme oder Fragen habe?
34 | Für diese Frage ist entscheidend, ob du eine Nutzungslizenz für unsere lexware-php-api erworben hast oder die kostenlose Variante nutzt. 35 | 36 | * Sofern eine Nutzungslizenz vorhanden ist, kannst du dich sich jederzeit gerne wie folgt an uns wenden: 37 | * per Mail an support@baebeca.de 38 | * per Telefon an 02261-8161691 39 | * einen Github [issue](https://github.com/Baebeca-Solutions/lexware-php-api/issues) öffnen 40 | * Wenn du die kostenlose Version benutzt, kannst du einen Github [issue](https://github.com/Baebeca-Solutions/lexware-php-api/issues) öffnen. 41 | 42 | ## Lizenz 43 | Unsere Software wurde unter der "GNU Affero General Public License v3.0" Lizenz veröffentlicht. 44 | Dies bedeutet, dass Sie unsere Software gerne in Ihren Projekten und Produkten nutzen dürfen, 45 | solange Sie Ihr Projekt dann ebenso Quelloffen unter den in der Lizenz genannten Rahmenbedingungen 46 | zur Verfügung stellen. 47 | 48 | Wenn Sie Ihre Lösung nicht veröffentlichen möchten, Support benötigen, individuelle 49 | Erweiterungen benötigen oder dieses Projekt einfach Unterstützen möchten, können Sie für 99,- EUR/Netto eine lifetime Nutzungslizenz erhalten. Setzte dich diesbezüglich einfach kurz mit uns via support@baebeca.de, 02261-8161691 oder über unsere [Website](https://www.baebeca.de/softwareentwicklung/projekte/lexware-php-client/) in Verbindung. -------------------------------------------------------------------------------- /callback.php: -------------------------------------------------------------------------------- 1 | organizationId == $company_id) exit('invalid organizationId'); 31 | 32 | switch ($data->eventType) { 33 | case 'invoice.status.changed': 34 | // do some stuff 35 | break; 36 | 37 | case 'invoice.created': 38 | // do some stuff 39 | break; 40 | 41 | case 'invoice.changed': 42 | // do some stuff 43 | break; 44 | 45 | case 'invoice.deleted': 46 | // do some stuff 47 | break; 48 | 49 | case 'credit-note.created': 50 | // do some stuff 51 | break; 52 | 53 | case 'credit-note.changed': 54 | // do some stuff 55 | break; 56 | 57 | case 'credit-note.deleted': 58 | // do some stuff 59 | break; 60 | 61 | case 'credit-note.status.changed': 62 | // do some stuff 63 | break; 64 | 65 | case 'quotation.created': 66 | // do some stuff 67 | break; 68 | 69 | case 'quotation.changed': 70 | // do some stuff 71 | break; 72 | 73 | case 'quotation.deleted': 74 | // do some stuff 75 | break; 76 | 77 | case 'quotation.status.changed': 78 | // do some stuff 79 | break; 80 | 81 | case 'order-confirmation.created': 82 | // do some stuff 83 | break; 84 | 85 | case 'order-confirmation.changed': 86 | // do some stuff 87 | break; 88 | 89 | case 'order-confirmation.deleted': 90 | // do some stuff 91 | break; 92 | 93 | case 'order-confirmation.status.changed': 94 | // do some stuff 95 | break; 96 | 97 | case 'contact.created': 98 | // do some stuff 99 | break; 100 | 101 | case 'contact.changed': 102 | // do some stuff 103 | break; 104 | 105 | case 'contact.deleted': 106 | // do some stuff 107 | break; 108 | 109 | case 'token.revoked': 110 | // do some stuff 111 | break; 112 | } 113 | } else { 114 | exit('invalid signature'); 115 | } -------------------------------------------------------------------------------- /example.php: -------------------------------------------------------------------------------- 1 | $api_key 9 | )); 10 | 11 | // show active Webhooks 12 | #print_r($lexoffice->get_events_all()); 13 | 14 | // create webhook 15 | #print_r($lexoffice->add_event('contact.created', 'https://domain.tld/lexoffice-php-client/callback.php')); 16 | 17 | // delete webhook 18 | #print_r($lexoffice->delete_event('a8a0a5a6-0dc1-4c9b-bfaa-7de4d4a3d6a5')); 19 | 20 | // get specific invoice 21 | #echo '
'.print_r($lexoffice->get_invoice('7f0f0f7f-dd61-4bf7-a9f7-a67b0530c7e9'), true).'
'; 22 | 23 | // echo specific invoice number 24 | #$invoice = $lexoffice->get_invoice('350d7ea4-63f9-44fb-a404-b4de167b4a8e'); 25 | #echo $invoice->voucherNumber; 26 | 27 | // download invoice pdf 28 | #$lexoffice->get_invoice_pdf('7f0f0f7f-dd61-4bf7-a9f7-a67b0530c7e9', 'test.pdf'), true); 29 | 30 | // create draft invoice 31 | /* 32 | print_r($lexoffice->create_invoice(array( 33 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 34 | 'introduction' => 'Einleitungstext', 35 | 'remark' => "Fußzeile\r\nMehrzeilig", 36 | 'address' => array( 37 | #'contactId' => '', 38 | 'name' => 'Frau Jane Doe', 39 | 'street' => 'Str. 1', 40 | 'zip' => '12345', 41 | 'city' => 'Stadt', 42 | 'countryCode' => 'DE', 43 | ), 44 | 'lineItems' => array( 45 | array( 46 | 'type' => 'custom', 47 | 'name' => 'Produktname', 48 | 'description' => 'Beschreibung', 49 | 'quantity' => 1, 50 | 'unitName' => 'Stück', 51 | 'unitPrice' => array( 52 | 'currency' => 'EUR', 53 | 'netAmount' => 10.99, 54 | 'taxRatePercentage' => 19, 55 | ), 56 | #'discountPercentage' => 0, 57 | ), 58 | ), 59 | 'totalPrice' => array( 60 | 'currency' => 'EUR', 61 | #'totalDiscountAbsolute' => 0, 62 | #'totalDiscountPercentage' => 0, 63 | ), 64 | 'taxConditions' => array( 65 | 'taxType' => 'net', 66 | ), 67 | 'shippingConditions' => array( 68 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 69 | 'shippingType' => 'delivery', 70 | ), 71 | 'paymentConditions' => array( 72 | 'paymentTermLabel' => 'Vorkasse', 73 | 'paymentTermDuration' => 1, 74 | ), 75 | ), false)); 76 | */ -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | This folder contains scripts for automated tests before new versions will be published. 2 | 3 | To start a test execute ./test.php 4 | All testscripts located in the subfolder "tests" will be executed and tested. 5 | 6 | Test definition: 7 | ```php 8 | // initiate test with test_start() 9 | test_start('description of the test'); 10 | 11 | // do funny stuff and test your code 12 | // log some output in your test 13 | test('log some messages'); 14 | 15 | // compare exepcted output with output and decide if your test was successful 16 | if ($something_is_true) { 17 | test_finished(true); 18 | } else { 19 | test_finished(false); 20 | } 21 | ``` 22 | 23 | Sample output 24 | ``` 25 | C:\Users\slutz\Downloads\php-7.1.1-nts-Win32-VC14-x64\php.exe C:\Users\slutz\Documents\GitHub\lexoffice-php-api\tests\test.php 26 | 20.11.2019 17:15:31 [] - include test: ./tests/001_webhooks.php 27 | 20.11.2019 17:15:31 [] - include test: ./tests/002_invoices.php 28 | 20.11.2019 17:15:31 [5dd574b3ef6ce] - start new test - 5dd574b3ef6ce 29 | 20.11.2019 17:15:31 [5dd574b3ef6ce] - description: create draft invoice 30 | 20.11.2019 17:15:33 [5dd574b3ef6ce] - draft invoice created - id: bcce6f19-e600-4641-b178-7691fa105635 31 | 20.11.2019 17:15:33 [5dd574b3ef6ce] ===> Testresult OK 32 | 33 | 20.11.2019 17:15:33 [] - include test: ./tests/010_error_handling.php 34 | 20.11.2019 17:15:33 [5dd574b50129b] - start new test - 5dd574b50129b 35 | 20.11.2019 17:15:33 [5dd574b50129b] - description: create draft invoice and download pdf (not possible) 36 | 20.11.2019 17:15:33 [5dd574b50129b] - draft invoice created - id: 66a0060d-b58c-4836-9cbe-5dfb1d8c59fa 37 | 20.11.2019 17:15:33 [5dd574b50129b] - try download pdf 38 | 20.11.2019 17:15:33 [5dd574b50129b] - lexoffice-php-api: error in api request - check details via $e->get_error() 39 | 20.11.2019 17:15:33 [5dd574b50129b] ===> Testresult OK 40 | 41 | 42 | Process finished with exit code 0 43 | ``` -------------------------------------------------------------------------------- /tests/test.php: -------------------------------------------------------------------------------- 1 | $api_key, 26 | 'ssl_verify' => false, 27 | 'sandbox' => $sandbox, 28 | 'sandbox_sso' => $sandbox_sso, 29 | )); 30 | 31 | 32 | $logfile_current_test = false; 33 | $logfile_current_test_content = ''; 34 | function test_start($description) { 35 | global $logfile_current_test, $unit, $logfile_current_test_content; 36 | $logfile_current_test = uniqid(); 37 | $logfile_current_test_content.= date('d.m.Y H:i:s')." [".$logfile_current_test."] - start new test - ".$logfile_current_test."\r\n"; 38 | echo date('d.m.Y H:i:s')." [".$logfile_current_test."] - start new test - ".$logfile_current_test."\r\n"; 39 | $logfile_current_test_content.= date('d.m.Y H:i:s')." [".$logfile_current_test."] - description: ".$description."\r\n"; 40 | echo date('d.m.Y H:i:s')." [".$logfile_current_test."] - description: ".$description."\r\n"; 41 | } 42 | function test($notice, $overide_debug = false) { 43 | global $logfile_current_test, $debug, $logfile_current_test_content; 44 | $logfile_current_test_content.= date('d.m.Y H:i:s')." [".$logfile_current_test."] - ".$notice."\r\n"; 45 | if ($overide_debug || $debug) echo date('d.m.Y H:i:s')." [".$logfile_current_test."] - ".$notice."\r\n"; 46 | } 47 | function test_finished($result) { 48 | global $logfile_current_test, $logfile_current_test_content; 49 | 50 | if ($result) { 51 | echo date('d.m.Y H:i:s')." [".$logfile_current_test."] ===> Testresult OK\r\n"; 52 | echo "\r\n"; 53 | } else { 54 | echo "\r\n==================== FAILED - last test output ====================\r\n"; 55 | echo date('d.m.Y H:i:s').$logfile_current_test_content."\r\n"; 56 | echo date('d.m.Y H:i:s')." [".$logfile_current_test."] ===> Testresult FAILED\r\n"; 57 | echo "==================== ====================\r\n"; 58 | exit(); 59 | } 60 | $logfile_current_test = false; 61 | $logfile_current_test_content = ''; 62 | } 63 | 64 | $tests = array_slice(scandir('./tests'), 2); 65 | foreach ($tests as $test) { 66 | $test_tmp = explode('_', $test); 67 | if (empty($run_specific_test) || $run_specific_test == (int)$test_tmp[0]) { 68 | if (substr($test, -4) != '.php') continue; 69 | test('include test: '.'./tests/'.$test, true); 70 | require_once ('./tests/'.$test); 71 | } else { 72 | test('skip include test: '.'./tests/'.$test); 73 | } 74 | } -------------------------------------------------------------------------------- /tests/tests/001_webhooks.php: -------------------------------------------------------------------------------- 1 | create_invoice([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'introduction' => 'Einleitungstext', 8 | 'remark' => "Fußzeile\r\nMehrzeilig", 9 | 'address' => [ 10 | #'contactId' => '', 11 | 'name' => 'Frau Jane Doe', 12 | 'street' => 'Str. 1', 13 | 'zip' => '12345', 14 | 'city' => 'Stadt', 15 | 'countryCode' => 'DE', 16 | ], 17 | 'lineItems' => [ 18 | [ 19 | 'type' => 'custom', 20 | 'name' => 'Produktname', 21 | 'description' => 'Beschreibung', 22 | 'quantity' => 1, 23 | 'unitName' => 'Stück', 24 | 'unitPrice' => [ 25 | 'currency' => 'EUR', 26 | 'netAmount' => 11.99, 27 | 'taxRatePercentage' => $taxrate_19, 28 | ], 29 | #'discountPercentage' => 0, 30 | ], 31 | ], 32 | 'totalPrice' => [ 33 | 'currency' => 'EUR', 34 | #'totalDiscountAbsolute' => 0, 35 | #'totalDiscountPercentage' => 0, 36 | ], 37 | 'taxConditions' => [ 38 | 'taxType' => 'net', 39 | ], 40 | 'shippingConditions' => [ 41 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 42 | 'shippingType' => 'delivery', 43 | ], 44 | 'paymentConditions' => [ 45 | 'paymentTermLabel' => 'Vorkasse', 46 | 'paymentTermDuration' => 1, 47 | ], 48 | ], false); 49 | 50 | if ($request->id) { 51 | test('draft invoice created - id: '.$request->id); 52 | // todo check if status is draft 53 | 54 | test_finished(true); 55 | } else { 56 | test_finished(false); 57 | } 58 | } catch(lexoffice_exception $e) { 59 | test($e->getMessage()); 60 | test(print_r($e->get_error(), true)); 61 | test_finished(false); 62 | } 63 | 64 | // todo create finished and check status 65 | 66 | // todo create finished, check status and downlaod pdf 67 | 68 | test_start('invoice - 0% UST position'); 69 | try { 70 | $request = $lexoffice->create_invoice([ 71 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 72 | 'introduction' => 'Einleitungstext', 73 | 'remark' => "Fußzeile\r\nMehrzeilig", 74 | 'address' => [ 75 | #'contactId' => '', 76 | 'name' => 'Frau Jane Doe', 77 | 'street' => 'Str. 1', 78 | 'zip' => '12345', 79 | 'city' => 'Stadt', 80 | 'countryCode' => 'DE', 81 | ], 82 | 'lineItems' => [ 83 | [ 84 | 'type' => 'custom', 85 | 'name' => 'Produktname', 86 | 'description' => 'Beschreibung', 87 | 'quantity' => 1, 88 | 'unitName' => 'Stück', 89 | 'unitPrice' => [ 90 | 'currency' => 'EUR', 91 | 'netAmount' => 11.99, 92 | 'taxRatePercentage' => 0, 93 | ], 94 | #'discountPercentage' => 0, 95 | ], 96 | ], 97 | 'totalPrice' => [ 98 | 'currency' => 'EUR', 99 | #'totalDiscountAbsolute' => 0, 100 | #'totalDiscountPercentage' => 0, 101 | ], 102 | 'taxConditions' => [ 103 | 'taxType' => 'net', 104 | ], 105 | 'shippingConditions' => [ 106 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 107 | 'shippingType' => 'delivery', 108 | ], 109 | 'paymentConditions' => [ 110 | 'paymentTermLabel' => 'Vorkasse', 111 | 'paymentTermDuration' => 1, 112 | ], 113 | ], true); 114 | 115 | if ($request->id) { 116 | test('invoice created - id: '.$request->id); 117 | 118 | test_finished(true); 119 | } else { 120 | test_finished(false); 121 | } 122 | } catch(lexoffice_exception $e) { 123 | test($e->getMessage()); 124 | test(print_r($e->get_error(), true)); 125 | test_finished(false); 126 | } 127 | 128 | 129 | test_start('invoice - 7% UST position'); 130 | try { 131 | $request = $lexoffice->create_invoice([ 132 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 133 | 'introduction' => 'Einleitungstext', 134 | 'remark' => "Fußzeile\r\nMehrzeilig", 135 | 'address' => [ 136 | #'contactId' => '', 137 | 'name' => 'Frau Jane Doe', 138 | 'street' => 'Str. 1', 139 | 'zip' => '12345', 140 | 'city' => 'Stadt', 141 | 'countryCode' => 'DE', 142 | ], 143 | 'lineItems' => [ 144 | [ 145 | 'type' => 'custom', 146 | 'name' => 'Produktname', 147 | 'description' => 'Beschreibung', 148 | 'quantity' => 1, 149 | 'unitName' => 'Stück', 150 | 'unitPrice' => [ 151 | 'currency' => 'EUR', 152 | 'netAmount' => 11.99, 153 | 'taxRatePercentage' => $taxrate_7, 154 | ], 155 | #'discountPercentage' => 0, 156 | ], 157 | ], 158 | 'totalPrice' => [ 159 | 'currency' => 'EUR', 160 | #'totalDiscountAbsolute' => 0, 161 | #'totalDiscountPercentage' => 0, 162 | ], 163 | 'taxConditions' => [ 164 | 'taxType' => 'net', 165 | ], 166 | 'shippingConditions' => [ 167 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 168 | 'shippingType' => 'delivery', 169 | ], 170 | 'paymentConditions' => [ 171 | 'paymentTermLabel' => 'Vorkasse', 172 | 'paymentTermDuration' => 1, 173 | ], 174 | ], true); 175 | 176 | if ($request->id) { 177 | test('invoice created - id: '.$request->id); 178 | 179 | test_finished(true); 180 | } else { 181 | test_finished(false); 182 | } 183 | } catch(lexoffice_exception $e) { 184 | test($e->getMessage()); 185 | test(print_r($e->get_error(), true)); 186 | test_finished(false); 187 | } 188 | 189 | test_start('invoice - 19% UST position'); 190 | try { 191 | $request = $lexoffice->create_invoice([ 192 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 193 | 'introduction' => 'Einleitungstext', 194 | 'remark' => "Fußzeile\r\nMehrzeilig", 195 | 'address' => [ 196 | #'contactId' => '', 197 | 'name' => 'Frau Jane Doe', 198 | 'street' => 'Str. 1', 199 | 'zip' => '12345', 200 | 'city' => 'Stadt', 201 | 'countryCode' => 'DE', 202 | ], 203 | 'lineItems' => [ 204 | [ 205 | 'type' => 'custom', 206 | 'name' => 'Produktname', 207 | 'description' => 'Beschreibung', 208 | 'quantity' => 1, 209 | 'unitName' => 'Stück', 210 | 'unitPrice' => [ 211 | 'currency' => 'EUR', 212 | 'netAmount' => 11.99, 213 | 'taxRatePercentage' => $taxrate_19, 214 | ], 215 | #'discountPercentage' => 0, 216 | ], 217 | ], 218 | 'totalPrice' => [ 219 | 'currency' => 'EUR', 220 | #'totalDiscountAbsolute' => 0, 221 | #'totalDiscountPercentage' => 0, 222 | ], 223 | 'taxConditions' => [ 224 | 'taxType' => 'net', 225 | ], 226 | 'shippingConditions' => [ 227 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 228 | 'shippingType' => 'delivery', 229 | ], 230 | 'paymentConditions' => [ 231 | 'paymentTermLabel' => 'Vorkasse', 232 | 'paymentTermDuration' => 1, 233 | ], 234 | ], true); 235 | 236 | if ($request->id) { 237 | test('invoice created - id: '.$request->id); 238 | 239 | test_finished(true); 240 | } else { 241 | test_finished(false); 242 | } 243 | } catch(lexoffice_exception $e) { 244 | test($e->getMessage()); 245 | test(print_r($e->get_error(), true)); 246 | test_finished(false); 247 | } 248 | 249 | test_start('invoice - 0%, 19, 7% UST position'); 250 | try { 251 | $request = $lexoffice->create_invoice([ 252 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 253 | 'introduction' => 'Einleitungstext', 254 | 'remark' => "Fußzeile\r\nMehrzeilig", 255 | 'address' => [ 256 | #'contactId' => '', 257 | 'name' => 'Frau Jane Doe', 258 | 'street' => 'Str. 1', 259 | 'zip' => '12345', 260 | 'city' => 'Stadt', 261 | 'countryCode' => 'DE', 262 | ], 263 | 'lineItems' => [ 264 | [ 265 | 'type' => 'custom', 266 | 'name' => 'Produktname', 267 | 'description' => 'Beschreibung', 268 | 'quantity' => 1, 269 | 'unitName' => 'Stück', 270 | 'unitPrice' => [ 271 | 'currency' => 'EUR', 272 | 'netAmount' => 11.99, 273 | 'taxRatePercentage' => 0, 274 | ], 275 | #'discountPercentage' => 0, 276 | ], 277 | [ 278 | 'type' => 'custom', 279 | 'name' => 'Produktname', 280 | 'description' => 'Beschreibung', 281 | 'quantity' => 1, 282 | 'unitName' => 'Stück', 283 | 'unitPrice' => [ 284 | 'currency' => 'EUR', 285 | 'netAmount' => 11.99, 286 | 'taxRatePercentage' => $taxrate_7, 287 | ], 288 | #'discountPercentage' => 0, 289 | ], 290 | [ 291 | 'type' => 'custom', 292 | 'name' => 'Produktname', 293 | 'description' => 'Beschreibung', 294 | 'quantity' => 1, 295 | 'unitName' => 'Stück', 296 | 'unitPrice' => [ 297 | 'currency' => 'EUR', 298 | 'netAmount' => 11.99, 299 | 'taxRatePercentage' => $taxrate_19, 300 | ], 301 | #'discountPercentage' => 0, 302 | ], 303 | ], 304 | 'totalPrice' => [ 305 | 'currency' => 'EUR', 306 | #'totalDiscountAbsolute' => 0, 307 | #'totalDiscountPercentage' => 0, 308 | ], 309 | 'taxConditions' => [ 310 | 'taxType' => 'net', 311 | ], 312 | 'shippingConditions' => [ 313 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 314 | 'shippingType' => 'delivery', 315 | ], 316 | 'paymentConditions' => [ 317 | 'paymentTermLabel' => 'Vorkasse', 318 | 'paymentTermDuration' => 1, 319 | ], 320 | ], true); 321 | 322 | if ($request->id) { 323 | test('invoice created - id: '.$request->id); 324 | 325 | test_finished(true); 326 | } else { 327 | test_finished(false); 328 | } 329 | } catch(lexoffice_exception $e) { 330 | test($e->getMessage()); 331 | test(print_r($e->get_error(), true)); 332 | test_finished(false); 333 | } 334 | 335 | test_start('invoice - negative amount position'); 336 | try { 337 | $request = $lexoffice->create_invoice([ 338 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 339 | 'introduction' => 'Einleitungstext', 340 | 'remark' => "Fußzeile\r\nMehrzeilig", 341 | 'address' => [ 342 | #'contactId' => '', 343 | 'name' => 'Frau Jane Doe', 344 | 'street' => 'Str. 1', 345 | 'zip' => '12345', 346 | 'city' => 'Stadt', 347 | 'countryCode' => 'DE', 348 | ], 349 | 'lineItems' => [ 350 | [ 351 | 'type' => 'custom', 352 | 'name' => 'Produktname', 353 | 'description' => 'Beschreibung', 354 | 'quantity' => 1, 355 | 'unitName' => 'Stück', 356 | 'unitPrice' => [ 357 | 'currency' => 'EUR', 358 | 'netAmount' => 11.99, 359 | 'taxRatePercentage' => $taxrate_19, 360 | ], 361 | #'discountPercentage' => 0, 362 | ], 363 | [ 364 | 'type' => 'custom', 365 | 'name' => 'Produktname', 366 | 'description' => 'Beschreibung', 367 | 'quantity' => 1, 368 | 'unitName' => 'Stück', 369 | 'unitPrice' => [ 370 | 'currency' => 'EUR', 371 | 'netAmount' => -11.99, 372 | 'taxRatePercentage' => $taxrate_19, 373 | ], 374 | #'discountPercentage' => 0, 375 | ], 376 | [ 377 | 'type' => 'custom', 378 | 'name' => 'Produktname', 379 | 'description' => 'Beschreibung', 380 | 'quantity' => 1, 381 | 'unitName' => 'Stück', 382 | 'unitPrice' => [ 383 | 'currency' => 'EUR', 384 | 'netAmount' => 3.99, 385 | 'taxRatePercentage' => $taxrate_19, 386 | ], 387 | #'discountPercentage' => 0, 388 | ], 389 | ], 390 | 'totalPrice' => [ 391 | 'currency' => 'EUR', 392 | #'totalDiscountAbsolute' => 0, 393 | #'totalDiscountPercentage' => 0, 394 | ], 395 | 'taxConditions' => [ 396 | 'taxType' => 'net', 397 | ], 398 | 'shippingConditions' => [ 399 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 400 | 'shippingType' => 'delivery', 401 | ], 402 | 'paymentConditions' => [ 403 | 'paymentTermLabel' => 'Vorkasse', 404 | 'paymentTermDuration' => 1, 405 | ], 406 | ], true); 407 | 408 | if ($request->id) { 409 | test('invoice created - id: '.$request->id); 410 | 411 | test_finished(true); 412 | } else { 413 | test_finished(false); 414 | } 415 | } catch(lexoffice_exception $e) { 416 | test($e->getMessage()); 417 | test(print_r($e->get_error(), true)); 418 | test_finished(false); 419 | } 420 | 421 | test_start('invoice - zero amount'); 422 | try { 423 | $request = $lexoffice->create_invoice([ 424 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 425 | 'introduction' => 'Einleitungstext', 426 | 'remark' => "Fußzeile\r\nMehrzeilig", 427 | 'address' => [ 428 | #'contactId' => '', 429 | 'name' => 'Frau Jane Doe', 430 | 'street' => 'Str. 1', 431 | 'zip' => '12345', 432 | 'city' => 'Stadt', 433 | 'countryCode' => 'DE', 434 | ], 435 | 'lineItems' => [ 436 | [ 437 | 'type' => 'custom', 438 | 'name' => 'Produktname', 439 | 'description' => 'Beschreibung', 440 | 'quantity' => 1, 441 | 'unitName' => 'Stück', 442 | 'unitPrice' => [ 443 | 'currency' => 'EUR', 444 | 'netAmount' => 11.99, 445 | 'taxRatePercentage' => $taxrate_19, 446 | ], 447 | #'discountPercentage' => 0, 448 | ], 449 | [ 450 | 'type' => 'custom', 451 | 'name' => 'Produktname', 452 | 'description' => 'Beschreibung', 453 | 'quantity' => 1, 454 | 'unitName' => 'Stück', 455 | 'unitPrice' => [ 456 | 'currency' => 'EUR', 457 | 'netAmount' => -11.99, 458 | 'taxRatePercentage' => $taxrate_19, 459 | ], 460 | #'discountPercentage' => 0, 461 | ], 462 | ], 463 | 'totalPrice' => [ 464 | 'currency' => 'EUR', 465 | #'totalDiscountAbsolute' => 0, 466 | #'totalDiscountPercentage' => 0, 467 | ], 468 | 'taxConditions' => [ 469 | 'taxType' => 'net', 470 | ], 471 | 'shippingConditions' => [ 472 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 473 | 'shippingType' => 'delivery', 474 | ], 475 | 'paymentConditions' => [ 476 | 'paymentTermLabel' => 'Vorkasse', 477 | 'paymentTermDuration' => 1, 478 | ], 479 | ], true); 480 | 481 | if ($request->id) { 482 | test('invoice created - id: '.$request->id); 483 | 484 | test_finished(true); 485 | } else { 486 | test_finished(false); 487 | } 488 | } catch(lexoffice_exception $e) { 489 | test($e->getMessage()); 490 | test(print_r($e->get_error(), true)); 491 | test_finished(false); 492 | } 493 | 494 | test_start('invoice - 100% discount'); 495 | try { 496 | $request = $lexoffice->create_invoice([ 497 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 498 | 'introduction' => 'Einleitungstext', 499 | 'remark' => "Fußzeile\r\nMehrzeilig", 500 | 'address' => [ 501 | #'contactId' => '', 502 | 'name' => 'Frau Jane Doe', 503 | 'street' => 'Str. 1', 504 | 'zip' => '12345', 505 | 'city' => 'Stadt', 506 | 'countryCode' => 'DE', 507 | ], 508 | 'lineItems' => [ 509 | [ 510 | 'type' => 'custom', 511 | 'name' => 'Produktname', 512 | 'description' => 'Beschreibung', 513 | 'quantity' => 1, 514 | 'unitName' => 'Stück', 515 | 'unitPrice' => [ 516 | 'currency' => 'EUR', 517 | 'netAmount' => 11.99, 518 | 'taxRatePercentage' => $taxrate_19, 519 | ], 520 | #'discountPercentage' => 0, 521 | ], 522 | ], 523 | 'totalPrice' => [ 524 | 'currency' => 'EUR', 525 | #'totalDiscountAbsolute' => 0, 526 | 'totalDiscountPercentage' => 100, 527 | ], 528 | 'taxConditions' => [ 529 | 'taxType' => 'net', 530 | ], 531 | 'shippingConditions' => [ 532 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 533 | 'shippingType' => 'delivery', 534 | ], 535 | 'paymentConditions' => [ 536 | 'paymentTermLabel' => 'Vorkasse', 537 | 'paymentTermDuration' => 1, 538 | ], 539 | ], true); 540 | 541 | if ($request->id) { 542 | test('invoice created - id: '.$request->id); 543 | 544 | test_finished(true); 545 | } else { 546 | test_finished(false); 547 | } 548 | } catch(lexoffice_exception $e) { 549 | test($e->getMessage()); 550 | test(print_r($e->get_error(), true)); 551 | test_finished(false); 552 | } 553 | 554 | 555 | test_start('invoice - text position'); 556 | try { 557 | $request = $lexoffice->create_invoice([ 558 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 559 | 'introduction' => 'Einleitungstext', 560 | 'remark' => "Fußzeile\r\nMehrzeilig", 561 | 'address' => [ 562 | #'contactId' => '', 563 | 'name' => 'Frau Jane Doe', 564 | 'street' => 'Str. 1', 565 | 'zip' => '12345', 566 | 'city' => 'Stadt', 567 | 'countryCode' => 'DE', 568 | ], 569 | 'lineItems' => [ 570 | [ 571 | 'type' => 'text', 572 | 'name' => 'blub blub bub', 573 | 'description' => 'Beschreibung', 574 | ], 575 | [ 576 | 'type' => 'custom', 577 | 'name' => 'Produktname', 578 | 'description' => 'Beschreibung', 579 | 'quantity' => 1, 580 | 'unitName' => 'Stück', 581 | 'unitPrice' => [ 582 | 'currency' => 'EUR', 583 | 'netAmount' => 11.99, 584 | 'taxRatePercentage' => $taxrate_19, 585 | ], 586 | #'discountPercentage' => 0, 587 | ], 588 | [ 589 | 'type' => 'custom', 590 | 'name' => 'Produktname', 591 | 'description' => 'Beschreibung', 592 | 'quantity' => 1, 593 | 'unitName' => 'Stück', 594 | 'unitPrice' => [ 595 | 'currency' => 'EUR', 596 | 'netAmount' => -3.99, 597 | 'taxRatePercentage' => $taxrate_19, 598 | ], 599 | #'discountPercentage' => 0, 600 | ], 601 | ], 602 | 'totalPrice' => [ 603 | 'currency' => 'EUR', 604 | #'totalDiscountAbsolute' => 0, 605 | #'totalDiscountPercentage' => 0, 606 | ], 607 | 'taxConditions' => [ 608 | 'taxType' => 'net', 609 | ], 610 | 'shippingConditions' => [ 611 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 612 | 'shippingType' => 'delivery', 613 | ], 614 | 'paymentConditions' => [ 615 | 'paymentTermLabel' => 'Vorkasse', 616 | 'paymentTermDuration' => 1, 617 | ], 618 | ], true); 619 | 620 | if ($request->id) { 621 | test('invoice created - id: '.$request->id); 622 | test_finished(true); 623 | } else { 624 | test_finished(false); 625 | } 626 | } catch(lexoffice_exception $e) { 627 | test($e->getMessage()); 628 | test(print_r($e->get_error(), true)); 629 | test_finished(false); 630 | } 631 | 632 | 633 | test_start('invoice - get all invoices'); 634 | $max_invoices_in_test_account = 0; 635 | try { 636 | $request = $lexoffice->get_invoices_all(); 637 | if (count($request)) { 638 | $max_invoices_in_test_account = count($request); 639 | test($max_invoices_in_test_account.' invoices in account'); 640 | test_finished(true); 641 | } else { 642 | test_finished(false); 643 | } 644 | } catch(lexoffice_exception $e) { 645 | if ($e->getMessage() == 'lexoffice-php-api: positive invoice count needed') { 646 | test_finished(true); 647 | } else { 648 | test($e->getMessage()); 649 | test(print_r($e->get_error(), true)); 650 | test_finished(false); 651 | } 652 | } 653 | 654 | 655 | test_start('invoice - get last -5 invoices'); 656 | try { 657 | $request = $lexoffice->get_last_invoices(-5); 658 | } catch(lexoffice_exception $e) { 659 | if ($e->getMessage() == 'lexoffice-php-api: positive invoice count needed') { 660 | test_finished(true); 661 | } else { 662 | test($e->getMessage()); 663 | test(print_r($e->get_error(), true)); 664 | test_finished(false); 665 | } 666 | } 667 | 668 | test_start('invoice - get last 20 invoices'); 669 | try { 670 | $request = $lexoffice->get_last_invoices(20); 671 | if (count($request) == 20) { 672 | test_finished(true); 673 | } else { 674 | test_finished(false); 675 | } 676 | } catch(lexoffice_exception $e) { 677 | if ($e->getMessage() == 'lexoffice-php-api: positive invoice count needed') { 678 | test_finished(true); 679 | } else { 680 | test($e->getMessage()); 681 | test(print_r($e->get_error(), true)); 682 | test_finished(false); 683 | } 684 | } 685 | 686 | test_start('invoice - get last 100 invoices'); 687 | try { 688 | $request = $lexoffice->get_last_invoices(100); 689 | if (count($request) == 100) { 690 | test_finished(true); 691 | } else { 692 | test_finished(false); 693 | } 694 | } catch(lexoffice_exception $e) { 695 | if ($e->getMessage() == 'lexoffice-php-api: positive invoice count needed') { 696 | test_finished(true); 697 | } else { 698 | test($e->getMessage()); 699 | test(print_r($e->get_error(), true)); 700 | test_finished(false); 701 | } 702 | } 703 | 704 | test_start('invoice - get last 120 invoices'); 705 | try { 706 | $request = $lexoffice->get_last_invoices(120); 707 | if (count($request) == 120) { 708 | test_finished(true); 709 | } else { 710 | test_finished(false); 711 | } 712 | } catch(lexoffice_exception $e) { 713 | if ($e->getMessage() == 'lexoffice-php-api: positive invoice count needed') { 714 | test_finished(true); 715 | } else { 716 | test($e->getMessage()); 717 | test(print_r($e->get_error(), true)); 718 | test_finished(false); 719 | } 720 | } 721 | 722 | test_start('invoice - get last '.$max_invoices_in_test_account.' invoices'); 723 | try { 724 | $request = $lexoffice->get_last_invoices($max_invoices_in_test_account); 725 | if (count($request) == $max_invoices_in_test_account) { 726 | test_finished(true); 727 | } else { 728 | test_finished(false); 729 | } 730 | } catch(lexoffice_exception $e) { 731 | if ($e->getMessage() == 'lexoffice-php-api: positive invoice count needed') { 732 | test_finished(true); 733 | } else { 734 | test($e->getMessage()); 735 | test(print_r($e->get_error(), true)); 736 | test_finished(false); 737 | } 738 | } 739 | 740 | test_start('invoice - 19% UST position with special chars in product'); 741 | try { 742 | $request = $lexoffice->create_invoice([ 743 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 744 | 'introduction' => 'Einleitungstext', 745 | 'remark' => "Fußzeile\r\nMehrzeilig", 746 | 'address' => [ 747 | #'contactId' => '', 748 | 'name' => 'Frau Jane Doe', 749 | 'street' => 'Str. 1', 750 | 'zip' => '12345', 751 | 'city' => 'Stadt', 752 | 'countryCode' => 'DE', 753 | ], 754 | 'lineItems' => [ 755 | [ 756 | 'type' => 'custom', 757 | 'name' => 'WEBINAR BLUB ABC - Duminică, 01.01.2000 la ora 13.00', 758 | 'description' => 'WEBINAR BLUB ABC - Duminică, 01.01.2000 la ora 13.00', 759 | 'quantity' => 1, 760 | 'unitName' => 'Stück', 761 | 'unitPrice' => [ 762 | 'currency' => 'EUR', 763 | 'netAmount' => 11.99, 764 | 'taxRatePercentage' => $taxrate_19, 765 | ], 766 | #'discountPercentage' => 0, 767 | ], 768 | ], 769 | 'totalPrice' => [ 770 | 'currency' => 'EUR', 771 | #'totalDiscountAbsolute' => 0, 772 | #'totalDiscountPercentage' => 0, 773 | ], 774 | 'taxConditions' => [ 775 | 'taxType' => 'net', 776 | ], 777 | 'shippingConditions' => [ 778 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 779 | 'shippingType' => 'delivery', 780 | ], 781 | 'paymentConditions' => [ 782 | 'paymentTermLabel' => 'Vorkasse', 783 | 'paymentTermDuration' => 1, 784 | ], 785 | ], true); 786 | 787 | if ($request->id) { 788 | test('invoice created - id: '.$request->id); 789 | 790 | test_finished(true); 791 | } else { 792 | test_finished(false); 793 | } 794 | } catch(lexoffice_exception $e) { 795 | test($e->getMessage()); 796 | test(print_r($e->get_error(), true)); 797 | test_finished(false); 798 | } 799 | 800 | /** only for special tests 801 | * generate big amount ofg invoices to test webhooks 802 | */ 803 | /* 804 | $amount = 50; 805 | test_start('big amount of '.$amount.' invoices - 19% UST position'); 806 | try { 807 | for ($i = 0; $i < $amount; $i++) { 808 | $request = $lexoffice->create_invoice([ 809 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 810 | 'introduction' => 'Einleitungstext', 811 | 'remark' => "Fußzeile\r\nMehrzeilig", 812 | 'address' => [ 813 | #'contactId' => '', 814 | 'name' => 'Frau Jane Doe', 815 | 'street' => 'Str. 1', 816 | 'zip' => '12345', 817 | 'city' => 'Stadt', 818 | 'countryCode' => 'DE', 819 | ], 820 | 'lineItems' => [ 821 | [ 822 | 'type' => 'custom', 823 | 'name' => 'Produktname', 824 | 'description' => 'Beschreibung', 825 | 'quantity' => 1, 826 | 'unitName' => 'Stück', 827 | 'unitPrice' => [ 828 | 'currency' => 'EUR', 829 | 'netAmount' => 11.99, 830 | 'taxRatePercentage' => $taxrate_19, 831 | ], 832 | #'discountPercentage' => 0, 833 | ], 834 | ], 835 | 'totalPrice' => [ 836 | 'currency' => 'EUR', 837 | #'totalDiscountAbsolute' => 0, 838 | #'totalDiscountPercentage' => 0, 839 | ], 840 | 'taxConditions' => [ 841 | 'taxType' => 'net', 842 | ], 843 | 'shippingConditions' => [ 844 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 845 | 'shippingType' => 'delivery', 846 | ], 847 | 'paymentConditions' => [ 848 | 'paymentTermLabel' => 'Vorkasse', 849 | 'paymentTermDuration' => 1, 850 | ], 851 | ], true); 852 | 853 | if (!isset($request->id) || empty($request->id)) { 854 | test_finished(false); 855 | } 856 | } 857 | } catch(lexoffice_exception $e) { 858 | test($e->getMessage()); 859 | test(print_r($e->get_error(), true)); 860 | test_finished(false); 861 | } 862 | test_finished(true); 863 | */ -------------------------------------------------------------------------------- /tests/tests/003_profile.php: -------------------------------------------------------------------------------- 1 | get_profile(); 5 | if (isset($request->organizationId) && !empty($request->organizationId)) { 6 | test_finished(true); 7 | } else { 8 | test_finished(false); 9 | } 10 | } catch (lexoffice_exception $e) { 11 | test($e->getMessage()); 12 | test(print_r($e->get_error(), true)); 13 | test_finished(false); 14 | } -------------------------------------------------------------------------------- /tests/tests/005_invoice_specific_contact.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | // use random name, use it in later search check 15 | 'name' => $random_contact_name, 16 | 'street' => 'Brink 1', 17 | 'zip' => '51647', 18 | 'city' => 'Gummersbach', 19 | 'countryCode' => 'DE', 20 | 'contactPersons' => array( 21 | array( 22 | 'salutation' => 'Herr', 23 | 'firstName' => 'John', 24 | 'lastName' => 'Doe', 25 | 'emailAddress' =>'support@baebeca.de', 26 | 'phoneNumber' => '022619202930', 27 | ) 28 | ), 29 | ), 30 | 'addresses' => array( 31 | 'billing' => array( 32 | array( 33 | 'street' => 'Brink 1', 34 | 'zip' => '51647', 35 | 'city' => 'Gummersbach', 36 | 'countryCode' => 'DE', 37 | ), 38 | ), 39 | 'shipping' => array( 40 | array( 41 | 'street' => 'Brink 1', 42 | 'zip' => '51647', 43 | 'city' => 'Gummersbach', 44 | 'countryCode' => 'DE', 45 | ), 46 | ), 47 | ), 48 | 'emailAddresses' => array( 49 | 'business' => array( 50 | 'support@baebeca.de' 51 | ), 52 | ), 53 | 'phoneNumbers' => array( 54 | 'business' => array( 55 | '022619202930' 56 | ), 57 | ), 58 | 'note' => '', 59 | )); 60 | 61 | if ($request->id) { 62 | try { 63 | $request = $lexoffice->create_invoice([ 64 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 65 | 'introduction' => 'Einleitungstext', 66 | 'remark' => "Fußzeile\r\nMehrzeilig", 67 | 'address' => [ 68 | 'contactId' => $request->id, 69 | ], 70 | 'lineItems' => [ 71 | [ 72 | 'type' => 'custom', 73 | 'name' => 'Produktname', 74 | 'description' => 'Beschreibung', 75 | 'quantity' => 1, 76 | 'unitName' => 'Stück', 77 | 'unitPrice' => [ 78 | 'currency' => 'EUR', 79 | 'netAmount' => 11.99, 80 | 'taxRatePercentage' => $taxrate_19, 81 | ], 82 | #'discountPercentage' => 0, 83 | ], 84 | ], 85 | 'totalPrice' => [ 86 | 'currency' => 'EUR', 87 | #'totalDiscountAbsolute' => 0, 88 | #'totalDiscountPercentage' => 0, 89 | ], 90 | 'taxConditions' => [ 91 | 'taxType' => 'net', 92 | ], 93 | 'shippingConditions' => [ 94 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 95 | 'shippingType' => 'delivery', 96 | ], 97 | 'paymentConditions' => [ 98 | 'paymentTermLabel' => 'Vorkasse', 99 | 'paymentTermDuration' => 1, 100 | ], 101 | ], true); 102 | 103 | if ($request->id) { 104 | test('invoice created - id: '.$request->id); 105 | test_finished(true); 106 | } else { 107 | test_finished(false); 108 | } 109 | } catch(lexoffice_exception $e) { 110 | test($e->getMessage()); 111 | test(print_r($e->get_error(), true)); 112 | test_finished(false); 113 | } 114 | } else { 115 | test_finished(false); 116 | } 117 | 118 | } catch(lexoffice_exception $e) { 119 | test($e->getMessage()); 120 | test(print_r($e->get_error(), true)); 121 | test_finished(false); 122 | } 123 | -------------------------------------------------------------------------------- /tests/tests/006_files.php: -------------------------------------------------------------------------------- 1 | upload_file(__DIR__.'\files\cat.jpg'); 6 | 7 | if ($request->id) { 8 | test('file id: '.$request->id); 9 | test_finished(true); 10 | } else { 11 | test_finished(false); 12 | } 13 | 14 | } catch(lexoffice_exception $e) { 15 | test($e->getMessage()); 16 | test(print_r($e->get_error(), true)); 17 | test_finished(false); 18 | } 19 | 20 | test_start('upload big voucher'); 21 | try { 22 | $request = $lexoffice->upload_file(__DIR__.'\files\cat_5245kb.jpg'); 23 | test_finished(false); 24 | 25 | } catch(lexoffice_exception $e) { 26 | if ($e->getMessage() == 'lexoffice-php-api: filesize to big') { 27 | test_finished(true); 28 | } else { 29 | test($e->getMessage()); 30 | test(print_r($e->get_error(), true)); 31 | test_finished(false); 32 | } 33 | } 34 | 35 | test_start('upload voucher pdf from an X-Rechnung'); 36 | try { 37 | $request = $lexoffice->upload_file(__DIR__.'\files\XRechnung-sample.pdf'); 38 | if ($request->id) { 39 | test('file id: '.$request->id); 40 | test_finished(true); 41 | } else { 42 | test_finished(false); 43 | } 44 | 45 | } catch(lexoffice_exception $e) { 46 | test($e->getMessage()); 47 | test(print_r($e->get_error(), true)); 48 | test_finished(false); 49 | } 50 | 51 | test_start('upload voucher xml from an X-Rechnung'); 52 | try { 53 | $request = $lexoffice->upload_file(__DIR__.'\files\XRechnung-sample.xml'); 54 | if ($request->id) { 55 | test('file id: '.$request->id); 56 | test_finished(true); 57 | } else { 58 | test_finished(false); 59 | } 60 | 61 | } catch(lexoffice_exception $e) { 62 | test($e->getMessage()); 63 | test(print_r($e->get_error(), true)); 64 | test_finished(false); 65 | } 66 | 67 | test_start('upload not existing voucher'); 68 | try { 69 | $request = $lexoffice->upload_file(__DIR__.'\files\1337.jpg'); 70 | test_finished(false); 71 | 72 | } catch(lexoffice_exception $e) { 73 | if ($e->getMessage() == 'lexoffice-php-api: file does not exist') { 74 | test_finished(true); 75 | } else { 76 | test($e->getMessage()); 77 | test(print_r($e->get_error(), true)); 78 | test_finished(false); 79 | } 80 | } 81 | 82 | test_start('upload invalid mime type'); 83 | try { 84 | $request = $lexoffice->upload_file(__DIR__.'\files\libssh2.dll'); 85 | test_finished(false); 86 | 87 | } catch(lexoffice_exception $e) { 88 | if ($e->getMessage() == 'lexoffice-php-api: invalid mime type') { 89 | test_finished(true); 90 | } else { 91 | test($e->getMessage()); 92 | test(print_r($e->get_error(), true)); 93 | test_finished(false); 94 | } 95 | } 96 | 97 | test_start('upload jpg without extension'); 98 | try { 99 | $request = $lexoffice->upload_file(__DIR__.'\files\cat_without_extension'); 100 | if ($request->id) { 101 | test('file id: '.$request->id); 102 | test_finished(true); 103 | } else { 104 | test_finished(false); 105 | } 106 | 107 | } catch(lexoffice_exception $e) { 108 | test($e->getMessage()); 109 | test(print_r($e->get_error(), true)); 110 | test_finished(false); 111 | } 112 | 113 | -------------------------------------------------------------------------------- /tests/tests/007_quotations.php: -------------------------------------------------------------------------------- 1 | create_quotation([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'expirationDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 8 | 'introduction' => 'Einleitungstext', 9 | 'remark' => "Fußzeile\r\nMehrzeilig", 10 | 'address' => [ 11 | #'contactId' => '', 12 | 'name' => 'Frau Jane Doe', 13 | 'street' => 'Str. 1', 14 | 'zip' => '12345', 15 | 'city' => 'Stadt', 16 | 'countryCode' => 'DE', 17 | ], 18 | 'lineItems' => [ 19 | [ 20 | 'type' => 'text', 21 | 'name' => 'blub blub bub', 22 | 'description' => 'Beschreibung', 23 | ], 24 | [ 25 | 'type' => 'custom', 26 | 'name' => 'Produktname', 27 | 'description' => 'Beschreibung', 28 | 'quantity' => 1, 29 | 'unitName' => 'Stück', 30 | 'unitPrice' => [ 31 | 'currency' => 'EUR', 32 | 'netAmount' => 11.99, 33 | 'taxRatePercentage' => $taxrate_19, 34 | ], 35 | #'discountPercentage' => 0, 36 | ], 37 | [ 38 | 'type' => 'custom', 39 | 'name' => 'Produktname', 40 | 'description' => 'Beschreibung', 41 | 'quantity' => 1, 42 | 'unitName' => 'Stück', 43 | 'unitPrice' => [ 44 | 'currency' => 'EUR', 45 | 'netAmount' => -3.99, 46 | 'taxRatePercentage' => $taxrate_19, 47 | ], 48 | #'discountPercentage' => 0, 49 | ], 50 | ], 51 | 'totalPrice' => [ 52 | 'currency' => 'EUR', 53 | #'totalDiscountAbsolute' => 0, 54 | #'totalDiscountPercentage' => 0, 55 | ], 56 | 'taxConditions' => [ 57 | 'taxType' => 'net', 58 | ], 59 | 'shippingConditions' => [ 60 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 61 | 'shippingType' => 'delivery', 62 | ], 63 | 'paymentConditions' => [ 64 | 'paymentTermLabel' => 'Vorkasse', 65 | 'paymentTermDuration' => 1, 66 | ], 67 | ], true); 68 | 69 | if ($request->id) { 70 | test('quote created - id: '.$request->id); 71 | test_finished(true); 72 | } else { 73 | test_finished(false); 74 | } 75 | } catch(lexoffice_exception $e) { 76 | test($e->getMessage()); 77 | test(print_r($e->get_error(), true)); 78 | test_finished(false); 79 | } 80 | 81 | test_start('get a quoation'); 82 | try { 83 | // $request->id from previous call 84 | $request = $lexoffice->get_quotation($request->id); 85 | 86 | if ($request->id) { 87 | test_finished(true); 88 | } else { 89 | test_finished(false); 90 | } 91 | 92 | } catch(lexoffice_exception $e) { 93 | test($e->getMessage()); 94 | test(print_r($e->get_error(), true)); 95 | test_finished(false); 96 | } 97 | -------------------------------------------------------------------------------- /tests/tests/008_order_confirmations.php: -------------------------------------------------------------------------------- 1 | create_orderconfirmation([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'introduction' => 'Einleitungstext', 8 | 'remark' => "Fußzeile\r\nMehrzeilig", 9 | 'address' => [ 10 | #'contactId' => '', 11 | 'name' => 'Frau Jane Doe', 12 | 'street' => 'Str. 1', 13 | 'zip' => '12345', 14 | 'city' => 'Stadt', 15 | 'countryCode' => 'DE', 16 | ], 17 | 'lineItems' => [ 18 | [ 19 | 'type' => 'custom', 20 | 'name' => 'Produktname', 21 | 'description' => 'Beschreibung', 22 | 'quantity' => 1, 23 | 'unitName' => 'Stück', 24 | 'unitPrice' => [ 25 | 'currency' => 'EUR', 26 | 'netAmount' => 11.99, 27 | 'taxRatePercentage' => $taxrate_19, 28 | ], 29 | #'discountPercentage' => 0, 30 | ], 31 | ], 32 | 'totalPrice' => [ 33 | 'currency' => 'EUR', 34 | #'totalDiscountAbsolute' => 0, 35 | #'totalDiscountPercentage' => 0, 36 | ], 37 | 'taxConditions' => [ 38 | 'taxType' => 'net', 39 | ], 40 | 'shippingConditions' => [ 41 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 42 | 'shippingType' => 'delivery', 43 | ], 44 | 'paymentConditions' => [ 45 | 'paymentTermLabel' => 'Vorkasse', 46 | 'paymentTermDuration' => 1, 47 | ], 48 | ]); 49 | 50 | if ($request->id) { 51 | test('order_confirmation created - id: '.$request->id); 52 | test_finished(true); 53 | } else { 54 | test_finished(false); 55 | } 56 | } catch(lexoffice_exception $e) { 57 | test($e->getMessage()); 58 | test(print_r($e->get_error(), true)); 59 | test_finished(false); 60 | } 61 | 62 | test_start('create order_confirmation with contact'); 63 | try { 64 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 65 | try { 66 | $request_contact = $lexoffice->create_contact(array( 67 | 'version' => 0, 68 | 'roles' => array( 69 | 'customer' => array( 70 | 'number' => '', 71 | ), 72 | ), 73 | 'company' => array( 74 | // use random name, use it in later search check 75 | 'name' => $random_contact_name, 76 | 'street' => 'Brink 1', 77 | 'zip' => '51647', 78 | 'city' => 'Gummersbach', 79 | 'countryCode' => 'DE', 80 | 'contactPersons' => array( 81 | array( 82 | 'salutation' => 'Herr', 83 | 'firstName' => 'John', 84 | 'lastName' => 'Doe', 85 | 'emailAddress' =>'support@baebeca.de', 86 | 'phoneNumber' => '022619202930', 87 | ) 88 | ), 89 | ), 90 | 'addresses' => array( 91 | 'billing' => array( 92 | array( 93 | 'street' => 'Brink 1', 94 | 'zip' => '51647', 95 | 'city' => 'Gummersbach', 96 | 'countryCode' => 'DE', 97 | ), 98 | ), 99 | 'shipping' => array( 100 | array( 101 | 'street' => 'Brink 1', 102 | 'zip' => '51647', 103 | 'city' => 'Gummersbach', 104 | 'countryCode' => 'DE', 105 | ), 106 | ), 107 | ), 108 | 'emailAddresses' => array( 109 | 'business' => array( 110 | 'support@baebeca.de' 111 | ), 112 | ), 113 | 'phoneNumbers' => array( 114 | 'business' => array( 115 | '022619202930' 116 | ), 117 | ), 118 | 'note' => '', 119 | )); 120 | 121 | if (!$request_contact->id) { 122 | test_finished(false); 123 | } 124 | 125 | } catch(lexoffice_exception $e) { 126 | test($e->getMessage()); 127 | test(print_r($e->get_error(), true)); 128 | test_finished(false); 129 | } 130 | 131 | 132 | $request = $lexoffice->create_orderconfirmation([ 133 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 134 | 'introduction' => 'Einleitungstext', 135 | 'remark' => "Fußzeile\r\nMehrzeilig", 136 | 'address' => [ 137 | 'contactId' => $request_contact->id, 138 | ], 139 | 'lineItems' => [ 140 | [ 141 | 'type' => 'custom', 142 | 'name' => 'Produktname', 143 | 'description' => 'Beschreibung', 144 | 'quantity' => 1, 145 | 'unitName' => 'Stück', 146 | 'unitPrice' => [ 147 | 'currency' => 'EUR', 148 | 'netAmount' => 11.99, 149 | 'taxRatePercentage' => $taxrate_19, 150 | ], 151 | #'discountPercentage' => 0, 152 | ], 153 | ], 154 | 'totalPrice' => [ 155 | 'currency' => 'EUR', 156 | #'totalDiscountAbsolute' => 0, 157 | #'totalDiscountPercentage' => 0, 158 | ], 159 | 'taxConditions' => [ 160 | 'taxType' => 'net', 161 | ], 162 | 'shippingConditions' => [ 163 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 164 | 'shippingType' => 'delivery', 165 | ], 166 | 'paymentConditions' => [ 167 | 'paymentTermLabel' => 'Vorkasse', 168 | 'paymentTermDuration' => 1, 169 | ], 170 | ]); 171 | 172 | if ($request->id) { 173 | test('order_confirmation created - id: '.$request->id); 174 | test_finished(true); 175 | } else { 176 | test_finished(false); 177 | } 178 | } catch(lexoffice_exception $e) { 179 | test($e->getMessage()); 180 | test(print_r($e->get_error(), true)); 181 | test_finished(false); 182 | } 183 | 184 | test_start('order_confirmation - 0% UST position'); 185 | try { 186 | $request = $lexoffice->create_orderconfirmation([ 187 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 188 | 'introduction' => 'Einleitungstext', 189 | 'remark' => "Fußzeile\r\nMehrzeilig", 190 | 'address' => [ 191 | #'contactId' => '', 192 | 'name' => 'Frau Jane Doe', 193 | 'street' => 'Str. 1', 194 | 'zip' => '12345', 195 | 'city' => 'Stadt', 196 | 'countryCode' => 'DE', 197 | ], 198 | 'lineItems' => [ 199 | [ 200 | 'type' => 'custom', 201 | 'name' => 'Produktname', 202 | 'description' => 'Beschreibung', 203 | 'quantity' => 1, 204 | 'unitName' => 'Stück', 205 | 'unitPrice' => [ 206 | 'currency' => 'EUR', 207 | 'netAmount' => 11.99, 208 | 'taxRatePercentage' => 0, 209 | ], 210 | #'discountPercentage' => 0, 211 | ], 212 | ], 213 | 'totalPrice' => [ 214 | 'currency' => 'EUR', 215 | #'totalDiscountAbsolute' => 0, 216 | #'totalDiscountPercentage' => 0, 217 | ], 218 | 'taxConditions' => [ 219 | 'taxType' => 'net', 220 | ], 221 | 'shippingConditions' => [ 222 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 223 | 'shippingType' => 'delivery', 224 | ], 225 | 'paymentConditions' => [ 226 | 'paymentTermLabel' => 'Vorkasse', 227 | 'paymentTermDuration' => 1, 228 | ], 229 | ]); 230 | 231 | if ($request->id) { 232 | test('order_confirmation created - id: '.$request->id); 233 | 234 | test_finished(true); 235 | } else { 236 | test_finished(false); 237 | } 238 | } catch(lexoffice_exception $e) { 239 | test($e->getMessage()); 240 | test(print_r($e->get_error(), true)); 241 | test_finished(false); 242 | } 243 | 244 | 245 | test_start('order_confirmation - 7% UST position'); 246 | try { 247 | $request = $lexoffice->create_orderconfirmation([ 248 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 249 | 'introduction' => 'Einleitungstext', 250 | 'remark' => "Fußzeile\r\nMehrzeilig", 251 | 'address' => [ 252 | #'contactId' => '', 253 | 'name' => 'Frau Jane Doe', 254 | 'street' => 'Str. 1', 255 | 'zip' => '12345', 256 | 'city' => 'Stadt', 257 | 'countryCode' => 'DE', 258 | ], 259 | 'lineItems' => [ 260 | [ 261 | 'type' => 'custom', 262 | 'name' => 'Produktname', 263 | 'description' => 'Beschreibung', 264 | 'quantity' => 1, 265 | 'unitName' => 'Stück', 266 | 'unitPrice' => [ 267 | 'currency' => 'EUR', 268 | 'netAmount' => 11.99, 269 | 'taxRatePercentage' => $taxrate_7, 270 | ], 271 | #'discountPercentage' => 0, 272 | ], 273 | ], 274 | 'totalPrice' => [ 275 | 'currency' => 'EUR', 276 | #'totalDiscountAbsolute' => 0, 277 | #'totalDiscountPercentage' => 0, 278 | ], 279 | 'taxConditions' => [ 280 | 'taxType' => 'net', 281 | ], 282 | 'shippingConditions' => [ 283 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 284 | 'shippingType' => 'delivery', 285 | ], 286 | 'paymentConditions' => [ 287 | 'paymentTermLabel' => 'Vorkasse', 288 | 'paymentTermDuration' => 1, 289 | ], 290 | ]); 291 | 292 | if ($request->id) { 293 | test('order_confirmation created - id: '.$request->id); 294 | 295 | test_finished(true); 296 | } else { 297 | test_finished(false); 298 | } 299 | } catch(lexoffice_exception $e) { 300 | test($e->getMessage()); 301 | test(print_r($e->get_error(), true)); 302 | test_finished(false); 303 | } 304 | 305 | test_start('invoice - 19% UST position'); 306 | try { 307 | $request = $lexoffice->create_orderconfirmation([ 308 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 309 | 'introduction' => 'Einleitungstext', 310 | 'remark' => "Fußzeile\r\nMehrzeilig", 311 | 'address' => [ 312 | #'contactId' => '', 313 | 'name' => 'Frau Jane Doe', 314 | 'street' => 'Str. 1', 315 | 'zip' => '12345', 316 | 'city' => 'Stadt', 317 | 'countryCode' => 'DE', 318 | ], 319 | 'lineItems' => [ 320 | [ 321 | 'type' => 'custom', 322 | 'name' => 'Produktname', 323 | 'description' => 'Beschreibung', 324 | 'quantity' => 1, 325 | 'unitName' => 'Stück', 326 | 'unitPrice' => [ 327 | 'currency' => 'EUR', 328 | 'netAmount' => 11.99, 329 | 'taxRatePercentage' => $taxrate_19, 330 | ], 331 | #'discountPercentage' => 0, 332 | ], 333 | ], 334 | 'totalPrice' => [ 335 | 'currency' => 'EUR', 336 | #'totalDiscountAbsolute' => 0, 337 | #'totalDiscountPercentage' => 0, 338 | ], 339 | 'taxConditions' => [ 340 | 'taxType' => 'net', 341 | ], 342 | 'shippingConditions' => [ 343 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 344 | 'shippingType' => 'delivery', 345 | ], 346 | 'paymentConditions' => [ 347 | 'paymentTermLabel' => 'Vorkasse', 348 | 'paymentTermDuration' => 1, 349 | ], 350 | ]); 351 | 352 | if ($request->id) { 353 | test('order_confirmation created - id: '.$request->id); 354 | 355 | test_finished(true); 356 | } else { 357 | test_finished(false); 358 | } 359 | } catch(lexoffice_exception $e) { 360 | test($e->getMessage()); 361 | test(print_r($e->get_error(), true)); 362 | test_finished(false); 363 | } 364 | 365 | 366 | test_start('order_confirmation - 0%, 19, 7% UST position'); 367 | try { 368 | $request = $lexoffice->create_orderconfirmation([ 369 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 370 | 'introduction' => 'Einleitungstext', 371 | 'remark' => "Fußzeile\r\nMehrzeilig", 372 | 'address' => [ 373 | #'contactId' => '', 374 | 'name' => 'Frau Jane Doe', 375 | 'street' => 'Str. 1', 376 | 'zip' => '12345', 377 | 'city' => 'Stadt', 378 | 'countryCode' => 'DE', 379 | ], 380 | 'lineItems' => [ 381 | [ 382 | 'type' => 'custom', 383 | 'name' => 'Produktname', 384 | 'description' => 'Beschreibung', 385 | 'quantity' => 1, 386 | 'unitName' => 'Stück', 387 | 'unitPrice' => [ 388 | 'currency' => 'EUR', 389 | 'netAmount' => 11.99, 390 | 'taxRatePercentage' => 0, 391 | ], 392 | #'discountPercentage' => 0, 393 | ], 394 | [ 395 | 'type' => 'custom', 396 | 'name' => 'Produktname', 397 | 'description' => 'Beschreibung', 398 | 'quantity' => 1, 399 | 'unitName' => 'Stück', 400 | 'unitPrice' => [ 401 | 'currency' => 'EUR', 402 | 'netAmount' => 11.99, 403 | 'taxRatePercentage' => $taxrate_7, 404 | ], 405 | #'discountPercentage' => 0, 406 | ], 407 | [ 408 | 'type' => 'custom', 409 | 'name' => 'Produktname', 410 | 'description' => 'Beschreibung', 411 | 'quantity' => 1, 412 | 'unitName' => 'Stück', 413 | 'unitPrice' => [ 414 | 'currency' => 'EUR', 415 | 'netAmount' => 11.99, 416 | 'taxRatePercentage' => $taxrate_19, 417 | ], 418 | #'discountPercentage' => 0, 419 | ], 420 | ], 421 | 'totalPrice' => [ 422 | 'currency' => 'EUR', 423 | #'totalDiscountAbsolute' => 0, 424 | #'totalDiscountPercentage' => 0, 425 | ], 426 | 'taxConditions' => [ 427 | 'taxType' => 'net', 428 | ], 429 | 'shippingConditions' => [ 430 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 431 | 'shippingType' => 'delivery', 432 | ], 433 | 'paymentConditions' => [ 434 | 'paymentTermLabel' => 'Vorkasse', 435 | 'paymentTermDuration' => 1, 436 | ], 437 | ]); 438 | 439 | if ($request->id) { 440 | test('order_confirmation created - id: '.$request->id); 441 | 442 | test_finished(true); 443 | } else { 444 | test_finished(false); 445 | } 446 | } catch(lexoffice_exception $e) { 447 | test($e->getMessage()); 448 | test(print_r($e->get_error(), true)); 449 | test_finished(false); 450 | } 451 | 452 | test_start('order_confirmation - negative amount position'); 453 | try { 454 | $request = $lexoffice->create_orderconfirmation([ 455 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 456 | 'introduction' => 'Einleitungstext', 457 | 'remark' => "Fußzeile\r\nMehrzeilig", 458 | 'address' => [ 459 | #'contactId' => '', 460 | 'name' => 'Frau Jane Doe', 461 | 'street' => 'Str. 1', 462 | 'zip' => '12345', 463 | 'city' => 'Stadt', 464 | 'countryCode' => 'DE', 465 | ], 466 | 'lineItems' => [ 467 | [ 468 | 'type' => 'custom', 469 | 'name' => 'Produktname', 470 | 'description' => 'Beschreibung', 471 | 'quantity' => 1, 472 | 'unitName' => 'Stück', 473 | 'unitPrice' => [ 474 | 'currency' => 'EUR', 475 | 'netAmount' => 11.99, 476 | 'taxRatePercentage' => $taxrate_19, 477 | ], 478 | #'discountPercentage' => 0, 479 | ], 480 | [ 481 | 'type' => 'custom', 482 | 'name' => 'Produktname', 483 | 'description' => 'Beschreibung', 484 | 'quantity' => 1, 485 | 'unitName' => 'Stück', 486 | 'unitPrice' => [ 487 | 'currency' => 'EUR', 488 | 'netAmount' => -11.99, 489 | 'taxRatePercentage' => $taxrate_19, 490 | ], 491 | #'discountPercentage' => 0, 492 | ], 493 | [ 494 | 'type' => 'custom', 495 | 'name' => 'Produktname', 496 | 'description' => 'Beschreibung', 497 | 'quantity' => 1, 498 | 'unitName' => 'Stück', 499 | 'unitPrice' => [ 500 | 'currency' => 'EUR', 501 | 'netAmount' => 3.99, 502 | 'taxRatePercentage' => $taxrate_19, 503 | ], 504 | #'discountPercentage' => 0, 505 | ], 506 | ], 507 | 'totalPrice' => [ 508 | 'currency' => 'EUR', 509 | #'totalDiscountAbsolute' => 0, 510 | #'totalDiscountPercentage' => 0, 511 | ], 512 | 'taxConditions' => [ 513 | 'taxType' => 'net', 514 | ], 515 | 'shippingConditions' => [ 516 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 517 | 'shippingType' => 'delivery', 518 | ], 519 | 'paymentConditions' => [ 520 | 'paymentTermLabel' => 'Vorkasse', 521 | 'paymentTermDuration' => 1, 522 | ], 523 | ], true); 524 | 525 | if ($request->id) { 526 | test('order_confirmation created - id: '.$request->id); 527 | 528 | test_finished(true); 529 | } else { 530 | test_finished(false); 531 | } 532 | } catch(lexoffice_exception $e) { 533 | test($e->getMessage()); 534 | test(print_r($e->get_error(), true)); 535 | test_finished(false); 536 | } 537 | 538 | test_start('order_confirmation - text position'); 539 | try { 540 | $request = $lexoffice->create_orderconfirmation([ 541 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 542 | 'introduction' => 'Einleitungstext', 543 | 'remark' => "Fußzeile\r\nMehrzeilig", 544 | 'address' => [ 545 | #'contactId' => '', 546 | 'name' => 'Frau Jane Doe', 547 | 'street' => 'Str. 1', 548 | 'zip' => '12345', 549 | 'city' => 'Stadt', 550 | 'countryCode' => 'DE', 551 | ], 552 | 'lineItems' => [ 553 | [ 554 | 'type' => 'text', 555 | 'name' => 'blub blub bub', 556 | 'description' => 'Beschreibung', 557 | ], 558 | [ 559 | 'type' => 'custom', 560 | 'name' => 'Produktname', 561 | 'description' => 'Beschreibung', 562 | 'quantity' => 1, 563 | 'unitName' => 'Stück', 564 | 'unitPrice' => [ 565 | 'currency' => 'EUR', 566 | 'netAmount' => 11.99, 567 | 'taxRatePercentage' => $taxrate_19, 568 | ], 569 | #'discountPercentage' => 0, 570 | ], 571 | [ 572 | 'type' => 'custom', 573 | 'name' => 'Produktname', 574 | 'description' => 'Beschreibung', 575 | 'quantity' => 1, 576 | 'unitName' => 'Stück', 577 | 'unitPrice' => [ 578 | 'currency' => 'EUR', 579 | 'netAmount' => -3.99, 580 | 'taxRatePercentage' => $taxrate_19, 581 | ], 582 | #'discountPercentage' => 0, 583 | ], 584 | ], 585 | 'totalPrice' => [ 586 | 'currency' => 'EUR', 587 | #'totalDiscountAbsolute' => 0, 588 | #'totalDiscountPercentage' => 0, 589 | ], 590 | 'taxConditions' => [ 591 | 'taxType' => 'net', 592 | ], 593 | 'shippingConditions' => [ 594 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 595 | 'shippingType' => 'delivery', 596 | ], 597 | 'paymentConditions' => [ 598 | 'paymentTermLabel' => 'Vorkasse', 599 | 'paymentTermDuration' => 1, 600 | ], 601 | ]); 602 | 603 | if ($request->id) { 604 | test('order_confirmation created - id: '.$request->id); 605 | test_finished(true); 606 | } else { 607 | test_finished(false); 608 | } 609 | } catch(lexoffice_exception $e) { 610 | test($e->getMessage()); 611 | test(print_r($e->get_error(), true)); 612 | test_finished(false); 613 | } 614 | 615 | -------------------------------------------------------------------------------- /tests/tests/009_dunnings.php: -------------------------------------------------------------------------------- 1 | create_invoice([ 5 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 6 | 'introduction' => 'Einleitungstext', 7 | 'remark' => "Fußzeile\r\nMehrzeilig", 8 | 'address' => [ 9 | #'contactId' => '', 10 | 'name' => 'Frau Jane Doe', 11 | 'street' => 'Str. 1', 12 | 'zip' => '12345', 13 | 'city' => 'Stadt', 14 | 'countryCode' => 'DE', 15 | ], 16 | 'lineItems' => [ 17 | [ 18 | 'type' => 'custom', 19 | 'name' => 'Produktname', 20 | 'description' => 'Beschreibung', 21 | 'quantity' => 1, 22 | 'unitName' => 'Stück', 23 | 'unitPrice' => [ 24 | 'currency' => 'EUR', 25 | 'netAmount' => 11.99, 26 | 'taxRatePercentage' => $taxrate_19, 27 | ], 28 | #'discountPercentage' => 0, 29 | ], 30 | ], 31 | 'totalPrice' => [ 32 | 'currency' => 'EUR', 33 | #'totalDiscountAbsolute' => 0, 34 | #'totalDiscountPercentage' => 0, 35 | ], 36 | 'taxConditions' => [ 37 | 'taxType' => 'net', 38 | ], 39 | 'shippingConditions' => [ 40 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 41 | 'shippingType' => 'delivery', 42 | ], 43 | 'paymentConditions' => [ 44 | 'paymentTermLabel' => 'Vorkasse', 45 | 'paymentTermDuration' => 1, 46 | ], 47 | ], true); 48 | 49 | if ($request->id) { 50 | test('invoice created - id: '.$request->id); 51 | 52 | test_finished(true); 53 | } else { 54 | test_finished(false); 55 | } 56 | } catch(lexoffice_exception $e) { 57 | test($e->getMessage()); 58 | test(print_r($e->get_error(), true)); 59 | test_finished(false); 60 | } 61 | 62 | 63 | test_start('create dunning from existing invoice'); 64 | try { 65 | $request = $lexoffice->create_dunning([ 66 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 67 | 'introduction' => 'Einleitungstext', 68 | 'remark' => "Fußzeile\r\nMehrzeilig", 69 | 'address' => [ 70 | #'contactId' => '', 71 | 'name' => 'Frau Jane Doe', 72 | 'street' => 'Str. 1', 73 | 'zip' => '12345', 74 | 'city' => 'Stadt', 75 | 'countryCode' => 'DE', 76 | ], 77 | 'lineItems' => [ 78 | [ 79 | 'type' => 'custom', 80 | 'name' => 'Produktname', 81 | 'description' => 'Beschreibung', 82 | 'quantity' => 1, 83 | 'unitName' => 'Stück', 84 | 'unitPrice' => [ 85 | 'currency' => 'EUR', 86 | 'netAmount' => 11.99, 87 | 'taxRatePercentage' => $taxrate_19, 88 | ], 89 | #'discountPercentage' => 0, 90 | ], 91 | ], 92 | 'totalPrice' => [ 93 | 'currency' => 'EUR', 94 | #'totalDiscountAbsolute' => 0, 95 | #'totalDiscountPercentage' => 0, 96 | ], 97 | 'taxConditions' => [ 98 | 'taxType' => 'net', 99 | ], 100 | 'shippingConditions' => [ 101 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 102 | 'shippingType' => 'delivery', 103 | ], 104 | 'paymentConditions' => [ 105 | 'paymentTermLabel' => 'Vorkasse', 106 | 'paymentTermDuration' => 1, 107 | ], 108 | ], $request->id); 109 | 110 | if ($request->id) { 111 | test('dunning created - id: '.$request->id); 112 | test_finished(true); 113 | } else { 114 | test_finished(false); 115 | } 116 | } catch(lexoffice_exception $e) { 117 | test($e->getMessage()); 118 | test(print_r($e->get_error(), true)); 119 | test_finished(false); 120 | } 121 | 122 | test_start('get dunning pdf'); 123 | @unlink(__DIR__.'/tmp/009_dunning.pdf'); 124 | if ($request->id) { 125 | test('download pdf and xml instantly without rendering'); 126 | $lexoffice->get_pdf('dunning', $request->id, __DIR__ . '/tmp/009_dunning.pdf'); 127 | if (is_file(__DIR__.'/tmp/009_dunning.pdf')) { 128 | unlink(__DIR__.'/tmp/009_dunning.pdf'); 129 | test_finished(true); 130 | } 131 | else { 132 | test_finished(false); 133 | } 134 | } else { 135 | test_finished(false); 136 | } -------------------------------------------------------------------------------- /tests/tests/010_error_handling.php: -------------------------------------------------------------------------------- 1 | create_invoice([ 5 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 6 | 'introduction' => 'Einleitungstext', 7 | 'remark' => "Fußzeile\r\nMehrzeilig", 8 | 'address' => [ 9 | #'contactId' => '', 10 | 'name' => 'Frau Jane Doe', 11 | 'street' => 'Str. 1', 12 | 'zip' => '12345', 13 | 'city' => 'Stadt', 14 | 'countryCode' => 'DE', 15 | ], 16 | 'lineItems' => [ 17 | [ 18 | 'type' => 'custom', 19 | 'name' => 'Produktname', 20 | 'description' => 'Beschreibung', 21 | 'quantity' => 1, 22 | 'unitName' => 'Stück', 23 | 'unitPrice' => [ 24 | 'currency' => 'EUR', 25 | 'netAmount' => 10.99, 26 | 'taxRatePercentage' => 19, 27 | ], 28 | #'discountPercentage' => 0, 29 | ], 30 | ], 31 | 'totalPrice' => [ 32 | 'currency' => 'EUR', 33 | #'totalDiscountAbsolute' => 0, 34 | #'totalDiscountPercentage' => 0, 35 | ], 36 | 'taxConditions' => [ 37 | 'taxType' => 'net', 38 | ], 39 | 'shippingConditions' => [ 40 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 41 | 'shippingType' => 'delivery', 42 | ], 43 | 'paymentConditions' => [ 44 | 'paymentTermLabel' => 'Vorkasse', 45 | 'paymentTermDuration' => 1, 46 | ], 47 | ], false); 48 | 49 | if ($request->id) { 50 | test('draft invoice created - id: '.$request->id); 51 | test('try download pdf'); 52 | try { 53 | $lexoffice->get_invoice_pdf($request->id, 'test.pdf'); 54 | } catch (lexoffice_exception $e) { 55 | test($e->getMessage()); 56 | if ($e->getMessage() == 'lexoffice-php-api: requested invoice is a draft. Cannot create/download pdf file. Check details via $e->get_error()') { 57 | test_finished(true); 58 | } else { 59 | test_finished(false); 60 | } 61 | } 62 | } else { 63 | test_finished(false); 64 | } 65 | } catch (lexoffice_exception $e) { 66 | test($e->getMessage()); 67 | test_finished(false); 68 | } 69 | -------------------------------------------------------------------------------- /tests/tests/011_oss_origin.php: -------------------------------------------------------------------------------- 1 | get_taxrates('ZZ', strtotime('2021-07-05')); 11 | if ($request['default'] === null) { 12 | test_finished(true); 13 | } else { 14 | var_dump($request); 15 | test_finished(false); 16 | } 17 | } 18 | catch (lexoffice_exception $e) { 19 | test($e->getMessage()); 20 | test_finished(false); 21 | } 22 | 23 | test_start('test taxrates country DE'); 24 | try { 25 | $request = $lexoffice->get_taxrates('DE', strtotime('2021-07-05')); 26 | if (!empty($request) && $request['default'] == 19 && in_array(7, $request['reduced'])) { 27 | test_finished(true); 28 | } else { 29 | test_finished(false); 30 | } 31 | } 32 | catch (lexoffice_exception $e) { 33 | test($e->getMessage()); 34 | test_finished(false); 35 | } 36 | 37 | test_start('test taxrates country nl - before oss'); 38 | try { 39 | $request = $lexoffice->get_taxrates('nl', strtotime('2021-06-05')); 40 | if (!empty($request) && $request['default'] == 19 && in_array(7, $request['reduced'])) { 41 | test_finished(true); 42 | } else { 43 | test_finished(false); 44 | } 45 | } 46 | catch (lexoffice_exception $e) { 47 | test($e->getMessage()); 48 | test_finished(false); 49 | } 50 | 51 | test_start('test taxrates country nl - after oss'); 52 | try { 53 | $request = $lexoffice->get_taxrates('nl', strtotime('2021-07-05')); 54 | if (!empty($request) && $request['default'] == 21 && in_array(9, $request['reduced'])) { 55 | test_finished(true); 56 | } else { 57 | test_finished(false); 58 | } 59 | } 60 | catch (lexoffice_exception $e) { 61 | test($e->getMessage()); 62 | test_finished(false); 63 | } 64 | 65 | test_start('test oss settings - DE'); 66 | try { 67 | $request = $lexoffice->is_oss_needed('DE', strtotime('2021-07-05')); 68 | if ($request === false) { 69 | test_finished(true); 70 | } else { 71 | test_finished(false); 72 | } 73 | } 74 | catch (lexoffice_exception $e) { 75 | test($e->getMessage()); 76 | test_finished(false); 77 | } 78 | 79 | test_start('test oss settings - NL'); 80 | try { 81 | $request = $lexoffice->is_oss_needed('NL', strtotime('2021-07-05')); 82 | if ($request === 'origin') { 83 | test_finished(true); 84 | } else { 85 | var_dump($request); 86 | test_finished(false); 87 | } 88 | } 89 | catch (lexoffice_exception $e) { 90 | test($e->getMessage()); 91 | test_finished(false); 92 | } 93 | 94 | test_start('test oss settings - NL - before oss'); 95 | try { 96 | $request = $lexoffice->is_oss_needed('NL', strtotime('2021-06-05')); 97 | if ($request === false) { 98 | test_finished(true); 99 | } else { 100 | test_finished(false); 101 | } 102 | } 103 | catch (lexoffice_exception $e) { 104 | test($e->getMessage()); 105 | test_finished(false); 106 | } 107 | 108 | test_start('test oss settings - ZZ'); 109 | try { 110 | $request = $lexoffice->is_oss_needed('ZZ', strtotime('2021-07-05')); 111 | if ($request === false) { 112 | test_finished(true); 113 | } else { 114 | test_finished(false); 115 | } 116 | } 117 | catch (lexoffice_exception $e) { 118 | test($e->getMessage()); 119 | test_finished(false); 120 | } 121 | 122 | test_start('test oss settings - GB'); 123 | try { 124 | $request = $lexoffice->is_oss_needed('GB', strtotime('2021-07-05')); 125 | if ($request === false) { 126 | test_finished(true); 127 | } else { 128 | test_finished(false); 129 | } 130 | } 131 | catch (lexoffice_exception $e) { 132 | test($e->getMessage()); 133 | test_finished(false); 134 | } 135 | 136 | test_start('test oss voucher category - GB'); 137 | try { 138 | $request = $lexoffice->get_oss_voucher_category('GB', strtotime('2021-07-05')); 139 | test_finished(false); 140 | } 141 | catch (lexoffice_exception $e) { 142 | if ($e->getMessage() === 'lexoffice-php-api: no possible OSS voucher category id') { 143 | test_finished(true); 144 | } else { 145 | test_finished(false); 146 | } 147 | } 148 | 149 | test_start('test oss voucher category - DE'); 150 | try { 151 | $request = $lexoffice->get_oss_voucher_category('DE', strtotime('2021-07-05')); 152 | test_finished(false); 153 | } 154 | catch (lexoffice_exception $e) { 155 | if ($e->getMessage() === 'lexoffice-php-api: no possible OSS voucher category id') { 156 | test_finished(true); 157 | } else { 158 | test_finished(false); 159 | } 160 | } 161 | 162 | test_start('test oss voucher category - NL, physical'); 163 | try { 164 | $request = $lexoffice->get_oss_voucher_category('NL', strtotime('2021-07-05'), 1); 165 | if ($request === '7c112b66-0565-479c-bc18-5845e080880a') { 166 | test_finished(true); 167 | } else { 168 | test_finished(false); 169 | } 170 | } 171 | catch (lexoffice_exception $e) { 172 | test($e->getMessage()); 173 | test_finished(false); 174 | } 175 | 176 | test_start('test oss voucher category - NL, service'); 177 | try { 178 | $request = $lexoffice->get_oss_voucher_category('NL', strtotime('2021-07-05'), 2); 179 | if ($request === 'd73b880f-c24a-41ea-a862-18d90e1c3d82') { 180 | test_finished(true); 181 | } else { 182 | test_finished(false); 183 | } 184 | } 185 | catch (lexoffice_exception $e) { 186 | test($e->getMessage()); 187 | test_finished(false); 188 | } 189 | 190 | test_start('check Innergemeinschaftliche Lieferung'); 191 | try { 192 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'PT', strtotime('2021-07-05'), true, true); 193 | if ($request === '9075a4e3-66de-4795-a016-3889feca0d20') { 194 | test_finished(true); 195 | } else { 196 | test_finished(false); 197 | } 198 | } 199 | catch (lexoffice_exception $e) { 200 | test(print_r($e->get_error(), true)); 201 | test_finished(false); 202 | } 203 | 204 | test_start('check Fernverkauf | vatid but not business, physical'); 205 | try { 206 | $request = $lexoffice->get_needed_voucher_booking_id(23, 'PT', strtotime('2021-07-05'), true, false, true); 207 | test_finished(false); 208 | } 209 | catch (lexoffice_exception $e) { 210 | test_finished($e->getMessage() === 'lexoffice-php-api: invalid OSS taxrate for given country'); 211 | } 212 | 213 | test_start('check Fernverkauf | vatid but not business, service'); 214 | try { 215 | $request = $lexoffice->get_needed_voucher_booking_id(23, 'PT', strtotime('2021-07-05'), true, false, false); 216 | test_finished(false); 217 | } 218 | catch (lexoffice_exception $e) { 219 | test_finished($e->getMessage() === 'lexoffice-php-api: invalid OSS taxrate for given country'); 220 | } 221 | 222 | end_oss_origin: -------------------------------------------------------------------------------- /tests/tests/012_tax.php: -------------------------------------------------------------------------------- 1 | is_european_member('de', strtotime('2021-06-27')); 5 | test('check DE'); 6 | if ($request) { 7 | test_finished(true); 8 | } else { 9 | test_finished(false); 10 | } 11 | } catch (lexoffice_exception $e) { 12 | test($e->getMessage()); 13 | test_finished(false); 14 | } 15 | 16 | test_start('check european member'); 17 | try { 18 | $request = $lexoffice->is_european_member('GB', strtotime('2021-06-27')); 19 | test('check GB'); 20 | if (!$request) { 21 | test_finished(true); 22 | } else { 23 | test_finished(false); 24 | } 25 | } catch (lexoffice_exception $e) { 26 | test($e->getMessage()); 27 | test_finished(false); 28 | } 29 | 30 | test_start('check taxrate Österreich'); 31 | try { 32 | $request = $lexoffice->check_taxrate(floatval(20), 'at', strtotime('2021-07-05')); 33 | test_finished($request); 34 | } 35 | catch (lexoffice_exception $e) { 36 | test($e->getMessage()); 37 | test_finished(false); 38 | } 39 | 40 | test_start('check taxrate DE 19% - ok'); 41 | try { 42 | $request = $lexoffice->check_taxrate(19, 'DE', strtotime('2020-06-04')); 43 | test_finished($request); 44 | } 45 | catch (lexoffice_exception $e) { 46 | test($e->getMessage()); 47 | test_finished(false); 48 | } 49 | 50 | test_start('check taxrate DE 19% - nok'); 51 | try { 52 | $request = $lexoffice->check_taxrate(19, 'DE', strtotime('2020-07-02')); 53 | test_finished(!$request); 54 | } 55 | catch (lexoffice_exception $e) { 56 | test($e->getMessage()); 57 | test_finished(false); 58 | } 59 | 60 | test_start('check taxrate DE 19% - ok'); 61 | try { 62 | $request = $lexoffice->check_taxrate(19, 'DE', strtotime('2021-06-04')); 63 | test_finished($request); 64 | } 65 | catch (lexoffice_exception $e) { 66 | test($e->getMessage()); 67 | test_finished(false); 68 | } 69 | 70 | test_start('check taxrate ES 22% - nok'); 71 | try { 72 | $request = $lexoffice->check_taxrate(22, 'ES', strtotime('2022-06-04')); 73 | test_finished(!$request); 74 | } 75 | catch (lexoffice_exception $e) { 76 | test($e->getMessage()); 77 | test_finished(false); 78 | } 79 | 80 | test_start('check taxrate DE 7% - ok'); 81 | try { 82 | $request = $lexoffice->check_taxrate(7, 'DE', strtotime('2020-06-04')); 83 | test_finished($request); 84 | } 85 | catch (lexoffice_exception $e) { 86 | test($e->getMessage()); 87 | test_finished(false); 88 | } 89 | 90 | test_start('check taxrate DE 7% - nok'); 91 | try { 92 | $request = $lexoffice->check_taxrate(7, 'DE', strtotime('2020-07-02')); 93 | test_finished(!$request); 94 | } 95 | catch (lexoffice_exception $e) { 96 | test($e->getMessage()); 97 | test_finished(false); 98 | } 99 | 100 | test_start('check taxrate DE 7% - ok'); 101 | try { 102 | $request = $lexoffice->check_taxrate(7, 'DE', strtotime('2021-06-04')); 103 | test_finished($request); 104 | } 105 | catch (lexoffice_exception $e) { 106 | test($e->getMessage()); 107 | test_finished(false); 108 | } 109 | 110 | test_start('check taxrate DE 16% - nok'); 111 | try { 112 | $request = $lexoffice->check_taxrate(16, 'DE', strtotime('2020-01-01')); 113 | test_finished(!$request); 114 | } 115 | catch (lexoffice_exception $e) { 116 | test($e->getMessage()); 117 | test_finished(false); 118 | } 119 | 120 | test_start('check taxrate DE 16% - ok'); 121 | try { 122 | $request = $lexoffice->check_taxrate(16, 'DE', strtotime('2020-07-04')); 123 | test_finished($request); 124 | } 125 | catch (lexoffice_exception $e) { 126 | test($e->getMessage()); 127 | test_finished(false); 128 | } 129 | 130 | test_start('check taxrate DE 16% - nok'); 131 | try { 132 | $request = $lexoffice->check_taxrate(16, 'DE', strtotime('2021-01-01')); 133 | test_finished(!$request); 134 | } 135 | catch (lexoffice_exception $e) { 136 | test($e->getMessage()); 137 | test_finished(false); 138 | } 139 | 140 | test_start('check taxrate DE 5% - nok'); 141 | try { 142 | $request = $lexoffice->check_taxrate(5, 'DE', strtotime('2020-01-01')); 143 | test_finished(!$request); 144 | } 145 | catch (lexoffice_exception $e) { 146 | test($e->getMessage()); 147 | test_finished(false); 148 | } 149 | 150 | test_start('check taxrate DE 5% - ok'); 151 | try { 152 | $request = $lexoffice->check_taxrate(5, 'DE', strtotime('2020-07-04')); 153 | test_finished($request); 154 | } 155 | catch (lexoffice_exception $e) { 156 | test($e->getMessage()); 157 | test_finished(false); 158 | } 159 | 160 | test_start('check taxrate DE 5% - nok'); 161 | try { 162 | $request = $lexoffice->check_taxrate(5, 'DE', strtotime('2021-01-01')); 163 | test_finished(!$request); 164 | } 165 | catch (lexoffice_exception $e) { 166 | test($e->getMessage()); 167 | test_finished(false); 168 | } -------------------------------------------------------------------------------- /tests/tests/013_contacts_create_big_amount.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 13 | 'version' => 0, 14 | 'roles' => array( 15 | 'customer' => array( 16 | 'number' => '', 17 | ), 18 | ), 19 | 'company' => array( 20 | // use random name, use it in later search check 21 | 'name' => $random_contact_name, 22 | 'street' => 'Brink 1', 23 | 'zip' => '51647', 24 | 'city' => 'Gummersbach', 25 | 'countryCode' => 'DE', 26 | 'contactPersons' => array( 27 | array( 28 | 'salutation' => 'Herr', 29 | 'firstName' => 'John', 30 | 'lastName' => 'Doe', 31 | 'emailAddress' =>'support@baebeca.de', 32 | 'phoneNumber' => '022619202930', 33 | ) 34 | ), 35 | ), 36 | 'addresses' => array( 37 | 'billing' => array( 38 | array( 39 | 'street' => 'Brink 1', 40 | 'zip' => '51647', 41 | 'city' => 'Gummersbach', 42 | 'countryCode' => 'DE', 43 | ), 44 | ), 45 | 'shipping' => array( 46 | array( 47 | 'street' => 'Brink 1', 48 | 'zip' => '51647', 49 | 'city' => 'Gummersbach', 50 | 'countryCode' => 'DE', 51 | ), 52 | ), 53 | ), 54 | 'emailAddresses' => array( 55 | 'business' => array( 56 | 'support@baebeca.de' 57 | ), 58 | ), 59 | 'phoneNumbers' => array( 60 | 'business' => array( 61 | '022619202930' 62 | ), 63 | ), 64 | 'note' => '', 65 | )); 66 | 67 | if ($request->id) { 68 | test('contact created - id: '.$request->id); 69 | test_finished(true); 70 | } else { 71 | test_finished(false); 72 | } 73 | 74 | } catch(lexoffice_exception $e) { 75 | test($e->getMessage()); 76 | test(print_r($e->get_error(), true)); 77 | test_finished(false); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /tests/tests/014_get_needed_tax_type.php: -------------------------------------------------------------------------------- 1 | get_needed_tax_type('de', '', true, strtotime('2024-03-26')); 5 | if ($request === 'net') { 6 | test_finished(true); 7 | } else { 8 | test_finished(false); 9 | } 10 | } catch (lexoffice_exception $e) { 11 | test($e->getMessage()); 12 | test_finished(false); 13 | } 14 | 15 | test_start('check EU with VAT'); 16 | try { 17 | $request = $lexoffice->get_needed_tax_type('at', 'AT0123456', false, strtotime('2024-03-26')); 18 | if ($request === 'intraCommunitySupply') { 19 | test_finished(true); 20 | } else { 21 | test_finished(false); 22 | } 23 | } catch (lexoffice_exception $e) { 24 | test($e->getMessage()); 25 | test_finished(false); 26 | } 27 | 28 | test_start('check EU without VAT'); 29 | try { 30 | $request = $lexoffice->get_needed_tax_type('at', '', false, strtotime('2024-03-26')); 31 | if ($request === 'net') { 32 | test_finished(true); 33 | } else { 34 | test_finished(false); 35 | } 36 | } catch (lexoffice_exception $e) { 37 | test($e->getMessage()); 38 | test_finished(false); 39 | } 40 | 41 | test_start('check World as service'); 42 | try { 43 | $request = $lexoffice->get_needed_tax_type('US', '', false, strtotime('2024-03-26')); 44 | if ($request === 'thirdPartyCountryService') { 45 | test_finished(true); 46 | } else { 47 | test_finished(false); 48 | } 49 | } catch (lexoffice_exception $e) { 50 | test($e->getMessage()); 51 | test_finished(false); 52 | } 53 | 54 | test_start('check World as physical'); 55 | try { 56 | $request = $lexoffice->get_needed_tax_type('US', '', true, strtotime('2024-03-26')); 57 | if ($request === 'thirdPartyCountryDelivery') { 58 | test_finished(true); 59 | } else { 60 | test_finished(false); 61 | } 62 | } catch (lexoffice_exception $e) { 63 | test($e->getMessage()); 64 | test_finished(false); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /tests/tests/015_oss_destination.php: -------------------------------------------------------------------------------- 1 | get_taxrates('ZZ', strtotime('2021-07-05')); 11 | if ($request['default'] === null) { 12 | test_finished(true); 13 | } else { 14 | var_dump($request); 15 | test_finished(false); 16 | } 17 | } 18 | catch (lexoffice_exception $e) { 19 | test($e->getMessage()); 20 | test_finished(false); 21 | } 22 | 23 | test_start('test taxrates country DE'); 24 | try { 25 | $request = $lexoffice->get_taxrates('DE', strtotime('2021-07-05')); 26 | if (!empty($request) && $request['default'] == 19 && in_array(7, $request['reduced'])) { 27 | test_finished(true); 28 | } else { 29 | test_finished(false); 30 | } 31 | } 32 | catch (lexoffice_exception $e) { 33 | test($e->getMessage()); 34 | test_finished(false); 35 | } 36 | 37 | test_start('test taxrates country nl - before oss'); 38 | try { 39 | $request = $lexoffice->get_taxrates('nl', strtotime('2021-06-05')); 40 | if (!empty($request) && $request['default'] == 19 && in_array(7, $request['reduced'])) { 41 | test_finished(true); 42 | } else { 43 | test_finished(false); 44 | } 45 | } 46 | catch (lexoffice_exception $e) { 47 | test($e->getMessage()); 48 | test_finished(false); 49 | } 50 | 51 | test_start('test taxrates country nl - after oss'); 52 | try { 53 | $request = $lexoffice->get_taxrates('nl', strtotime('2021-07-05')); 54 | if (!empty($request) && $request['default'] == 21 && in_array(9, $request['reduced'])) { 55 | test_finished(true); 56 | } else { 57 | test_finished(false); 58 | } 59 | } 60 | catch (lexoffice_exception $e) { 61 | test($e->getMessage()); 62 | test_finished(false); 63 | } 64 | 65 | test_start('test oss settings - DE'); 66 | try { 67 | $request = $lexoffice->is_oss_needed('DE', strtotime('2021-07-05')); 68 | if ($request === false) { 69 | test_finished(true); 70 | } else { 71 | test_finished(false); 72 | } 73 | } 74 | catch (lexoffice_exception $e) { 75 | test($e->getMessage()); 76 | test_finished(false); 77 | } 78 | 79 | test_start('test oss settings - NL'); 80 | try { 81 | $request = $lexoffice->is_oss_needed('NL', strtotime('2021-07-05')); 82 | if ($request === 'destination') { 83 | test_finished(true); 84 | } else { 85 | var_dump($request); 86 | test_finished(false); 87 | } 88 | } 89 | catch (lexoffice_exception $e) { 90 | test($e->getMessage()); 91 | test_finished(false); 92 | } 93 | 94 | test_start('test oss settings - NL - before oss'); 95 | try { 96 | $request = $lexoffice->is_oss_needed('NL', strtotime('2021-06-05')); 97 | if ($request === false) { 98 | test_finished(true); 99 | } else { 100 | test_finished(false); 101 | } 102 | } 103 | catch (lexoffice_exception $e) { 104 | test($e->getMessage()); 105 | test_finished(false); 106 | } 107 | 108 | test_start('test oss settings - ZZ'); 109 | try { 110 | $request = $lexoffice->is_oss_needed('ZZ', strtotime('2021-07-05')); 111 | if ($request === false) { 112 | test_finished(true); 113 | } else { 114 | test_finished(false); 115 | } 116 | } 117 | catch (lexoffice_exception $e) { 118 | test($e->getMessage()); 119 | test_finished(false); 120 | } 121 | 122 | test_start('test oss settings - GB'); 123 | try { 124 | $request = $lexoffice->is_oss_needed('GB', strtotime('2021-07-05')); 125 | if ($request === false) { 126 | test_finished(true); 127 | } else { 128 | test_finished(false); 129 | } 130 | } 131 | catch (lexoffice_exception $e) { 132 | test($e->getMessage()); 133 | test_finished(false); 134 | } 135 | 136 | test_start('test oss voucher category - GB'); 137 | try { 138 | $request = $lexoffice->get_oss_voucher_category('GB', strtotime('2021-07-05')); 139 | test_finished(false); 140 | } 141 | catch (lexoffice_exception $e) { 142 | if ($e->getMessage() === 'lexoffice-php-api: no possible OSS voucher category id') { 143 | test_finished(true); 144 | } else { 145 | test_finished(false); 146 | } 147 | } 148 | 149 | test_start('test oss voucher category - DE'); 150 | try { 151 | $request = $lexoffice->get_oss_voucher_category('DE', strtotime('2021-07-05')); 152 | test_finished(false); 153 | } 154 | catch (lexoffice_exception $e) { 155 | if ($e->getMessage() === 'lexoffice-php-api: no possible OSS voucher category id') { 156 | test_finished(true); 157 | } else { 158 | test_finished(false); 159 | } 160 | } 161 | 162 | test_start('test oss voucher category - NL - physical'); 163 | try { 164 | $request = $lexoffice->get_oss_voucher_category('NL', strtotime('2021-07-05'), 1); 165 | if ($request === '4ebd965a-7126-416c-9d8c-a5c9366ee473') { 166 | test_finished(true); 167 | } else { 168 | test_finished(false); 169 | } 170 | } 171 | catch (lexoffice_exception $e) { 172 | test($e->getMessage()); 173 | test_finished(false); 174 | } 175 | 176 | test_start('test oss voucher category - NL - service'); 177 | try { 178 | $request = $lexoffice->get_oss_voucher_category('NL', strtotime('2021-07-05'), 2); 179 | if ($request === '7ecea006-844c-4c98-a02d-aa3142640dd5') { 180 | test_finished(true); 181 | } else { 182 | test_finished(false); 183 | } 184 | } 185 | catch (lexoffice_exception $e) { 186 | test($e->getMessage()); 187 | test_finished(false); 188 | } 189 | 190 | test_start('check Innergemeinschaftliche Lieferung'); 191 | try { 192 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'PT', strtotime('2021-07-05'), true, true); 193 | if ($request === '9075a4e3-66de-4795-a016-3889feca0d20') { 194 | test_finished(true); 195 | } else { 196 | test_finished(false); 197 | } 198 | } 199 | catch (lexoffice_exception $e) { 200 | test(print_r($e->get_error(), true)); 201 | test_finished(false); 202 | } 203 | 204 | test_start('check Fernverkauf | vatid but not business, physical'); 205 | try { 206 | $request = $lexoffice->get_needed_voucher_booking_id(23, 'PT', strtotime('2021-07-05'), true, false, true); 207 | test($request); 208 | if ($request === '4ebd965a-7126-416c-9d8c-a5c9366ee473') { 209 | test_finished(true); 210 | } else { 211 | test_finished(false); 212 | } 213 | } 214 | catch (lexoffice_exception $e) { 215 | test(print_r($e->get_error(), true)); 216 | test_finished(false); 217 | } 218 | 219 | test_start('check Fernverkauf | vatid but not business, service'); 220 | try { 221 | $request = $lexoffice->get_needed_voucher_booking_id(23, 'PT', strtotime('2021-07-05'), true, false, false); 222 | test($request); 223 | if ($request === '7ecea006-844c-4c98-a02d-aa3142640dd5') { 224 | test_finished(true); 225 | } else { 226 | test_finished(false); 227 | } 228 | } 229 | catch (lexoffice_exception $e) { 230 | test(print_r($e->get_error(), true)); 231 | test_finished(false); 232 | } 233 | 234 | test_start('check Fernverkauf | SE | private'); 235 | try { 236 | $request = $lexoffice->get_needed_voucher_booking_id(25, 'SE', strtotime('2021-07-05'), false, false); 237 | 238 | #if ($request === '7c112b66-0565-479c-bc18-5845e080880a') { // distance 239 | if ($request === '4ebd965a-7126-416c-9d8c-a5c9366ee473') { // origin 240 | test_finished(true); 241 | } else { 242 | test('failed with: '.$request); 243 | test_finished(false); 244 | } 245 | } 246 | catch (lexoffice_exception $e) { 247 | test(print_r($e->get_error(), true)); 248 | test_finished(false); 249 | } 250 | 251 | test_start('create netto oss voucher 13% / 23% Portugal with get_oss_voucher_category()'); 252 | try { 253 | // create contact 254 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 255 | $request = $lexoffice->create_contact(array( 256 | 'version' => 0, 257 | 'roles' => array( 258 | 'customer' => array( 259 | 'number' => '', 260 | ), 261 | ), 262 | 'company' => array( 263 | 'name' => $random_contact_name, 264 | 'street' => 'Brink 1', 265 | 'zip' => '51647', 266 | 'city' => 'Gummersbach', 267 | 'countryCode' => 'PT', 268 | ), 269 | 'addresses' => array( 270 | 'billing' => array( 271 | array( 272 | 'street' => 'Brink 1', 273 | 'zip' => '51647', 274 | 'city' => 'Gummersbach', 275 | 'countryCode' => 'PT', 276 | ), 277 | ), 278 | ), 279 | )); 280 | 281 | // create voucher 282 | $request = $lexoffice->create_voucher([ 283 | 'version' => 0, 284 | 'voucherDate' => '2021-07-05', 285 | 'dueDate' => '2021-07-10', 286 | 'type' => 'salesinvoice', 287 | 'voucherNumber' => "21-001003RP", 288 | 'contactId' => $request->id, 289 | 'totalGrossAmount' => 236.00, 290 | 'voucherItems' => [ 291 | [ 292 | 'amount' => 100.00, 293 | 'taxAmount' => 23.00, 294 | 'taxRatePercent' => 23, 295 | 'categoryId' => $lexoffice->get_oss_voucher_category('pt', strtotime('2021-07-05'), 1), 296 | ], 297 | [ 298 | 'amount' => 100.00, 299 | 'taxAmount' => 13.00, 300 | 'taxRatePercent' => 13, 301 | 'categoryId' => $lexoffice->get_oss_voucher_category('pt', strtotime('2021-07-05'), 1), 302 | ], 303 | ], 304 | 'taxType' => "net", 305 | 'totalTaxAmount' => 36.00, 306 | ]); 307 | 308 | if ($request->id) { 309 | test('voucher created - id: '.$request->id); 310 | test_finished(true); 311 | } else { 312 | test_finished(false); 313 | } 314 | } catch(lexoffice_exception $e) { 315 | test($e->getMessage()); 316 | test(print_r($e->get_error(), true)); 317 | test_finished(false); 318 | } 319 | 320 | test_start('create brutto oss voucher 13% / 23% Portugal with get_oss_voucher_category()'); 321 | try { 322 | // create contact 323 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 324 | $request = $lexoffice->create_contact(array( 325 | 'version' => 0, 326 | 'roles' => array( 327 | 'customer' => array( 328 | 'number' => '', 329 | ), 330 | ), 331 | 'company' => array( 332 | 'name' => $random_contact_name, 333 | 'street' => 'Brink 1', 334 | 'zip' => '51647', 335 | 'city' => 'Gummersbach', 336 | 'countryCode' => 'PT', 337 | ), 338 | 'addresses' => array( 339 | 'billing' => array( 340 | array( 341 | 'street' => 'Brink 1', 342 | 'zip' => '51647', 343 | 'city' => 'Gummersbach', 344 | 'countryCode' => 'PT', 345 | ), 346 | ), 347 | ), 348 | )); 349 | 350 | // create voucher 351 | $request = $lexoffice->create_voucher([ 352 | 'version' => 0, 353 | 'voucherDate' => '2021-07-05', 354 | 'dueDate' => '2021-07-10', 355 | 'type' => 'salesinvoice', 356 | 'voucherNumber' => "21-001003RP", 357 | 'contactId' => $request->id, 358 | 'totalGrossAmount' => 236.00, 359 | 'voucherItems' => [ 360 | [ 361 | 'amount' => 123.00, 362 | 'taxAmount' => 23.00, 363 | 'taxRatePercent' => 23, 364 | 'categoryId' => $lexoffice->get_oss_voucher_category('pt', strtotime('2021-07-05'), 1), 365 | ], 366 | [ 367 | 'amount' => 113.00, 368 | 'taxAmount' => 13.00, 369 | 'taxRatePercent' => 13, 370 | 'categoryId' => $lexoffice->get_oss_voucher_category('pt', strtotime('2021-07-05'), 1), 371 | ], 372 | ], 373 | 'taxType' => "gross", 374 | 'totalTaxAmount' => 36.00, 375 | ]); 376 | 377 | if ($request->id) { 378 | test('voucher created - id: '.$request->id); 379 | test_finished(true); 380 | } else { 381 | test_finished(false); 382 | } 383 | } catch(lexoffice_exception $e) { 384 | test($e->getMessage()); 385 | test(print_r($e->get_error(), true)); 386 | test_finished(false); 387 | } 388 | 389 | test_start('create netto oss voucher 13% / 23% Portugal with get_needed_voucher_booking_id()'); 390 | try { 391 | // create contact 392 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 393 | $request = $lexoffice->create_contact(array( 394 | 'version' => 0, 395 | 'roles' => array( 396 | 'customer' => array( 397 | 'number' => '', 398 | ), 399 | ), 400 | 'company' => array( 401 | 'name' => $random_contact_name, 402 | 'street' => 'Brink 1', 403 | 'zip' => '51647', 404 | 'city' => 'Gummersbach', 405 | 'countryCode' => 'PT', 406 | ), 407 | 'addresses' => array( 408 | 'billing' => array( 409 | array( 410 | 'street' => 'Brink 1', 411 | 'zip' => '51647', 412 | 'city' => 'Gummersbach', 413 | 'countryCode' => 'PT', 414 | ), 415 | ), 416 | ), 417 | )); 418 | 419 | // create voucher 420 | $request = $lexoffice->create_voucher([ 421 | 'version' => 0, 422 | 'voucherDate' => '2021-07-05', 423 | 'dueDate' => '2021-07-10', 424 | 'type' => 'salesinvoice', 425 | 'voucherNumber' => "21-001003RP", 426 | 'contactId' => $request->id, 427 | 'totalGrossAmount' => 236.00, 428 | 'voucherItems' => [ 429 | [ 430 | 'amount' => 100.00, 431 | 'taxAmount' => 23.00, 432 | 'taxRatePercent' => 23, 433 | 'categoryId' => $lexoffice->get_needed_voucher_booking_id(23, 'PT', strtotime('2021-07-05'), false, false, true), 434 | ], 435 | [ 436 | 'amount' => 100.00, 437 | 'taxAmount' => 13.00, 438 | 'taxRatePercent' => 13, 439 | 'categoryId' => $lexoffice->get_needed_voucher_booking_id(13, 'PT', strtotime('2021-07-05'), false, false, true), 440 | ], 441 | ], 442 | 'taxType' => "net", 443 | 'totalTaxAmount' => 36.00, 444 | ]); 445 | 446 | if ($request->id) { 447 | test('voucher created - id: '.$request->id); 448 | test_finished(true); 449 | } else { 450 | test_finished(false); 451 | } 452 | } catch(lexoffice_exception $e) { 453 | test($e->getMessage()); 454 | test(print_r($e->get_error(), true)); 455 | test_finished(false); 456 | } 457 | 458 | test_start('create brutto oss voucher 13% / 23% Portugal with get_needed_voucher_booking_id()'); 459 | try { 460 | // create contact 461 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 462 | $request = $lexoffice->create_contact(array( 463 | 'version' => 0, 464 | 'roles' => array( 465 | 'customer' => array( 466 | 'number' => '', 467 | ), 468 | ), 469 | 'company' => array( 470 | 'name' => $random_contact_name, 471 | 'street' => 'Brink 1', 472 | 'zip' => '51647', 473 | 'city' => 'Gummersbach', 474 | 'countryCode' => 'PT', 475 | ), 476 | 'addresses' => array( 477 | 'billing' => array( 478 | array( 479 | 'street' => 'Brink 1', 480 | 'zip' => '51647', 481 | 'city' => 'Gummersbach', 482 | 'countryCode' => 'PT', 483 | ), 484 | ), 485 | ), 486 | )); 487 | 488 | // create voucher 489 | $request = $lexoffice->create_voucher([ 490 | 'version' => 0, 491 | 'voucherDate' => '2021-07-05', 492 | 'dueDate' => '2021-07-10', 493 | 'type' => 'salesinvoice', 494 | 'voucherNumber' => "21-001003RP", 495 | 'contactId' => $request->id, 496 | 'totalGrossAmount' => 236.00, 497 | 'voucherItems' => [ 498 | [ 499 | 'amount' => 123.00, 500 | 'taxAmount' => 23.00, 501 | 'taxRatePercent' => 23, 502 | 'categoryId' => $lexoffice->get_needed_voucher_booking_id(23, 'PT', strtotime('2021-07-05'), false, false, true), 503 | ], 504 | [ 505 | 'amount' => 113.00, 506 | 'taxAmount' => 13.00, 507 | 'taxRatePercent' => 13, 508 | 'categoryId' => $lexoffice->get_needed_voucher_booking_id(13, 'PT', strtotime('2021-07-05'), false, false, true), 509 | ], 510 | ], 511 | 'taxType' => "gross", 512 | 'totalTaxAmount' => 36.00, 513 | ]); 514 | 515 | if ($request->id) { 516 | test('voucher created - id: '.$request->id); 517 | test_finished(true); 518 | } else { 519 | test_finished(false); 520 | } 521 | } catch(lexoffice_exception $e) { 522 | test($e->getMessage()); 523 | test(print_r($e->get_error(), true)); 524 | test_finished(false); 525 | } 526 | 527 | end_oss_destination: -------------------------------------------------------------------------------- /tests/tests/016_delivery_notes.php: -------------------------------------------------------------------------------- 1 | create_delivery_note([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'introduction' => 'Einleitungstext', 8 | 'remark' => "Fußzeile\r\nMehrzeilig", 9 | 'address' => [ 10 | #'contactId' => '', 11 | 'name' => 'Frau Jane Doe', 12 | 'street' => 'Str. 1', 13 | 'zip' => '12345', 14 | 'city' => 'Stadt', 15 | 'countryCode' => 'DE', 16 | ], 17 | 'lineItems' => [ 18 | [ 19 | 'type' => 'custom', 20 | 'name' => 'Produktname', 21 | 'description' => 'Beschreibung', 22 | 'quantity' => 1, 23 | 'unitName' => 'Stück', 24 | 'unitPrice' => [ 25 | 'currency' => 'EUR', 26 | 'netAmount' => 11.99, 27 | 'taxRatePercentage' => $taxrate_19, 28 | ], 29 | #'discountPercentage' => 0, 30 | ], 31 | ], 32 | 'totalPrice' => [ 33 | 'currency' => 'EUR', 34 | #'totalDiscountAbsolute' => 0, 35 | #'totalDiscountPercentage' => 0, 36 | ], 37 | 'taxConditions' => [ 38 | 'taxType' => 'net', 39 | ], 40 | 'shippingConditions' => [ 41 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 42 | 'shippingType' => 'delivery', 43 | ], 44 | 'paymentConditions' => [ 45 | 'paymentTermLabel' => 'Vorkasse', 46 | 'paymentTermDuration' => 1, 47 | ], 48 | ]); 49 | 50 | if ($request->id) { 51 | test('delivery_note created - id: '.$request->id); 52 | test_finished(true); 53 | } else { 54 | test_finished(false); 55 | } 56 | } catch(lexoffice_exception $e) { 57 | test($e->getMessage()); 58 | test(print_r($e->get_error(), true)); 59 | test_finished(false); 60 | } 61 | 62 | test_start('create delivery_note with contact'); 63 | try { 64 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 65 | try { 66 | $request_contact = $lexoffice->create_contact(array( 67 | 'version' => 0, 68 | 'roles' => array( 69 | 'customer' => array( 70 | 'number' => '', 71 | ), 72 | ), 73 | 'company' => array( 74 | // use random name, use it in later search check 75 | 'name' => $random_contact_name, 76 | 'street' => 'Brink 1', 77 | 'zip' => '51647', 78 | 'city' => 'Gummersbach', 79 | 'countryCode' => 'DE', 80 | 'contactPersons' => array( 81 | array( 82 | 'salutation' => 'Herr', 83 | 'firstName' => 'John', 84 | 'lastName' => 'Doe', 85 | 'emailAddress' =>'support@baebeca.de', 86 | 'phoneNumber' => '022619202930', 87 | ) 88 | ), 89 | ), 90 | 'addresses' => array( 91 | 'billing' => array( 92 | array( 93 | 'street' => 'Brink 1', 94 | 'zip' => '51647', 95 | 'city' => 'Gummersbach', 96 | 'countryCode' => 'DE', 97 | ), 98 | ), 99 | 'shipping' => array( 100 | array( 101 | 'street' => 'Brink 1', 102 | 'zip' => '51647', 103 | 'city' => 'Gummersbach', 104 | 'countryCode' => 'DE', 105 | ), 106 | ), 107 | ), 108 | 'emailAddresses' => array( 109 | 'business' => array( 110 | 'support@baebeca.de' 111 | ), 112 | ), 113 | 'phoneNumbers' => array( 114 | 'business' => array( 115 | '022619202930' 116 | ), 117 | ), 118 | 'note' => '', 119 | )); 120 | 121 | if (!$request_contact->id) { 122 | test_finished(false); 123 | } 124 | 125 | } catch(lexoffice_exception $e) { 126 | test($e->getMessage()); 127 | test(print_r($e->get_error(), true)); 128 | test_finished(false); 129 | } 130 | 131 | 132 | $request = $lexoffice->create_delivery_note([ 133 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 134 | 'introduction' => 'Einleitungstext', 135 | 'remark' => "Fußzeile\r\nMehrzeilig", 136 | 'address' => [ 137 | 'contactId' => $request_contact->id, 138 | ], 139 | 'lineItems' => [ 140 | [ 141 | 'type' => 'custom', 142 | 'name' => 'Produktname', 143 | 'description' => 'Beschreibung', 144 | 'quantity' => 1, 145 | 'unitName' => 'Stück', 146 | 'unitPrice' => [ 147 | 'currency' => 'EUR', 148 | 'netAmount' => 11.99, 149 | 'taxRatePercentage' => $taxrate_19, 150 | ], 151 | #'discountPercentage' => 0, 152 | ], 153 | ], 154 | 'totalPrice' => [ 155 | 'currency' => 'EUR', 156 | #'totalDiscountAbsolute' => 0, 157 | #'totalDiscountPercentage' => 0, 158 | ], 159 | 'taxConditions' => [ 160 | 'taxType' => 'net', 161 | ], 162 | 'shippingConditions' => [ 163 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 164 | 'shippingType' => 'delivery', 165 | ], 166 | 'paymentConditions' => [ 167 | 'paymentTermLabel' => 'Vorkasse', 168 | 'paymentTermDuration' => 1, 169 | ], 170 | ]); 171 | 172 | if ($request->id) { 173 | test('delivery_note created - id: '.$request->id); 174 | test_finished(true); 175 | } else { 176 | test_finished(false); 177 | } 178 | } catch(lexoffice_exception $e) { 179 | test($e->getMessage()); 180 | test(print_r($e->get_error(), true)); 181 | test_finished(false); 182 | } 183 | -------------------------------------------------------------------------------- /tests/tests/017_credit_notes.php: -------------------------------------------------------------------------------- 1 | create_creditnote([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'introduction' => 'Einleitungstext', 8 | 'remark' => "Fußzeile\r\nMehrzeilig", 9 | 'address' => [ 10 | #'contactId' => '', 11 | 'name' => 'Frau Jane Doe', 12 | 'street' => 'Str. 1', 13 | 'zip' => '12345', 14 | 'city' => 'Stadt', 15 | 'countryCode' => 'DE', 16 | ], 17 | 'lineItems' => [ 18 | [ 19 | 'type' => 'custom', 20 | 'name' => 'WEBINAR BLUB ABC - Duminică, 01.01.2000 la ora 13.00', 21 | 'description' => 'WEBINAR BLUB ABC - Duminică, 01.01.2000 la ora 13.00', 22 | 'quantity' => 1, 23 | 'unitName' => 'Stück', 24 | 'unitPrice' => [ 25 | 'currency' => 'EUR', 26 | 'netAmount' => 11.99, 27 | 'taxRatePercentage' => $taxrate_19, 28 | ], 29 | #'discountPercentage' => 0, 30 | ], 31 | ], 32 | 'totalPrice' => [ 33 | 'currency' => 'EUR', 34 | #'totalDiscountAbsolute' => 0, 35 | #'totalDiscountPercentage' => 0, 36 | ], 37 | 'taxConditions' => [ 38 | 'taxType' => 'net', 39 | ], 40 | 'shippingConditions' => [ 41 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 42 | 'shippingType' => 'delivery', 43 | ], 44 | 'paymentConditions' => [ 45 | 'paymentTermLabel' => 'Vorkasse', 46 | 'paymentTermDuration' => 1, 47 | ], 48 | ], true); 49 | 50 | if ($request->id) { 51 | test('invoice created - id: '.$request->id); 52 | 53 | test_finished(true); 54 | } else { 55 | test_finished(false); 56 | } 57 | } catch(lexoffice_exception $e) { 58 | test($e->getMessage()); 59 | test(print_r($e->get_error(), true)); 60 | test_finished(false); 61 | } 62 | -------------------------------------------------------------------------------- /tests/tests/018_contacts_wildcards.php: -------------------------------------------------------------------------------- 1 | search_contact(array( 5 | 'email' => 'klaus@hansbernd.de', 6 | 'customer' => true, 7 | )); 8 | 9 | if (count($request->content) === 1) { 10 | test('found ' . count($request->content) . ' contacts'); 11 | test_finished(true); 12 | } elseif (count($request->content) > 1) { 13 | test('found '.count($request->content).' contacts'); 14 | test_finished(false); 15 | } else { 16 | test('not found, create contact for test'); 17 | $request = $lexoffice->create_contact(array( 18 | 'version' => 0, 19 | 'roles' => array( 20 | 'customer' => array( 21 | 'number' => '', 22 | ), 23 | ), 24 | 'person' => array( 25 | 'salutation' => 'Herr', 26 | 'firstName' => 'John', 27 | 'lastName' => 'Doe', 28 | ), 29 | 'addresses' => array( 30 | 'billing' => array( 31 | array( 32 | 'street' => 'Brink 1', 33 | 'zip' => '51647', 34 | 'city' => 'Gummersbach', 35 | 'countryCode' => 'DE', 36 | ), 37 | ), 38 | ), 39 | 'emailAddresses' => array( 40 | 'business' => array( 41 | 'klaus@hansbernd.de' 42 | ), 43 | ), 44 | 'note' => '', 45 | )); 46 | 47 | test_finished(true); 48 | } 49 | 50 | } 51 | catch(lexoffice_exception $e) { 52 | test($e->getMessage()); 53 | test(print_r($e->get_error(), true)); 54 | test_finished(false); 55 | } 56 | 57 | test_start('search for email with contains "klaus@hans"'); 58 | try { 59 | $request = $lexoffice->search_contact(array( 60 | 'email' => 'klaus@hans', 61 | 'customer' => true, 62 | )); 63 | 64 | if (count($request->content) === 1) { 65 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 66 | test_finished(true); 67 | } else { 68 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 69 | test_finished(false); 70 | } 71 | 72 | } 73 | catch(lexoffice_exception $e) { 74 | test($e->getMessage()); 75 | test(print_r($e->get_error(), true)); 76 | test_finished(false); 77 | } 78 | 79 | test_start('search for email with wildcards "k___s@hansbernd.de"'); 80 | try { 81 | $request = $lexoffice->search_contact(array( 82 | 'email' => 'k___s@hansbernd.de', 83 | 'customer' => true, 84 | ), true); 85 | 86 | if (count($request->content) === 1) { 87 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 88 | test_finished(true); 89 | } else { 90 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 91 | test_finished(false); 92 | } 93 | 94 | } 95 | catch(lexoffice_exception $e) { 96 | test($e->getMessage()); 97 | test(print_r($e->get_error(), true)); 98 | test_finished(false); 99 | } 100 | 101 | test_start('search for email with wildcards "k_%s@hansbernd.de"'); 102 | try { 103 | $request = $lexoffice->search_contact(array( 104 | 'email' => 'k_%s@hansbernd.de', 105 | 'customer' => true, 106 | ), true); 107 | 108 | if (count($request->content) === 1) { 109 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 110 | test_finished(true); 111 | } else { 112 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 113 | test_finished(false); 114 | } 115 | 116 | } catch(lexoffice_exception $e) { 117 | test($e->getMessage()); 118 | test(print_r($e->get_error(), true)); 119 | test_finished(false); 120 | } 121 | 122 | test_start('search for email with wildcards "kl__s@hansbernd.de"'); 123 | try { 124 | $request = $lexoffice->search_contact(array( 125 | 'email' => 'kl__s@hansbernd.de', 126 | 'customer' => true, 127 | ), true); 128 | 129 | if (count($request->content) === 1) { 130 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 131 | test_finished(true); 132 | } else { 133 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 134 | test_finished(false); 135 | } 136 | 137 | } catch(lexoffice_exception $e) { 138 | test($e->getMessage()); 139 | test(print_r($e->get_error(), true)); 140 | test_finished(false); 141 | } 142 | 143 | test_start('search for email with wildcards "%_s@hansbernd.de"'); 144 | try { 145 | $request = $lexoffice->search_contact(array( 146 | 'email' => '%_s@hansbernd.de', 147 | 'customer' => true, 148 | ), true); 149 | 150 | if (count($request->content) === 1) { 151 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 152 | test_finished(true); 153 | } else { 154 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 155 | test_finished(false); 156 | } 157 | 158 | } catch(lexoffice_exception $e) { 159 | test($e->getMessage()); 160 | test(print_r($e->get_error(), true)); 161 | test_finished(false); 162 | } 163 | 164 | 165 | test_start('search for email with wildcards "%@hansbernd.de"'); 166 | try { 167 | $request = $lexoffice->search_contact(array( 168 | 'email' => '%s@hansbernd.de', 169 | 'customer' => true, 170 | ), true); 171 | 172 | if (count($request->content) === 1) { 173 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 174 | test_finished(true); 175 | } else { 176 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 177 | test_finished(false); 178 | } 179 | 180 | } catch(lexoffice_exception $e) { 181 | test($e->getMessage()); 182 | test(print_r($e->get_error(), true)); 183 | test_finished(false); 184 | } 185 | 186 | test_start('search for email with wildcards "klaus@hansbernd.__"'); 187 | try { 188 | $request = $lexoffice->search_contact(array( 189 | 'email' => 'klaus@hansbernd.__', 190 | 'customer' => true, 191 | ), true); 192 | 193 | if (count($request->content) === 1) { 194 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 195 | test_finished(true); 196 | } else { 197 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 198 | test_finished(false); 199 | } 200 | 201 | } catch(lexoffice_exception $e) { 202 | test($e->getMessage()); 203 | test(print_r($e->get_error(), true)); 204 | test_finished(false); 205 | } 206 | test_start('search for email with wildcards "klaus@hansber%"'); 207 | try { 208 | $request = $lexoffice->search_contact(array( 209 | 'email' => 'klaus@hansber%', 210 | 'customer' => true, 211 | ), true); 212 | 213 | if (count($request->content) === 1) { 214 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 215 | test_finished(true); 216 | } else { 217 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 218 | test_finished(false); 219 | } 220 | 221 | } catch(lexoffice_exception $e) { 222 | test($e->getMessage()); 223 | test(print_r($e->get_error(), true)); 224 | test_finished(false); 225 | } 226 | -------------------------------------------------------------------------------- /tests/tests/019_contacts_no_wildcards.php: -------------------------------------------------------------------------------- 1 | search_contact(array( 5 | 'email' => 'klaus@hansbernd.de', 6 | 'customer' => true, 7 | )); 8 | 9 | if (count($request->content) === 1) { 10 | test('found ' . count($request->content) . ' contacts'); 11 | test_finished(true); 12 | } elseif (count($request->content) > 1) { 13 | test('found '.count($request->content).' contacts'); 14 | test_finished(false); 15 | } else { 16 | test('not found, create contact for test'); 17 | $request = $lexoffice->create_contact(array( 18 | 'version' => 0, 19 | 'roles' => array( 20 | 'customer' => array( 21 | 'number' => '', 22 | ), 23 | ), 24 | 'person' => array( 25 | 'salutation' => 'Herr', 26 | 'firstName' => 'John', 27 | 'lastName' => 'Doe', 28 | ), 29 | 'addresses' => array( 30 | 'billing' => array( 31 | array( 32 | 'street' => 'Brink 1', 33 | 'zip' => '51647', 34 | 'city' => 'Gummersbach', 35 | 'countryCode' => 'DE', 36 | ), 37 | ), 38 | ), 39 | 'emailAddresses' => array( 40 | 'business' => array( 41 | 'klaus@hansbernd.de' 42 | ), 43 | ), 44 | 'note' => '', 45 | )); 46 | 47 | test_finished(true); 48 | } 49 | 50 | } 51 | catch(lexoffice_exception $e) { 52 | test($e->getMessage()); 53 | test(print_r($e->get_error(), true)); 54 | test_finished(false); 55 | } 56 | 57 | test_start('search for email with contains "klaus@hans"'); 58 | try { 59 | $request = $lexoffice->search_contact(array( 60 | 'email' => 'klaus@hans', 61 | 'customer' => true, 62 | )); 63 | 64 | if (count($request->content) === 1) { 65 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 66 | test_finished(true); 67 | } else { 68 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 69 | test_finished(false); 70 | } 71 | 72 | } 73 | catch(lexoffice_exception $e) { 74 | test($e->getMessage()); 75 | test(print_r($e->get_error(), true)); 76 | test_finished(false); 77 | } 78 | 79 | test_start('search for email with wildcards "k___s@hansbernd.de"'); 80 | try { 81 | $request = $lexoffice->search_contact(array( 82 | 'email' => 'k___s@hansbernd.de', 83 | 'customer' => true, 84 | )); 85 | 86 | if (count($request->content) === 0) { 87 | test_finished(true); 88 | } else { 89 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 90 | test_finished(false); 91 | } 92 | 93 | } 94 | catch(lexoffice_exception $e) { 95 | test($e->getMessage()); 96 | test(print_r($e->get_error(), true)); 97 | test_finished(false); 98 | } 99 | 100 | /* 101 | test_start('search for email with contains "k_*s@hansbernd.de"'); 102 | try { 103 | $request = $lexoffice->search_contact(array( 104 | 'email' => 'k_*s@hansbernd.de', 105 | 'customer' => true, 106 | )); 107 | 108 | if (count($request->content) === 1) { 109 | test('found '.count($request->content).' contacts - '.$request->content[0]->emailAddresses->business[0]); 110 | test_finished(true); 111 | } else { 112 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 113 | test_finished(false); 114 | } 115 | 116 | } catch(lexoffice_exception $e) { 117 | test($e->getMessage()); 118 | test(print_r($e->get_error(), true)); 119 | test_finished(false); 120 | } 121 | */ 122 | 123 | test_start('search for email with wildcards "kl__s@hansbernd.de"'); 124 | try { 125 | $request = $lexoffice->search_contact(array( 126 | 'email' => 'kl__s@hansbernd.de', 127 | 'customer' => true, 128 | )); 129 | 130 | if (count($request->content) === 0) { 131 | test_finished(true); 132 | } else { 133 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 134 | test_finished(false); 135 | } 136 | 137 | } catch(lexoffice_exception $e) { 138 | test($e->getMessage()); 139 | test(print_r($e->get_error(), true)); 140 | test_finished(false); 141 | } 142 | 143 | test_start('search for email with wildcards "%_s@hansbernd.de"'); 144 | try { 145 | $request = $lexoffice->search_contact(array( 146 | 'email' => '%_s@hansbernd.de', 147 | 'customer' => true, 148 | )); 149 | 150 | if (count($request->content) === 0) { 151 | test_finished(true); 152 | } else { 153 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 154 | test_finished(false); 155 | } 156 | 157 | } catch(lexoffice_exception $e) { 158 | test($e->getMessage()); 159 | test(print_r($e->get_error(), true)); 160 | test_finished(false); 161 | } 162 | 163 | 164 | test_start('search for email with wildcards "%@hansbernd.de"'); 165 | try { 166 | $request = $lexoffice->search_contact(array( 167 | 'email' => '%s@hansbernd.de', 168 | 'customer' => true, 169 | )); 170 | 171 | if (count($request->content) === 0) { 172 | test_finished(true); 173 | } else { 174 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 175 | test_finished(false); 176 | } 177 | 178 | } catch(lexoffice_exception $e) { 179 | test($e->getMessage()); 180 | test(print_r($e->get_error(), true)); 181 | test_finished(false); 182 | } 183 | 184 | test_start('search for email with wildcards "klaus@hansbernd.__"'); 185 | try { 186 | $request = $lexoffice->search_contact(array( 187 | 'email' => 'klaus@hansbernd.__', 188 | 'customer' => true, 189 | )); 190 | 191 | if (count($request->content) === 0) { 192 | test_finished(true); 193 | } else { 194 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 195 | test_finished(false); 196 | } 197 | 198 | } catch(lexoffice_exception $e) { 199 | test($e->getMessage()); 200 | test(print_r($e->get_error(), true)); 201 | test_finished(false); 202 | } 203 | test_start('search for email with wildcards "klaus@hansber%"'); 204 | try { 205 | $request = $lexoffice->search_contact(array( 206 | 'email' => 'klaus@hansber%', 207 | 'customer' => true, 208 | )); 209 | 210 | if (count($request->content) === 0) { 211 | test_finished(true); 212 | } else { 213 | test('found '.count($request->content).' contacts - '.print_r($request->content, true)); 214 | test_finished(false); 215 | } 216 | 217 | } catch(lexoffice_exception $e) { 218 | test($e->getMessage()); 219 | test(print_r($e->get_error(), true)); 220 | test_finished(false); 221 | } 222 | -------------------------------------------------------------------------------- /tests/tests/020_validate_vat_id.php: -------------------------------------------------------------------------------- 1 | valid_vat_id('ATU99999999')) { 5 | test_finished(true); 6 | } else { 7 | test_finished(false); 8 | } 9 | 10 | test_start('Validate vat_id - incorrect id - Austria '); 11 | if (!$lexoffice->valid_vat_id('ATU999999997')) { 12 | test_finished(true); 13 | } else { 14 | test_finished(false); 15 | } 16 | 17 | test_start('Validate vat_id - Belgium 1'); 18 | if ($lexoffice->valid_vat_id('BE0999999999')) { 19 | test_finished(true); 20 | } else { 21 | test_finished(false); 22 | } 23 | 24 | test_start('Validate vat_id - Belgium 2'); 25 | if ($lexoffice->valid_vat_id('BE9999999999')) { 26 | test_finished(true); 27 | } else { 28 | test_finished(false); 29 | } 30 | 31 | test_start('Validate vat_id - Bulgaria 1'); 32 | if ($lexoffice->valid_vat_id('BG999999999')) { 33 | test_finished(true); 34 | } else { 35 | test_finished(false); 36 | } 37 | 38 | 39 | test_start('Validate vat_id - Bulgaria 2'); 40 | if ($lexoffice->valid_vat_id('BG9999999999')) { 41 | test_finished(true); 42 | } else { 43 | test_finished(false); 44 | } 45 | 46 | 47 | test_start('Validate vat_id - Cyprus'); 48 | if ($lexoffice->valid_vat_id('CY99999999L')) { 49 | test_finished(true); 50 | } else { 51 | test_finished(false); 52 | } 53 | 54 | test_start('Validate vat_id - incorrect id - Cyprus'); 55 | if (!$lexoffice->valid_vat_id('CY9999999L')) { 56 | test_finished(true); 57 | } else { 58 | test_finished(false); 59 | } 60 | 61 | 62 | test_start('Validate vat_id - Czech Republic 1'); 63 | if ($lexoffice->valid_vat_id('CZ99999999')) { 64 | test_finished(true); 65 | } else { 66 | test_finished(false); 67 | } 68 | 69 | test_start('Validate vat_id - Czech Republic 2'); 70 | if ($lexoffice->valid_vat_id('CZ999999999')) { 71 | test_finished(true); 72 | } else { 73 | test_finished(false); 74 | } 75 | 76 | test_start('Validate vat_id - Czech Republic 3'); 77 | if ($lexoffice->valid_vat_id('CZ9999999999')) { 78 | test_finished(true); 79 | } else { 80 | test_finished(false); 81 | } 82 | 83 | test_start('Validate vat_id - Germany'); 84 | if ($lexoffice->valid_vat_id('DE999999999')) { 85 | test_finished(true); 86 | } else { 87 | test_finished(false); 88 | } 89 | 90 | test_start('Validate vat_id - Denmark'); 91 | if ($lexoffice->valid_vat_id('DK99999999')) { 92 | test_finished(true); 93 | } else { 94 | test_finished(false); 95 | } 96 | 97 | test_start('Validate vat_id - Estonia'); 98 | if ($lexoffice->valid_vat_id('EE999999999')) { 99 | test_finished(true); 100 | } else { 101 | test_finished(false); 102 | } 103 | 104 | test_start('Validate vat_id - Greece'); 105 | if ($lexoffice->valid_vat_id('EL999999999')) { 106 | test_finished(true); 107 | } else { 108 | test_finished(false); 109 | } 110 | 111 | test_start('Validate vat_id - Spain'); 112 | if ($lexoffice->valid_vat_id('ESX9999999X')) { 113 | test_finished(true); 114 | } else { 115 | test_finished(false); 116 | } 117 | 118 | test_start('Validate vat_id - Finland'); 119 | if ($lexoffice->valid_vat_id('FI99999999')) { 120 | test_finished(true); 121 | } else { 122 | test_finished(false); 123 | } 124 | 125 | test_start('Validate vat_id - France'); 126 | if ($lexoffice->valid_vat_id('FRXX999999999')) { 127 | test_finished(true); 128 | } else { 129 | test_finished(false); 130 | } 131 | 132 | test_start('Validate vat_id - United Kingdom 1'); 133 | if ($lexoffice->valid_vat_id('GB999999999')) { 134 | test_finished(true); 135 | } else { 136 | test_finished(false); 137 | } 138 | 139 | test_start('Validate vat_id - United Kingdom 2'); 140 | if ($lexoffice->valid_vat_id('GB999999999999')) { 141 | test_finished(true); 142 | } else { 143 | test_finished(false); 144 | } 145 | 146 | test_start('Validate vat_id - United Kingdom 3'); 147 | if ($lexoffice->valid_vat_id('GBGD999')) { 148 | test_finished(true); 149 | } else { 150 | test_finished(false); 151 | } 152 | 153 | test_start('Validate vat_id - United Kingdom 4'); 154 | if ($lexoffice->valid_vat_id('GBHA999')) { 155 | test_finished(true); 156 | } else { 157 | test_finished(false); 158 | } 159 | 160 | test_start('Validate vat_id - Croatia'); 161 | if ($lexoffice->valid_vat_id('HR99999999999')) { 162 | test_finished(true); 163 | } else { 164 | test_finished(false); 165 | } 166 | 167 | test_start('Validate vat_id - Hungary'); 168 | if ($lexoffice->valid_vat_id('HU99999999')) { 169 | test_finished(true); 170 | } else { 171 | test_finished(false); 172 | } 173 | 174 | test_start('Validate vat_id - Ireland 1'); 175 | if ($lexoffice->valid_vat_id('IE9S99999L')) { 176 | test_finished(true); 177 | } else { 178 | test_finished(false); 179 | } 180 | 181 | test_start('Validate vat_id - Ireland 2'); 182 | if ($lexoffice->valid_vat_id('IE9999999LI')) { 183 | test_finished(true); 184 | } else { 185 | test_finished(false); 186 | } 187 | 188 | test_start('Validate vat_id - Italy'); 189 | if ($lexoffice->valid_vat_id('IT99999999999')) { 190 | test_finished(true); 191 | } else { 192 | test_finished(false); 193 | } 194 | 195 | test_start('Validate vat_id - Lithuania 1'); 196 | if ($lexoffice->valid_vat_id('LT999999999')) { 197 | test_finished(true); 198 | } else { 199 | test_finished(false); 200 | } 201 | 202 | test_start('Validate vat_id - Lithuania 2'); 203 | if ($lexoffice->valid_vat_id('LT999999999999')) { 204 | test_finished(true); 205 | } else { 206 | test_finished(false); 207 | } 208 | 209 | test_start('Validate vat_id - Luxemburg'); 210 | if ($lexoffice->valid_vat_id('LU99999999')) { 211 | test_finished(true); 212 | } else { 213 | test_finished(false); 214 | } 215 | 216 | test_start('Validate vat_id - Latvia'); 217 | if ($lexoffice->valid_vat_id('LV99999999999')) { 218 | test_finished(true); 219 | } else { 220 | test_finished(false); 221 | } 222 | 223 | test_start('Validate vat_id - Malta'); 224 | if ($lexoffice->valid_vat_id('MT99999999')) { 225 | test_finished(true); 226 | } else { 227 | test_finished(false); 228 | } 229 | 230 | test_start('Validate vat_id - Netherlends'); 231 | if ($lexoffice->valid_vat_id('NLXXXXXXXXXX99')) { 232 | test_finished(true); 233 | } else { 234 | test_finished(false); 235 | } 236 | 237 | test_start('Validate vat_id - Poland'); 238 | if ($lexoffice->valid_vat_id('PL9999999999')) { 239 | test_finished(true); 240 | } else { 241 | test_finished(false); 242 | } 243 | 244 | test_start('Validate vat_id - Portugal'); 245 | if ($lexoffice->valid_vat_id('PT999999999')) { 246 | test_finished(true); 247 | } else { 248 | test_finished(false); 249 | } 250 | 251 | test_start('Validate vat_id - Romania'); 252 | if ($lexoffice->valid_vat_id('RO999999999')) { 253 | test_finished(true); 254 | } else { 255 | test_finished(false); 256 | } 257 | 258 | test_start('Validate vat_id - Sweden'); 259 | if ($lexoffice->valid_vat_id('SE999999999999')) { 260 | test_finished(true); 261 | } else { 262 | test_finished(false); 263 | } 264 | 265 | test_start('Validate vat_id - Slovenia'); 266 | if ($lexoffice->valid_vat_id('SI99999999')) { 267 | test_finished(true); 268 | } else { 269 | test_finished(false); 270 | } 271 | 272 | test_start('Validate vat_id - incorrect id - Slovenia'); 273 | if (!$lexoffice->valid_vat_id(' ')) { 274 | test_finished(true); 275 | } else { 276 | test_finished(false); 277 | } 278 | 279 | test_start('Validate vat_id - Slovakia'); 280 | if ($lexoffice->valid_vat_id('SK9999999999')) { 281 | test_finished(true); 282 | } else { 283 | test_finished(false); 284 | } 285 | 286 | test_start('Validate vat_id - extra spaces - Slovakia'); 287 | if ($lexoffice->valid_vat_id(' SK9999999999 ')) { 288 | test_finished(true); 289 | } else { 290 | test_finished(false); 291 | } -------------------------------------------------------------------------------- /tests/tests/021_e_invoice_pdf_rendering.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | 'street' => 'Brink 1', 16 | 'zip' => '51647', 17 | 'city' => 'Gummersbach', 18 | 'countryCode' => 'DE', 19 | 'contactPersons' => array( 20 | array( 21 | 'salutation' => 'Herr', 22 | 'firstName' => 'John', 23 | 'lastName' => 'Doe', 24 | 'emailAddress' =>'support@baebeca.de', 25 | 'phoneNumber' => '022619202930', 26 | ) 27 | ), 28 | ), 29 | 'addresses' => array( 30 | 'billing' => array( 31 | array( 32 | 'street' => 'Brink 1', 33 | 'zip' => '51647', 34 | 'city' => 'Gummersbach', 35 | 'countryCode' => 'DE', 36 | ), 37 | ), 38 | ), 39 | 'emailAddresses' => array( 40 | 'business' => array( 41 | 'support@baebeca.de' 42 | ), 43 | ), 44 | 'phoneNumbers' => array( 45 | 'business' => array( 46 | '022619202930' 47 | ), 48 | ), 49 | 'xRechnung' => [ 50 | 'buyerReference' => '04011000-1234512345-35', 51 | 'vendorNumberAtCustomer' => '70123456', 52 | ], 53 | 'note' => '', 54 | )); 55 | 56 | if ($request->id) { 57 | test('contact created - id: '.$request->id); 58 | $contact = $request->id; 59 | test_finished(true); 60 | } else { 61 | test_finished(false); 62 | } 63 | 64 | } 65 | catch(lexoffice_exception $e) { 66 | test($e->getMessage()); 67 | test(print_r($e->get_error(), true)); 68 | test_finished(false); 69 | } 70 | 71 | test_start('create final invoice and download non rendered version'); 72 | try { 73 | $request = $lexoffice->create_invoice([ 74 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 75 | 'introduction' => 'Einleitungstext', 76 | 'remark' => "Fußzeile\r\nMehrzeilig", 77 | 'address' => [ 78 | 'contactId' => $contact, 79 | ], 80 | 'lineItems' => [ 81 | [ 82 | 'type' => 'custom', 83 | 'name' => 'Produktname', 84 | 'description' => 'Beschreibung', 85 | 'quantity' => 1, 86 | 'unitName' => 'Stück', 87 | 'unitPrice' => [ 88 | 'currency' => 'EUR', 89 | 'netAmount' => 11.99, 90 | 'taxRatePercentage' => 0, 91 | ], 92 | #'discountPercentage' => 0, 93 | ], 94 | ], 95 | 'totalPrice' => [ 96 | 'currency' => 'EUR', 97 | #'totalDiscountAbsolute' => 0, 98 | #'totalDiscountPercentage' => 0, 99 | ], 100 | 'taxConditions' => [ 101 | 'taxType' => 'net', 102 | ], 103 | 'shippingConditions' => [ 104 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 105 | 'shippingType' => 'delivery', 106 | ], 107 | 'paymentConditions' => [ 108 | 'paymentTermLabel' => 'Vorkasse', 109 | 'paymentTermDuration' => 1, 110 | ], 111 | 'xRechnung' => [ 112 | 'buyerReference' => '04011000-1234512345-35', 113 | ] 114 | ], true); 115 | 116 | if ($request->id) { 117 | @unlink(__DIR__.'/tmp/021_invoice_final.pdf'); 118 | @unlink(__DIR__.'/tmp/021_invoice_final.pdf.xml'); 119 | test('x-invoice created - id: '.$request->id); 120 | test('download pdf and xml instantly without rendering'); 121 | $lexoffice->get_pdf('invoices', $request->id, __DIR__ . '/tmp/021_invoice_final.pdf'); 122 | 123 | if ( 124 | is_file(__DIR__.'/tmp/021_invoice_final.pdf') && 125 | is_file(__DIR__.'/tmp/021_invoice_final.pdf.xml') 126 | ) { 127 | unlink(__DIR__.'/tmp/021_invoice_final.pdf'); 128 | unlink(__DIR__.'/tmp/021_invoice_final.pdf.xml'); 129 | test_finished(true); 130 | } 131 | else { 132 | test_finished(false); 133 | } 134 | } else { 135 | test_finished(false); 136 | } 137 | } catch(lexoffice_exception $e) { 138 | test($e->getMessage()); 139 | test(print_r($e->get_error(), true)); 140 | test_finished(false); 141 | } 142 | 143 | test_start('create draft invoice and download non rendered version'); 144 | try { 145 | $request = $lexoffice->create_invoice([ 146 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 147 | 'introduction' => 'Einleitungstext', 148 | 'remark' => "Fußzeile\r\nMehrzeilig", 149 | 'address' => [ 150 | 'contactId' => $contact, 151 | ], 152 | 'lineItems' => [ 153 | [ 154 | 'type' => 'custom', 155 | 'name' => 'Produktname', 156 | 'description' => 'Beschreibung', 157 | 'quantity' => 1, 158 | 'unitName' => 'Stück', 159 | 'unitPrice' => [ 160 | 'currency' => 'EUR', 161 | 'netAmount' => 11.99, 162 | 'taxRatePercentage' => 0, 163 | ], 164 | #'discountPercentage' => 0, 165 | ], 166 | ], 167 | 'totalPrice' => [ 168 | 'currency' => 'EUR', 169 | #'totalDiscountAbsolute' => 0, 170 | #'totalDiscountPercentage' => 0, 171 | ], 172 | 'taxConditions' => [ 173 | 'taxType' => 'net', 174 | ], 175 | 'shippingConditions' => [ 176 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 177 | 'shippingType' => 'delivery', 178 | ], 179 | 'paymentConditions' => [ 180 | 'paymentTermLabel' => 'Vorkasse', 181 | 'paymentTermDuration' => 1, 182 | ], 183 | 'xRechnung' => [ 184 | 'buyerReference' => '04011000-1234512345-35', 185 | ] 186 | ], false); 187 | 188 | if ($request->id) { 189 | @unlink(__DIR__.'/tmp/021_invoice_draft.pdf'); 190 | @unlink(__DIR__.'/tmp/021_invoice_draft.pdf.xml'); 191 | test('x-invoice created - id: '.$request->id); 192 | test('download pdf and xml instantly without rendering'); 193 | $request = $lexoffice->get_pdf('invoices', $request->id, __DIR__ . '/tmp/021_invoice_draft.pdf'); 194 | if ( 195 | $request === false // at the moment no pdfs for drafts 196 | #is_file(__DIR__.'/tmp/021_invoice_draft.pdf') && 197 | #is_file(__DIR__.'/tmp/021_invoice_draft.pdf.xml') 198 | ) { 199 | unlink(__DIR__.'/tmp/021_invoice_draft.pdf'); 200 | unlink(__DIR__.'/tmp/021_invoice_draft.pdf.xml'); 201 | test_finished(true); 202 | } 203 | else { 204 | test_finished(false); 205 | } 206 | } else { 207 | test_finished(false); 208 | } 209 | } catch(lexoffice_exception $e) { 210 | test($e->getMessage()); 211 | test(print_r($e->get_error(), true)); 212 | test_finished(false); 213 | } 214 | 215 | @unlink(__DIR__.'/tmp/021_invoice_final.pdf'); 216 | @unlink(__DIR__.'/tmp/021_invoice_final.pdf.xml'); 217 | @unlink(__DIR__.'/tmp/021_invoice_draft.pdf'); 218 | @unlink(__DIR__.'/tmp/021_invoice_draft.pdf.xml'); -------------------------------------------------------------------------------- /tests/tests/100_tax_net_company_destinantion.php: -------------------------------------------------------------------------------- 1 | test_set_profile('net', false, 'DESTINATION'); 3 | 4 | test_start('check voucher booking id - germany sell after oss'); 5 | try { 6 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'de', strtotime('2021-07-05'), false, true, true); 7 | test_finished($request === '8f8664a8-fd86-11e1-a21f-0800200c9a66'); 8 | } 9 | catch (lexoffice_exception $e) { 10 | test($e->getMessage()); 11 | test_finished(false); 12 | } 13 | 14 | test_start('check voucher booking id - nl physical good sell - 0% - before oss'); 15 | try { 16 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'nl', strtotime('2021-06-27'), false, true, true); 17 | test_finished($request === '8f8664a1-fd86-11e1-a21f-0800200c9a66'); 18 | } 19 | catch (lexoffice_exception $e) { 20 | test($e->getMessage()); 21 | test_finished(false); 22 | } 23 | 24 | 25 | test_start('check voucher booking id - nl physical good sell - 0% - after oss'); 26 | try { 27 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'nl', strtotime('2021-07-05'), false, true, true); 28 | test_finished($request === '4ebd965a-7126-416c-9d8c-a5c9366ee473'); 29 | } 30 | catch (lexoffice_exception $e) { 31 | test($e->getMessage()); 32 | test_finished(false); 33 | } 34 | 35 | test_start('check voucher booking id - nl digital good sell - 0% - before oss'); 36 | try { 37 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'nl', strtotime('2021-06-05'),false, true, false); 38 | test_finished($request === '8f8664a1-fd86-11e1-a21f-0800200c9a66'); 39 | } 40 | catch (lexoffice_exception $e) { 41 | test($e->getMessage()); 42 | test_finished(false); 43 | } 44 | 45 | test_start('check voucher booking id - nl digital good sell - 0% - after oss'); 46 | try { 47 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'nl', strtotime('2021-07-05'),false, true, false); 48 | test_finished($request === '7ecea006-844c-4c98-a02d-aa3142640dd5'); 49 | } 50 | catch (lexoffice_exception $e) { 51 | test($e->getMessage()); 52 | test_finished(false); 53 | } 54 | 55 | test_start('check voucher booking id - nl physical good sell - 21% - before oss'); 56 | try { 57 | $request = $lexoffice->get_needed_voucher_booking_id(21, 'nl', strtotime('2021-06-05'), false, false, true); 58 | test_finished($request === '8f8664a1-fd86-11e1-a21f-0800200c9a66'); 59 | } 60 | catch (lexoffice_exception $e) { 61 | test($e->getMessage()); 62 | test_finished(false); 63 | } 64 | 65 | test_start('check voucher booking id - nl physical good sell - 21% - after oss'); 66 | try { 67 | $request = $lexoffice->get_needed_voucher_booking_id(21, 'nl', strtotime('2021-07-05'), false, false, true); 68 | test_finished($request === '4ebd965a-7126-416c-9d8c-a5c9366ee473'); 69 | } 70 | catch (lexoffice_exception $e) { 71 | test($e->getMessage()); 72 | test_finished(false); 73 | } 74 | 75 | test_start('check voucher booking id - nl digital good sell - 9% - before oss'); 76 | try { 77 | $request = $lexoffice->get_needed_voucher_booking_id(9, 'nl', strtotime('2021-06-05'), false, false, false); 78 | test_finished($request === '8f8664a1-fd86-11e1-a21f-0800200c9a66'); 79 | } 80 | catch (lexoffice_exception $e) { 81 | test($e->getMessage()); 82 | test_finished(false); 83 | } 84 | 85 | test_start('check voucher booking id - nl digital good sell - 9% - after oss'); 86 | try { 87 | $request = $lexoffice->get_needed_voucher_booking_id(9, 'nl', strtotime('2021-07-05'), false, false, false); 88 | test_finished($request === '7ecea006-844c-4c98-a02d-aa3142640dd5'); 89 | } 90 | catch (lexoffice_exception $e) { 91 | test($e->getMessage()); 92 | test_finished(false); 93 | } 94 | 95 | test_start('check voucher booking id - ch b2b digital good sell'); 96 | try { 97 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'ch', strtotime('2021-07-05'),false, true, false); 98 | test_finished($request === 'ef5b1a6e-f690-4004-9a19-91276348894f'); 99 | } 100 | catch (lexoffice_exception $e) { 101 | test($e->getMessage()); 102 | test_finished(false); 103 | } 104 | 105 | test_start('check voucher booking id - ch b2c digital good sell'); 106 | try { 107 | $request = $lexoffice->get_needed_voucher_booking_id(19, 'ch', strtotime('2021-07-05'),false, false, false); 108 | test_finished(false); 109 | } 110 | catch (lexoffice_exception $e) { 111 | test_finished($e->getMessage() === 'lexoffice-php-api: unknown booking scenario, world service with taxes. cannot decide correct booking category'); 112 | } 113 | 114 | $lexoffice->test_clear_profile(); -------------------------------------------------------------------------------- /tests/tests/100_tax_net_company_origin.php: -------------------------------------------------------------------------------- 1 | test_set_profile('net', false, 'ORIGIN'); 3 | 4 | test_start('check voucher booking id - germany sell before oss'); 5 | try { 6 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'de', strtotime('2021-06-27'), false, true, true); 7 | test_finished($request === '8f8664a8-fd86-11e1-a21f-0800200c9a66'); 8 | } 9 | catch (lexoffice_exception $e) { 10 | test($e->getMessage()); 11 | test_finished(false); 12 | } 13 | 14 | $lexoffice->test_clear_profile(); -------------------------------------------------------------------------------- /tests/tests/100_tax_taxfree_company.php: -------------------------------------------------------------------------------- 1 | test_set_profile('vatfree', true, 'ORIGIN'); 3 | 4 | test_start('check voucher booking id - germany sell before oss - tax_free_company'); 5 | try { 6 | $request = $lexoffice->get_needed_voucher_booking_id(0, 'de', strtotime('2021-06-27'), false, true, true); 7 | test_finished($request === '7a1efa0e-6283-4cbf-9583-8e88d3ba5960'); 8 | } 9 | catch (lexoffice_exception $e) { 10 | test($e->getMessage()); 11 | test_finished(false); 12 | } 13 | 14 | $lexoffice->test_clear_profile(); -------------------------------------------------------------------------------- /tests/tests/110_vouchers_e_invoices.php: -------------------------------------------------------------------------------- 1 | get_voucher_files($id, __DIR__ . '/tmp/XRechnung-sample'); 10 | $payload_a = file_get_contents(__DIR__ . '/files/XRechnung-sample.xml'); 11 | $payload_b = file_get_contents(__DIR__ . '/tmp/XRechnung-sample_1.xml'); 12 | 13 | if ($payload_a === $payload_a && file_exists(__DIR__ . '/tmp/XRechnung-sample_1.pdf')) { 14 | unlink(__DIR__.'\tmp\XRechnung-sample_1.xml'); 15 | unlink(__DIR__.'\tmp\XRechnung-sample_1.pdf'); 16 | test_finished(true); 17 | } else { 18 | test_finished($payload_b); 19 | } 20 | } catch (lexoffice_exception $e) { 21 | test($e->getMessage()); 22 | test(print_r($e->get_error(), true)); 23 | test_finished(false); 24 | } -------------------------------------------------------------------------------- /tests/tests/120_invoices_e_invoices.php: -------------------------------------------------------------------------------- 1 | get_pdf('invoices', $id_xrechnung, __DIR__.'/tmp/120_XRechnung.pdf'); 11 | if (file_exists(__DIR__.'/tmp/120_XRechnung.pdf') && file_exists(__DIR__.'/tmp/120_XRechnung.pdf.xml')) { 12 | unlink(__DIR__.'\tmp\120_XRechnung.pdf'); 13 | unlink(__DIR__.'\tmp\120_XRechnung.pdf.xml'); 14 | test_finished(true); 15 | } 16 | else { 17 | test_finished(false); 18 | } 19 | } 20 | catch(lexoffice_exception $e) { 21 | test($e->getMessage()); 22 | test(print_r($e->get_error(), true)); 23 | test_finished(false); 24 | } 25 | 26 | test_start('download pdf without additional xml from an default invoice'); 27 | try { 28 | $lexoffice->get_pdf('invoices', $id_defaultInvoice, __DIR__.'/tmp/120_Rechnung.pdf'); 29 | if (file_exists(__DIR__.'/tmp/120_Rechnung.pdf') && !file_exists(__DIR__.'/tmp/120_Rechnung.pdf.xml')) { 30 | unlink(__DIR__.'\tmp\120_Rechnung.pdf'); 31 | test_finished(true); 32 | } 33 | else { 34 | test_finished(false); 35 | } 36 | } 37 | catch(lexoffice_exception $e) { 38 | test($e->getMessage()); 39 | test(print_r($e->get_error(), true)); 40 | test_finished(false); 41 | } -------------------------------------------------------------------------------- /tests/tests/301_contact_with_multiple_addresses.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | // use random name, use it in later search check 15 | 'name' => $random_contact_name, 16 | 'street' => 'Brink 1', 17 | 'zip' => '51647', 18 | 'city' => 'Gummersbach', 19 | 'countryCode' => 'DE', 20 | 'contactPersons' => array( 21 | array( 22 | 'salutation' => 'Herr', 23 | 'firstName' => 'John', 24 | 'lastName' => 'Doe', 25 | 'emailAddress' =>'support@baebeca.de', 26 | 'phoneNumber' => '022619202930', 27 | ) 28 | ), 29 | ), 30 | 'addresses' => array( 31 | 'billing' => array( 32 | array( 33 | 'street' => 'Brink 1', 34 | 'zip' => '51647', 35 | 'city' => 'Gummersbach', 36 | 'countryCode' => 'DE', 37 | ), 38 | ), 39 | 'shipping' => array( 40 | array( 41 | 'street' => 'Brink 1', 42 | 'zip' => '51647', 43 | 'city' => 'Gummersbach', 44 | 'countryCode' => 'DE', 45 | ), 46 | ), 47 | ), 48 | 'emailAddresses' => array( 49 | 'business' => array( 50 | 'support@baebeca.de' 51 | ), 52 | ), 53 | 'phoneNumbers' => array( 54 | 'business' => array( 55 | '022619202930' 56 | ), 57 | ), 58 | 'note' => '', 59 | )); 60 | 61 | if ($request->id) { 62 | test('contact created - id: '.$request->id); 63 | test_finished(true); 64 | } else { 65 | test_finished(false); 66 | } 67 | 68 | } catch(lexoffice_exception $e) { 69 | test($e->getMessage()); 70 | test(print_r($e->get_error(), true)); 71 | test_finished(false); 72 | } -------------------------------------------------------------------------------- /tests/tests/302_contact_with_empty_mail.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | // use random name, use it in later search check 15 | 'name' => $random_contact_name, 16 | 'street' => 'Brink 1', 17 | 'zip' => '51647', 18 | 'city' => 'Gummersbach', 19 | 'countryCode' => 'DE', 20 | 'contactPersons' => array( 21 | array( 22 | 'salutation' => 'Herr', 23 | 'firstName' => 'John', 24 | 'lastName' => 'Doe', 25 | 'emailAddress' =>'support@baebeca.de', 26 | 'phoneNumber' => '022619202930', 27 | ) 28 | ), 29 | ), 30 | 'addresses' => array( 31 | 'billing' => array( 32 | array( 33 | 'street' => 'Brink 1', 34 | 'zip' => '51647', 35 | 'city' => 'Gummersbach', 36 | 'countryCode' => 'DE', 37 | ), 38 | ), 39 | ), 40 | 'emailAddresses' => array( 41 | 'business' => array( 42 | '' 43 | ), 44 | ), 45 | 'phoneNumbers' => array( 46 | 'business' => array( 47 | '0123456' 48 | ), 49 | ), 50 | 'note' => '', 51 | )); 52 | 53 | if ($request->id) { 54 | test('contact created - id: '.$request->id); 55 | test_finished(true); 56 | } else { 57 | test_finished(false); 58 | } 59 | 60 | } catch(lexoffice_exception $e) { 61 | test($e->getMessage()); 62 | test(print_r($e->get_error(), true)); 63 | test_finished(false); 64 | } -------------------------------------------------------------------------------- /tests/tests/303_contact_with_empty_phone_number.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | // use random name, use it in later search check 15 | 'name' => $random_contact_name, 16 | 'street' => 'Brink 1', 17 | 'zip' => '51647', 18 | 'city' => 'Gummersbach', 19 | 'countryCode' => 'DE', 20 | 'contactPersons' => array( 21 | array( 22 | 'salutation' => 'Herr', 23 | 'firstName' => 'John', 24 | 'lastName' => 'Doe', 25 | 'emailAddress' =>'support@baebeca.de', 26 | 'phoneNumber' => '022619202930', 27 | ) 28 | ), 29 | ), 30 | 'addresses' => array( 31 | 'billing' => array( 32 | array( 33 | 'street' => 'Brink 1', 34 | 'zip' => '51647', 35 | 'city' => 'Gummersbach', 36 | 'countryCode' => 'DE', 37 | ), 38 | ), 39 | ), 40 | 'emailAddresses' => array( 41 | 'business' => array( 42 | 'support@baebeca.de' 43 | ), 44 | ), 45 | 'phoneNumbers' => array( 46 | 'business' => array( 47 | '' 48 | ), 49 | ), 50 | 'note' => '', 51 | )); 52 | 53 | if ($request->id) { 54 | test('contact created - id: '.$request->id); 55 | test_finished(true); 56 | } else { 57 | test_finished(false); 58 | } 59 | 60 | } catch(lexoffice_exception $e) { 61 | test($e->getMessage()); 62 | test(print_r($e->get_error(), true)); 63 | test_finished(false); 64 | } -------------------------------------------------------------------------------- /tests/tests/304_contact_with_invalid_phone_number.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | 'street' => 'Brink 1', 16 | 'zip' => '51647', 17 | 'city' => 'Gummersbach', 18 | 'countryCode' => 'DE', 19 | 'contactPersons' => array( 20 | array( 21 | 'salutation' => 'Herr', 22 | 'firstName' => 'John', 23 | 'lastName' => 'Doe', 24 | 'emailAddress' =>'', 25 | 'phoneNumber' => 'Sun 123456789, 987654321', 26 | ) 27 | ), 28 | ), 29 | 'addresses' => array( 30 | 'billing' => array( 31 | array( 32 | 'street' => 'Brink 1', 33 | 'zip' => '51647', 34 | 'city' => 'Gummersbach', 35 | 'countryCode' => 'DE', 36 | ), 37 | ), 38 | ), 39 | 'emailAddresses' => array( 40 | 'business' => array( 41 | 'support@baebeca.de' 42 | ), 43 | ), 44 | 'phoneNumbers' => array( 45 | 'business' => array( 46 | '34535345 12121221 8888888888' 47 | ), 48 | ), 49 | 'note' => '', 50 | )); 51 | 52 | if ($request->id) { 53 | test('contact created - id: '.$request->id); 54 | $update_id = $request->id; 55 | $contact = $lexoffice->get_contact($request->id); 56 | if ($contact->company->contactPersons[0]->phoneNumber === '123456789') test_finished(true); 57 | else test_finished(false); 58 | } else { 59 | test_finished(false); 60 | } 61 | 62 | } catch(lexoffice_exception $e) { 63 | test($e->getMessage()); 64 | test(print_r($e->get_error(), true)); 65 | test_finished(false); 66 | } 67 | 68 | test_start('update phone number with letters and invalid size(>30) - company'); 69 | try { 70 | $contact = $lexoffice->get_contact($request->id); 71 | $contact->phoneNumbers->office[0] = "Manager Julius Cesar 034247632477mistake"; 72 | $contact->phoneNumbers->business[0] = "Crazy 098934343444544654689893844345345436546456 Frog"; 73 | $request = $lexoffice->update_contact($request->id, $contact); 74 | if ($request->id) { 75 | test('contact updated - id: '.$request->id); 76 | $contact_new = $lexoffice->get_contact($request->id); 77 | if ($contact_new->phoneNumbers->office[0] === "034247632477" && !isset($contact_new->phoneNumbers->business[0])) { 78 | test_finished(true); 79 | } 80 | else { 81 | test_finished(false); 82 | } 83 | } else { 84 | test_finished(false); 85 | } 86 | } catch(lexoffice_exception $e) { 87 | test($e->getMessage()); 88 | test(print_r($e->get_error(), true)); 89 | test_finished(false); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /tests/tests/305_contact_with_invalid_mail.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | 'street' => 'Brink 1', 16 | 'zip' => '51647', 17 | 'city' => 'Gummersbach', 18 | 'countryCode' => 'DE' 19 | ), 20 | 'emailAddresses' => array( 21 | 'business' => array( 22 | '..test@email.@company.com', 23 | ), 24 | ) 25 | )); 26 | test_finished(true); 27 | } catch(lexoffice_exception $e) { 28 | if ($e->get_error()['Response']->IssueList[0]->source === 'emailAddresses[0].emailAddress') { 29 | test_finished(true); 30 | } 31 | else { 32 | test_finished(true); 33 | } 34 | } 35 | 36 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 37 | test_start('Create Contact with invalid E-Mail Address(Contact Person)'); 38 | try { 39 | $request = $lexoffice->create_contact(array( 40 | 'version' => 0, 41 | 'roles' => array( 42 | 'customer' => array( 43 | 'number' => '', 44 | ), 45 | ), 46 | 'company' => array( 47 | 'name' => $random_contact_name, 48 | 'street' => 'Brink 1', 49 | 'zip' => '51647', 50 | 'city' => 'Gummersbach', 51 | 'countryCode' => 'DE', 52 | 'contactPersons' => array( 53 | array( 54 | 'salutation' => 'Herr', 55 | 'firstName' => 'John', 56 | 'lastName' => 'Doe', 57 | 'emailAddress' =>'..test@email.@company.com', 58 | 'phoneNumber' => '022619202930', 59 | ) 60 | ), 61 | ), 62 | 'emailAddresses' => array( 63 | 'business' => array( 64 | '' 65 | ), 66 | ) 67 | )); 68 | test_finished(false); 69 | test_finished(true); 70 | } catch(lexoffice_exception $e) { 71 | if ($e->get_error()['Response']->IssueList[0]->source === 'emailAddresses[0].emailAddress') { 72 | test_finished(true); 73 | } 74 | else { 75 | test_finished(true); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /tests/tests/306_contact_with_strange_mail.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | 'street' => 'Brink 1', 16 | 'zip' => '51647', 17 | 'city' => 'Gummersbach', 18 | 'countryCode' => 'DE' 19 | ), 20 | 'emailAddresses' => array( 21 | 'business' => array( 22 | 'r.-klaus@t-online.de', 23 | ), 24 | ) 25 | )); 26 | if ($request->id) { 27 | $contact = $lexoffice->get_contact($request->id); 28 | if (!empty($contact->emailAddresses->business[0])) { 29 | test_finished(true); 30 | } 31 | else { 32 | test_finished(false); 33 | } 34 | } else { 35 | test_finished(false); 36 | } 37 | } catch(lexoffice_exception $e) { 38 | test($e->getMessage()); 39 | test(print_r($e->get_error(), true)); 40 | test_finished(false); 41 | } 42 | 43 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 44 | test_start('Create Contact with invalid E-Mail Address(Contact Person)'); 45 | try { 46 | $request = $lexoffice->create_contact(array( 47 | 'version' => 0, 48 | 'roles' => array( 49 | 'customer' => array( 50 | 'number' => '', 51 | ), 52 | ), 53 | 'company' => array( 54 | 'name' => $random_contact_name, 55 | 'street' => 'Brink 1', 56 | 'zip' => '51647', 57 | 'city' => 'Gummersbach', 58 | 'countryCode' => 'DE', 59 | 'contactPersons' => array( 60 | array( 61 | 'salutation' => 'Herr', 62 | 'firstName' => 'John', 63 | 'lastName' => 'Doe', 64 | 'emailAddress' =>'r.-klaus@t-online.de', 65 | 'phoneNumber' => '022619202930', 66 | ) 67 | ), 68 | ), 69 | )); 70 | if ($request->id) { 71 | $contact = $lexoffice->get_contact($request->id); 72 | if (!empty($contact->company->contactPersons[0]->emailAddress)) { 73 | test_finished(true); 74 | } 75 | else test_finished(false); 76 | } else { 77 | test_finished(false); 78 | } 79 | } catch(lexoffice_exception $e) { 80 | test($e->getMessage()); 81 | test(print_r($e->get_error(), true)); 82 | test_finished(false); 83 | } -------------------------------------------------------------------------------- /tests/tests/307_contact_with_umlaut_mail_domain.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | 'street' => 'Brink 1', 16 | 'zip' => '51647', 17 | 'city' => 'Gummersbach', 18 | 'countryCode' => 'DE' 19 | ), 20 | 'emailAddresses' => array( 21 | 'business' => array( 22 | 'hans@klöse.de', 23 | ), 24 | ) 25 | )); 26 | if ($request->id) { 27 | $contact = $lexoffice->get_contact($request->id); 28 | if (!empty($contact->emailAddresses->business[0])) { 29 | test_finished(true); 30 | } 31 | else { 32 | test_finished(false); 33 | } 34 | } else { 35 | test_finished(false); 36 | } 37 | } catch(lexoffice_exception $e) { 38 | test($e->getMessage()); 39 | test(print_r($e->get_error(), true)); 40 | test_finished(false); 41 | } 42 | 43 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 44 | test_start('Create Contact with invalid E-Mail Address(Contact Person)'); 45 | try { 46 | $request = $lexoffice->create_contact(array( 47 | 'version' => 0, 48 | 'roles' => array( 49 | 'customer' => array( 50 | 'number' => '', 51 | ), 52 | ), 53 | 'company' => array( 54 | 'name' => $random_contact_name, 55 | 'street' => 'Brink 1', 56 | 'zip' => '51647', 57 | 'city' => 'Gummersbach', 58 | 'countryCode' => 'DE', 59 | 'contactPersons' => array( 60 | array( 61 | 'salutation' => 'Herr', 62 | 'firstName' => 'John', 63 | 'lastName' => 'Doe', 64 | 'emailAddress' =>'hans@klöse.de', 65 | 'phoneNumber' => '022619202930', 66 | ) 67 | ), 68 | ), 69 | )); 70 | if ($request->id) { 71 | $contact = $lexoffice->get_contact($request->id); 72 | if (!empty($contact->company->contactPersons[0]->emailAddress)) { 73 | test_finished(true); 74 | } 75 | else test_finished(false); 76 | } else { 77 | test_finished(false); 78 | } 79 | } catch(lexoffice_exception $e) { 80 | test($e->getMessage()); 81 | test(print_r($e->get_error(), true)); 82 | test_finished(false); 83 | } -------------------------------------------------------------------------------- /tests/tests/308_contact_with_umlaut_mail_local.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | 'street' => 'Brink 1', 16 | 'zip' => '51647', 17 | 'city' => 'Gummersbach', 18 | 'countryCode' => 'DE' 19 | ), 20 | 'emailAddresses' => array( 21 | 'business' => array( 22 | 'häns@klose.de', 23 | ), 24 | ) 25 | )); 26 | if ($request->id) { 27 | $contact = $lexoffice->get_contact($request->id); 28 | if (!empty($contact->emailAddresses->business[0])) { 29 | test_finished(true); 30 | } 31 | else { 32 | test_finished(false); 33 | } 34 | } else { 35 | test_finished(false); 36 | } 37 | } catch(lexoffice_exception $e) { 38 | test($e->getMessage()); 39 | test(print_r($e->get_error(), true)); 40 | test_finished(false); 41 | } 42 | 43 | $random_contact_name = 'contact_'.rand(11111111, 999999999999); 44 | test_start('Create Contact with invalid E-Mail Address(Contact Person)'); 45 | try { 46 | $request = $lexoffice->create_contact(array( 47 | 'version' => 0, 48 | 'roles' => array( 49 | 'customer' => array( 50 | 'number' => '', 51 | ), 52 | ), 53 | 'company' => array( 54 | 'name' => $random_contact_name, 55 | 'street' => 'Brink 1', 56 | 'zip' => '51647', 57 | 'city' => 'Gummersbach', 58 | 'countryCode' => 'DE', 59 | 'contactPersons' => array( 60 | array( 61 | 'salutation' => 'Herr', 62 | 'firstName' => 'John', 63 | 'lastName' => 'Doe', 64 | 'emailAddress' =>'häns@klose.de', 65 | 'phoneNumber' => '022619202930', 66 | ) 67 | ), 68 | ), 69 | )); 70 | if ($request->id) { 71 | $contact = $lexoffice->get_contact($request->id); 72 | if (!empty($contact->company->contactPersons[0]->emailAddress)) { 73 | test_finished(true); 74 | } 75 | else test_finished(false); 76 | } else { 77 | test_finished(false); 78 | } 79 | } catch(lexoffice_exception $e) { 80 | test($e->getMessage()); 81 | test(print_r($e->get_error(), true)); 82 | test_finished(false); 83 | } -------------------------------------------------------------------------------- /tests/tests/400_vouchers.php: -------------------------------------------------------------------------------- 1 | create_voucher([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'type' => 'salesinvoice', 8 | 'voucherNumber' => "Test-1234", 9 | 'totalGrossAmount' => 25251578.84, 10 | 'totalTaxAmount' => 4031764.69, 11 | 'taxType' => "gross", 12 | 'useCollectiveContact' => true, 13 | 'voucherItems' => [ 14 | [ 15 | 'amount' => 25251578.84, 16 | 'taxAmount' => 4031764.69, 17 | 'taxRatePercent' => $taxrate_19, 18 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 19 | ], 20 | ], 21 | ]); 22 | 23 | if ($request->id) { 24 | test('voucher created - id: '.$request->id); 25 | test_finished(true); 26 | } else { 27 | test_finished(false); 28 | } 29 | } catch(lexoffice_exception $e) { 30 | test($e->getMessage()); 31 | test(print_r($e->get_error(), true)); 32 | test_finished(false); 33 | } 34 | 35 | test_start('create Warenverkauf voucher'); 36 | try { 37 | $request = $lexoffice->create_voucher([ 38 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 39 | 'type' => 'salesinvoice', 40 | 'voucherNumber' => "Test-1234-Ware", 41 | 'totalGrossAmount' => 25251578.84, 42 | 'totalTaxAmount' => 4031764.69, 43 | 'taxType' => "gross", 44 | 'useCollectiveContact' => true, 45 | 'voucherItems' => [ 46 | [ 47 | 'amount' => 25251578.84, 48 | 'taxAmount' => 4031764.69, 49 | 'taxRatePercent' => $taxrate_19, 50 | 'categoryId' => '8f8664a8-fd86-11e1-a21f-0800200c9a66', 51 | ], 52 | ], 53 | ]); 54 | 55 | if ($request->id) { 56 | test('voucher created - id: '.$request->id); 57 | test_finished(true); 58 | } else { 59 | test_finished(false); 60 | } 61 | } catch(lexoffice_exception $e) { 62 | test($e->getMessage()); 63 | test(print_r($e->get_error(), true)); 64 | test_finished(false); 65 | } 66 | 67 | test_start('create mixed tax voucher 16/19'); 68 | try { 69 | $request = $lexoffice->create_voucher([ 70 | 'version' => 0, 71 | 'voucherDate' => '2021-02-27', 72 | 'dueDate' => '2021-03-06', 73 | 'type' => 'salesinvoice', 74 | 'voucherNumber' => "21-001003RP", 75 | 'useCollectiveContact' => true, 76 | 'totalGrossAmount' => 9974.69, 77 | 'voucherItems' => [ 78 | [ 79 | 'amount' => "1748.81", 80 | 'taxAmount' => "279.81", 81 | 'taxRatePercent' => 16, 82 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 83 | ], 84 | [ 85 | 'amount' => "6677.37", 86 | 'taxAmount' => "1268.70", 87 | 'taxRatePercent' => 19, 88 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 89 | ], 90 | ], 91 | 'taxType' => "net", 92 | 'totalTaxAmount' => '1548.51', 93 | 'remark' => 'Erdbeerkuchen', 94 | ]); 95 | 96 | if ($request->id) { 97 | test('voucher created - id: '.$request->id); 98 | test_finished(true); 99 | } else { 100 | test_finished(false); 101 | } 102 | } catch(lexoffice_exception $e) { 103 | test($e->getMessage()); 104 | test(print_r($e->get_error(), true)); 105 | test_finished(false); 106 | } 107 | 108 | test_start('create voucher #74228'); 109 | try { 110 | $request = $lexoffice->create_voucher([ 111 | 'version' => 0, 112 | 'type' => 'salesinvoice', 113 | 'voucherNumber' => '6126', 114 | 'voucherDate' => '2021-09-13', 115 | 'dueDate' => '2021-09-20', 116 | 'useCollectiveContact' => true, 117 | 'totalGrossAmount' => 175.37, 118 | 'taxType' => "gross", 119 | 'totalTaxAmount' => 28.00, 120 | 'voucherItems' => [ 121 | [ 122 | 'amount' => 175.37, 123 | 'taxAmount' => 28.00, 124 | 'taxRatePercent' => 19, 125 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 126 | ], 127 | ], 128 | ]); 129 | 130 | if ($request->id) { 131 | test('voucher created - id: '.$request->id); 132 | test_finished(true); 133 | } else { 134 | test_finished(false); 135 | } 136 | } catch(lexoffice_exception $e) { 137 | test($e->getMessage()); 138 | test(print_r($e->get_error(), true)); 139 | test_finished(false); 140 | } 141 | 142 | test_start('create voucher with pdf'); 143 | $voucher_id = false; 144 | try { 145 | $request = $lexoffice->create_voucher([ 146 | 'version' => 0, 147 | 'type' => 'salesinvoice', 148 | 'voucherNumber' => 'dummy_pdf_upload', 149 | 'voucherDate' => '2021-09-13', 150 | 'dueDate' => '2021-09-20', 151 | 'useCollectiveContact' => true, 152 | 'totalGrossAmount' => 175.37, 153 | 'taxType' => "gross", 154 | 'totalTaxAmount' => 28.00, 155 | 'voucherItems' => [ 156 | [ 157 | 'amount' => 175.37, 158 | 'taxAmount' => 28.00, 159 | 'taxRatePercent' => 19, 160 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 161 | ], 162 | ], 163 | ]); 164 | 165 | if ($request->id) { 166 | test('voucher created - id: '.$request->id); 167 | try { 168 | $voucher_id = $request->id; // used in next test 169 | $lexoffice->upload_voucher($request->id, __DIR__.'/files/dummy.pdf'); 170 | test_finished(true); 171 | } catch(lexoffice_exception $e) { 172 | test($e->getMessage()); 173 | test(print_r($e->get_error(), true)); 174 | test_finished(false); 175 | } 176 | } else { 177 | test_finished(false); 178 | } 179 | } catch(lexoffice_exception $e) { 180 | test($e->getMessage()); 181 | test(print_r($e->get_error(), true)); 182 | test_finished(false); 183 | } 184 | 185 | test_start('add additonal pdf to previous created voucher'); 186 | try { 187 | if (empty($voucher_id)) test_finished(false); 188 | $lexoffice->upload_voucher($voucher_id, __DIR__.'/files/dummy_2.pdf'); 189 | test_finished(true); 190 | } catch(lexoffice_exception $e) { 191 | test($e->getMessage()); 192 | test(print_r($e->get_error(), true)); 193 | test_finished(false); 194 | } 195 | 196 | 197 | /** only enabled if needed */ 198 | /* 199 | test_start('get all vouchers'); 200 | try { 201 | $request = $lexoffice->get_vouchers('salesinvoice', 'draft,open,paid,paidoff,voided,transferred,sepadebit,accepted,rejected', 'both'); 202 | 203 | if (count($request)) { 204 | test('get '.count($request).' vouchers'); 205 | test_finished(true); 206 | } else { 207 | test_finished(false); 208 | } 209 | } catch(lexoffice_exception $e) { 210 | test($e->getMessage()); 211 | test(print_r($e->get_error(), true)); 212 | test_finished(false); 213 | } 214 | */ -------------------------------------------------------------------------------- /tests/tests/401_voucher_with_rounding.php: -------------------------------------------------------------------------------- 1 | create_voucher([ 6 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 7 | 'type' => 'salesinvoice', 8 | 'voucherNumber' => "Test-1234", 9 | 'totalGrossAmount' => 134, 10 | 'totalTaxAmount' => 13, 11 | 'taxType' => "net", 12 | 'useCollectiveContact' => true, 13 | 'voucherItems' => [ 14 | [ 15 | 'amount' => 37.79, 16 | 'taxAmount' => 7.18, 17 | 'taxRatePercent' => 19, 18 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 19 | ], 20 | [ 21 | 'amount' => 83.14, 22 | 'taxAmount' => 5.82, 23 | 'taxRatePercent' => 7, 24 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 25 | ], 26 | [ 27 | 'amount' => 0.07, 28 | 'taxAmount' => 0, 29 | 'taxRatePercent' => 0, 30 | 'categoryId' => 'aba9020f-d0a6-47ca-ace6-03d6ed492351', 31 | ], 32 | ], 33 | ]); 34 | 35 | if ($request->id) { 36 | test('voucher created - id: '.$request->id); 37 | test_finished(true); 38 | } else { 39 | test_finished(false); 40 | } 41 | } catch(lexoffice_exception $e) { 42 | test($e->getMessage()); 43 | test(print_r($e->get_error(), true)); 44 | test_finished(false); 45 | } -------------------------------------------------------------------------------- /tests/tests/402_vouchers_create_big_amount.php: -------------------------------------------------------------------------------- 1 | create_voucher([ 20 | 'version' => 0, 21 | 'type' => 'salesinvoice', 22 | 'voucherNumber' => '6126', 23 | 'voucherDate' => '20'.$year.'-'.$month.'-'.$day, 24 | 'dueDate' => '20'.$year.'-'.$month.'-'.$day, 25 | 'useCollectiveContact' => true, 26 | 'totalGrossAmount' => 175.37, 27 | 'taxType' => "gross", 28 | 'totalTaxAmount' => 28.00, 29 | 'voucherItems' => [ 30 | [ 31 | 'amount' => 175.37, 32 | 'taxAmount' => 28.00, 33 | 'taxRatePercent' => 19, 34 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 35 | ], 36 | ], 37 | ]); 38 | 39 | if ($request->id) { 40 | test('voucher created ('.$i.' / '.$amount_vouchers.') - id: '.$request->id); 41 | test_finished(true); 42 | } else { 43 | test_finished(false); 44 | } 45 | } catch(lexoffice_exception $e) { 46 | test($e->getMessage()); 47 | test(print_r($e->get_error(), true)); 48 | test_finished(false); 49 | } 50 | } 51 | } 52 | 53 | if ($upload_vouchers_with_image) { 54 | test_start('create '.$amount_k.'k vouchers with image'); 55 | $amount_vouchers = $amount_k*1000; 56 | for ($i = 0; $i <= $amount_vouchers; $i++) { 57 | try { 58 | $day = rand(1, 28); 59 | if (strlen($day) == 1) $day = '0'.$day; 60 | $month = rand(1, 12); 61 | if (strlen($month) == 1) $month = '0'.$month; 62 | $year = rand(19, 21); 63 | 64 | $request = $lexoffice->create_voucher([ 65 | 'version' => 0, 66 | 'type' => 'salesinvoice', 67 | 'voucherNumber' => '6126', 68 | 'voucherDate' => '20'.$year.'-'.$month.'-'.$day, 69 | 'dueDate' => '20'.$year.'-'.$month.'-'.$day, 70 | 'useCollectiveContact' => true, 71 | 'totalGrossAmount' => 175.37, 72 | 'taxType' => "gross", 73 | 'totalTaxAmount' => 28.00, 74 | 'voucherItems' => [ 75 | [ 76 | 'amount' => 175.37, 77 | 'taxAmount' => 28.00, 78 | 'taxRatePercent' => 19, 79 | 'categoryId' => '8f8664a1-fd86-11e1-a21f-0800200c9a66', 80 | ], 81 | ], 82 | ]); 83 | 84 | if ($request->id) { 85 | test('voucher created ('.$i.' / '.$amount_vouchers.') - id: '.$request->id); 86 | 87 | try { 88 | $lexoffice->upload_voucher($request->id, __DIR__.'/files/dummy_2.pdf'); 89 | test('voucher uploaded'); 90 | } catch (lexoffice_exception $e2) { 91 | test($e2->getMessage()); 92 | test(print_r($e2->get_error(), true)); 93 | test_finished(false); 94 | } 95 | } else { 96 | test_finished(false); 97 | } 98 | } catch(lexoffice_exception $e) { 99 | test($e->getMessage()); 100 | test(print_r($e->get_error(), true)); 101 | test_finished(false); 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /tests/tests/403_invoice_empty_contact_address.php: -------------------------------------------------------------------------------- 1 | create_contact(array( 7 | 'version' => 0, 8 | 'roles' => array( 9 | 'customer' => array( 10 | 'number' => '', 11 | ), 12 | ), 13 | 'company' => array( 14 | 'name' => $random_contact_name, 15 | ), 16 | 'note' => '', 17 | )); 18 | if ($request->id) { 19 | test('contact created - id: '.$request->id); 20 | test_finished(true); 21 | } else { 22 | test_finished(false); 23 | } 24 | 25 | } catch(lexoffice_exception $e) { 26 | test($e->getMessage()); 27 | test(print_r($e->get_error(), true)); 28 | test_finished(false); 29 | } 30 | 31 | test_start('Create invoice (Empty address - returns error)'); 32 | try { 33 | $request_2 = $lexoffice->create_invoice([ 34 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 35 | 'introduction' => 'Einleitungstext', 36 | 'remark' => "Fußzeile\r\nMehrzeilig", 37 | 'address' => [ 38 | 'contactId' => $request->id, 39 | ], 40 | 'lineItems' => [ 41 | [ 42 | 'type' => 'custom', 43 | 'name' => 'Produktname', 44 | 'description' => 'Beschreibung', 45 | 'quantity' => 1, 46 | 'unitName' => 'Stück', 47 | 'unitPrice' => [ 48 | 'currency' => 'EUR', 49 | 'netAmount' => 11.99, 50 | 'taxRatePercentage' => 19, 51 | ], 52 | ], 53 | ], 54 | 'totalPrice' => [ 55 | 'currency' => 'EUR' 56 | ], 57 | 'taxConditions' => [ 58 | 'taxType' => 'net', 59 | ], 60 | 'shippingConditions' => [ 61 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 62 | 'shippingType' => 'delivery', 63 | ], 64 | 'paymentConditions' => [ 65 | 'paymentTermLabel' => 'Vorkasse', 66 | 'paymentTermDuration' => 1, 67 | ], 68 | ], true); 69 | 70 | } catch(lexoffice_exception $e) { 71 | if ($e->get_error()['Response']->message == 'Referenced contact needs to have exactly one billing address, but 0 addresses were found.') { 72 | test_finished(true); 73 | } else { 74 | test('We expect that this invoice will fail, because the contact has no address. seems like a lexoffice bug.'); 75 | test('If this bug on lexoffice side is fixed, please revert all the changes from case #215872 in related projects'); 76 | test($e->getMessage()); 77 | test(print_r($e->get_error(), true)); 78 | test_finished(false); 79 | } 80 | } 81 | 82 | // the invoice shows address from request, but invoice is linked to contactId 83 | test_start('Create invoice (Contact without address, but it is specified in create_invoice request)'); 84 | try { 85 | $request_2 = $lexoffice->create_invoice([ 86 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 87 | 'introduction' => 'Einleitungstext', 88 | 'remark' => "Fußzeile\r\nMehrzeilig", 89 | 'address' => [ 90 | 'contactId' => $request->id, 91 | 'name' => 'Jane Doe', 92 | 'street' => 'Str. 1', 93 | 'zip' => '12345', 94 | 'city' => 'Stadt', 95 | 'countryCode' => 'DE', 96 | ], 97 | 'lineItems' => [ 98 | [ 99 | 'type' => 'custom', 100 | 'name' => 'Produktname', 101 | 'description' => 'Beschreibung', 102 | 'quantity' => 1, 103 | 'unitName' => 'Stück', 104 | 'unitPrice' => [ 105 | 'currency' => 'EUR', 106 | 'netAmount' => 11.99, 107 | 'taxRatePercentage' => 19, 108 | ], 109 | ], 110 | ], 111 | 'totalPrice' => [ 112 | 'currency' => 'EUR' 113 | ], 114 | 'taxConditions' => [ 115 | 'taxType' => 'net', 116 | ], 117 | 'shippingConditions' => [ 118 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 119 | 'shippingType' => 'delivery', 120 | ], 121 | 'paymentConditions' => [ 122 | 'paymentTermLabel' => 'Vorkasse', 123 | 'paymentTermDuration' => 1, 124 | ], 125 | ], true); 126 | 127 | if ($request_2->id) { 128 | test('invoice created - id: '.$request_2->id); 129 | test_finished(true); 130 | } else { 131 | test_finished(false); 132 | } 133 | } catch(lexoffice_exception $e) { 134 | test($e->getMessage()); 135 | test(print_r($e->get_error(), true)); 136 | test_finished(false); 137 | } -------------------------------------------------------------------------------- /tests/tests/404_invoicesMultilineTermLabel.php: -------------------------------------------------------------------------------- 1 | create_invoice([ 17 | 'voucherDate' => substr(date('c'), 0, 19).'.000'.substr(date('c'), 19), 18 | 'introduction' => 'Einleitungstext', 19 | 'remark' => "Fußzeile\r\nMehrzeilig", 20 | 'address' => [ 21 | #'contactId' => '', 22 | 'name' => 'Frau Jane Doe', 23 | 'street' => 'Str. 1', 24 | 'zip' => '12345', 25 | 'city' => 'Stadt', 26 | 'countryCode' => 'DE', 27 | ], 28 | 'lineItems' => [ 29 | [ 30 | 'type' => 'custom', 31 | 'name' => 'Produktname', 32 | 'description' => 'Beschreibung', 33 | 'quantity' => 1, 34 | 'unitName' => 'Stück', 35 | 'unitPrice' => [ 36 | 'currency' => 'EUR', 37 | 'netAmount' => 11.99, 38 | 'taxRatePercentage' => $taxrate_19, 39 | ], 40 | #'discountPercentage' => 0, 41 | ], 42 | ], 43 | 'totalPrice' => [ 44 | 'currency' => 'EUR', 45 | #'totalDiscountAbsolute' => 0, 46 | #'totalDiscountPercentage' => 0, 47 | ], 48 | 'taxConditions' => [ 49 | 'taxType' => 'net', 50 | ], 51 | 'shippingConditions' => [ 52 | 'shippingDate' => date(DATE_RFC3339_EXTENDED), 53 | 'shippingType' => 'delivery', 54 | ], 55 | 'paymentConditions' => [ 56 | 'paymentTermLabel' => $label, 57 | 'paymentTermDuration' => 1, 58 | ], 59 | ]); 60 | 61 | if ($request->id) { 62 | test('invoice created - id: '.$request->id); 63 | test_finished(true); 64 | } else { 65 | test_finished(false); 66 | } 67 | } catch(lexoffice_exception $e) { 68 | test($e->getMessage()); 69 | test(print_r($e->get_error(), true)); 70 | test_finished(false); 71 | } -------------------------------------------------------------------------------- /tests/tests/500_articles.php: -------------------------------------------------------------------------------- 1 | create_article([ 6 | 'title' => 'Testartikel', 7 | 'description' => 'Beschreibung', 8 | 'type' => 'PRODUCT', 9 | 'unitName' => 'Stück', 10 | 'price' => [ 11 | 'leadingPrice' => 'NET', 12 | 'netPrice' => 44.99, 13 | 'taxRate' => $taxrate_19, 14 | ], 15 | ]); 16 | 17 | if ($request->id) { 18 | test('article created - id: '.$request->id); 19 | test_finished(true); 20 | } else { 21 | test_finished(false); 22 | } 23 | } catch(lexoffice_exception $e) { 24 | test($e->getMessage()); 25 | test(print_r($e->get_error(), true)); 26 | test_finished(false); 27 | } 28 | 29 | test_start('create article SERVICE'); 30 | try { 31 | $request = $lexoffice->create_article([ 32 | 'title' => 'Testservice', 33 | 'description' => 'Beschreibung', 34 | 'type' => 'SERVICE', 35 | 'unitName' => 'Stück', 36 | 'price' => [ 37 | 'leadingPrice' => 'NET', 38 | 'netPrice' => 44.99, 39 | 'taxRate' => $taxrate_19, 40 | ], 41 | ]); 42 | 43 | if ($request->id) { 44 | test('article created - id: '.$request->id); 45 | test_finished(true); 46 | } else { 47 | test_finished(false); 48 | } 49 | } catch(lexoffice_exception $e) { 50 | test($e->getMessage()); 51 | test(print_r($e->get_error(), true)); 52 | test_finished(false); 53 | } -------------------------------------------------------------------------------- /tests/tests/501_articles_all.php: -------------------------------------------------------------------------------- 1 | get_articles_all(); 6 | 7 | if (count($request)) { 8 | test('get '.count($request).' articles'); 9 | test_finished(true); 10 | } else { 11 | test_finished(false); 12 | } 13 | } catch(lexoffice_exception $e) { 14 | test($e->getMessage()); 15 | test(print_r($e->get_error(), true)); 16 | test_finished(false); 17 | } -------------------------------------------------------------------------------- /tests/tests/901_http_429_rate_limit.php: -------------------------------------------------------------------------------- 1 | configure_rate_limit(false); 4 | $success = false; 5 | for ($i = 0; $i <= 20; $i++) { 6 | try { 7 | $request = $lexoffice->search_contact(['name' => 'ratelimit_'.rand(0, 99999999)]); 8 | test('request ...'); 9 | } catch (lexoffice_exception $e) { 10 | if ($e->getMessage() == 'lexoffice-php-api: Rate limit exceeded') { 11 | $success = true; 12 | break; 13 | } 14 | } 15 | } 16 | test($i.' request needed'); 17 | test_finished($success); 18 | 19 | test_start('rate limit check with enabled repeat'); 20 | $lexoffice->configure_rate_limit(); 21 | $success = true; 22 | for ($i = 0; $i <= 20; $i++) { 23 | try { 24 | $request = $lexoffice->search_contact(['name' => 'ratelimit_'.rand(0, 99999999)]); 25 | test('request ...'); 26 | } catch (lexoffice_exception $e) { 27 | if ($e->getMessage() == 'lexoffice-php-api: Rate limit exceeded') { 28 | $success = false; 29 | break; 30 | } 31 | } 32 | } 33 | test($i.' request needed'); 34 | test_finished($success); 35 | 36 | test_start('rate limit check with enabled repeat and callable'); 37 | $lexoffice->configure_rate_limit_callable(function($state){test('callback: '.(string) $state);}); 38 | $success = true; 39 | for ($i = 0; $i <= 20; $i++) { 40 | try { 41 | $request = $lexoffice->search_contact(['name' => 'ratelimit_'.rand(0, 99999999)]); 42 | test('request ...'); 43 | } catch (lexoffice_exception $e) { 44 | if ($e->getMessage() == 'lexoffice-php-api: Rate limit exceeded') { 45 | $success = false; 46 | break; 47 | } 48 | } 49 | } 50 | test($i.' request needed'); 51 | test_finished($success); 52 | $lexoffice->configure_rate_limit_callable(); 53 | 54 | test_start('rate limit check with disabled repeat and callable'); 55 | $lexoffice->configure_rate_limit(false); 56 | $lexoffice->configure_rate_limit_callable(function($state){test('callback: '.(string) $state);}); 57 | $success = false; 58 | for ($i = 0; $i <= 20; $i++) { 59 | try { 60 | $request = $lexoffice->search_contact(['name' => 'ratelimit_'.rand(0, 99999999)]); 61 | test('request ...'); 62 | } catch (lexoffice_exception $e) { 63 | if ($e->getMessage() == 'lexoffice-php-api: Rate limit exceeded') { 64 | $success = true; 65 | break; 66 | } 67 | } 68 | } 69 | test($i.' request needed'); 70 | test_finished($success); 71 | $lexoffice->configure_rate_limit(); 72 | $lexoffice->configure_rate_limit_callable(); 73 | -------------------------------------------------------------------------------- /tests/tests/999_api_access.php: -------------------------------------------------------------------------------- 1 | 'roflcopter', 5 | 'ssl_verify' => false, 6 | )); 7 | 8 | try { 9 | $request = $lexoffice->get_profile(); 10 | } catch (lexoffice_exception $e) { 11 | if ($e->getMessage() == 'lexoffice-php-api: invalid API Key') { 12 | test_finished(true); 13 | } else { 14 | test_finished(false); 15 | } 16 | } 17 | 18 | test_start('incorrect api key'); 19 | $lexoffice = new lexoffice_client(array( 20 | 'api_key' => 'f059d449-504e-4786-bf16-d1ef03b589af', 21 | 'ssl_verify' => false, 22 | )); 23 | 24 | try { 25 | $request = $lexoffice->get_profile(); 26 | } catch (lexoffice_exception $e) { 27 | if ($e->getMessage() == 'lexoffice-php-api: invalid API Key') { 28 | test_finished(true); 29 | } else { 30 | test_finished(false); 31 | } 32 | } 33 | 34 | 35 | test_start('empty api key'); 36 | try { 37 | $lexoffice = new lexoffice_client(array( 38 | 'api_key' => '', 39 | 'ssl_verify' => false, 40 | )); 41 | } catch (lexoffice_exception $e) { 42 | if ($e->getMessage() == 'lexoffice-php-api: no api_key is given') { 43 | test_finished(true); 44 | } else { 45 | test_finished(false); 46 | } 47 | } 48 | 49 | test_start('false api key'); 50 | try { 51 | $lexoffice = new lexoffice_client(array( 52 | 'api_key' => false, 53 | 'ssl_verify' => false, 54 | )); 55 | } catch (lexoffice_exception $e) { 56 | if ($e->getMessage() == 'lexoffice-php-api: no api_key is given') { 57 | test_finished(true); 58 | } else { 59 | test_finished(false); 60 | } 61 | } 62 | 63 | test_start('true api key'); 64 | $lexoffice = new lexoffice_client(array( 65 | 'api_key' => true, 66 | 'ssl_verify' => false, 67 | )); 68 | 69 | try { 70 | $request = $lexoffice->get_profile(); 71 | } catch (lexoffice_exception $e) { 72 | if ($e->getMessage() == 'lexoffice-php-api: invalid API Key') { 73 | test_finished(true); 74 | } else { 75 | test_finished(false); 76 | } 77 | } -------------------------------------------------------------------------------- /tests/tests/files/XRechnung-sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/XRechnung-sample.pdf -------------------------------------------------------------------------------- /tests/tests/files/XRechnung-sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 6 | 7 | 8 | urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0 9 | 10 | 11 | 12 | RE0049 13 | 380 14 | 15 | 20241128 16 | 17 | 18 | Rechnung 19 | AFM 20 | 21 | 22 | Unsere Lieferungen/Leistungen stellen wir Ihnen wie folgt in Rechnung. 23 | AAI 24 | 25 | 26 | Vielen Dank für die gute Zusammenarbeit. 27 | SUR 28 | 29 | 30 | 31 | 32 | 33 | 1 34 | 35 | 36 | Bananen 37 | Test 38 | 39 | 40 | 41 | 20.0000 42 | 1.0000 43 | 44 | 45 | 46 | 5.0000 47 | 48 | 49 | 50 | VAT 51 | S 52 | 19.00 53 | 54 | 55 | 100.00 56 | 57 | 58 | 59 | 60 | 987654321 61 | 62 | 123456 63 | Baebeca Solutions GmbH 64 | 65 | lexoffice_api_test@baebeca.de 66 | 67 | 02261-816160 68 | 69 | 70 | lexoffice_api_test@baebeca.de 71 | 72 | 73 | 74 | 51647 75 | Brink 1 76 | Gummersbach 77 | DE 78 | 79 | 80 | lexoffice_api_test@baebeca.de 81 | 82 | 83 | DE323775624 84 | 85 | 86 | 87 | Baebeca Solutions GmbH 88 | 89 | 51647 90 | Brink 1 91 | Gummersbach 92 | DE 93 | 94 | 95 | DE323775624 96 | 97 | 98 | 99 | 100 | 101 | 102 | 20241128 103 | 104 | 105 | 106 | 107 | RE0049 108 | EUR 109 | 110 | 1 111 | Überweisung 112 | 113 | DE02120300000000202051 114 | Demo - Kontoinhaber 115 | 116 | 117 | BYLADEM1001 118 | 119 | 120 | 121 | 19.00 122 | VAT 123 | 100.00 124 | S 125 | 19.00 126 | 127 | 128 | Zahlbar sofort, rein netto 129 | 130 | 20241128 131 | 132 | 133 | 134 | 100.00 135 | 0.00 136 | 0.00 137 | 100.00 138 | 19.00 139 | 119.00 140 | 0.00 141 | 119.00 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /tests/tests/files/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/cat.jpg -------------------------------------------------------------------------------- /tests/tests/files/cat_5245kb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/cat_5245kb.jpg -------------------------------------------------------------------------------- /tests/tests/files/cat_without_extension: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/cat_without_extension -------------------------------------------------------------------------------- /tests/tests/files/dummy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/dummy.pdf -------------------------------------------------------------------------------- /tests/tests/files/dummy_12_pages.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/dummy_12_pages.pdf -------------------------------------------------------------------------------- /tests/tests/files/dummy_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/dummy_2.pdf -------------------------------------------------------------------------------- /tests/tests/files/libssh2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baebeca-Solutions/lexware-php-api/ded431ffb9f152e88e1753dd7421e2e4af51e28b/tests/tests/files/libssh2.dll --------------------------------------------------------------------------------